home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
CLIPPER
/
OBJECT
/
CONTROL.PRG
< prev
next >
Wrap
Text File
|
1992-12-04
|
3KB
|
112 lines
#include "Objects.ch"
#include "GetExit.ch"
#include "Inkey.ch"
#include "Set.ch"
//----------------------------------------------------------------------------//
CLASS TControl
DATA ExitState, Name, SubScript, Reader, cColorSpec
DATA bBlock, bPreBlock, bPostBlock, bAction
DATA HasFocus
METHOD New()
METHOD Display() VIRTUAL
METHOD SetFocus( lOnOff )
METHOD KeyApply( nKey )
METHOD UnDo() VIRTUAL
METHOD CtrReader( oControl )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD TControl::New()
::Name = ""
::Reader = { | oControl | oControl:CtrReader( oControl ) }
::bPreBlock = { || .t. }
::bPostBlock = { || .t. }
::HasFocus = .f.
::bAction = { || nil }
return Self
//----------------------------------------------------------------------------//
METHOD TControl::SetFocus( lOnOff )
::HasFocus = lOnOff
SetCursor( If( ::HasFocus, 0, 1 ) )
::Display()
return
//----------------------------------------------------------------------------//
METHOD TControl::KeyApply( nKey )
if SetKey( nKey ) != nil
Eval( SetKey( nKey ) ) // , ProcName(), ProcLine, ReadVar() )
else
do case
case nKey == K_ESC
if Set( _SET_ESCAPE )
::UnDo()
::ExitState = GE_ESCAPE
endif
case nKey == K_ENTER
::ExitState = GE_ENTER
case nKey == K_CTRL_W
::ExitState = GE_WRITE
case nKey == K_UP
::ExitState = GE_UP
case nKey == K_SH_TAB
::ExitState = GE_UP
case nKey == K_DOWN
::ExitState = GE_DOWN
case nKey == K_TAB
::ExitState = GE_DOWN
case nKey == K_RIGHT
::ExitState = GE_DOWN
case nKey == K_LEFT
::ExitState = GE_UP
endcase
endif
return
//----------------------------------------------------------------------------//
METHOD TControl::CtrReader( oControl )
if Eval( ::bPreBlock )
::ExitState = GE_NOEXIT
::SetFocus( .t. )
do while ::ExitState == GE_NOEXIT
::KeyApply( InKey( 0 ) )
if ! Eval( ::bPostBlock ) .and. ;
::ExitState != GE_ESCAPE
::ExitState = GE_NOEXIT
endif
enddo
::SetFocus( .f. )
endif
return
//----------------------------------------------------------------------------//