#include "fivewin.ch"
static dDate, dBOM, dOffSet
static nMonth, cMonth, nYear
static oBrw, oDate
//----------------------------------------------------------------------------//
function Main()
local oDlg, oFont, oFontD, oCbx, d
local aMth[ 12 ]
local aWeek[ 7 ], oGet3
SET CENTURY ON
// SET DATE ITALIAN
SET DATE BRIT
/*
AEval( aMth, { |c,i| aMth[ i ] := NToCMonth( i ) } )
AEval( aWeek, { |c,i| aWeek[ i ] := Left( NToCDOW( i ), 3 ) } )
*/
aMth:={"Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"}
aWeek:={"Dom","Lun","Mar","Mie","Jue","Vie","Sab"}
SetDate( dDate := Date() )
DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-20
DEFINE FONT oFontD NAME "COPPERPLATE GOTHIC BOLD" SIZE 0,-36
DEFINE DIALOG oDlg SIZE 542,490 PIXEL TRUEPIXEL ;
FONT oFont TITLE "CALENDAR WITH XBROWSE"
@ 20, 20 COMBOBOX oCbx VAR nMonth ITEMS aMth SIZE 150,300 PIXEL OF oDlg UPDATE ;
ON CHANGE ResetCal()
@ 20,200 GET nYear PICTURE "9999" SIZE 100,34 PIXEL OF oDlg UPDATE ;
SPINNER MAX 2999 MIN 1900 ;
ON CHANGE ReSetCal()
/*
@ 20,380 GET oDate VAR dDate SIZE 120,34 PIXEL OF oDlg ;
SPINNER ;
; //ON CHANGE SetDate( dDate ) ;
VALID SetDate( dDate )
*/
@ 20,330 GET oDate VAR dDate SIZE 190, 34 PIXEL OF oDlg ;
BITMAP "..\bitmaps\chkyes.bmp" ;
ACTION( CAMBIA_ACION() ) // SPINNER
oDate:lBtnTransparent := .t. // transparent button get oDate
oDate:lAdjustBtn := .t. // Button Get Adjust Witdh oDate
oDate:lDisColors := .f. // Deactive disable color
oDate:nClrTextDis := CLR_WHITE // Color text disable status
oDate:nClrPaneDis := CLR_BLUE // Color Pane disable status
@ 60,20 XBROWSE oBrw SIZE 502,-20 PIXEL OF oDlg ;
DATASOURCE Array( 6 ) COLUMNS 1,2,3,4,5,6,7 ;
HEADERS aWeek ;
NOBORDER
AEval( oBrw:aCols, { |o| SetupCol( o ) } )
WITH OBJECT oBrw
:lRecordSelector := .f.
:lHScroll := .f.
:lVScroll := .f.
:lDisplayZeros := .f.
:lColChangeNotify := .t.
:nRowHeight := 60
:nwidths := 70
:nRowDividerStyle := ;
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:oDataFonts := oFontD
:nDataStrAligns:= AL_CENTER
:bChange := { || dDate := dOffSet + oBrw:nColSel + 7 * ( oBrw:nRowSel - 1 ), oDate:Refresh() }
:blDblClick := {|nRow, nCol, nFlags| MSGINFO(dDate,"Fecha Seleccionada") }
//
:CreateFromCode()
END
oDlg:bStart := { || SetDate( dDate ) }
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont, oFontD
return nil
FUNCTION CAMBIA_ACION()
? "que desea hacer en argentina? "
RETURN( .T. )
function SetUpCol( oCol )
local nClrPane := oCol:oBrw:oWnd:nClrPane
oCol:bEditValue := { || dOffSet + 7 * ( oCol:oBrw:nArrayAt - 1 ) + oCol:nArrayCol }
oCol:bStrData := { |x,o| DAY( o:Value ) }
if oCol:nArrayCol == 1
oCol:bClrStd := { || If( MONTH( oCol:Value ) == nMonth, { CLR_HRED, CLR_WHITE }, ;
{ CLR_HGRAY, nClrPane } ) }
oCol:bClrHeader:= { || { CLR_HRED, CLR_WHITE } }
else
oCol:bClrStd := { || If( MONTH( oCol:Value ) == nMonth, { CLR_BLACK, CLR_WHITE }, ;
{ CLR_HGRAY, nClrPane } ) }
endif
return nil
function SetDate( dDate )
local nDays, nRow, nCol, nLen
if dBOM != BOM( dDate )
dBOM := BOM( dDate )
dOffSet := dBOM - DOW( dBOM )
nMonth := Month( dDate )
cMonth := CMONTH( dDate )
nYear := Year( dDate )
endif
if oBrw != nil
nDays := dDate - dOffSet
nRow := Int( nDays / 7 ) + 1
if ( nCol := nDays % 7 ) == 0
nCol := 7
nRow--
endif
WITH OBJECT oBrw
:nRowSel := ;
:nArrayAt := nRow
:nColSel := nCol
nLen := Ceiling( ( EOM( dDate ) - dOffSet ) / 7 )
:bKeyCount := { || nLen }
:Refresh()
:oWnd:Update()
:SetFocus()
END
endif
return .t.
function ResetCal()
local dNewDate := STOD( STRZERO( nYear, 4 ) + STRZERO( nMonth, 2 ) + "01" )
dDate := dNewDate + MIN( DAY( dDate ), LASTDAYOM( dNewDate ) ) - 1
oDate:Refresh()
SetDate( dDate )
return .t.