#include "FiveWin.ch"
//----------------------------------------------------------------------------//
CLASS TMetro
DATA oWnd, oFont, oFontB
DATA cFileName
DATA aButtons
DATA nOriginX, nOriginY
DATA nBtnWidth, nBtnHeight
DATA cTitle
DATA nRow, nCol
DATA oTimer
DATA hBitmap
DATA nTimeRow INIT 13
DATA nTimeCol INIT 135
DATA nTitleRow INIT 3
DATA nTitleCol INIT 16
DATA nDayRow INIT 2
DATA nDayCol INIT 130
DATA nMonthRow INIT 7
DATA nMonthCol INIT 130
METHOD New( cTitle, nBtnWidth, nBtnHeight, cFileName )
METHOD Activate()
METHOD AddButton( cCaption, nClrText, nClrPane, lLarge, cImgName, bAction )
METHOD End() INLINE ::oWnd:End(), ::oFont:End(), ::oFontB:End(), DeleteObject( ::hBitmap )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( cTitle, nBtnWidth, nBtnHeight, cFileName ) CLASS TMetro
DEFAULT cTitle := "MyApp", nBtnWidth := 132, nBtnHeight := 132
::cTitle = cTitle
::aButtons = {}
::nBtnWidth = nBtnWidth
::nBtnHeight = nBtnHeight
::nOriginX = 200
::nOriginY = 200
::nRow = 0
::nCol = 0
if File( cFileName )
::hBitmap = ReadBitmap( 0, cFileName )
endif
DEFINE FONT ::oFont NAME "Segoe UI Light" SIZE 0, -52
DEFINE FONT ::oFontB NAME "Segoe UI Light" SIZE 0, -60 BOLD
DEFINE WINDOW ::oWnd STYLE nOr( WS_POPUP, WS_VISIBLE ) ;
COLOR CLR_WHITE, RGB( 15, 109, 57 )
DEFINE TIMER ::oTimer OF ::oWnd ACTION ::oWnd:Say( ::nTimeRow, ::nTimeCol, Time(),, CLR_BLACK, ::oFontB )
ACTIVATE TIMER ::oTimer
return Self
//----------------------------------------------------------------------------//
METHOD Activate() CLASS TMetro
ACTIVATE WINDOW ::oWnd MAXIMIZED ;
ON PAINT ( cPS,;
DrawBitmap( hDC, ::hBitmap, 0, 0, GetSysMetrics( 0 ), GetSysMetrics( 1 ) ),;
::oWnd:Say( ::nTitleRow, ::nTitleCol, ::cTitle,,, ::oFont,, .T. ),;
::oWnd:Say( ::nDayRow, ::nDayCol, CDoW( Date() ),,, ::oFont,, .T. ),;
::oWnd:Say( ::nMonthRow, ::nMonthCol, CMonth( Date() ) + " " + ;
AllTrim( Str( Day( Date() ) ) ),,, ::oFont,, .T. ) )
return nil
//----------------------------------------------------------------------------//
METHOD AddButton( cCaption, nClrText, nClrPane, lLarge, cImgName, bAction ) CLASS TMetro
local oBtn
local nX := ::nOriginX + ( ::nRow * ( ::nBtnHeight + 8 ) )
local nY := ::nOriginY + ( ::nCol * ( ::nBtnWidth + 8 ) )
DEFAULT lLarge := .F.
if File( cImgName )
@ nX, nY BTNBMP oBtn ;
SIZE ( ::nBtnWidth * If( lLarge, 2, 1 ) ) + If( lLarge, 8, 0 ), ::nBtnHeight ;
OF ::oWnd PROMPT cCaption NOBORDER FILENAME cImgName
else
@ nX, nY BTNBMP oBtn ;
SIZE ( ::nBtnWidth * If( lLarge, 2, 1 ) ) + If( lLarge, 8, 0 ), ::nBtnHeight ;
OF ::oWnd PROMPT cCaption NOBORDER RESOURCE cImgName
endif
oBtn:bAction = bAction
oBtn:SetColor( nClrText, nClrPane )
AAdd( ::aButtons, oBtn )
::nCol++
if lLarge
::nCol++
endif
if ( ATail( ::aButtons ):nLeft + ATail( ::aButtons ):nWidth ) > ( ::nOriginY * 4 ) + 50
::nRow++
::nCol = 0
endif
return nil
//----------------------------------------------------------------------------//