seeing btnsetup prg ( fwh/sample)
How we can personalize each button from enduser?
#xcommand DEFINE METRO <oMtr> ;
[ BACKGROUND <cFileName> ] ;
[ BTNSIZE <nBtnWidth>, <nBtnHeight> ] ;
[ TITLE <cTitle> ] ;
[ SUBTITLE <cSubTitle> ] ;
[ TO <nEndCol> ] ;
[ USER <cUser> ] ;
=> ;
<oMtr> := TMetro():New( <cTitle>,<cSubTitle>, <nBtnWidth>, <nBtnHeight>, <cFileName>,<nEndCol>,<cUser> )
#xcommand DEFINE METROBUTTON [<oBtn>] ;
[ PROMPT <cPrompt> ] ;
[ COLOR <nClrText>, <nClrPane> ] ;
[ IMAGE <cImgName> ] ;
[ TOOLTIP <cToolTip> ] ;
[ OF <oMetro> ] ;
[ <large: LARGE> ] ;
[ ACTION <uAction,...> ] ;
=> ;
[ <oBtn> := ] <oMetro>:AddButton( <cPrompt>, <nClrText>, <nClrPane>, <.large.>, <cImgName>,<cToolTip>, [{||<uAction>}] )
#xcommand DEFINE METROBTNUSER [<oBtn>] ;
[ PROMPT <cPrompt> ] ;
[ COLOR <nClrText>, <nClrPane> ] ;
[ IMAGE <cImgName> ] ;
[ TOOLTIP <cToolTip> ] ;
[ OF <oMetro> ] ;
[ <large: LARGE> ] ;
[ ACTION <uAction,...> ] ;
=> ;
[ <oBtn> := ] <oMetro>:AddButtonUser( <cPrompt>, <nClrText>, <nClrPane>, <.large.>, <cImgName>,<cToolTip>, [{||<uAction>}] )
#xcommand ACTIVATE METRO <oMtr> => <oMtr>:Activate()
#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
//New data
DATA oFontsmaller
DATA cSubtitle
DATA nEndCol
DATA cUser, cUserBtn
DATA lBotton
METHOD New( cTitle,cSubTitle, nBtnWidth, nBtnHeight, cFileName,nEndCol,cUser,lBotton )
METHOD Activate()
METHOD AddButton( cCaption, nClrText, nClrPane, lLarge, cImgName,cToolTip, bAction )
METHOD End() INLINE ::oWnd:End()
METHOD AddButtonUser( cCaption, nClrText, nClrPane, lLarge, cImgName,cToolTip, bAction )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( cTitle,cSubTitle, nBtnWidth, nBtnHeight, cFileName,nEndCol,cUser,lBotton ) CLASS TMetro
DEFAULT cTitle := "MyApp", nBtnWidth := 132, nBtnHeight := 132 ,nEndCol :=50,lBotton:=.f.
::cTitle = cTitle
::cSubTitle = cSubTitle
::cUser = cUser
::aButtons = {}
::nBtnWidth = nBtnWidth
::nBtnHeight = nBtnHeight
::nOriginX = 200
::nOriginY = 200
::nEndCol = nEndCol
::nRow = 0
::nCol = 0
::lBotton = lBotton
if File( cFileName )
::hBitmap = ReadBitmap( 0, cFileName )
endif
DEFINE FONT ::oFont NAME "Segoe UI Light" SIZE 0, -52
DEFINE FONT ::oFontsmaller NAME "Segoe UI Light" SIZE 0, -24
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( IF(::lBotton,43,13), ::nEndCol*3, Time(),,/* CLR_BLACK */ , ::oFontB )
ACTIVATE TIMER ::oTimer
return Self
//----------------------------------------------------------------------------//
METHOD Activate() CLASS TMetro
IF ::lBotton
ACTIVATE WINDOW ::oWnd MAXIMIZED ;
ON PAINT ( DrawBitmap( hDC, ::hBitmap, 0, 0, GetSysMetrics( 0 ), GetSysMetrics( 1 ) ),;
::oWnd:Say( 3, 16, ::cTitle,,, ::oFont,, .T. ),;
::oWnd:Say( 7, 16, ::cSubTitle,,, ::oFontsmaller,, .T. ),;
::oWnd:Say( 49, ::nEndCol*3, ::cUser,,, ::oFontsmaller,, .T. ),;
::oWnd:Say( 47, 16, CMonth( Date() ),,, ::oFont,, .T. ),;
::oWnd:Say( 42, 16, CDoW( Date() )+ " " + ;
AllTrim( Str( Day( Date() ) ) ),,, ::oFont,, .T. ) ) ;
ON CLICK ::oWnd:End()
else
ACTIVATE WINDOW ::oWnd MAXIMIZED ;
ON PAINT ( DrawBitmap( hDC, ::hBitmap, 0, 0, GetSysMetrics( 0 ), GetSysMetrics( 1 ) ),;
::oWnd:Say( 3, 16, ::cTitle,,, ::oFont,, .T. ),;
::oWnd:Say( 7, 16, ::cSubTitle,,, ::oFontsmaller,, .T. ),;
::oWnd:Say( 49, ::nEndCol*3, ::cUser,,, ::oFontsmaller,, .T. ),;
::oWnd:Say( 7, 130, CMonth( Date() ),,, ::oFont,, .T. ),;
::oWnd:Say( 2, 130, CDoW( Date() )+ " " + ;
AllTrim( Str( Day( Date() ) ) ),,, ::oFont,, .T. ) ) ;
ON CLICK ::oWnd:End()
endif
return nil
//----------------------------------------------------------------------------//
METHOD AddButton( cCaption, nClrText, nClrPane, lLarge, cImgName,cToolTip, bAction ) 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 FILENAME cImgName TOOLTIP cToolTip
oBtn:bAction = bAction
oBtn:SetColor( nClrText, nClrPane )
AAdd( ::aButtons, oBtn )
::nCol++
if lLarge
::nCol++
endif
if ( ATail( ::aButtons ):nLeft + ATail( ::aButtons ):nWidth ) > ( ::nOriginY * 4 ) + ::nEndCol
::nRow++
::nCol = 0
endif
return nil
//----------------------------------------------------------------------------//
METHOD AddButtonUser ( cCaption, nClrText, nClrPane, lLarge, cImgName,cToolTip, bAction ) CLASS TMetro
local oBtn
local nX := 75
local nY := ::nEndCol*12
DEFAULT lLarge := .F.
@ nX, nY*2 BTNBMP oBtn ;
SIZE ( ::nBtnWidth * If( lLarge, 2, 1 ) ) + If( lLarge, 8, 0 ), ::nBtnHeight ;
PIXEL OF ::oWnd PROMPT cCaption NOBORDER FILENAME cImgName TOOLTIP cToolTip
oBtn:bAction = bAction
* oBtn:SetColor( nClrText, nClrPane )
oBtn:ltransparent:=.t.
return nil
#include "FiveWin.ch"
#include "metro.ch"
#include "xbrowse.ch"
//----------------------------------------------------------------------------//
function Main()
local oMetro
DEFINE METRO oMetro ;
TITLE "My FWH Metro app";
SUBTITLE "FiveWin Windows Metro Ui Engine 1.0" ;
TO 50 ;
USER "MdaSolutions Srl" ;
BOTTON
// BACKGROUND "earth.bmp"
//BTNSIZE 250,100
DEFINE METROBTNUSER OF oMetro ;
PROMPT "Antonio"+CRLF+" Linares" ;
IMAGE ".\metro\2.bmp"
DEFINE METROBUTTON OF oMetro ;
PROMPT "Files" COLOR CLR_WHITE, RGB( 2, 174, 224 ) ;
IMAGE ".\metro\files.bmp" ;
ACTION Files()
DEFINE METROBUTTON OF oMetro ;
PROMPT "Customers" COLOR CLR_WHITE, RGB( 234, 112, 39 ) ;
IMAGE ".\metro\CLIENTI.bmp" ;
TOOLTIP "Gestione Clienti"
DEFINE METROBUTTON OF oMetro ;
PROMPT "Stock" COLOR CLR_WHITE, RGB( 181, 31, 60 ) LARGE ;
IMAGE ".\metro\FORNITORI.bmp" ;
TOOLTIP "Gestione Fornitori"
DEFINE METROBUTTON OF oMetro ;
PROMPT "Utilities" COLOR CLR_WHITE, RGB( 24, 152, 78 ) ;
IMAGE ".\metro\utilities.bmp" ;
ACTION Control_Panel() ;
TOOLTIP "Control Panel"
DEFINE METROBUTTON OF oMetro ;
PROMPT "Reports" COLOR CLR_WHITE, RGB( 2, 174, 224 ) ;
IMAGE ".\metro\print.bmp" ;
TOOLTIP "Reports"
DEFINE METROBUTTON OF oMetro ;
PROMPT "Graphics" COLOR CLR_WHITE, RGB( 234, 112, 39 ) LARGE ;
IMAGE ".\metro\graphics.bmp" ;
TOOLTIP "Statistics"
DEFINE METROBUTTON OF oMetro ;
PROMPT "Calculator" COLOR CLR_WHITE, RGB( 86, 177, 14 ) ;
IMAGE ".\metro\calculator.bmp" ;
ACTION WinExec( "calc" ) ;
TOOLTIP "Calculator"
DEFINE METROBUTTON OF oMetro ;
PROMPT "Save" COLOR CLR_WHITE, RGB( 86, 177, 14 ) ;
IMAGE ".\metro\SAVE.bmp" ;
ACTION WinExec( "calc" )
DEFINE METROBUTTON OF oMetro ;
PROMPT "Contact" COLOR CLR_WHITE, RGB( 213, 177, 1 ) ;
IMAGE ".\metro\contact.bmp"
DEFINE METROBUTTON OF oMetro ;
PROMPT "Internet" COLOR CLR_WHITE, RGB( 2, 70, 133 ) LARGE ;
IMAGE ".\metro\set.bmp"
DEFINE METROBUTTON OF oMetro ;
PROMPT "Calendar" COLOR CLR_WHITE, RGB( 2, 174, 224 ) ;
IMAGE ".\metro\calendar.bmp"
DEFINE METROBUTTON OF oMetro ;
PROMPT "Exit" COLOR CLR_WHITE, RGB( 2, 174, 224 ) ;
IMAGE ".\metro\exit.bmp" ;
ACTION If( MsgYesNo( "Want to exit ?" ), oMetro:End(),);
TOOLTIP "Exit from Metro UI"
ACTIVATE METRO oMetro
return nil
//----------------------------------------------------------------------------//
function Files()
local oWnd, oBar
DEFINE WINDOW oWnd TITLE "Files"
DEFINE BUTTONBAR oBar OF oWnd 2007 SIZE 80, 80
DEFINE BUTTON OF oBar FILENAME "c:\work\fwh\bitmaps\32x32\new.bmp" PROMPT "New"
DEFINE BUTTON OF oBar FILENAME "c:\work\fwh\bitmaps\32x32\edit.bmp" PROMPT "Edit"
DEFINE BUTTON OF oBar FILENAME "c:\work\fwh\bitmaps\32x32\quit.bmp" PROMPT "Exit" ;
ACTION oWnd:End()
DEFINE MESSAGE OF oWnd 2007 PROMPT "Files management"
ACTIVATE WINDOW oWnd
return nil
//----------------------------------------------------------------------------------//
function Control_Panel()
local oWnd, oFont, oBrw, oFont2, oFont3
local aItems := { "Personalize", "Users", "Wireless", "Notifications", "Privacy", "General", "Search" }
DEFINE FONT oFont NAME "Segoe UI Light" SIZE 0, -52
DEFINE FONT oFont2 NAME "Segoe UI Light" SIZE 0, -32
DEFINE FONT oFont3 NAME "Segoe UI Light" SIZE 0, -16
DEFINE WINDOW oWnd STYLE nOr( WS_POPUP, WS_VISIBLE ) ;
COLOR RGB( 170, 170, 170 ), CLR_WHITE
@ 2, 10 SAY "Control Panel" FONT oFont SIZE 300, 100
@ 2, 80 SAY "Personalize" FONT oFont SIZE 300, 100
@ 9, 7 XBROWSE oBrw ARRAY aItems COLSIZES 800 CELL ;
FONT oFont2 SIZE 400, 700 NOBORDER OF oWnd
oBrw:nDataLines = 2
oBrw:lRecordSelector = .F.
oBrw:lHeader = .F.
oBrw:lHScroll = .F.
oBrw:lVScroll = .F.
oBrw:nStretchCol = 1
oBrw:bClrStd = { || { RGB( 170, 170, 170 ), CLR_WHITE } }
oBrw:bClrSelFocus = { || { CLR_WHITE, RGB( 34, 177, 76 ) } }
oBrw:SetColor( "B/W*" )
oBrw:CreateFromCode()
oBrw:aCols[ 1 ]:bPaintText = { | oCol, hDC, cText, aCoors, aColors, lHighlight | DrawRow( oCol, hDC, cText, aCoors, oFont3 ) }
oBrw:SetFocus()
ACTIVATE WINDOW oWNd MAXIMIZED ;
ON CLICK oWnd:End()
return nil
function DrawRow( oCol, hDC, cText, aCoors, oFont )
local hOldFont
local aItems := { "Customize your lock screen and user tile",;
"Change your account or add new ones",;
"Turn wireless and airplane mode on or off",;
"Choose if apps notify you",;
"Control how apps use your personal info",;
"Change time zone and keyboard settings",;
"Pick what/where you want to search" }
DrawText( hDC, cText, aCoors )
aCoors[ 1 ] += 45
hOldFont = SelectObject( hDC, oFont:hFont )
DrawText( hDC, aItems[ oCol:oBrw:KeyNo ], aCoors )
SelectObject( hDC, hOldFont )
return ni
runs without compile in windows 8, tablets with windows 8 and smartphones with windows phone 8, etc...
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 48 guests