Code: Select all | Expand
#define _DDE_CH
#define _FOLDER_CH
#define _VIDEO_CH
#define _TREE_CH
#define _ODBC_CH
#include "Fivewin.ch"
#include "TSButton.ch"
#define CLR_LIGHT nRGB( 192, 192, 56 )
#define CLR_SHADOW nRGB( 102, 51, 0 )
Static oWnd, aChild[ 4 ]
//--------------------------------------------------------------------------//
Function Main()
Local oBar, oIco, oBtn[ 2 ]
DEFINE ICON oIco RESOURCE "Super"
DEFINE WINDOW oWnd FROM 100, 100 TO 490, 600 PIXEL ;
TITLE "Super Buttons ¡ NO DLL's at all !" ;
MENU BuildMenu() ;
COLORS CLR_BLACK, CLR_CYAN ;
ICON oIco ;
MDI
ACTIVATE WINDOW oWnd VALID ( oIco:End(), .T. )
Return Nil
//--------------------------------------------------------------------------//
Static Function Child1()
Local oIco, oFont[ 2 ], oBrush, bTColor, bBColor, oBtn[ 14 ], ;
oBmp[ 5 ], oBar, ;
lEnable := .F.
// text and background colors now can be code blocks
// here defining text and background colors for buttons 5 and 6
bTColor := { |oBtn| If( ! oBtn:lActive, CLR_GRAY, ;
If( oBtn:lMouseOver, CLR_HBLUE, ;
If( oBtn:lPressed, CLR_HRED, CLR_BLACK ) ) ) }
bBColor := { |oBtn| If( oBtn:lActive, CLR_HGRAY, CLR_GRAY ) }
If aChild[ 1 ] == Nil
DEFINE FONT oFont[ 1 ] NAME "MS Sans Serif" SIZE 0, -6
DEFINE FONT oFont[ 2 ] NAME "MS Sans Serif" SIZE 0, -8 BOLD
DEFINE ICON oIco RESOURCE "Super"
DEFINE BRUSH oBrush RESOURCE "WPaper"
DEFINE WINDOW aChild[ 1 ] FROM 0, 0 TO 346, 500 PIXEL OF oWnd ;
TITLE "Super Buttons ¡ Any purpose buttons with NO DLL's !" ;
COLORS CLR_BLACK, CLR_CYAN ICON oIco ;
STYLE nOR( WS_DLGFRAME, WS_VISIBLE ) ;
MDICHILD
DEFINE SBUTTONBAR oBar OF aChild[ 1 ] SIZE 25, 25 3D
oBar:SetBrush( oBrush )
DEFINE SBUTTON oBtn[ 1 ] OF oBar ;
RESOURCE "ANIMATED Trafica" ;
ACTION Child2() ;
WHEN lEnable ;
TOOLTIP "Animated" ;
MESSAGE "Animated Super Buttons in Buttonbars" ;
BRUSH oBrush ;
LOOK W97
DEFINE SBUTTON oBtn[ 7 ] OF oBar ;
RESOURCE "Super1", "Super2", "Super3", "Super2" ;
TOOLTIP "Button Matrixes" ;
MESSAGE "Bus reservations" ;
LOOK W97 ;
ACTION Child3() ;
BRUSH oBrush ;
MENU ACTION MenuPop( oBtn[ 1 ] )
DEFINE SBUTTON oBtn[ 8 ] OF oBar ;
RESOURCE "Cut1", "Cut2",, "Cut2" ;
TOOLTIP "LOOK W97" ;
MESSAGE "Super Buttons in Buttonbars" ;
LOOK W97 ;
BRUSH oBrush ;
GROUP
DEFINE SBUTTON oBtn[ 9 ] OF oBar ;
RESOURCE "Paste1", "Paste2",, "Paste2" ;
TOOLTIP "LOOK W97" ;
MESSAGE "Super Buttons in Buttonbars" ;
LOOK W97 ;
BRUSH oBrush
DEFINE SBUTTON oBtn[ 10 ] OF oBar ;
RESOURCE "Del1", "Del2",, "Del2" ;
TOOLTIP "LOOK W97" ;
MESSAGE "Super Buttons in Buttonbars" ;
LOOK W97 ;
BRUSH oBrush
DEFINE SBUTTON oBtn[ 2 ] OF oBar ;
CAPTION "Exit" ;
ACTION aChild[ 1 ]:End() ;
FONT oFont[ 1 ] ;
TOOLTIP "LOOK W97" ;
MESSAGE "Super Buttons in Buttonbars with 3D text raised" ;
LOOK W97 ;
BRUSH oBrush ;
GROUP
// 3D effect (raised) in text
oBtn[ 2 ]:SetText( Nil, Nil, Nil, .T. )
// New V.5.0 Animated button
@ 60, 80 SBUTTON oBtn[ 11 ] OF aChild[ 1 ] SIZE 36, 36 PIXELS ;
RESOURCE "ANIMATED BusIn" WHEN lEnable ;
MESSAGE "ANIMATED Button" ACTION Tone( 500 )
// "Shape" feature in TSButton
@60, 140 SBUTTON oBtn[ 3 ] OF aChild[ 1 ] FONT oFont[ 2 ] ;
SIZE 74, 26 PIXELS ;
RESOURCE "Lamp1", "Lamp2",, "Lamp3", "Shape3" ;
SHAPE ;
PROMPT "Activate" ;
TEXT ON_RIGHT ;
ACTION ( lEnable := ! lEnable, oBtn[ 1 ]:Refresh(), ;
ASend( aChild[ 1 ]:aControls, "Refresh" ), ;
ShowBitMaps( oFont[ 1 ], oBmp ), ;
If( lEnable, oBtn[ 3 ]:lEverPress := .T., ;
oBtn[ 3 ]:lEverPress := .F. ) ) ;
COLORS CLR_BLACK ;
MESSAGE 'See new "Shape" feature and 3D text (bas-relief), ' + ;
'specific position, specific 3D colors, Everpressed' ;
TOOLTIP "Activate / Deactivate Buttons"
// 3D effect (raised) in text with specific position and specific colors
oBtn[ 3 ]:SetText( Nil, 7, 20, .F., CLR_LIGHT, CLR_SHADOW )
// New V.5.0 Animated button
@ 60,237 SBUTTON oBtn[ 11 ] OF aChild[ 1 ] SIZE 36, 36 PIXELS ;
RESOURCE "ANIMATED Roll" WHEN lEnable ;
MESSAGE "ANIMATED Button" ACTION Tone( 500 )
// New "Shape" feature in TSButton
@60, 300 SBUTTON oBtn[ 4 ] OF aChild[ 1 ] FONT oFont[ 2 ] ;
SIZE 74, 26 PIXELS ;
RESOURCE "Lamp1", "Lamp2",, "Lamp3", "Shape3" ;
SHAPE ;
PROMPT "Exit" ;
TEXT ON_LEFT ;
ACTION aChild[ 1 ]:End();
COLORS CLR_BLACK ;
TOOLTIP "End Program" ;
MESSAGE 'See new "Shape" feature and 3D text (bas-relief), ' + ;
'default position, specific 3D colors'
// 3D effect (raised) in text with default position, specific colors
oBtn[ 4 ]:SetText( Nil, Nil, Nil, .F., CLR_LIGHT, CLR_SHADOW )
// New V.5.0 Animated button
@ 60,394 SBUTTON oBtn[ 12 ] OF aChild[ 1 ] SIZE 36, 36 PIXELS ;
RESOURCE "ANIMATED BusOut" WHEN lEnable ;
MESSAGE "ANIMATED Button" ACTION Tone( 500 )
@120, 90 SBUTTON oBtn[ 5 ] OF aChild[ 1 ] FONT oFont[ 1 ] ;
SIZE 100, 50 PIXELS ;
PROMPT "Buttons" + CRLF + "From" + CRLF + "Resources" ;
BORDER ;
RESOURCE "Direc1", "Direc2", "Direc3", "Direc4" ;
WHEN lEnable ;
ACTION fResource() ;
TOOLTIP "TEXT ON RIGHT (Default)" ;
MESSAGE "Super Buttons: Multiline text, Dinamic Colors" ;
COLORS bTColor, bBColor ;
TEXT ON_RIGHT
// New V.5.0 Animated button
@120,237 SBUTTON oBtn[ 14 ] OF aChild[ 1 ] SIZE 36, 36 PIXELS ;
RESOURCE "ANIMATED Pig" WHEN lEnable ;
MESSAGE "4 clips ANIMATED Button" ACTION Tone( 500 )
// Using Multi-Bitmaps 4 states in a single bitmap (Delphi style)
// Animation requires a Multi-Bitmap with 4 or more clips
// All clips will be used in animation (except clip 3 reserved for inactive state)
@120, 320 SBUTTON oBtn[ 6 ] OF aChild[ 1 ] FONT oFont[ 1 ] ;
SIZE 100, 50 PIXELS ;
PROMPT "Buttons" + CRLF + "From" + CRLF + "Code" ;
BORDER ;
RESOURCE "ANIMATED DirecM" ; // new animation feature
WHEN lEnable ;
ACTION fCodigo() ;
TOOLTIP "TEXT ON_LEFT" ;
MESSAGE "Super Buttons: Multiline text, Dinamic Colors" ;
COLORS bTColor, bBColor ;
TEXT ON_LEFT
SET MESSAGE OF aChild[ 1 ] TO "Super Buttons, ¡ All of the buttons " + ;
"in a stand alone class (NO BtnBmp subclass)"
ACTIVATE WINDOW aChild[ 1 ] ;
ON INIT ( oBtn [ 3 ]:SetFocus(), ;
MsgBlink( "Wellcome to; Super Buttons", ;
aChild[ 1 ],,,, .F. ) ) ;
VALID ( aChild[ 1 ] := Nil, oFont[ 1 ]:End(), ;
oFont[ 2 ]:End(), oIco:End(), ;
oBrush:End(), If( oBmp[ 1 ] != Nil, ;
AEval( oBmp, { |o| DeleteObject( o ) } ), Nil ), .T. )
Else
aChild[ 1 ]:SetFocus()
EndIf
Return Nil
//--------------------------------------------------------------------------//
Static Function BuildMenu()
Local oMenu
MENU oMenu
MENUITEM "&TSButton" ACTION Child1()
MENUITEM "&Help" ACTION WinExec( "Start ..\doc\Tsbutton.htm", 0 )
MENUITEM "&Exit" ACTION oWnd:End()
ENDMENU
Return oMenu
//--------------------------------------------------------------------------//
Static Function ShowBitMaps( oFont, oBmp )
@198, 160 SAY "Bitmaps used by these buttons" FONT oFont ;
COLOR CLR_BLACK, CLR_CYAN SIZE 200, 12 PIXEL OF aChild[ 1 ]
@215, 80 BITMAP oBmp[ 1 ] RESOURCE "Direc1" OF aChild[ 1 ] PIXEL
@215,120 BITMAP oBmp[ 2 ] RESOURCE "Direc2" OF aChild[ 1 ] PIXEL
@215,165 BITMAP oBmp[ 3 ] RESOURCE "Direc3" OF aChild[ 1 ] PIXEL
@215,205 BITMAP oBmp[ 4 ] RESOURCE "Direc4" OF aChild[ 1 ] PIXEL
@215,315 BITMAP oBmp[ 5 ] RESOURCE "DirecM" OF aChild[ 1 ] PIXEL
@247, 90 SAY " 1 2 3 4" FONT oFont ;
COLOR CLR_BLACK, CLR_CYAN SIZE 200, 12 PIXEL OF aChild[ 1 ]
@247, 330 SAY " 1 2 3 4" FONT oFont ;
COLOR CLR_BLACK, CLR_CYAN SIZE 120, 12 PIXEL OF aChild[ 1 ]
@260, 80 SAY "Normal Pressed Inactive Pointed" FONT oFont ;
COLOR CLR_BLACK, CLR_CYAN SIZE 200, 12 PIXEL OF aChild[ 1 ]
@260, 310 SAY "Four states in a single Bitmap" FONT oFont ;
COLOR CLR_BLACK, CLR_CYAN SIZE 150, 12 PIXEL OF aChild[ 1 ]
Return Nil
//--------------------------------------------------------------------------//
Static Function fResource()
Local oDlg, oFont, oGet, oBrush, cVar, bColor, ;
lEnable := .F., ;
oBtn := Array( 9 )
cVar := Space( 10 )
DEFINE BRUSH oBrush RESOURCE "Back2"
DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0,-12
DEFINE DIALOG oDlg NAME "DIALOG_1" ;
TITLE "Super Buttons in dialogs from resources" FONT oFont
REDEFINE GET oGet VAR cVar ID 101 OF oDlg ;
VALID ( If( Empty( cVar ), ;
( Msginfo( "You must to write something in get" ), ;
.F. ), .T. ) )
REDEFINE SBUTTON oBtn[ 8 ] ID 208 OF oDlg FONT oFont ;
PROMPT "&File" ;
ACTION MenuArch( oBtn[ 8 ] ), oGet:SetFocus() ;
MESSAGE "Emulating menus in dialogs with Super Buttons" ;
TOOLTIP "LOOK W97, CANCEL, Text only" ;
LOOK W97 CANCEL
REDEFINE SBUTTON oBtn[ 9 ] ID 209 OF oDlg FONT oFont ;
PROMPT "&Exit" ;
MESSAGE "Emulating menus in dialogs with Super Buttons" ;
ACTION oDlg:End() ;
TOOLTIP "LOOK W97, CANCEL, Text only" ;
LOOK W97 CANCEL
REDEFINE SBUTTON oBtn[ 1 ] ID 201 ;
RESOURCE "OK1","OK2","OK3", "OK4" OF oDlg FONT oFont;
PROMPT "A&ctivate" ;
ACTION ( lEnable := ! lEnable, oBtn[ 3 ]:Refresh(), ;
oBtn[ 5 ]:Refresh() );
TOOLTIP "BRUSH, TEXT ON_TOP, BORDER" BORDER ;
MESSAGE "Write anything in Get to use this button" ;
COLORS { |oBtn| If( oBtn:lMouseOver, CLR_WHITE, CLR_BLACK ) }, ;
CLR_GREEN ;
BRUSH oBrush ROUNDRECT ;
TEXT POSITION ON_TOP
REDEFINE SBUTTON oBtn[ 2 ] ID 202 ;
RESOURCE "CANCEL1", "CANCEL2", "CANCEL3", "CANCEL4" ;
OF oDlg PROMPT "&Exit" FONT oFont ;
ACTION oDlg:End() ;
TOOLTIP "TEXT ON RIGHT (Default), MENU, CANCEL" ;
MESSAGE "Super Buttons with menu" ;
COLORS CLR_BLACK, ;
{|oB| If( oB:lMouseOver, {CLR_WHITE,CLR_BLUE }, ;
{CLR_BLUE,CLR_WHITE} ) };
TEXT POSITION ON_RIGHT CANCEL ;
MENU ACTION MenuPop( oBtn[ 2 ] )
REDEFINE SBUTTON oBtn[ 3 ] ID 203 ;
RESOURCE "HELP1", "HELP2", "HELP3", "HELP4" OF oDlg ;
PROMPT "&SButton" + CRLF + "From" + CRLF + "Code" ;
FONT oFont ACTION fCodigo() ;
MESSAGE "Super Buttons: Multiline text, Dinamic Colors" ;
TOOLTIP "TEXT ON RIGHT (default)" ;
WHEN lEnable ;
COLORS {|oBtn| If( oBtn:lActive, ;
If( oBtn:lMouseOver, CLR_HBLUE, CLR_BLACK), CLR_BLACK ) }, ;
{|oBtn| If( oBtn:lActive, {CLR_YELLOW,CLR_BLUE, .T. }, CLR_GRAY ) } ;
TEXT POSITION ON_RIGHT
REDEFINE SBUTTON oBtn[ 4 ] ID 204 ;
RESOURCE "STOP1", "STOP2", "STOP3", "STOP4" OF oDlg FONT oFont;
PROMPT "&Prueba" ;
ACTION ( MsgInfo( "Ok" ) ) ;
CANCEL ;
MESSAGE "Super Buttons with menu" ;
TOOLTIP "TEXT ON_TOP, MENU, CANCEL" ;
COLORS { |oBtn| If( oBtn:lMouseOver, CLR_WHITE, CLR_BLACK ) }, {CLR_GREEN,CLR_YELLOW} ;
TEXT POSITION ON_TOP ;
MENU ACTION MenuPop( Self )
REDEFINE SBUTTON oBtn[ 5 ] ID 205 ;
RESOURCE "STOP1","STOP2","STOP3", "STOP4" OF oDlg FONT oFont;
PROMPT "P&rueba" ;
ACTION ( MsgInfo( "Ok" ), oGet:SetFocus() ) ;
WHEN lEnable ;
TOOLTIP "TEXT ON_BOTTOM CANCEL" ;
COLORS { |oBtn| If( oBtn:lMouseOver, CLR_BLUE, CLR_BLACK ) }, ;
{ |oBtn| If( oBtn:lActive, {CLR_RED,CLR_HGRAY}, CLR_GRAY ) } ;
CANCEL ;
TEXT POSITION ON_BOTTOM
REDEFINE SBUTTON oBtn[ 6 ] ID 206 ;
RESOURCE "HELP1", "HELP2", "HELP3", "HELP4" OF oDlg ;
PROMPT "Pr&ueba" ;
FONT oFont ACTION MsgInfo( "Ok");
TOOLTIP "LOOK W97, TEXT ON_BOTTOM" ;
MESSAGE "Write anything in Get to use this button" ;
TEXT POSITION ON_BOTTOM ;
LOOK W97
// 3D text bas-relief
oBtn[ 6 ]:SetText( Nil, Nil, Nil, .T. )
REDEFINE SBUTTON oBtn[ 7 ] ID 207 ;
RESOURCE "HELP1", "HELP2", "HELP3", "HELP4" OF oDlg ;
PROMPT "Prue&ba" ;
FONT oFont ACTION MsgInfo( "Ok") ;
MESSAGE "Super Buttons with menu & Look W97" ;
TOOLTIP "LOOK W97, MENU, TEXT ON_TOP" ;
TEXT POSITION ON_TOP ;
MENU ACTION MenuPop( Self ) ;
LOOK W97
// 3D text bas-relief
oBtn[ 7 ]:SetText( Nil, Nil, Nil, .F. )
// Now TSLines is included in TSButton
ACTIVATE DIALOG oDlg CENTERED ON INIT ( oGet:SetFocus(), ;
oDlg:oMsgBar := TMsgBar():New( oDlg, "Super Buttons, ¡ All of " + ;
"the buttons in a stand alone class (NO BtnBmp subclass)" ) ) ;
ON PAINT TSLines():New( 17, 0, 500,, "HLINE", oDlg, CLR_WHITE, CLR_GRAY )
oFont:End()
oBrush:End()
Return Nil
//--------------------------------------------------------------------------//
Static Function MenuPop( oBtn )
Local oMenu, aRect
aRect := GetClientRect( oBtn:hWnd )
MENU oMenu POPUP
MENUITEM "&Undo" RESOURCE "Deshacer"
SEPARATOR
MENUITEM "Cu&t" RESOURCE "Cortar"
MENUITEM "&Copy" RESOURCE "Copiar"
MENUITEM "&Paste" RESOURCE "Pegar"
MENUITEM "&Delete" RESOURCE "Borrar"
SEPARATOR
MENUITEM "&Select All"
ENDMENU
ACTIVATE POPUP oMenu AT aRect[ 3 ] + 1, aRect[ 2 ] OF oBtn
Return Nil
//--------------------------------------------------------------------------//
Static Function MenuArch( oBtn )
Local oMenu, aRect
aRect := GetClientRect( oBtn:hWnd )
MENU oMenu POPUP
MENUITEM "&New"
MENUITEM "&Open"
SEPARATOR
MENUITEM "&Save"
MENUITEM "Save &As"
MENUITEM "&Close"
MENUITEM "&Print"
SEPARATOR
MENUITEM "P&rinter Setup"
ENDMENU
ACTIVATE POPUP oMenu AT aRect[ 3 ] + 1, aRect[ 2 ] OF oBtn
Return Nil
//--------------------------------------------------------------------------//
Static Function Child2()
Local oFont, oBtn[ 6 ], oBrush, nEle, ;
aVisit := Array( 5 )
If aChild[ 2 ] == Nil
AFill( aVisit, .F. )
DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, -10 BOLD UNDERLINE ITALIC
DEFINE BRUSH oBrush RESOURCE "Back1"
DEFINE WINDOW aChild[ 2 ] FROM 0, 0 TO 346, 400 PIXEL OF oWnd ;
TITLE "Super Buttons ¡ Todos los Botones SIN DLL's !" ;
COLORS CLR_BLACK, CLR_CYAN ;
STYLE nOR( WS_DLGFRAME, WS_VISIBLE ) ;
BRUSH oBrush ;
MDICHILD
// here using SetText() and SetColor() Methods
@20, 30 SBUTTON oBtn[ 1 ] OF aChild[ 2 ] FONT oFont PIXEL ;
CAPTION "Products" SIZE 75, 20 ;
COLORS { |oBtn| If( aVisit[ 1 ], CLR_HGREEN, CLR_YELLOW ) }, ;
CLR_BLACK ;
ACTION ( oBtn[ 1 ]:SetText( "Productos" ), ;
oBtn[ 1 ]:SetColor( CLR_HRED, CLR_BLACK ), ;
oBtn[ 1 ]:Refresh() ) ;
MESSAGE "http://www.superbuttons.com/products.html" ;
TOOLTIP "NOBOX" ;
NOBOX
@20,110 SBUTTON oBtn[ 2 ] OF aChild[ 2 ] FONT oFont PIXEL ;
PROMPT "Downloads" SIZE 75, 20 ;
COLORS { |oBtn| If( aVisit[ 2 ], CLR_HGREEN, CLR_YELLOW ) }, ;
CLR_BLACK ;
ACTION ( aVisit[ 2 ] := ! aVisit[ 2 ], oBtn[ 2 ]:Refresh() ) ;
MESSAGE "http://www.superbuttons.com/Dowloads.html" ;
TOOLTIP "NOBOX" ;
NOBOX
@20,190 SBUTTON oBtn[ 3 ] OF aChild[ 2 ] FONT oFont PIXEL ;
CAPTION "Shopping" SIZE 75, 20 ;
COLORS { |oBtn| If( aVisit[ 3 ], CLR_HGREEN, CLR_YELLOW ) }, ;
CLR_BLACK ;
ACTION ( aVisit[ 3 ] := ! aVisit[ 3 ], oBtn[ 3 ]:Refresh() ) ;
MESSAGE "http://www.superbuttons.com/Shopping.html" ;
TOOLTIP "NOBOX" ;
NOBOX
@20,270 SBUTTON oBtn[ 4 ] OF aChild[ 2 ] FONT oFont PIXEL ;
CAPTION "Links" SIZE 75, 20 ;
COLORS { |oBtn| If( aVisit[ 4 ], CLR_HGREEN, CLR_YELLOW ) }, ;
CLR_BLACK ;
ACTION ( aVisit[ 4 ] := ! aVisit[ 4 ], oBtn[ 4 ]:Refresh() ) ;
MESSAGE "http://www.superbuttons.com/links.html" ;
TOOLTIP "NOBOX" ;
NOBOX
@250,20 SBUTTON oBtn[ 5 ] OF aChild[ 2 ] FONT oFont PIXEL ;
CAPTION "Home Page" SIZE 75, 15 ;
COLORS { |oBtn| If( oBtn:lMouseOver, CLR_YELLOW, CLR_BLACK ) }, ;
CLR_HGRAY ;
ACTION aChild[ 2 ]:End() ;
MESSAGE "http://www.superbuttons.com" ;
TOOLTIP "BRUSH, NOBOX" ;
BRUSH oBrush ;
NOBOX
@270,50 SBUTTON oBtn[ 6 ] OF aChild[ 2 ] FONT oFont PIXEL ;
CAPTION "Web Master: Manuel Mercado" SIZE 200, 15 ;
COLORS { |oBtn| If( oBtn:lMouseOver, CLR_YELLOW, CLR_BLACK ) } ;
ACTION aChild[ 2 ]:End() ;
MESSAGE "mmercadog@prodigy.net.mx" ;
TOOLTIP "BRUSH, NOBOX" ;
BRUSH oBrush ;
NOBOX
// don't want dotted rectangle in focus
For nEle := 1 To 6
oBtn[ nEle ]:nStyle := nAnd( oBtn[ nEle ]:nStyle, nNot( WS_TABSTOP ) )
Next
SET MESSAGE OF aChild[ 2 ] TO "Super Buttons, ¡ Emulating Hiperlinks !"
ACTIVATE WINDOW aChild[ 2 ] ;
VALID ( aChild[ 2 ] := Nil, oFont:End(), oBrush:End(), .T. )
Else
aChild[ 2 ]:SetFocus()
EndIf
Return Nil
//--------------------------------------------------------------------------//
Static Function Child3()
// using matrixes of Super Buttons
Local oFont, oFont1, nEle, bAction, oBut, nAct, nSub, oBar, oBar1, ;
aBtn1, aBtn2, aCapt1, aCapt2, aAct1, aAct2
If aChild[ 3 ] == Nil
// Method Disable() permits virtually inactivate a button (not actually),
// it can be done by passing a key code as parameter.
// To use this facility, is necessary to define the third bitmap (inactive
// state) or a multi-bitmap (4 in 1).
bAction := {|oBtn| oBtn:cCaption := "", oBtn:Disable( VK_RBUTTON ), ;
oBtn:Refresh() }
DEFINE FONT oFont NAME "Arial" SIZE 0, -12
DEFINE FONT oFont1 NAME "Arial" SIZE 0, -8
DEFINE WINDOW aChild[ 3 ] OF oWnd FROM 0, 0 TO 250, 500 PIXEL ;
TITLE "Super Buttons Matrixes of Buttons. " + ;
" Bus Reservations" ;
COLOR CLR_BLACK, CLR_CYAN ;
MDICHILD
// playing with empty buttonbars just for aparience
DEFINE BUTTONBAR oBar OF aChild[ 3 ] SIZE 10, 10 LEFT
DEFINE BUTTONBAR oBar1 OF aChild[ 3 ] SIZE 20, 20 RIGHT
// un array para los objetos TSButton
// para matrices de botones, el array debe ser bidimensional
aBtn1 := { Array( 10 ), Array( 10 ) } // matriz de botones
// buttons actions must be codeblocks contained in a unidimentional
// array
aAct1 := Array( 20 )
AFill( aAct1, bAction )
// buttons captions must be contained in a unidimentional array
aCapt1 := { "1", "5", "9", "13", "17", "21", "25", "29", "33", "37", ;
"2", "6", "10", "14", "18", "22", "26", "30", "34", "38" }
// creando la matriz
@10,90 SBGROUP aBtn1 OF aChild[ 3 ] ;
CAPTION aCapt1 ;
SIZE 34, 34 PIXELS ;
FONT oFont ;
ACTION aAct1 ;
RESOURCE "Seatm", "Seatm", "Seatm", "Seatm" ; // multi bitmap
MESSAGE "Click izquierdo: Reservar Asientos. " + ;
"Click derecho: Cancelar Reservación." ;
COLORS CLR_WHITE, CLR_CYAN ;
TEXT ON_CENTER ;
LOOK W97
// para usar un bitmap multiple ( 4 en 1 ) debes definir el mismo
// bitmap para los cuatro estados
nAct := 1
// here I'm using the "Cargo" variable to store the button's caption
// in order to restore it later when reactivate the button
// Virtual disable let you to use right click to reset a button
For nEle := 1 To Len( aBtn1 )
For nSub := 1 To Len( aBtn1[ nEle ] )
aBtn1[ nEle, nSub ]:Cargo := aCapt1[ nAct++ ]
aBtn1[ nEle, nSub ]:bRClicked := {|oBtn| fCancel( oBtn ) }
Next
Next
// let's define another matrix ( only 4 statements)
aBtn2 := { Array( 10 ), Array( 10 ) }
AFill( aAct2 := Array( 20 ), bAction )
aCapt2 := { "3", "7", "11", "15", "19", "23", "27", "31", "35", "39", ;
"4", "8", "12", "16", "20", "24", "28", "32", "36", "40" }
@108,90 SBGROUP aBtn2 ;
PROMPT aCapt2 OF aChild[ 3 ] ;
SIZE 34, 34 PIXELS ;
FONT oFont ;
ACTION aAct2 ;
RESOURCE "Seatm", "Seatm", "Seatm", "Seatm" ; // multi bitmap
MESSAGE "Left Click: To reservate seats. " + ;
"Right Click: To Cancel Reservation." ;
COLORS CLR_WHITE, CLR_CYAN ;
TEXT ON_CENTER ;
LOOK W97
nAct := 1
For nEle := 1 To Len( aBtn2 )
For nSub := 1 To Len( aBtn2[ nEle ] )
aBtn2[ nEle, nSub ]:Cargo := aCapt2[ nAct++ ]
aBtn2[ nEle, nSub ]:bRClicked := {|oBtn| fCancel( oBtn ) }
Next
Next
// the folowing buttons are no part of a group
@10, 20 SBUTTON oBut PROMPT "Exit" OF aChild[ 3 ] FONT oFont ;
SIZE 60,20 PIXEL ACTION aChild[ 3 ]:End() ;
COLORS CLR_WHITE, CLR_BLUE
@128, 20 SBUTTON OF aChild[ 3 ] RESOURCE "Driver" PIXEL ; // FONT oFont ;
MESSAGE "Please, don't disturb the driver" ;
COLOR CLR_BLACK, CLR_CYAN ;
NOBOX
@176, 60 SBUTTON RESOURCE "TV" OF aChild[ 3 ] PIXEL ;
FONT oFont1 ;
CAPTION "TV" ;
COLOR CLR_WHITE, CLR_CYAN ;
TEXT ON_CENTER ;
NOBOX
@176,200 SBUTTON RESOURCE "TV" OF aChild[ 3 ] PIXEL ;
FONT oFont1 ;
CAPTION "TV" ;
COLOR CLR_WHITE, CLR_CYAN ;
TEXT ON_CENTER ;
NOBOX
@176,310 SBUTTON RESOURCE "Seatm", "Seatm", "Seatm", "Seatm" OF aChild[ 3 ] PIXEL ;
FONT oFont1 ;
CAPTION "TV" ;
COLOR CLR_WHITE, CLR_CYAN ;
TEXT ON_CENTER ;
NOBOX ;
ACTION aAct2
SET MESSAGE OF aChild[ 3 ] TO "Super Buttons, ¡ Matrixes of Buttons !"
ACTIVATE WINDOW aChild[ 3 ] ;
VALID ( aChild[ 3 ] := Nil, oFont:End(), oFont1:End(), .T. )
Else
aChild[ 3 ]:SetFocus()
EndIf
Return Nil
//--------------------------------------------------------------------------//
Static Function fCancel( oBtn )
MsgInfo( "Reservation Canceled" )
oBtn:Enable()
oBtn:cCaption := oBtn:Cargo
oBtn:Refresh()
Return Nil
//--------------------------------------------------------------------------//
Static Function fCodigo()
Local oDlg, oFont, oGet, oBrush, cVar, bColor, ;
lEnable := .F., ;
oBtn := Array( 9 )
cVar := Space( 10 )
DEFINE BRUSH oBrush RESOURCE "Back1"
DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, -8
DEFINE DIALOG oDlg FROM 0, 0 TO 316, 360 PIXEL ;
TITLE "Super Buttons in dialogs from code" ;
COLOR CLR_BLACK, CLR_HGRAY
oDlg:nStyle := nOr( oDlg:nStyle, 4 )
@0, 1 SBUTTON oBtn[ 8 ] OF oDlg FONT oFont ;
SIZE 18, 8 PIXELS ;
PROMPT "&File" ;
ACTION MenuArch( oBtn[ 8 ] ), oGet:SetFocus() ;
MESSAGE "Emulating menus in dialogs with Super Buttons" ;
TOOLTIP "LOOK W97, CANCEL, Text only" ;
LOOK W97 CANCEL
// we don't want tab stops in menus
oBtn[ 8 ]:nStyle := nAnd( oBtn[ 8 ]:nStyle, nNot( WS_TABSTOP ) )
@0, 20 SBUTTON oBtn[ 9 ] OF oDlg FONT oFont ;
SIZE 12, 8 PIXELS ;
PROMPT "&Exit" ;
MESSAGE "Emulating menus in dialogs with Super Buttons" ;
ACTION oDlg:End() ;
TOOLTIP "LOOK W97, CANCEL, text only" ;
LOOK W97 CANCEL
// we don't want tab stop in menus
oBtn[ 9 ]:nStyle := nAnd( oBtn[ 9 ]:nStyle, nNot( WS_TABSTOP ) )
@ 31, 62 GET oGet VAR cVar OF oDlg SIZE 51, 11 PIXEL;
VALID ( If( Empty( cVar ), ;
( Msginfo( "You must to write something in get" ), ;
.F. ), .T. ) )
@59, 1 SBUTTON oBtn[ 1 ] FONT oFont ;
SIZE 50, 25 PIXELS ;
RESOURCE "OK1", "OK2", "OK3", "OK4" OF oDlg ;
PROMPT "A&ctivate" ;
ACTION ( lEnable := ! lEnable, oBtn[ 3 ]:Refresh(), ;
oBtn[ 5 ]:Refresh() );
TOOLTIP "BRUSH, TEXT ON_TOP" ;
MESSAGE "Write anything in Get to use this button" ;
COLORS { |oBtn| If( oBtn:lMouseOver, CLR_WHITE, CLR_BLACK ) }, ;
CLR_HGRAY ;
BRUSH oBrush ;
TEXT POSITION ON_TOP
// background color is degraded (two colors) with circled gradient (5)
@59, 61 SBUTTON oBtn[ 2 ] FONT oFont ;
SIZE 50, 25 PIXELS ;
RESOURCE "CANCEL1", "CANCEL2", "CANCEL3", "CANCEL4" ;
OF oDlg PROMPT "Ca&ncel" ;
ACTION oDlg:End() ;
TOOLTIP "TEXT ON RIGHT (Default), ROUND, MENU, CANCEL" ;
MESSAGE "Super Buttons with menu" ;
CANCEL ;
ROUNDRECT ; // elliptic button
COLORS CLR_WHITE, { CLR_HGREEN, CLR_BLACK, 5 } ; // degraded background color
MENU ACTION MenuPop( Self )
// background color is degraded (two colors) with gradient to horiz center (4)
@59, 121 SBUTTON oBtn[ 3 ] FONT oFont ;
SIZE 50, 25 PIXELS ;
RESOURCE "HELP1", "HELP2", "HELP3", "HELP4" OF oDlg ;
PROMPT "&Multi" + CRLF + "Line" + CRLF + "Text" ;
ACTION MsgInfo( "Ok" ) ;
MESSAGE "Super Buttons: Multiline text, Dinamic Colors" ;
TOOLTIP "TEXT ON RIGHT, ROUND" ;
WHEN lEnable ;
TEXT POSITION ON_RIGHT ;
COLORS {|oBtn| If( oBtn:lActive, ;
If( oBtn:lMouseOver, CLR_YELLOW, CLR_HBLUE), ;
CLR_BLACK ) }, ;
{|oBtn| If( oBtn:lActive, ;
{ CLR_YELLOW, CLR_GREEN, 4 }, ; // degraded background color
CLR_GRAY ) } ;
ROUNDRECT // elliptic button
// background color is degraded (two colors) with gradient to vert center (3)
@98, 7 SBUTTON oBtn[ 4 ] ;
SIZE 28, 28 PIXELS ;
RESOURCE "STOP1","STOP2","STOP3", "STOP4" OF oDlg ;
PROMPT "&Prueba" ;
ACTION ( MsgInfo( "Ok" ), oGet:SetFocus() ) ;
MESSAGE "Super Buttons with menu. Degraded background color." ;
TOOLTIP "TEXT ON_TOP, BITMAP OPAQUE, MENU, NOBORDER, CANCEL" ;
NOBORDER ;
COLORS { |oBtn| If( oBtn:lMouseOver, CLR_WHITE, CLR_BLACK ) }, ;
{ CLR_BLUE, CLR_WHITE, 3} ; // degraded background color
BITMAP OPAQUE ;
CANCEL ;
TEXT POSITION ON_TOP ;
MENU ACTION MenuPop( Self )
// background color is degraded (two colors) with vertical gradient (1)
@98, 52 SBUTTON oBtn[ 5 ] FONT oFont ;
SIZE 28, 28 PIXELS ;
RESOURCE "STOP1", "STOP2", "STOP3", "STOP4" OF oDlg ;
PROMPT "P&rueba" ;
ACTION ( MsgInfo( "Ok" ), oGet:SetFocus() ) ;
WHEN lEnable ;
TOOLTIP "TEXT ON_BOTTOM CANCEL, ROUND" ;
COLORS { |oBtn| If( oBtn:lMouseOver, CLR_BLUE, CLR_BLACK ) }, ;
{ |oBtn| If( oBtn:lActive, ;
{CLR_WHITE, CLR_RED, 1 }, ; // degraded background color
CLR_GRAY ) } ;
CANCEL ;
ROUND BORDER ; // elliptic button
TEXT POSITION ON_BOTTOM
@98, 95 SBUTTON oBtn[ 6 ] FONT oFont ;
SIZE 27, 28 PIXELS ;
RESOURCE "HELP1", "HELP2", "HELP3", "HELP4" OF oDlg ;
PROMPT "Pr&ueba" ;
ACTION MsgInfo( "Ok") ;
TOOLTIP "LOOK W97, TEXT ON_BOTTOM" ;
MESSAGE "Write anything in Get to use this button" ;
TEXT POSITION ON_BOTTOM ;
LOOK W97
@98, 138 SBUTTON oBtn[ 7 ] FONT oFont ;
SIZE 27, 28 PIXELS ;
RESOURCE "HELP1", "HELP2", "HELP3", "HELP4" OF oDlg ;
PROMPT "Pr&ueba" ;
ACTION MsgInfo( "Ok") ;
MESSAGE "Super Buttons with menu and Look W97" ;
TOOLTIP "LOOK W97, MENU, TEXT ON_TOP" ;
TEXT POSITION ON_TOP ;
MENU ACTION MenuPop( Self ) ;
LOOK W97
// Now TSLines is included in TSButton
ACTIVATE DIALOG oDlg CENTERED ON INIT ( oGet:SetFocus(), ;
oDlg:oMsgBar := TMsgBar():New( oDlg, "Super Buttons, ¡ All of " + ;
"the buttons in a stand alone class (NO BtnBmp subclass)" ) ) ;
ON PAINT TSLines():New( 19, 0, 500,, "HLINE", oDlg, CLR_WHITE, CLR_GRAY )
oFont:End()
oBrush:End()
Return Nil