Tree view icon support and refreshing individual rows.

This commit is contained in:
pinkerton%netscape.com 1998-08-13 20:13:07 +00:00
Родитель 4ca9baabbd
Коммит 04152890df
2 изменённых файлов: 128 добавлений и 6 удалений

Просмотреть файл

@ -376,6 +376,43 @@ CHyperTreeFlexTable :: EraseTableBackground ( ) const
} // EraseTableBackground
void
CHyperTreeFlexTable :: DrawIconsSelf( const STableCell& inCell, IconTransformType inTransformType,
const Rect& inIconRect) const
{
HT_Resource cellNode = HT_GetNthItem(GetHTView(), URDFUtilities::PPRowToHTRow(inCell.row) );
// draw the gif if specified, otherwise draw the normal way.
char* url = NULL;
PRBool success = HT_GetTemplateData ( cellNode, gNavCenter->RDF_smallIcon, HT_COLUMN_STRING, &url );
if ( success && url ) {
// extract the image drawing class out of the HT node. If one is not there yet,
// create it.
CTreeIcon* icon = static_cast<CTreeIcon*>(HT_GetNodeFEData(cellNode));
if ( !icon ) {
icon = new CTreeIcon(url, const_cast<CHyperTreeFlexTable*>(this), cellNode);
if ( !icon )
return;
HT_SetNodeFEData(cellNode, icon);
}
// setup where we should draw
Point topLeft;
topLeft.h = inIconRect.left; topLeft.v = inIconRect.top;
uint16 width = inIconRect.right - inIconRect.left;
uint16 height = inIconRect.bottom - inIconRect.top;
// draw
icon->SetImageURL ( url );
icon->DrawImage ( topLeft, kTransformNone, width, height );
}
else
CStandardFlexTable::DrawIconsSelf(inCell, inTransformType, inIconRect);
} // DrawIconsSelf
//
// DrawSelf
//
@ -407,6 +444,23 @@ CHyperTreeFlexTable :: DrawSelf ( )
} // DrawSelf
//
// RedrawRow
//
// Redraw the row corresponding to the given HT node
//
void
CHyperTreeFlexTable :: RedrawRow ( HT_Resource inNode )
{
TableIndexT row = URDFUtilities::HTRowToPPRow(HT_GetNodeIndex(HT_GetView(inNode), inNode));
STableCell left ( row, 1 );
STableCell right ( row, LArray::index_Last );
RefreshCellRange( left, right );
} // RedrawRow
//
// EraseCellBackground
//
@ -1588,4 +1642,41 @@ CPopdownFlexTable :: OpenSelection()
if ( GetNextSelectedRow(selectedRow) && !CmdPeriod() )
OpenRow(selectedRow);
}
#endif
#endif
#pragma mark -
CTreeIcon :: CTreeIcon ( const string & inURL, CHyperTreeFlexTable* inParent, HT_Resource inNode )
: CImageIconMixin(inURL), mTree(inParent), mNode(inNode)
{
}
CTreeIcon :: ~CTreeIcon ( )
{
}
//
// ImageIsReady
//
// Tell the tree view to redraw the cell representing this node
//
void
CTreeIcon :: ImageIsReady ( )
{
mTree->RedrawRow(mNode);
}
void
CTreeIcon :: DrawStandby ( const Point & inTopLeft,
const IconTransformType inTransform ) const
{
Rect where;
where.top = inTopLeft.v; where.left = inTopLeft.h;
where.right = where.left + 16; where.bottom = where.top + 16;
TableIndexT row = URDFUtilities::HTRowToPPRow(HT_GetNodeIndex(HT_GetView(mNode), mNode));
mTree->CStandardFlexTable::DrawIconsSelf(STableCell(row, mTree->FindTitleColumnID()),
inTransform, where);
} // DrawStandby

Просмотреть файл

@ -48,10 +48,11 @@ class CHyperTreeFlexTable :
public CTiledImageMixin
{
public:
enum {
class_ID = 'htFT',
nameColumn = 'NCnC'
};
enum {
class_ID = 'htFT',
nameColumn = 'NCnC'
};
friend class CTreeIcon;
CHyperTreeFlexTable(LStream *inStream);
~CHyperTreeFlexTable();
@ -72,6 +73,8 @@ public:
virtual void SetTargetFrame ( const char* inFrame ) ;
virtual const char* GetTargetFrame ( ) const ;
virtual void RedrawRow ( HT_Resource ) ;
protected:
// Background image tiling stuff
@ -92,6 +95,8 @@ protected:
virtual void DrawCellContents( const STableCell &inCell, const Rect &inLocalRect);
virtual void EraseCellBackground( const STableCell& inCell, const Rect& inLocalRect);
virtual ResIDT GetIconID(TableIndexT inRow) const;
virtual void DrawIconsSelf( const STableCell& inCell, IconTransformType inTransformType,
const Rect& inIconRect) const ;
virtual UInt16 GetNestedLevel(TableIndexT inRow) const;
virtual void SetCellExpansion( const STableCell& inCell, Boolean inExpand);
virtual Boolean CellHasDropFlag(const STableCell& inCell, Boolean& outIsExpanded) const;
@ -224,4 +229,30 @@ private:
// void OpenSelection();
void OpenRow ( TableIndexT inRow ) ;
}; // class CPopdownFlexTable
}; // class CPopdownFlexTable
#pragma mark -- class CTreeIcon --
//
// class CTreeIcon
//
// A very simple class that knows how to draw gifs as icons.
//
class CTreeIcon : public CImageIconMixin
{
public:
CTreeIcon ( const string & inURL, CHyperTreeFlexTable* inTree, HT_Resource inNode ) ;
~CTreeIcon ( ) ;
private:
void ImageIsReady ( ) ;
void DrawStandby ( const Point & inTopLeft,
const IconTransformType inTransform ) const;
CHyperTreeFlexTable* mTree;
HT_Resource mNode;
}; // class CTreeIcon