home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
CLIPPER
/
OBJECT
/
VIEW.PRG
< prev
next >
Wrap
Text File
|
1992-11-10
|
5KB
|
213 lines
#include "Objects.ch"
//----------------------------------------------------------------------------//
CLASS TView
DATA nTop, nLeft, nBottom, nRight
DATA cMessage, cBackImage, cMsgBack
DATA cClrNormal, cClrFocus
DATA lEndExec, lFocused, lVisible, lShadow
DATA oParent
METHOD New( nTop, nLeft, nBottom, nRight )
METHOD Show()
METHOD Display() VIRTUAL
METHOD Hide()
METHOD SetFocus( lOnOff )
METHOD lIsOver()
METHOD Move( nRow, nCol )
METHOD Size( nHeigh, nWidth )
METHOD KeyApply( nKey ) VIRTUAL
METHOD Exec()
METHOD EndExec()
METHOD Init() VIRTUAL
METHOD nAbsTop()
METHOD nAbsLeft()
ENDCLASS
//----------------------------------------------------------------------------//
METHOD TView::New( nTop, nLeft, nBottom, nRight )
::nTop = If( nTop == nil, 0, nTop )
::nLeft = If( nLeft == nil, 0, nLeft )
::nBottom = If( nBottom == nil, 0, nBottom )
::nRight = If( nRight == nil, 0, nRight )
::cBackImage = ""
::cMsgBack = ""
::cClrNormal = "N/W"
::cClrFocus = "W/N"
::lEndExec = .f.
::lFocused = .f.
::lVisible = .f.
::lShadow = .f.
return Self
//----------------------------------------------------------------------------//
METHOD TView::Show()
local nMCrsOld := SetMCursor( 0 )
if ! ::lVisible
::lVisible = .t.
::cBackImage = SaveScreen( ::nTop, ::nLeft,;
::nBottom + If( ::lShadow, 1, 0 ),;
::nRight + If( ::lShadow, 2, 0 ) )
::Display()
endif
SetMCursor( nMCrsOld )
return
//----------------------------------------------------------------------------//
METHOD TView::Hide()
local nMCrsOld := SetMCursor( 0 )
if ::lVisible
::lVisible = .f.
RestScreen( ::nTop, ::nLeft,;
::nBottom + If( ::lShadow, 1, 0 ),;
::nRight + If( ::lShadow, 2, 0 ), ::cBackImage )
::cBackImage = ""
endif
SetMCursor( nMCrsOld )
return
//----------------------------------------------------------------------------//
METHOD TView::SetFocus( lOnOff )
::lFocused = lOnOff
if ::cMessage != nil
@ Set( _SET_MESSAGE ), 0 SAY If( Set( _SET_MCENTER ),;
PadC( ::cMessage, MaxCol() + 1 ), PadR( ::cMessage, MaxCol() + 1 ) ) ;
COLOR ::cClrNormal
endif
return
//----------------------------------------------------------------------------//
METHOD TView::lIsOver( nRow, nCol )
return nRow >= ::nTop .and. nRow <= ::nBottom .and. ;
nCol >= ::nLeft .and. nCol <= ::nRight
//----------------------------------------------------------------------------//
METHOD TView::Move( nRow, nCol )
local nMCrsOld := SetMCursor()
local nWidth := ::nRight - ::nLeft
local nHeigh := ::nBottom - ::nTop
local lWasVisible := ::lVisible
if nRow != ::nTop .or. nCol != ::nLeft
SetMCursor( 0 )
DispBegin()
if ::lVisible
::Hide()
endif
::nTop = nRow
::nLeft = nCol
::nBottom = nRow + nHeigh
::nRight = nCol + nWidth
if lWasVisible
::Show()
endif
DispEnd()
SetMcursor( nMCrsOld )
endif
return
//----------------------------------------------------------------------------//
METHOD TView::Size( nHeigh, nWidth )
local nMCrsOld := SetMCursor()
local lWasVisible := ::lVisible
if ( nHeigh > 1 .and. nWidth > 1 ) .and. ;
( ( nHeigh != ::nBottom - ::nTop + 1 ) .or. ;
( nWidth != ::nRight - ::nLeft + 1 ) )
SetMCursor( 0 )
DispBegin()
if ::lVisible
::Hide()
endif
::nBottom = ::nTop + nHeigh - 1
::nRight = ::nLeft + nWidth - 1
if lWasVisible
::Show()
endif
DispEnd()
SetMCursor( nMCrsOld )
endif
return
//----------------------------------------------------------------------------//
METHOD TView::Exec()
local nCrsOld := SetCursor( 0 )
local nKey
::lEndExec = .f.
::Show()
::SetFocus( .t. )
do while ! ::lEndExec
nKey = nMKeyWait()
if nKey == 0
::Click( nMRow(), nMCol() )
do while lMPressed()
MUpdate()
enddo
else
if SetKey( nKey ) != nil
Eval( SetKey( nKey ) )
else
::KeyApply( nKey )
endif
endif
enddo
::Hide()
SetCursor( nCrsOld )
return
//----------------------------------------------------------------------------//
METHOD TView::EndExec()
::lEndExec = .t.
return
//----------------------------------------------------------------------------//
METHOD TView::nAbsTop()
return ::nTop + If( ::oParent != nil, ::oParent:nAbsTop(), 0 )
//----------------------------------------------------------------------------//
METHOD TView::nAbsLeft()
return ::nLeft + If( ::oParent != nil, ::oParent:nAbsLeft(), 0 )
//----------------------------------------------------------------------------//