#ifndef _WX_TREECTRL_H_BASE_
#define _WX_TREECTRL_H_BASE_
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#include "wx/defs.h"
+
+#if wxUSE_TREECTRL
+
+#include "wx/control.h"
#include "wx/treebase.h"
+#include "wx/textctrl.h" // wxTextCtrl::ms_classinfo used through wxCLASSINFO macro
-class WXDLLEXPORT wxImageList;
+class WXDLLIMPEXP_FWD_CORE wxImageList;
// ----------------------------------------------------------------------------
// wxTreeCtrlBase
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxTreeCtrlBase : public wxControl
+class WXDLLIMPEXP_CORE wxTreeCtrlBase : public wxControl
{
public:
wxTreeCtrlBase()
// arbitrary default
m_spacing = 18;
+
+ // quick DoGetBestSize calculation
+ m_quickBestSize = true;
}
virtual ~wxTreeCtrlBase();
// ---------
// get the total number of items in the control
- virtual size_t GetCount() const = 0;
+ virtual unsigned int GetCount() const = 0;
// indent is the number of pixels the children are indented relative to
// the parents position. SetIndent() also redraws the control
// get the item's font
virtual wxFont GetItemFont(const wxTreeItemId& item) const = 0;
+ // get the items state
+ int GetItemState(const wxTreeItemId& item) const
+ {
+ return DoGetItemState(item);
+ }
+
// modifiers
// ---------
// set items label
virtual void SetItemText(const wxTreeItemId& item, const wxString& text) = 0;
- // get one of the images associated with the item (normal by default)
+ // set one of the images associated with the item (normal by default)
virtual void SetItemImage(const wxTreeItemId& item,
int image,
wxTreeItemIcon which = wxTreeItemIcon_Normal) = 0;
virtual void SetItemFont(const wxTreeItemId& item,
const wxFont& font) = 0;
+ // set the items state (special state values: wxTREE_ITEMSTATE_NONE/NEXT/PREV)
+ void SetItemState(const wxTreeItemId& item, int state);
+
// item status inquiries
// ---------------------
virtual bool IsSelected(const wxTreeItemId& item) const = 0;
// is item text in bold font?
virtual bool IsBold(const wxTreeItemId& item) const = 0;
+ // is the control empty?
+ bool IsEmpty() const;
+
// number of children
// ------------------
// control with a lot of items (~ O(number of items)).
virtual size_t GetSelections(wxArrayTreeItemIds& selections) const = 0;
+ // get the last item to be clicked when the control has wxTR_MULTIPLE
+ // equivalent to GetSelection() if not wxTR_MULTIPLE
+ virtual wxTreeItemId GetFocusedItem() const = 0;
+
+
+ // Clears the currently focused item
+ virtual void ClearFocusedItem() = 0;
+ // Sets the currently focused item. Item should be valid
+ virtual void SetFocusedItem(const wxTreeItemId& item) = 0;
+
+
// get the parent of this item (may return NULL if root)
virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const = 0;
// expand this item
virtual void Expand(const wxTreeItemId& item) = 0;
+ // expand the item and all its children recursively
+ void ExpandAllChildren(const wxTreeItemId& item);
+ // expand all items
+ void ExpandAll();
// collapse the item without removing its children
virtual void Collapse(const wxTreeItemId& item) = 0;
+ // collapse the item and all its children
+ void CollapseAllChildren(const wxTreeItemId& item);
+ // collapse all items
+ void CollapseAll();
// collapse the item and remove all children
virtual void CollapseAndReset(const wxTreeItemId& item) = 0;
// toggles the current state
virtual void UnselectAll() = 0;
// select this item
virtual void SelectItem(const wxTreeItemId& item, bool select = true) = 0;
+ // selects all (direct) children for given parent (only for
+ // multiselection controls)
+ virtual void SelectChildren(const wxTreeItemId& parent) = 0;
// unselect this item
void UnselectItem(const wxTreeItemId& item) { SelectItem(item, false); }
// toggle item selection
// been before. textCtrlClass parameter allows you to create an edit
// control of arbitrary user-defined class deriving from wxTextCtrl.
virtual wxTextCtrl *EditLabel(const wxTreeItemId& item,
- wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl)) = 0;
+ wxClassInfo* textCtrlClass = wxCLASSINFO(wxTextCtrl)) = 0;
// returns the same pointer as StartEdit() if the item is being edited,
// NULL otherwise (it's assumed that no more than one item may be
// edited simultaneously)
// coordinates specified are relative to the client area of tree ctrl)
// and, in the second variant, fill the flags parameter with a bitmask
// of wxTREE_HITTEST_xxx constants.
- wxTreeItemId HitTest(const wxPoint& point)
- { int dummy; return DoHitTest(point, dummy); }
- wxTreeItemId HitTest(const wxPoint& point, int& flags)
- { return DoHitTest(point, flags); }
+ wxTreeItemId HitTest(const wxPoint& point) const
+ { int dummy; return DoTreeHitTest(point, dummy); }
+ wxTreeItemId HitTest(const wxPoint& point, int& flags) const
+ { return DoTreeHitTest(point, flags); }
// get the bounding rectangle of the item (or of its label only)
virtual bool GetBoundingRect(const wxTreeItemId& item,
virtual bool ShouldInheritColours() const { return false; }
+ // hint whether to calculate best size quickly or accurately
+ void SetQuickBestSize(bool q) { m_quickBestSize = q; }
+ bool GetQuickBestSize() const { return m_quickBestSize; }
+
protected:
virtual wxSize DoGetBestSize() const;
+ // common part of Get/SetItemState()
+ virtual int DoGetItemState(const wxTreeItemId& item) const = 0;
+ virtual void DoSetItemState(const wxTreeItemId& item, int state) = 0;
+
// common part of Append/Prepend/InsertItem()
//
// pos is the position at which to insert the item or (size_t)-1 to append
// real HitTest() implementation: again, can't be called just HitTest()
// because it's overloaded and so the non-virtual overload would be hidden
- virtual wxTreeItemId DoHitTest(const wxPoint& point, int& flags) = 0;
+ // (and can't be called DoHitTest() because this is already in wxWindow)
+ virtual wxTreeItemId DoTreeHitTest(const wxPoint& point,
+ int& flags) const = 0;
wxImageList *m_imageListNormal, // images for tree elements
m_ownsImageListState;
// spacing between left border and the text
- unsigned short m_spacing;
+ unsigned int m_spacing;
+
+ // whether full or quick calculation is done in DoGetBestSize
+ bool m_quickBestSize;
- DECLARE_NO_COPY_CLASS(wxTreeCtrlBase)
+ wxDECLARE_NO_COPY_CLASS(wxTreeCtrlBase);
};
// ----------------------------------------------------------------------------
#if defined(__WXUNIVERSAL__)
#include "wx/generic/treectlg.h"
#elif defined(__WXPALMOS__)
- #include "wx/palmos/treectrl.h"
+ #include "wx/generic/treectlg.h"
#elif defined(__WXMSW__)
- #include "wx/msw/treectrl.h"
+ #include "wx/msw/treectrl.h"
#elif defined(__WXMOTIF__)
#include "wx/generic/treectlg.h"
#elif defined(__WXGTK__)
#include "wx/generic/treectlg.h"
#endif
-#endif // _WX_TREECTRL_H_BASE_
+#endif // wxUSE_TREECTRL
+#endif // _WX_TREECTRL_H_BASE_