home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
CLIPPER
/
OBJECTS
/
BUTTON.PRG
next >
Wrap
Text File
|
1992-12-04
|
2KB
|
88 lines
#include "Objects.ch"
#include "Inkey.ch"
//----------------------------------------------------------------------------//
CLASS TButton FROM TControl
DATA nRow, nCol, cText, cBack
METHOD New( nRow, nCol, cText, bAction )
METHOD Display()
METHOD KeyApply( nKey )
METHOD SetFocus( lOnOff )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD TButton::New( nRow, nCol, cText, bAction )
DEFAULT bAction := { || nil }
::Parent:New()
::nRow := nRow
::nCol := nCol
::cText := cText
::cBack := SaveScreen( nRow, nCol, nRow + 1, nCol + Len( cText ) )
::bAction := bAction
return self
//----------------------------------------------------------------------------//
METHOD TButton::Display()
BtnDraw( ::nRow, ::nCol, ::cText, If( ::HasFocus, 127, 112 ), 123 )
return
//----------------------------------------------------------------------------//
METHOD TButton::KeyApply( nKey )
If nKey == K_ENTER .or. nKey == K_SPACE
RestScreen( ::nRow, ::nCol, ::nRow + 1, ::nCol + Len( ::cText ), ;
::cBack )
ScrSayHot( ::nRow, ::nCol + 1, ::cText, "W+/W", "BG+/W" )
InKey( 0.5 )
Eval( ::bAction )
RestScreen( ::nRow, ::nCol, ::nRow + 1, ::nCol + Len( ::cText ), ;
::cBack )
::Display()
else
::Parent:KeyApply( nKey )
endif
return
//----------------------------------------------------------------------------//
METHOD TButton::SetFocus( lOnOff )
SetCursor( If( lOnOff, 0, 1 ) )
::Parent:SetFocus( lOnOff )
return
//----------------------------------------------------------------------------//
function nBtnOk() // Friend Function
KEYBOARD Chr( K_CTRL_W )
return 1
//----------------------------------------------------------------------------//
function nBtnCancel() // Friend Function
KEYBOARD Chr( K_ESC )
return 0
//----------------------------------------------------------------------------//