home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
CLIPPER
/
OBJECT
/
WINDOW.PRG
< prev
Wrap
Text File
|
1992-12-04
|
4KB
|
144 lines
#include "Objects.ch"
#include "InKey.ch"
static cFrame
//----------------------------------------------------------------------------//
CLASS TWindow FROM TView
DATA cTitle, cImage, cFrame
DATA cClrFocus, cClrFrame, cClrTitle
DATA lCloseable, lMaximizable, lGrow
METHOD New( nTop, nLeft, nBottom, nRight, cTitle, cColors, lShadow )
METHOD NewCentered( nHeight, nWidth, cTitle, cColors, lShadow )
METHOD Display()
METHOD Click( nMRow, nMCol )
METHOD Say( nRow, nCol, cText, cColor )
METHOD SayCenter( nRow, cText, cColor )
METHOD KeyApply( nKey )
ENDCLASS
//----------------------------------------------------------------------------//
METHOD TWindow::New( nTop, nLeft, nBottom, nRight, cTitle, cColors, lShadow )
local acColors := aStr2Array( If( cColors == nil, SetColor(), cColors ), "," )
::Parent:New( nTop, nLeft, nBottom, nRight )
DEFAULT cTitle = ""
::cTitle = cTitle
::lShadow = .t.
::lCloseable = .t.
::lGrow = .t.
::lMaximizable = .f.
::cClrFrame = acColors[ 1 ]
::cClrTitle = acColors[ 4 ]
::cImage = ""
if cFrame == nil
cFrame = If( lIsCua(), " ▐╠═╚▌ ", " │┘─└│ " )
endif
return Self
//----------------------------------------------------------------------------//
METHOD TWindow::NewCentered( nHeight, nWidth, cTitle, cColors, lShadow )
local nTop := ( MaxRow() / 2 ) - ( nHeight / 2 )
local nBottom := nTop + nHeight
local nLeft := ( MaxCol() / 2 ) - ( nWidth / 2 )
local nRight := nLeft + nWidth
return ::New( nTop, nLeft, nBottom, nRight, cTitle, cColors, lShadow )
//----------------------------------------------------------------------------//
METHOD TWindow::Display()
local nMCrsOld := SetMCursor( 0 )
DispBegin()
@ ::nTop, ::nLeft, ::nBottom, ::nRight BOX cFrame COLOR ::cClrFrame
if ! Empty( ::cTitle )
@ ::nTop, ::nLeft SAY PadC( ::cTitle, ::nRight - ::nLeft + 1 ) ;
COLOR ::cClrTitle
endif
if ::lCloseable
@ ::nTop, ::nLeft SAY If( lIsCua(), "╔╩", " ≡" ) COLOR ::cClrTitle
endif
if ::lShadow
if ::nRight <= MaxCol() - 1 .and. ::nTop <= MaxRow() - 1
ScrShadow( ::nTop + 1, ::nRight + 1, ::nBottom, ::nRight + 2 )
endif
if ::nBottom <= MaxRow() - 1 .and. ::nLeft <= MaxCol() - 2
ScrShadow( ::nBottom + 1, ::nLeft + 2, ::nBottom + 1, ::nRight + 2 )
endif
endif
DispEnd()
SetMCursor( nMCrsOld )
return
//----------------------------------------------------------------------------//
METHOD TWindow::Click( nMRow, nMCol )
do case
case nMRow == ::nTop .and. nMCol == ::nLeft
::EndExec()
case nMRow == ::nTop
do while lMPressed()
::Move( nMRow(), nMCol() )
MUpdate()
enddo
case nMRow == ::nBottom .and. nMCol == ::nRight
do while lMPressed()
::Size( nMRow() - ::nTop + 1, nMCol() - ::nLeft + 1 )
MUpdate()
enddo
endcase
return
//----------------------------------------------------------------------------//
METHOD TWindow::Say( nRow, nCol, cText, cColor )
DEFAULT cColor = ::cColor
@ ::nTop + nRow, ::nLeft + nCol SAY cText COLOR cColor
return
//----------------------------------------------------------------------------//
METHOD TWindow::SayCenter( nRow, cText, cColor )
local nCol := ( ( ::nRight - ::nLeft ) / 2 ) - ( Len( cText ) / 2 ) + 1
::Say( nRow, nCol, cText, cColor )
return
//----------------------------------------------------------------------------//
METHOD TWindow::KeyApply( nKey )
do case
case nKey == K_ESC
::EndExec()
endcase
return
//----------------------------------------------------------------------------//