X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/22f3361e1cf25c52a2da8fdfc5cb081809e18fb9..d53c798cf954483a97b0611184b34e63cad7ed99:/include/wx/generic/treectlg.h diff --git a/include/wx/generic/treectlg.h b/include/wx/generic/treectlg.h index e24dd825ce..68fb89b8b2 100644 --- a/include/wx/generic/treectlg.h +++ b/include/wx/generic/treectlg.h @@ -6,13 +6,13 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) 1997,1998 Robert Roebling -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _GENERIC_TREECTRL_H_ #define _GENERIC_TREECTRL_H_ -#if defined(__GNUG__) && !defined(__APPLE__) +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma interface "treectlg.h" #endif @@ -185,7 +185,8 @@ public: // if 'recursively' is FALSE, only immediate children count, otherwise // the returned number is the number of all items in this branch - size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE); + size_t GetChildrenCount(const wxTreeItemId& item, + bool recursively = TRUE) const; // navigation // ---------- @@ -207,9 +208,9 @@ public: #if WXWIN_COMPATIBILITY_2_2 // deprecated: Use GetItemParent instead. wxTreeItemId GetParent(const wxTreeItemId& item) const - { return GetItemParent( item ); } + { return GetItemParent( item ); } - // Expose the base class method hidden by the one above. + // Expose the base class method hidden by the one above. wxWindow *GetParent() const { return wxScrolledWindow::GetParent(); } #endif // WXWIN_COMPATIBILITY_2_2 @@ -221,9 +222,11 @@ public: // the same! // get the first child of this item - wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& cookie) const; + wxTreeItemId GetFirstChild(const wxTreeItemId& item, + wxTreeItemIdValue& cookie) const; // get the next child - wxTreeItemId GetNextChild(const wxTreeItemId& item, long& cookie) const; + wxTreeItemId GetNextChild(const wxTreeItemId& item, + wxTreeItemIdValue& cookie) const; // get the last child of this item - this method doesn't use cookies wxTreeItemId GetLastChild(const wxTreeItemId& item) const; @@ -299,9 +302,18 @@ public: // remove the selection from currently selected item (if any) void Unselect(); + // or from the given one (multiselect mode only) + void UnselectItem(const wxTreeItemId& item) { SelectItem(item, false); } + // or from all void UnselectAll(); // select this item - void SelectItem(const wxTreeItemId& item, bool unselect_others=TRUE, bool extended_select=FALSE); + void SelectItem(const wxTreeItemId& item, bool select = true); + // toggle the item selection + void ToggleItemSelection(const wxTreeItemId& item) + { + SelectItem(item, !IsSelected(item)); + } + // make sure this item is visible (expanding the parent item and/or // scrolling to this item if necessary) void EnsureVisible(const wxTreeItemId& item); @@ -342,28 +354,51 @@ public: // NB: this function is not reentrant and not MT-safe (FIXME)! void SortChildren(const wxTreeItemId& item); +#if WXWIN_COMPATIBILITY_2_4 // deprecated functions: use Set/GetItemImage directly - // get the selected item image int GetItemSelectedImage(const wxTreeItemId& item) const { return GetItemImage(item, wxTreeItemIcon_Selected); } - // set the selected item image void SetItemSelectedImage(const wxTreeItemId& item, int image) { SetItemImage(item, image, wxTreeItemIcon_Selected); } + // use the versions taking wxTreeItemIdValue cookies (note that + // GetNextChild() is not inside wxDEPRECATED on purpose, as otherwise we + // get twice as many warnings without any added benefit: it is always used + // with GetFirstChild() anyhow) + wxDEPRECATED( wxTreeItemId GetFirstChild(const wxTreeItemId& item, + long& cookie) const ); + wxTreeItemId GetNextChild(const wxTreeItemId& item, + long& cookie) const; +#endif // WXWIN_COMPATIBILITY_2_4 + + virtual bool ShouldInheritColours() const { return false; } + // implementation only from now on // overridden base class virtuals virtual bool SetBackgroundColour(const wxColour& colour); virtual bool SetForegroundColour(const wxColour& colour); + virtual void Freeze(); + virtual void Thaw(); + // callbacks void OnPaint( wxPaintEvent &event ); void OnSetFocus( wxFocusEvent &event ); void OnKillFocus( wxFocusEvent &event ); void OnChar( wxKeyEvent &event ); void OnMouse( wxMouseEvent &event ); - void OnIdle( wxIdleEvent &event ); + void OnGetToolTip( wxTreeEvent &event ); + void OnInternalIdle( ); + virtual wxVisualAttributes GetDefaultAttributes() const + { + return GetClassDefaultAttributes(GetWindowVariant()); + } + + static wxVisualAttributes + GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); + // implementation helpers protected: friend class wxGenericTreeItem; @@ -376,7 +411,9 @@ protected: wxGenericTreeItem *m_anchor; wxGenericTreeItem *m_current, - *m_key_current; + *m_key_current, + // A hint to select a parent item after deleting a child + *m_select_me; unsigned short m_indent; unsigned short m_spacing; int m_lineHeight; @@ -394,18 +431,17 @@ protected: *m_imageListState, *m_imageListButtons; + int m_freezeCount; int m_dragCount; wxPoint m_dragStart; wxGenericTreeItem *m_dropTarget; wxCursor m_oldCursor; // cursor is changed while dragging wxGenericTreeItem *m_oldSelection; + wxGenericTreeItem *m_underMouse; // for visual effects wxTreeTextCtrl *m_textCtrl; wxTimer *m_renameTimer; - wxBitmap *m_arrowRight, - *m_arrowDown; - // incremental search data wxString m_findPrefix; wxTimer *m_findTimer; @@ -420,6 +456,10 @@ protected: void DrawLine(const wxTreeItemId& item, bool below); void DrawDropEffect(wxGenericTreeItem *item); + void DoSelectItem(const wxTreeItemId& id, + bool unselect_others = TRUE, + bool extended_select = FALSE); + wxTreeItemId DoInsertItem(const wxTreeItemId& parent, size_t previous, const wxString& text, @@ -432,9 +472,7 @@ protected: // find the first item starting with the given prefix after the given item wxTreeItemId FindItem(const wxTreeItemId& id, const wxString& prefix) const; - bool HasButtons(void) const - { return (m_imageListButtons != NULL) - || HasFlag(wxTR_TWIST_BUTTONS|wxTR_HAS_BUTTONS); } + bool HasButtons() const { return HasFlag(wxTR_HAS_BUTTONS); } void CalculateLineHeight(); int GetLineHeight(wxGenericTreeItem *item) const; @@ -470,7 +508,7 @@ private: DECLARE_NO_COPY_CLASS(wxGenericTreeCtrl) }; -#if !defined(__WXMSW__) || defined(__WIN16__) || defined(__WXUNIVERSAL__) +#if !defined(__WXMSW__) || defined(__WXUNIVERSAL__) /* * wxTreeCtrl has to be a real class or we have problems with * the run-time information. @@ -493,7 +531,7 @@ public: { } }; -#endif // !__WXMSW__ || __WIN16__ || __WXUNIVERSAL__ +#endif // !__WXMSW__ || __WXUNIVERSAL__ #endif // wxUSE_TREECTRL