home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
CLIPPER
/
OBJECT
/
CTRRADIO.PRG
< prev
next >
Wrap
Text File
|
1992-12-04
|
3KB
|
100 lines
#include "Objects.ch"
#include "InKey.ch"
//────────────────────────────────────────────────────────────────────────────//
CLASS TCtrRadio FROM TControl
DATA nTop, nLeft, nBottom, nRight
DATA cLabel
DATA oMnuRadio
METHOD New( nRow, nCol, bSetGet, acItems, cLabel, bWhen, bValid )
METHOD Display()
METHOD KeyApply( nKey )
METHOD SetFocus( lOnOff )
ENDCLASS
//────────────────────────────────────────────────────────────────────────────//
METHOD TCtrRadio::New( nRow, nCol, bSetGet, acItems, cLabel, bWhen, bValid )
local nOption := Eval( bSetGet )
local nWidth := 0
DEFAULT cLabel := ""
AEval( acItems, { | cItem | nWidth := Max( nWidth, Len( cItem ) + 1 ) } )
::Parent:New()
::oMnuRadio = TMenu():New( If( nOption == 0, 1, nOption ) )
::nTop = nRow
::nLeft = nCol
::nBottom = nRow + Len( acItems ) + 1
::nRight = nCol + nWidth + 6
::bBlock = bSetGet
::cLabel = cLabel
AEval( acItems, { | cItem, n | AAdd( ::oMnuRadio:aoItems, TRadio():;
New( nRow + n, nCol + 1, PadR( cItem, nWidth ) ) ) } )
return Self
//────────────────────────────────────────────────────────────────────────────//
METHOD TCtrRadio::Display()
@ ::nTop, ::nLeft TO ::nBottom, ::nRight
if ! Empty( ::cLabel )
@ ::nTop, ::nLeft + 1 SAY " " + ::cLabel + " "
endif
::oMnuRadio:aoItems[ ::oMnuRadio:nOption ]:lCheck = .t.
::oMnuRadio:Display()
return
//────────────────────────────────────────────────────────────────────────────//
METHOD TCtrRadio::SetFocus( lOnOff )
SetCursor( If( lOnOff, 0, 1 ) )
if lOnOff
::oMnuRadio:aoItems[ ::oMnuRadio:nOption ]:SetFocus( lOnOff )
else
::oMnuRadio:aoItems[ ::oMnuRadio:nOption ]:lFocus = .f.
::oMnuRadio:aoItems[ ::oMnuRadio:nOption ]:lCheck = .t.
::oMnuRadio:aoItems[ ::oMnuRadio:nOption ]:Display()
Eval( ::bBlock, ::oMnuRadio:nOption )
endif
return
//────────────────────────────────────────────────────────────────────────────//
METHOD TCtrRadio::KeyApply( nKey )
do case
case nKey == K_HOME
::oMnuRadio:KeyApply( nKey )
case nKey == K_END
::oMnuRadio:KeyApply( nKey )
case nKey == K_DOWN
::oMnuRadio:KeyApply( nKey )
case nKey == K_UP
::oMnuRadio:KeyApply( nKey )
otherwise
::Parent:KeyApply( nKey )
endcase
return
//────────────────────────────────────────────────────────────────────────────//