home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 16
/
CD_ASCQ_16_0994.iso
/
news
/
4611
/
fw16d.ins
/
SOURCE
/
CLASSES
/
TREEITEM.PRG
< prev
next >
Wrap
Text File
|
1994-04-24
|
4KB
|
166 lines
#include "FiveWin.ch"
#define ID_EMPTY Chr( 0 )
#define ID_VERTLINE Chr( 1 )
#define ID_VERTHORZ Chr( 2 )
#define ID_CORNLINE Chr( 3 )
static aLines
//----------------------------------------------------------------------------//
CLASS TTreeItem
DATA cDraw, cLabel
DATA oPrev, oNext
DATA oTree
DATA lOpened
DATA nLevel
DATA hBmpOpen, hBmpClose
METHOD New( cLabel, nLevel, hBmpOpen, hBmpClose ) CONSTRUCTOR
METHOD Open() INLINE ;
If( ! ::lOpened .and. ::oTree != nil, ::lOpened := .t.,)
METHOD Close() INLINE If( ::lOpened, ::lOpened := .f.,)
METHOD Skip( @n )
METHOD GetNext() INLINE If( ::lOpened, ::oTree:oFirst, ::oNext )
METHOD GetPrev()
METHOD GetText() INLINE If( ::oTree != nil .and. ::lOpened, " - ", ;
If( ::oTree != nil, " + ", " " ) ) + ::cDraw + ::cLabel
METHOD GetLabel()
METHOD Draw( cPrevDraw )
METHOD SetNext( oItem ) INLINE ::oNext := oItem,;
If( ::oTree != nil, ::oTree:oLast:SetNext( oItem ),)
METHOD Toggle() INLINE If( ::lOpened, ::Close(), ::Open() )
METHOD ColSizes()
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( cLabel, nLevel, hBmpOpen, hBmpClose ) CLASS TTreeItem
::cDraw = ""
::cLabel = cLabel
::lOpened = .f.
::nLevel = nLevel
::hBmpOpen = hBmpOpen
::hBmpClose = hBmpClose
if aLines == nil
aLines = { LoadBitmap( GetResources(), "VertLine" ),;
LoadBitmap( GetResources(), "VertHorz" ),;
LoadBitmap( GetResources(), "CornLine" ) }
endif
return nil
//----------------------------------------------------------------------------//
METHOD Skip( n ) CLASS TTreeItem
local nCount := 0
local oItem := Self
if n > 0
while nCount < n .and. oItem:GetNext() != nil
oItem = oItem:GetNext()
nCount++
end
n = nCount
endif
if n < 0
while nCount < -n .and. oItem:GetPrev() != nil
oItem = oItem:GetPrev()
nCount++
end
n = -nCount
endif
return oItem
//----------------------------------------------------------------------------//
METHOD GetPrev() CLASS TTreeItem
if ::oPrev != nil
if ::oPrev:nLevel < ::nLevel
return ::oPrev
else
if ::oPrev:lOpened
return ::oPrev:oTree:GetLast()
else
return ::oPrev
endif
endif
endif
return nil
//----------------------------------------------------------------------------//
METHOD Draw( cPrevDraw ) CLASS TTreeItem
DEFAULT cPrevDraw := ""
::cDraw = cPrevDraw + ;
If( ::oPrev != nil,;
If( ::oNext != nil .and. ::oNext:nLevel == ::nLevel,;
ID_VERTHORZ, ID_CORNLINE ), ID_EMPTY )
If ::oTree != nil
::oTree:Draw( cPrevDraw + ;
If( ::oNext != nil,;
If( ::oNext:nLevel < ::nLevel, ID_VERTHORZ, ID_VERTLINE ),;
ID_EMPTY ) )
endif
return nil
//----------------------------------------------------------------------------//
METHOD GetLabel() CLASS TTreeItem
local aLabel := Array( ::nLevel + 1 )
local n, nLine
AFill( aLabel, 0 )
AAdd( aLabel, ::cLabel )
for n = 1 to Len( ::cDraw )
nLine = Asc( SubStr( ::cDraw, n, 1 ) )
if nLine != 0
aLabel[ n ] = aLines[ nLine ]
endif
next
aLabel[ ::nLevel + 1 ] = If( ::oTree != nil,;
If( ::lOpened, ::hBmpClose, ::hBmpOpen ), 0 )
return aLabel
//----------------------------------------------------------------------------//
METHOD ColSizes() CLASS TTreeItem
local aCols := Array( ::nLevel + 1 )
AFill( aCols, 16 )
AAdd( aCols, 300 )
return aCols
//----------------------------------------------------------------------------//