added missing DeleteItem(long itemId) function

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@182 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1998-07-07 13:16:37 +00:00
parent 0e338ff9a3
commit a32dd69091
2 changed files with 113 additions and 106 deletions

View File

@@ -123,41 +123,41 @@ enum {
class WXDLLEXPORT wxTreeItem: public wxObject class WXDLLEXPORT wxTreeItem: public wxObject
{ {
public:
long m_mask;
long m_itemId;
long m_state;
long m_stateMask;
wxString m_text;
int m_image;
int m_selectedImage;
int m_children;
long m_data;
wxTreeItem();
// Accessors
inline long GetMask() const { return m_mask; }
inline long GetItemId() const { return m_itemId; }
inline long GetState() const { return m_state; }
inline long GetStateMask() const { return m_stateMask; }
inline wxString GetText() const { return m_text; }
inline int GetImage() const { return m_image; }
inline int GetSelectedImage() const { return m_selectedImage; }
inline int GetChildren() const { return m_children; }
inline long GetData() const { return m_data; }
inline void SetMask(long mask) { m_mask = mask; }
inline void SetItemId(long id) { m_itemId = m_itemId = id; }
inline void GetState(long state) { m_state = state; }
inline void SetStateMask(long stateMask) { m_stateMask = stateMask; }
inline void GetText(const wxString& text) { m_text = text; }
inline void SetImage(int image) { m_image = image; }
inline void SetSelectedImage(int selImage) { m_selectedImage = selImage; }
inline void SetChildren(int children) { m_children = children; }
inline void SetData(long data) { m_data = data; }
DECLARE_DYNAMIC_CLASS(wxTreeItem) DECLARE_DYNAMIC_CLASS(wxTreeItem)
public:
long m_mask;
long m_itemId;
long m_state;
long m_stateMask;
wxString m_text;
int m_image;
int m_selectedImage;
int m_children;
long m_data;
wxTreeItem(void);
// Accessors
inline long GetMask() const { return m_mask; }
inline long GetItemId() const { return m_itemId; }
inline long GetState() const { return m_state; }
inline long GetStateMask() const { return m_stateMask; }
inline wxString GetText() const { return m_text; }
inline int GetImage() const { return m_image; }
inline int GetSelectedImage() const { return m_selectedImage; }
inline int GetChildren() const { return m_children; }
inline long GetData() const { return m_data; }
inline void SetMask(long mask) { m_mask = mask; }
inline void SetItemId(long id) { m_itemId = m_itemId = id; }
inline void GetState(long state) { m_state = state; }
inline void SetStateMask(long stateMask) { m_stateMask = stateMask; }
inline void GetText(const wxString& text) { m_text = text; }
inline void SetImage(int image) { m_image = image; }
inline void SetSelectedImage(int selImage) { m_selectedImage = selImage; }
inline void SetChildren(int children) { m_children = children; }
inline void SetData(long data) { m_data = data; }
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -218,18 +218,18 @@ class WXDLLEXPORT wxGenericTreeItem: public wxTreeItem
wxGenericTreeItem *m_parent; wxGenericTreeItem *m_parent;
bool m_hasHilight; bool m_hasHilight;
wxGenericTreeItem(void) {}; wxGenericTreeItem() {};
wxGenericTreeItem( wxGenericTreeItem *parent ); wxGenericTreeItem( wxGenericTreeItem *parent );
wxGenericTreeItem( wxGenericTreeItem *parent, const wxTreeItem& item, wxDC *dc ); wxGenericTreeItem( wxGenericTreeItem *parent, const wxTreeItem& item, wxDC *dc );
void SetItem( const wxTreeItem &item, wxDC *dc ); void SetItem( const wxTreeItem &item, wxDC *dc );
void SetText( const wxString &text, wxDC *dc ); void SetText( const wxString &text, wxDC *dc );
void Reset(void); void Reset();
void GetItem( wxTreeItem &item ) const; void GetItem( wxTreeItem &item ) const;
void AddChild( const wxTreeItem &item ); void AddChild( const wxTreeItem &item );
bool HasChildren(void); bool HasChildren();
bool HasPlus(void); bool HasPlus();
int NumberOfVisibleDescendents(void); int NumberOfVisibleDescendents();
int NumberOfVisibleChildren(void); int NumberOfVisibleChildren();
wxGenericTreeItem *FindItem( long itemId ) const; wxGenericTreeItem *FindItem( long itemId ) const;
void AddChild( wxGenericTreeItem *child ); void AddChild( wxGenericTreeItem *child );
void SetCross( int x, int y ); void SetCross( int x, int y );
@@ -242,7 +242,7 @@ class WXDLLEXPORT wxGenericTreeItem: public wxTreeItem
void SendExpand( wxWindow *target ); void SendExpand( wxWindow *target );
void SendCollapse( wxWindow *target ); void SendCollapse( wxWindow *target );
void SetHilight( bool set = TRUE ); void SetHilight( bool set = TRUE );
bool HasHilight(void); bool HasHilight();
bool IsExpanded() const { return !m_isCollapsed; } bool IsExpanded() const { return !m_isCollapsed; }
}; };
@@ -252,78 +252,77 @@ class WXDLLEXPORT wxGenericTreeItem: public wxTreeItem
class wxTreeCtrl: public wxScrolledWindow class wxTreeCtrl: public wxScrolledWindow
{ {
DECLARE_DYNAMIC_CLASS(wxTreeCtrl) public:
wxTreeCtrl();
wxTreeCtrl(wxWindow *parent, const wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTR_HAS_BUTTONS,
const wxString& name = "wxTreeCtrl" );
~wxTreeCtrl();
bool Create(wxWindow *parent, const wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTR_HAS_BUTTONS,
const wxString& name = "wxTreeCtrl");
public: int GetCount() const;
long InsertItem( long parent, const wxString& label, int image = -1,
int selImage = -1, long insertAfter = wxTREE_INSERT_LAST );
long InsertItem( long parent, wxTreeItem &info,
long insertAfter = wxTREE_INSERT_LAST );
void DeleteItem( long item );
bool DeleteAllItems();
bool ExpandItem( long item, int action );
bool GetItem( wxTreeItem &info ) const;
long GetItemData( long item ) const;
wxString GetItemText( long item ) const;
int GetItemImage(long item) const;
long GetParent( long item ) const;
long GetRootItem() const;
long GetSelection() const;
bool SelectItem( long item ) const;
bool ItemHasChildren( long item ) const;
void SetIndent( int indent );
int GetIndent() const;
bool SetItem( wxTreeItem &info );
bool SetItemData( long item, long data );
bool SetItemText( long item, const wxString &text );
void SetItemImage(long item, int image, int imageSel) const;
long HitTest( const wxPoint& point, int &flags );
wxTreeCtrl(void); void AdjustMyScrollbars();
wxTreeCtrl(wxWindow *parent, wxWindowID id = -1, void PaintLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level, int &y );
const wxPoint& pos = wxDefaultPosition, void OnPaint( const wxPaintEvent &event );
const wxSize& size = wxDefaultSize, void OnSetFocus( const wxFocusEvent &event );
long style = wxTR_HAS_BUTTONS, void OnKillFocus( const wxFocusEvent &event );
const wxString& name = "wxTreeCtrl" ); void OnChar( wxKeyEvent &event );
~wxTreeCtrl(void); void OnMouse( const wxMouseEvent &event );
bool Create(wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTR_HAS_BUTTONS,
const wxString& name = "wxTreeCtrl");
int GetCount(void) const; void SetImageList(wxImageList *imageList) { m_imageList = imageList; }
long InsertItem( long parent, const wxString& label, int image = -1, wxImageList *GetImageList() const { return m_imageList; }
int selImage = -1, long insertAfter = wxTREE_INSERT_LAST );
long InsertItem( long parent, wxTreeItem &info, long insertAfter = wxTREE_INSERT_LAST );
bool DeleteAllItems(void);
bool ExpandItem( long item, int action );
bool GetItem( wxTreeItem &info ) const;
long GetItemData( long item ) const;
wxString GetItemText( long item ) const;
int GetItemImage(long item) const;
long GetParent( long item ) const;
long GetRootItem(void) const;
long GetSelection(void) const;
bool SelectItem( long item ) const;
bool ItemHasChildren( long item ) const;
void SetIndent( int indent );
int GetIndent(void) const;
bool SetItem( wxTreeItem &info );
bool SetItemData( long item, long data );
bool SetItemText( long item, const wxString &text );
void SetItemImage(long item, int image, int imageSel) const;
long HitTest( const wxPoint& point, int &flags );
void AdjustMyScrollbars(void); private:
void PaintLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level, int &y ); wxGenericTreeItem *m_anchor;
void OnPaint( const wxPaintEvent &event ); wxGenericTreeItem *m_current;
void OnSetFocus( const wxFocusEvent &event ); bool m_hasFocus;
void OnKillFocus( const wxFocusEvent &event ); int m_xScroll,m_yScroll;
void OnChar( wxKeyEvent &event ); int m_indent;
void OnMouse( const wxMouseEvent &event ); long m_lastId;
int m_lineHeight;
wxPen m_dottedPen;
bool m_isCreated;
wxPaintDC *m_dc;
wxBrush *m_hilightBrush;
wxImageList *m_imageList;
void SetImageList(wxImageList *imageList) { m_imageList = imageList; } void CalculateLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level, int &y );
wxImageList *GetImageList() const { return m_imageList; } void CalculatePositions();
wxGenericTreeItem *FindItem( long itemId ) const;
private: void RefreshLine( wxGenericTreeItem *item );
wxGenericTreeItem *m_anchor;
wxGenericTreeItem *m_current;
bool m_hasFocus;
int m_xScroll,m_yScroll;
int m_indent;
long m_lastId;
int m_lineHeight;
wxPen m_dottedPen;
bool m_isCreated;
wxPaintDC *m_dc;
wxBrush *m_hilightBrush;
wxImageList *m_imageList;
void CalculateLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level, int &y );
void CalculatePositions(void);
wxGenericTreeItem *FindItem( long itemId ) const;
void RefreshLine( wxGenericTreeItem *item );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxTreeCtrl)
}; };
#endif #endif

View File

@@ -627,6 +627,14 @@ bool wxTreeCtrl::ExpandItem( long item, int action )
return TRUE; return TRUE;
}; };
void wxTreeCtrl::DeleteItem( long item )
{
wxGenericTreeItem *pItem = FindItem( item );
wxCHECK_RET( pItem != NULL, "wxTreeCtrl::DeleteItem: no such pItem." );
pItem->m_parent->m_children.DeleteObject(pItem);
Refresh();
}
bool wxTreeCtrl::DeleteAllItems() bool wxTreeCtrl::DeleteAllItems()
{ {
delete m_anchor; delete m_anchor;