Code: Select all
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