many changes to make generic tree control (more) MSW compatible:

1) wxEVT_COMMAND_TREE_EXPANDING event now generated
 2) tree control doesn't not delete children on branch collapse any more
 3) migging image list and image-related functions added (but not yet
    implemented)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@160 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 1998-07-01 15:42:11 +00:00
parent fd02ae23c2
commit 74bedbeb40
2 changed files with 153 additions and 96 deletions

View File

@ -35,6 +35,8 @@ class wxTreeEvent;
class wxGenericTreeItem; class wxGenericTreeItem;
class wxTreeCtrl; class wxTreeCtrl;
class wxImageList;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// constants // constants
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -153,7 +155,7 @@ class WXDLLEXPORT wxTreeItem: public wxObject
inline void SetStateMask(long stateMask) { m_stateMask = stateMask; } inline void SetStateMask(long stateMask) { m_stateMask = stateMask; }
inline void GetText(const wxString& text) { m_text = text; } inline void GetText(const wxString& text) { m_text = text; }
inline void SetImage(int image) { m_image = image; } inline void SetImage(int image) { m_image = image; }
inline void GetSelectedImage(int selImage) { m_selectedImage = selImage; } inline void SetSelectedImage(int selImage) { m_selectedImage = selImage; }
inline void SetChildren(int children) { m_children = children; } inline void SetChildren(int children) { m_children = children; }
inline void SetData(long data) { m_data = data; } inline void SetData(long data) { m_data = data; }
}; };
@ -177,6 +179,7 @@ class WXDLLEXPORT wxTreeEvent: public wxCommandEvent
inline long GetOldItem() const { return m_oldItem; } inline long GetOldItem() const { return m_oldItem; }
inline wxTreeItem& GetItem() const { return (wxTreeItem&) m_item; } inline wxTreeItem& GetItem() const { return (wxTreeItem&) m_item; }
inline wxPoint GetPoint() const { return m_pointDrag; } inline wxPoint GetPoint() const { return m_pointDrag; }
inline void SetCode(int code) { m_code = code; }
inline int GetCode() const { return m_code; } inline int GetCode() const { return m_code; }
}; };
@ -199,20 +202,13 @@ typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
// wxGenericTreeItem // wxGenericTreeItem
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class WXDLLEXPORT wxGenericTreeItem: public wxObject class WXDLLEXPORT wxGenericTreeItem: public wxTreeItem
{ {
DECLARE_DYNAMIC_CLASS(wxGenericTreeItem) DECLARE_DYNAMIC_CLASS(wxGenericTreeItem)
public:
long m_itemId; public:
long m_state; bool m_hasChildren,
wxString m_text; m_isCollapsed;
int m_image;
int m_selectedImage;
// int m_children;
bool m_hasChildren;
long m_data;
int m_x,m_y; int m_x,m_y;
int m_height,m_width; int m_height,m_width;
@ -221,7 +217,7 @@ class WXDLLEXPORT wxGenericTreeItem: public wxObject
wxList m_children; wxList m_children;
wxGenericTreeItem *m_parent; wxGenericTreeItem *m_parent;
bool m_hasHilight; bool m_hasHilight;
wxGenericTreeItem(void) {}; wxGenericTreeItem(void) {};
wxGenericTreeItem( wxGenericTreeItem *parent ); wxGenericTreeItem( wxGenericTreeItem *parent );
wxGenericTreeItem( wxGenericTreeItem *parent, const wxTreeItem& item, wxDC *dc ); wxGenericTreeItem( wxGenericTreeItem *parent, const wxTreeItem& item, wxDC *dc );
@ -244,8 +240,10 @@ class WXDLLEXPORT wxGenericTreeItem: public wxObject
void SendSelected( wxWindow *target ); void SendSelected( wxWindow *target );
void SendDelete( wxWindow *target ); void SendDelete( wxWindow *target );
void SendExpand( wxWindow *target ); void SendExpand( wxWindow *target );
void SendCollapse( wxWindow *target );
void SetHilight( bool set = TRUE ); void SetHilight( bool set = TRUE );
bool HasHilight(void); bool HasHilight(void);
bool IsExpanded() const { return !m_isCollapsed; }
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -255,41 +253,43 @@ class WXDLLEXPORT wxGenericTreeItem: public wxObject
class wxTreeCtrl: public wxScrolledWindow class wxTreeCtrl: public wxScrolledWindow
{ {
DECLARE_DYNAMIC_CLASS(wxTreeCtrl) DECLARE_DYNAMIC_CLASS(wxTreeCtrl)
public: public:
wxTreeCtrl(void); wxTreeCtrl(void);
wxTreeCtrl(wxWindow *parent, const wxWindowID id = -1, wxTreeCtrl(wxWindow *parent, const wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
const long style = wxTR_HAS_BUTTONS, long style = wxTR_HAS_BUTTONS,
const wxString& name = "wxTreeCtrl" ); const wxString& name = "wxTreeCtrl" );
~wxTreeCtrl(void); ~wxTreeCtrl(void);
bool Create(wxWindow *parent, const wxWindowID id = -1, bool Create(wxWindow *parent, const wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
const long style = wxTR_HAS_BUTTONS, long style = wxTR_HAS_BUTTONS,
const wxString& name = "wxTreeCtrl"); const wxString& name = "wxTreeCtrl");
int GetCount(void) const; int GetCount(void) const;
long InsertItem( const long parent, const wxString& label, const int image = -1, long InsertItem( long parent, const wxString& label, const int image = -1,
const int selImage = -1, const long insertAfter = wxTREE_INSERT_LAST ); const int selImage = -1, long insertAfter = wxTREE_INSERT_LAST );
long InsertItem( const long parent, wxTreeItem &info, const long insertAfter = wxTREE_INSERT_LAST ); long InsertItem( long parent, wxTreeItem &info, long insertAfter = wxTREE_INSERT_LAST );
bool DeleteAllItems(void); bool DeleteAllItems(void);
bool ExpandItem( const long item, const int action ); bool ExpandItem( long item, const int action );
bool GetItem( wxTreeItem &info ) const; bool GetItem( wxTreeItem &info ) const;
long GetItemData( const long item ) const; long GetItemData( long item ) const;
wxString GetItemText( const long item ) const; wxString GetItemText( long item ) const;
long GetParent( const long item ) const; int GetItemImage(long item) const;
long GetParent( long item ) const;
long GetRootItem(void) const; long GetRootItem(void) const;
long GetSelection(void) const; long GetSelection(void) const;
bool SelectItem( const long item ) const; bool SelectItem( long item ) const;
bool ItemHasChildren( const long item ) const; bool ItemHasChildren( long item ) const;
void SetIndent( const int indent ); void SetIndent( const int indent );
int GetIndent(void) const; int GetIndent(void) const;
bool SetItem( wxTreeItem &info ); bool SetItem( wxTreeItem &info );
bool SetItemData( const long item, const long data ); bool SetItemData( long item, long data );
bool SetItemText( const long item, const wxString &text ); bool SetItemText( long item, const wxString &text );
void SetItemImage(long item, int image, int imageSel) const;
long HitTest( const wxPoint& point, int &flags ); long HitTest( const wxPoint& point, int &flags );
void AdjustMyScrollbars(void); void AdjustMyScrollbars(void);
@ -299,9 +299,12 @@ class wxTreeCtrl: public wxScrolledWindow
void OnKillFocus( const wxFocusEvent &event ); void OnKillFocus( const wxFocusEvent &event );
void OnChar( wxKeyEvent &event ); void OnChar( wxKeyEvent &event );
void OnMouse( const wxMouseEvent &event ); void OnMouse( const wxMouseEvent &event );
void SetImageList(wxImageList *imageList) { m_imageList = imageList; }
wxImageList *GetImageList() const { return m_imageList; }
private: private:
wxGenericTreeItem *m_anchor; wxGenericTreeItem *m_anchor;
wxGenericTreeItem *m_current; wxGenericTreeItem *m_current;
bool m_hasFocus; bool m_hasFocus;
@ -312,13 +315,14 @@ class wxTreeCtrl: public wxScrolledWindow
wxPen m_dottedPen; wxPen m_dottedPen;
bool m_isCreated; bool m_isCreated;
wxPaintDC *m_dc; wxPaintDC *m_dc;
wxBrush *m_hilightBrush; wxBrush *m_hilightBrush;
wxImageList *m_imageList;
void CalculateLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level, int &y ); void CalculateLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level, int &y );
void CalculatePositions(void); void CalculatePositions(void);
wxGenericTreeItem *FindItem( const long itemId ) const; wxGenericTreeItem *FindItem( long itemId ) const;
void RefreshLine( wxGenericTreeItem *item ); void RefreshLine( wxGenericTreeItem *item );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@ -21,7 +21,7 @@
IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxTreeItem, wxObject)
wxTreeItem::wxTreeItem(void) wxTreeItem::wxTreeItem()
{ {
m_mask = 0; m_mask = 0;
m_itemId = 0; m_itemId = 0;
@ -100,7 +100,7 @@ void wxGenericTreeItem::SetText( const wxString &text, wxDC *dc )
m_height = lh; m_height = lh;
}; };
void wxGenericTreeItem::Reset(void) void wxGenericTreeItem::Reset()
{ {
m_itemId = -1; m_itemId = -1;
m_state = 0; m_state = 0;
@ -118,6 +118,7 @@ void wxGenericTreeItem::Reset(void)
m_yCross = 0; m_yCross = 0;
m_level = 0; m_level = 0;
m_children.DeleteContents( TRUE ); m_children.DeleteContents( TRUE );
m_isCollapsed = TRUE;
m_parent = NULL; m_parent = NULL;
}; };
@ -137,17 +138,20 @@ void wxGenericTreeItem::GetItem( wxTreeItem &item ) const
item.m_data = m_data; item.m_data = m_data;
}; };
bool wxGenericTreeItem::HasChildren(void) bool wxGenericTreeItem::HasChildren()
{ {
return m_hasChildren; return m_hasChildren;
}; };
bool wxGenericTreeItem::HasPlus(void) bool wxGenericTreeItem::HasPlus()
{ {
return (m_hasChildren && (m_children.Number() == 0)); if ( !HasChildren() )
return FALSE;
return !IsExpanded();
}; };
int wxGenericTreeItem::NumberOfVisibleDescendents(void) int wxGenericTreeItem::NumberOfVisibleDescendents()
{ {
int ret = m_children.Number(); int ret = m_children.Number();
wxNode *node = m_children.First(); wxNode *node = m_children.First();
@ -160,9 +164,9 @@ int wxGenericTreeItem::NumberOfVisibleDescendents(void)
return ret; return ret;
}; };
int wxGenericTreeItem::NumberOfVisibleChildren(void) int wxGenericTreeItem::NumberOfVisibleChildren()
{ {
return m_children.Number(); return m_isCollapsed ? 0 : m_children.Number();
}; };
wxGenericTreeItem *wxGenericTreeItem::FindItem( long itemId ) const wxGenericTreeItem *wxGenericTreeItem::FindItem( long itemId ) const
@ -277,8 +281,7 @@ void wxGenericTreeItem::SendSelected( wxWindow *target )
void wxGenericTreeItem::SendDelete( wxWindow *target ) void wxGenericTreeItem::SendDelete( wxWindow *target )
{ {
wxTreeEvent event( wxEVT_COMMAND_TREE_DELETE_ITEM, wxTreeEvent event( wxEVT_COMMAND_TREE_DELETE_ITEM, target->GetId() );
target->GetId() );
PrepareEvent( event ); PrepareEvent( event );
event.SetEventObject( target ); event.SetEventObject( target );
target->ProcessEvent( event ); target->ProcessEvent( event );
@ -286,10 +289,31 @@ void wxGenericTreeItem::SendDelete( wxWindow *target )
void wxGenericTreeItem::SendExpand( wxWindow *target ) void wxGenericTreeItem::SendExpand( wxWindow *target )
{ {
wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_EXPANDED, m_isCollapsed = FALSE;
target->GetId() );
PrepareEvent( event ); wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_EXPANDING, target->GetId() );
event.SetCode(wxTREE_EXPAND_EXPAND);
event.SetEventObject( target ); event.SetEventObject( target );
PrepareEvent( event );
target->ProcessEvent( event );
event.SetEventType(wxEVT_COMMAND_TREE_ITEM_EXPANDED);
PrepareEvent( event );
target->ProcessEvent( event );
};
void wxGenericTreeItem::SendCollapse( wxWindow *target )
{
m_isCollapsed = TRUE;
wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_EXPANDING, target->GetId() );
event.SetCode(wxTREE_EXPAND_COLLAPSE);
event.SetEventObject( target );
PrepareEvent( event );
target->ProcessEvent( event );
event.SetEventType(wxEVT_COMMAND_TREE_ITEM_EXPANDED);
PrepareEvent( event );
target->ProcessEvent( event ); target->ProcessEvent( event );
}; };
@ -298,7 +322,7 @@ void wxGenericTreeItem::SetHilight( bool set )
m_hasHilight = set; m_hasHilight = set;
}; };
bool wxGenericTreeItem::HasHilight(void) bool wxGenericTreeItem::HasHilight()
{ {
return m_hasHilight; return m_hasHilight;
}; };
@ -318,7 +342,7 @@ BEGIN_EVENT_TABLE(wxTreeCtrl,wxScrolledWindow)
EVT_KILL_FOCUS (wxTreeCtrl::OnKillFocus) EVT_KILL_FOCUS (wxTreeCtrl::OnKillFocus)
END_EVENT_TABLE() END_EVENT_TABLE()
wxTreeCtrl::wxTreeCtrl(void) wxTreeCtrl::wxTreeCtrl()
{ {
m_current = NULL; m_current = NULL;
m_anchor = NULL; m_anchor = NULL;
@ -336,7 +360,7 @@ wxTreeCtrl::wxTreeCtrl(void)
wxTreeCtrl::wxTreeCtrl(wxWindow *parent, const wxWindowID id, wxTreeCtrl::wxTreeCtrl(wxWindow *parent, const wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
const long style, const wxString& name ) long style, const wxString& name )
{ {
m_current = NULL; m_current = NULL;
m_anchor = NULL; m_anchor = NULL;
@ -352,7 +376,7 @@ wxTreeCtrl::wxTreeCtrl(wxWindow *parent, const wxWindowID id,
Create( parent, id, pos, size, style, name ); Create( parent, id, pos, size, style, name );
}; };
wxTreeCtrl::~wxTreeCtrl(void) wxTreeCtrl::~wxTreeCtrl()
{ {
if (m_dc) delete m_dc; if (m_dc) delete m_dc;
}; };
@ -360,7 +384,7 @@ wxTreeCtrl::~wxTreeCtrl(void)
bool wxTreeCtrl::Create(wxWindow *parent, const wxWindowID id, bool wxTreeCtrl::Create(wxWindow *parent, const wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
const long style long style
, const wxString& name ) , const wxString& name )
{ {
wxScrolledWindow::Create( parent, id, pos, size, style, name ); wxScrolledWindow::Create( parent, id, pos, size, style, name );
@ -369,14 +393,14 @@ bool wxTreeCtrl::Create(wxWindow *parent, const wxWindowID id,
return TRUE; return TRUE;
}; };
int wxTreeCtrl::GetCount(void) const int wxTreeCtrl::GetCount() const
{ {
if (!m_anchor) return 0; if (!m_anchor) return 0;
return m_anchor->NumberOfVisibleDescendents(); return m_anchor->NumberOfVisibleDescendents();
}; };
long wxTreeCtrl::InsertItem( const long parent, const wxString& label, const int image, long wxTreeCtrl::InsertItem( long parent, const wxString& label, int image,
const int selImage, const long WXUNUSED(insertAfter) ) int selImage, long WXUNUSED(insertAfter) )
{ {
wxGenericTreeItem *p = NULL; wxGenericTreeItem *p = NULL;
if (parent == 0) if (parent == 0)
@ -457,7 +481,7 @@ long wxTreeCtrl::InsertItem( const long parent, const wxString& label, const int
return m_lastId; return m_lastId;
}; };
long wxTreeCtrl::InsertItem( const long parent, wxTreeItem &info, const long WXUNUSED(insertAfter) ) long wxTreeCtrl::InsertItem( long parent, wxTreeItem &info, long WXUNUSED(insertAfter) )
{ {
int oldMask = info.m_mask; int oldMask = info.m_mask;
wxGenericTreeItem *p = NULL; wxGenericTreeItem *p = NULL;
@ -537,17 +561,20 @@ long wxTreeCtrl::InsertItem( const long parent, wxTreeItem &info, const long WXU
return ret; return ret;
}; };
bool wxTreeCtrl::ExpandItem( const long item, const int action ) bool wxTreeCtrl::ExpandItem( long item, int action )
{ {
wxGenericTreeItem *i = FindItem( item ); wxGenericTreeItem *i = FindItem( item );
if (!i) return FALSE; if (!i)
return FALSE;
switch (action) switch (action)
{ {
case wxTREE_EXPAND_EXPAND: case wxTREE_EXPAND_EXPAND:
{ {
i->SendExpand( this ); i->SendExpand( this );
break; break;
}; }
case wxTREE_EXPAND_COLLAPSE_RESET: case wxTREE_EXPAND_COLLAPSE_RESET:
case wxTREE_EXPAND_COLLAPSE: case wxTREE_EXPAND_COLLAPSE:
{ {
@ -555,42 +582,52 @@ bool wxTreeCtrl::ExpandItem( const long item, const int action )
while (node) while (node)
{ {
wxGenericTreeItem *child = (wxGenericTreeItem*)node->Data(); wxGenericTreeItem *child = (wxGenericTreeItem*)node->Data();
#if 0 // VZ: don't delete items when the branch is collapsed
child->SendDelete( this ); child->SendDelete( this );
delete node; delete node;
node = i->m_children.First(); node = i->m_children.First();
#else
if ( child->IsExpanded() )
ExpandItem( child->m_itemId, wxTREE_EXPAND_COLLAPSE );
node = node->Next();
#endif
}; };
int cw = 0; i->SendCollapse( this );
int ch = 0;
GetClientSize( &cw, &ch );
wxRect rect;
rect.x = 0;
rect.width = cw;
wxClientDC dc(this);
PrepareDC(dc);
rect.y = dc.LogicalToDeviceY( i->m_y );
long doY = 0;
dc.GetDeviceOrigin( NULL, &doY );
rect.height = ch-rect.y-doY;
Refresh( TRUE, &rect );
AdjustMyScrollbars();
break; break;
}; }
case wxTREE_EXPAND_TOGGLE: case wxTREE_EXPAND_TOGGLE:
{ {
if (i->HasPlus()) if ( i->IsExpanded() )
ExpandItem( item, wxTREE_EXPAND_EXPAND );
else
ExpandItem( item, wxTREE_EXPAND_COLLAPSE ); ExpandItem( item, wxTREE_EXPAND_COLLAPSE );
break; else
}; ExpandItem( item, wxTREE_EXPAND_EXPAND );
return TRUE;
}
}; };
int cw = 0;
int ch = 0;
GetClientSize( &cw, &ch );
wxRect rect;
rect.x = 0;
rect.width = cw;
wxClientDC dc(this);
PrepareDC(dc);
rect.y = dc.LogicalToDeviceY( i->m_y );
long doY = 0;
dc.GetDeviceOrigin( NULL, &doY );
rect.height = ch-rect.y-doY;
Refresh( TRUE, &rect );
AdjustMyScrollbars();
return TRUE; return TRUE;
}; };
bool wxTreeCtrl::DeleteAllItems(void) bool wxTreeCtrl::DeleteAllItems()
{ {
delete m_anchor; delete m_anchor;
m_anchor = NULL; m_anchor = NULL;
@ -606,21 +643,27 @@ bool wxTreeCtrl::GetItem( wxTreeItem &info ) const
return TRUE; return TRUE;
}; };
long wxTreeCtrl::GetItemData( const long item ) const long wxTreeCtrl::GetItemData( long item ) const
{ {
wxGenericTreeItem *i = FindItem( item ); wxGenericTreeItem *i = FindItem( item );
if (!i) return 0; if (!i) return 0;
return i->m_data; return i->m_data;
}; };
wxString wxTreeCtrl::GetItemText( const long item ) const wxString wxTreeCtrl::GetItemText( long item ) const
{ {
wxGenericTreeItem *i = FindItem( item ); wxGenericTreeItem *i = FindItem( item );
if (!i) return ""; if (!i) return "";
return i->m_text; return i->m_text;
}; };
long wxTreeCtrl::GetParent( const long item ) const int wxTreeCtrl::GetItemImage(long item) const
{
wxGenericTreeItem *i = FindItem( item );
return i == 0 ? -1 : i->GetImage();
}
long wxTreeCtrl::GetParent( long item ) const
{ {
wxGenericTreeItem *i = FindItem( item ); wxGenericTreeItem *i = FindItem( item );
if (!i) return -1; if (!i) return -1;
@ -629,36 +672,36 @@ long wxTreeCtrl::GetParent( const long item ) const
return i->m_parent->m_itemId; return i->m_parent->m_itemId;
}; };
long wxTreeCtrl::GetRootItem(void) const long wxTreeCtrl::GetRootItem() const
{ {
if (m_anchor) return m_anchor->m_itemId; if (m_anchor) return m_anchor->m_itemId;
return -1; return -1;
}; };
long wxTreeCtrl::GetSelection(void) const long wxTreeCtrl::GetSelection() const
{ {
return 0; return 0;
}; };
bool wxTreeCtrl::SelectItem( const long WXUNUSED(item) ) const bool wxTreeCtrl::SelectItem( long WXUNUSED(item) ) const
{ {
return FALSE; return FALSE;
}; };
bool wxTreeCtrl::ItemHasChildren( const long item ) const bool wxTreeCtrl::ItemHasChildren( long item ) const
{ {
wxGenericTreeItem *i = FindItem( item ); wxGenericTreeItem *i = FindItem( item );
if (!i) return FALSE; if (!i) return FALSE;
return i->m_hasChildren; return i->m_hasChildren;
}; };
void wxTreeCtrl::SetIndent( const int indent ) void wxTreeCtrl::SetIndent( int indent )
{ {
m_indent = indent; m_indent = indent;
Refresh(); Refresh();
}; };
int wxTreeCtrl::GetIndent(void) const int wxTreeCtrl::GetIndent() const
{ {
return m_indent; return m_indent;
}; };
@ -669,10 +712,11 @@ bool wxTreeCtrl::SetItem( wxTreeItem &info )
if (!i) return FALSE; if (!i) return FALSE;
wxClientDC dc(this); wxClientDC dc(this);
i->SetItem( info, &dc ); i->SetItem( info, &dc );
Refresh();
return TRUE; return TRUE;
}; };
bool wxTreeCtrl::SetItemData( const long item, const long data ) bool wxTreeCtrl::SetItemData( long item, long data )
{ {
wxGenericTreeItem *i = FindItem( item ); wxGenericTreeItem *i = FindItem( item );
if (!i) return FALSE; if (!i) return FALSE;
@ -680,7 +724,7 @@ bool wxTreeCtrl::SetItemData( const long item, const long data )
return TRUE; return TRUE;
}; };
bool wxTreeCtrl::SetItemText( const long item, const wxString &text ) bool wxTreeCtrl::SetItemText( long item, const wxString &text )
{ {
wxGenericTreeItem *i = FindItem( item ); wxGenericTreeItem *i = FindItem( item );
if (!i) return FALSE; if (!i) return FALSE;
@ -689,6 +733,15 @@ bool wxTreeCtrl::SetItemText( const long item, const wxString &text )
return TRUE; return TRUE;
}; };
void wxTreeCtrl::SetItemImage(long item, int image, int imageSel) const
{
wxGenericTreeItem *i = FindItem( item );
if ( i != 0 ) {
i->SetImage(image);
i->SetSelectedImage(imageSel);
}
}
long wxTreeCtrl::HitTest( const wxPoint& point, int &flags ) long wxTreeCtrl::HitTest( const wxPoint& point, int &flags )
{ {
flags = 0; flags = 0;
@ -696,7 +749,7 @@ long wxTreeCtrl::HitTest( const wxPoint& point, int &flags )
return m_anchor->HitTest( point, flags ); return m_anchor->HitTest( point, flags );
}; };
void wxTreeCtrl::AdjustMyScrollbars(void) void wxTreeCtrl::AdjustMyScrollbars()
{ {
if (m_anchor) if (m_anchor)
{ {
@ -792,7 +845,7 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level,
}; };
y += m_lineHeight; y += m_lineHeight;
if (child->NumberOfVisibleChildren() > 0) if ( child->IsExpanded() && child->NumberOfVisibleChildren() > 0)
PaintLevel( child, dc, level+1, y ); PaintLevel( child, dc, level+1, y );
node = node->Next(); node = node->Next();
}; };
@ -899,14 +952,14 @@ void wxTreeCtrl::CalculateLevel( wxGenericTreeItem *item, wxPaintDC &dc, int lev
child->m_height = m_lineHeight; child->m_height = m_lineHeight;
y += m_lineHeight; y += m_lineHeight;
if (child->NumberOfVisibleChildren() > 0) if ( child->IsExpanded() && child->NumberOfVisibleChildren() > 0 )
CalculateLevel( child, dc, level+1, y ); CalculateLevel( child, dc, level+1, y );
node = node->Next(); node = node->Next();
}; };
}; };
void wxTreeCtrl::CalculatePositions(void) void wxTreeCtrl::CalculatePositions()
{ {
if (!m_anchor) if (!m_anchor)
return; return;