Full source code provided...
metro.prg
- Code: Select all Expand view RUN
#include "FiveWin.ch"
#xcommand DEFINE METRO <oMtr> ;
[ BACKGROUND <cFileName> ] ;
[ BTNSIZE <nBtnWidth>, <nBtnHeight> ] ;
[ TITLE <cTitle> ] ;
=> ;
<oMtr> := TMetro():New( <cTitle>, <nBtnWidth>, <nBtnHeight>, <cFileName> )
#xcommand DEFINE METROBUTTON [<oBtn>] ;
[ PROMPT <cPrompt> ] ;
[ COLOR <nClrText>, <nClrPane> ] ;
[ OF <oMetro> ] ;
[ <large: LARGE> ] ;
=> ;
[ <oBtn> := ] <oMetro>:AddButton( <cPrompt>, <nClrText>, <nClrPane>, <.large.> )
#xcommand ACTIVATE METRO <oMtr> => <oMtr>:Activate()
//----------------------------------------------------------------------------//
function Main()
local oMetro
DEFINE METRO oMetro ;
TITLE "My FWH Metro app"
DEFINE METROBUTTON OF oMetro ;
PROMPT "Files" COLOR CLR_WHITE, RGB( 2, 174, 224 )
DEFINE METROBUTTON OF oMetro ;
PROMPT "Customers" COLOR CLR_WHITE, RGB( 234, 112, 39 )
DEFINE METROBUTTON OF oMetro ;
PROMPT "Stock" COLOR CLR_WHITE, RGB( 181, 31, 60 ) LARGE
DEFINE METROBUTTON OF oMetro ;
PROMPT "Utilities" COLOR CLR_WHITE, RGB( 24, 152, 78 )
DEFINE METROBUTTON OF oMetro ;
PROMPT "Reports" COLOR CLR_WHITE, RGB( 2, 174, 224 )
DEFINE METROBUTTON OF oMetro ;
PROMPT "Graphics" COLOR CLR_WHITE, RGB( 234, 112, 39 ) LARGE
DEFINE METROBUTTON OF oMetro ;
PROMPT "Internet" COLOR CLR_WHITE, RGB( 2, 70, 133 ) LARGE
DEFINE METROBUTTON OF oMetro ;
PROMPT "Calculator" COLOR CLR_WHITE, RGB( 86, 177, 14 )
DEFINE METROBUTTON OF oMetro ;
PROMPT "Contact" COLOR CLR_WHITE, RGB( 213, 177, 1 )
DEFINE METROBUTTON OF oMetro ;
PROMPT "Exit" COLOR CLR_WHITE, RGB( 2, 174, 224 )
ACTIVATE METRO oMetro
return nil
//----------------------------------------------------------------------------//
CLASS TMetro
DATA oWnd, oFont
DATA cFileName
DATA aButtons
DATA nOriginX, nOriginY
DATA nBtnWidth, nBtnHeight
DATA cTitle
DATA nRow, nCol
METHOD New( cTitle, nBtnWidth, nBtnHeight, cFileName )
METHOD Activate()
METHOD AddButton( cCaption, nClrText, nClrPane, lLarge )
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
DEFINE FONT ::oFont NAME "Segoe UI Light" SIZE 0, -52
DEFINE WINDOW ::oWnd STYLE nOr( WS_POPUP, WS_VISIBLE ) ;
COLOR CLR_WHITE, RGB( 15, 109, 57 )
return Self
//----------------------------------------------------------------------------//
METHOD Activate() CLASS TMetro
ACTIVATE WINDOW ::oWnd MAXIMIZED ;
ON PAINT ::oWnd:Say( 3, 16, ::cTitle,,, ::oFont ) ;
ON CLICK ::oWnd:End()
return nil
//----------------------------------------------------------------------------//
METHOD AddButton( cCaption, nClrText, nClrPane, lLarge ) CLASS TMetro
local oBtn
local nX := ::nOriginX + ( ::nRow * ( ::nBtnHeight + 8 ) )
local nY := ::nOriginY + ( ::nCol * ( ::nBtnWidth + 8 ) )
DEFAULT lLarge := .F.
@ nX, nY BTNBMP oBtn ;
SIZE ( ::nBtnWidth * If( lLarge, 2, 1 ) ) + If( lLarge, 8, 0 ), ::nBtnHeight ;
PIXEL OF ::oWnd PROMPT cCaption NOBORDER
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
//----------------------------------------------------------------------------//