/////////////////////////////////////////////////////////////////////////////
-// Name: treectrl.h
+// Name: wx/os2/treectrl.h
// Purpose: wxTreeCtrl class
-// Author: AUTHOR
+// Author: David Webster
// Modified by:
-// Created: ??/??/98
+// Created: 01/23/03
// RCS-ID: $Id$
-// Copyright: (c) AUTHOR
-// Licence: wxWindows licence
+// Copyright: (c) David Webster
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TREECTRL_H_
#define _WX_TREECTRL_H_
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
#ifdef __GNUG__
-#pragma interface "treectrl.h"
+ #pragma interface "treectrl.h"
#endif
-#include "wx/control.h"
-#include "wx/event.h"
-#include "wx/imaglist.h"
-
-#define wxTREE_MASK_HANDLE 0x0001
-#define wxTREE_MASK_STATE 0x0002
-#define wxTREE_MASK_TEXT 0x0004
-#define wxTREE_MASK_IMAGE 0x0008
-#define wxTREE_MASK_SELECTED_IMAGE 0x0010
-#define wxTREE_MASK_CHILDREN 0x0020
-#define wxTREE_MASK_DATA 0x0040
-
-#define wxTREE_STATE_BOLD 0x0001
-#define wxTREE_STATE_DROPHILITED 0x0002
-#define wxTREE_STATE_EXPANDED 0x0004
-#define wxTREE_STATE_EXPANDEDONCE 0x0008
-#define wxTREE_STATE_FOCUSED 0x0010
-#define wxTREE_STATE_SELECTED 0x0020
-#define wxTREE_STATE_CUT 0x0040
-
-#define wxTREE_HITTEST_ABOVE 0x0001 // Above the client area.
-#define wxTREE_HITTEST_BELOW 0x0002 // Below the client area.
-#define wxTREE_HITTEST_NOWHERE 0x0004 // In the client area but below the last item.
-#define wxTREE_HITTEST_ONITEMBUTTON 0x0010 // On the button associated with an item.
-#define wxTREE_HITTEST_ONITEMICON 0x0020 // On the bitmap associated with an item.
-#define wxTREE_HITTEST_ONITEMINDENT 0x0040 // In the indentation associated with an item.
-#define wxTREE_HITTEST_ONITEMLABEL 0x0080 // On the label (string) associated with an item.
-#define wxTREE_HITTEST_ONITEMRIGHT 0x0100 // In the area to the right of an item.
-#define wxTREE_HITTEST_ONITEMSTATEICON 0x0200 // On the state icon for a tree view item that is in a user-defined state.
-#define wxTREE_HITTEST_TOLEFT 0x0400 // To the right of the client area.
-#define wxTREE_HITTEST_TORIGHT 0x0800 // To the left of the client area.
-
-#define wxTREE_HITTEST_ONITEM (wxTREE_HITTEST_ONITEMICON | wxTREE_HITTEST_ONITEMLABEL | wxTREE_HITTEST_ONITEMSTATEICON)
-
-// Flags for GetNextItem
-enum {
- wxTREE_NEXT_CARET, // Retrieves the currently selected item.
- wxTREE_NEXT_CHILD, // Retrieves the first child item. The hItem parameter must be NULL.
- wxTREE_NEXT_DROPHILITE, // Retrieves the item that is the target of a drag-and-drop operation.
- wxTREE_NEXT_FIRSTVISIBLE, // Retrieves the first visible item.
- wxTREE_NEXT_NEXT, // Retrieves the next sibling item.
- wxTREE_NEXT_NEXTVISIBLE, // Retrieves the next visible item that follows the specified item.
- wxTREE_NEXT_PARENT, // Retrieves the parent of the specified item.
- wxTREE_NEXT_PREVIOUS, // Retrieves the previous sibling item.
- wxTREE_NEXT_PREVIOUSVISIBLE, // Retrieves the first visible item that precedes the specified item.
- wxTREE_NEXT_ROOT // Retrieves the first child item of the root item of which the specified item is a part.
-};
+#if wxUSE_TREECTRL
+
+#include "wx/textctrl.h"
+#include "wx/dynarray.h"
+#include "wx/treebase.h"
+#include "wx/hashmap.h"
+
+// the type for "untyped" data
+typedef long wxDataType;
+
+// fwd decl
+class WXDLLEXPORT wxImageList;
+class WXDLLEXPORT wxDragImage;
+struct WXDLLEXPORT wxTreeViewItem;
+
+// a callback function used for sorting tree items, it should return -1 if the
+// first item precedes the second, +1 if the second precedes the first or 0 if
+// they're equivalent
+class wxTreeItemData;
-// Flags for ExpandItem
-enum {
+// flags for deprecated `Expand(int action)'
+enum
+{
wxTREE_EXPAND_EXPAND,
wxTREE_EXPAND_COLLAPSE,
wxTREE_EXPAND_COLLAPSE_RESET,
wxTREE_EXPAND_TOGGLE
};
-// Flags for InsertItem
-enum {
- wxTREE_INSERT_LAST = -1,
- wxTREE_INSERT_FIRST = -2,
- wxTREE_INSERT_SORT = -3
-};
+// flags for deprecated InsertItem() variant
+#define wxTREE_INSERT_FIRST 0xFFFF0001
+#define wxTREE_INSERT_LAST 0xFFFF0002
-class WXDLLEXPORT wxTreeItem: public wxObject
-{
- 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();
-
-// 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 SetState(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 GetSelectedImage(int selImage) { m_selectedImage = selImage; }
- inline void SetChildren(int children) { m_children = children; }
- inline void SetData(long data) { m_data = data; }
-};
+// hash storing attributes for our items
+WX_DECLARE_EXPORTED_VOIDPTR_HASH_MAP(wxTreeItemAttr *, wxMapTreeAttr);
-class WXDLLEXPORT wxTreeCtrl: public wxControl
+// ----------------------------------------------------------------------------
+// wxTreeCtrl
+// ----------------------------------------------------------------------------
+class WXDLLEXPORT wxTreeCtrl : public wxControl
{
public:
- /*
- * Public interface
- */
-
// creation
// --------
- wxTreeCtrl();
-
- inline wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = "wxTreeCtrl")
+ wxTreeCtrl() { Init(); }
+
+ wxTreeCtrl( wxWindow* pParent
+ ,wxWindowID vId = -1
+ ,const wxPoint& rPos = wxDefaultPosition
+ ,const wxSize& rSize = wxDefaultSize
+ ,long lStyle = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT
+ ,const wxValidator& rValidator = wxDefaultValidator
+ ,const wxString& rsName = wxTreeCtrlNameStr
+ )
{
- Create(parent, id, pos, size, style, validator, name);
+ Create( pParent
+ ,vId
+ ,rPos
+ ,rSize
+ ,lStyle
+ ,rValidator
+ ,rsName
+ );
}
- ~wxTreeCtrl();
-
- bool Create(wxWindow *parent, wxWindowID id = -1,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = "wxTreeCtrl");
-
- // accessors
+ virtual ~wxTreeCtrl();
+
+ bool Create( wxWindow* pParent
+ ,wxWindowID vId = -1
+ ,const wxPoint& rPos = wxDefaultPosition
+ ,const wxSize& rSize = wxDefaultSize
+ ,long lStyle = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT
+ ,const wxValidator& rValidator = wxDefaultValidator
+ ,const wxString& rsName = wxTreeCtrlNameStr
+ );
+
+ //
+ // Accessors
// ---------
- //
- int GetCount() const;
-
- // indent
- int GetIndent() const;
- void SetIndent(int indent);
- // image list
- wxImageList *GetImageList(int which = wxIMAGE_LIST_NORMAL) const;
- void SetImageList(wxImageList *imageList, int which = wxIMAGE_LIST_NORMAL);
-
- // navigation inside the tree
- long GetNextItem(long item, int code) const;
- bool ItemHasChildren(long item) const;
- long GetChild(long item) const;
- long GetParent(long item) const;
- long GetFirstVisibleItem() const;
- long GetNextVisibleItem(long item) const;
- long GetSelection() const;
- long GetRootItem() const;
-
- // generic function for (g|s)etting item attributes
- bool GetItem(wxTreeItem& info) const;
- bool SetItem(wxTreeItem& info);
- // item state
- int GetItemState(long item, long stateMask) const;
- bool SetItemState(long item, long state, long stateMask);
- // item image
- bool SetItemImage(long item, int image, int selImage);
- // item text
- wxString GetItemText(long item) const;
- void SetItemText(long item, const wxString& str);
- // custom data associated with the item
- long GetItemData(long item) const;
- bool SetItemData(long item, long data);
- // convenience function
- bool IsItemExpanded(long item)
- {
- return (GetItemState(item, wxTREE_STATE_EXPANDED) &
- wxTREE_STATE_EXPANDED) != 0;
- }
-
- // bounding rect
- bool GetItemRect(long item, wxRect& rect, bool textOnly = FALSE) const;
- //
- wxTextCtrl* GetEditControl() const;
-
- // operations
+ //
+
+ //
+ // Get the total number of items in the control
+ //
+ size_t GetCount(void) const;
+
+ //
+ // Indent is the number of pixels the children are indented relative to
+ // the parents position. SetIndent() also redraws the control
+ // immediately.
+ //
+ unsigned int GetIndent(void) const;
+ void SetIndent(unsigned int uIndent);
+
+ //
+ // Spacing is the number of pixels between the start and the Text
+ //
+ unsigned int GetSpacing(void) const { return 18; } // return wxGTK default
+ void SetSpacing(unsigned int uSpacing) { }
+
+ //
+ // Image list: these functions allow to associate an image list with
+ // the control and retrieve it. Note that the control does _not_ delete
+ // the associated image list when it's deleted in order to allow image
+ // lists to be shared between different controls.
+ //
+ // OS/2 doesn't really use imagelists as MSW does, but since the MSW
+ // control is the basis for this one, until I decide how to get rid of
+ // the need for them they are here for now.
+ //
+ wxImageList* GetImageList(void) const;
+ wxImageList* GetStateImageList(void) const;
+
+ void AssignImageList(wxImageList* pImageList);
+ void AssignStateImageList(wxImageList* pImageList);
+ void SetImageList(wxImageList* pImageList);
+ void SetStateImageList(wxImageList* pImageList);
+
+ //
+ // Functions to work with tree ctrl items. Unfortunately, they can _not_ be
+ // member functions of wxTreeItem because they must know the tree the item
+ // belongs to for Windows implementation and storing the pointer to
+ // wxTreeCtrl in each wxTreeItem is just too much waste.
+
+ //
+ // Item's label
+ //
+ wxString GetItemText(const wxTreeItemId& rItem) const;
+ void SetItemText( const wxTreeItemId& rItem
+ ,const wxString& rsText
+ );
+
+ //
+ // One of the images associated with the item (normal by default)
+ //
+ int GetItemImage( const wxTreeItemId& rItem
+ ,wxTreeItemIcon vWhich = wxTreeItemIcon_Normal
+ ) const;
+ void SetItemImage( const wxTreeItemId& rItem
+ ,int nImage
+ ,wxTreeItemIcon vWhich = wxTreeItemIcon_Normal
+ );
+
+ //
+ // Data associated with the item
+ //
+ wxTreeItemData* GetItemData(const wxTreeItemId& rItem) const;
+ void SetItemData( const wxTreeItemId& rItem
+ ,wxTreeItemData* pData
+ );
+
+ //
+ // Item's text colour
+ //
+ wxColour GetItemTextColour(const wxTreeItemId& rItem) const;
+ void SetItemTextColour( const wxTreeItemId& rItem
+ ,const wxColour& rColor
+ );
+
+ //
+ // Item's background colour
+ //
+ wxColour GetItemBackgroundColour(const wxTreeItemId& rItem) const;
+ void SetItemBackgroundColour( const wxTreeItemId& rItem
+ ,const wxColour& rColour
+ );
+
+ //
+ // Item's font
+ //
+ wxFont GetItemFont(const wxTreeItemId& rItem) const;
+ void SetItemFont( const wxTreeItemId& rItem
+ ,const wxFont& rFont
+ );
+
+ //
+ // Force appearance of [+] button near the item. This is useful to
+ // allow the user to expand the items which don't have any children now
+ // - but instead add them only when needed, thus minimizing memory
+ // usage and loading time.
+ //
+ void SetItemHasChildren( const wxTreeItemId& rItem
+ ,bool bHas = TRUE
+ );
+
+ //
+ // The item will be shown in bold
+ //
+ void SetItemBold( const wxTreeItemId& rItem
+ ,bool bBold = TRUE
+ );
+
+ //
+ // The item will be shown with a drop highlight
+ //
+ void SetItemDropHighlight( const wxTreeItemId& rItem
+ ,bool bHighlight = TRUE
+ );
+
+ //
+ // Item status inquiries
+ // ---------------------
+ //
+
+ //
+ // Is the item visible (it might be outside the view or not expanded)?
+ //
+ bool IsVisible(const wxTreeItemId& rItem) const;
+
+ //
+ // Does the item has any children?
+ //
+ bool ItemHasChildren(const wxTreeItemId& rItem) const;
+
+ //
+ // Is the item expanded (only makes sense if HasChildren())?
+ //
+ bool IsExpanded(const wxTreeItemId& rItem) const;
+
+ //
+ // Is this item currently selected (the same as has focus)?
+ //
+ bool IsSelected(const wxTreeItemId& rItem) const;
+
+ //
+ // Is item text in bold font?
+ //
+ bool IsBold(const wxTreeItemId& rItem) const;
+
+ //
+ // Number of children
+ // ------------------
+ //
+
+ //
+ // 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& rItem
+ ,bool bRecursively = TRUE
+ ) const;
+
+ //
+ // Navigation
+ // ----------
+ //
+
+ //
+ // Get the root tree item
+ //
+ wxTreeItemId GetRootItem(void) const;
+
+ //
+ // Get the item currently selected (may return NULL if no selection)
+ //
+ wxTreeItemId GetSelection(void) const;
+
+ //
+ // Get the items currently selected, return the number of such item
+ //
+ size_t GetSelections(wxArrayTreeItemIds& rSelections) const;
+
+ //
+ // Get the parent of this item (may return NULL if root)
+ //
+ wxTreeItemId GetItemParent(const wxTreeItemId& rItem) const;
+
+#if WXWIN_COMPATIBILITY_2_2
+ // deprecated: Use GetItemParent instead.
+ wxTreeItemId GetParent(const wxTreeItemId& rItem) const
+ { return GetItemParent(rItem); }
+
+ // Expose the base class method hidden by the one above.
+ wxWindow* GetParent(void) const { return wxControl::GetParent(); }
+#endif // WXWIN_COMPATIBILITY_2_2
+
+ // for this enumeration function you must pass in a "cookie" parameter
+ // which is opaque for the application but is necessary for the library
+ // to make these functions reentrant (i.e. allow more than one
+ // enumeration on one and the same object simultaneously). Of course,
+ // the "cookie" passed to GetFirstChild() and GetNextChild() should be
+ // the same!
+
+ // get the first child of this item
+ wxTreeItemId GetFirstChild(const wxTreeItemId& item,
+ wxTreeItemIdValue& cookie) const;
+ // get the next child
+ 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& rItem) const;
+
+ //
+ // Get the next sibling of this item
+ //
+ wxTreeItemId GetNextSibling(const wxTreeItemId& rItem) const;
+
+ //
+ // Get the previous sibling
+ //
+ wxTreeItemId GetPrevSibling(const wxTreeItemId& rItem) const;
+
+ //
+ // Get first visible item
+ //
+ wxTreeItemId GetFirstVisibleItem(void) const;
+
+ //
+ // Get the next visible item: item must be visible itself!
+ // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
+ //
+ wxTreeItemId GetNextVisible(const wxTreeItemId& rItem) const;
+
+ //
+ // Get the previous visible item: item must be visible itself!
+ //
+ wxTreeItemId GetPrevVisible(const wxTreeItemId& rItem) const;
+
+ //
+ // Operations
+ // ----------
+ //
+
+ //
+ // Add the root node to the tree
+ //
+ wxTreeItemId AddRoot( const wxString& rsText
+ ,int nImage = -1
+ ,int nSelectedImage = -1
+ ,wxTreeItemData* pData = NULL
+ );
+
+ //
+ // Insert a new item in as the first child of the parent
+ //
+ wxTreeItemId PrependItem( const wxTreeItemId& rParent
+ ,const wxString& rsText
+ ,int nImage = -1
+ ,int nSelectedImage = -1
+ ,wxTreeItemData* pData = NULL
+ );
+
+ //
+ // Insert a new item after a given one
+ //
+ wxTreeItemId InsertItem( const wxTreeItemId& rParent
+ ,const wxTreeItemId& rIdPrevious
+ ,const wxString& rsText
+ ,int nImage = -1
+ ,int nSelectedImage = -1
+ ,wxTreeItemData* pData = NULL
+ );
+
+ //
+ // Insert a new item before the one with the given index
+ //
+ wxTreeItemId InsertItem( const wxTreeItemId& pParent
+ ,size_t nIndex
+ ,const wxString& rsText
+ ,int nImage = -1
+ ,int nSelectedImage = -1
+ ,wxTreeItemData* pData = NULL
+ );
+
+ //
+ // Insert a new item in as the last child of the parent
+ //
+ wxTreeItemId AppendItem( const wxTreeItemId& rParent
+ ,const wxString& rsText
+ ,int nImage = -1
+ ,int nSelectedImage = -1
+ ,wxTreeItemData* pData = NULL
+ );
+
+ //
+ // Delete this item and associated data if any
+ //
+ void Delete(const wxTreeItemId& rItem);
+
+ //
+ // Delete all children (but don't delete the item itself)
+ //
+ void DeleteChildren(const wxTreeItemId& rItem);
+
+ //
+ // Delete all items from the tree
+ //
+ void DeleteAllItems(void);
+
+ //
+ // Expand this item
+ //
+ void Expand(const wxTreeItemId& rItem);
+
+ //
+ // Collapse the item without removing its children
+ //
+ void Collapse(const wxTreeItemId& rItem);
+
+ //
+ // Collapse the item and remove all children
+ //
+ void CollapseAndReset(const wxTreeItemId& rItem);
+
+ //
+ // Toggles the current state
+ //
+ void Toggle(const wxTreeItemId& rItem);
+
+ //
+ // Remove the selection from currently selected item (if any)
+ //
+ void Unselect(void);
+
+ //
+ // Unselect all items (only makes sense for multiple selection control)
+ //
+ void UnselectAll(void);
+
+ //
+ // Select this item
+ //
+ void SelectItem(const wxTreeItemId& rItem);
+
+ //
+ // Make sure this item is visible (expanding the parent item and/or
+ // scrolling to this item if necessary)
+ //
+ void EnsureVisible(const wxTreeItemId& rItem);
+
+ //
+ // Scroll to this item (but don't expand its parent)
+ //
+ void ScrollTo(const wxTreeItemId& rItem);
+
+ //
+ // OS/2 does not use a separate edit field for editting text. Here for
+ // interface compatibility, only.
+ //
+ wxTextCtrl* EditLabel( const wxTreeItemId& rItem
+ ,wxClassInfo* pTextCtrlClass = CLASSINFO(wxTextCtrl)
+ );
+
+ //
+ // returns NULL for OS/2 in ALL cases
+ //
+ wxTextCtrl* GetEditControl(void) const {return (wxTextCtrl*)NULL;}
+
+ //
+ // End editing and accept or discard the changes to item label
+ //
+ void EndEditLabel( const wxTreeItemId& rItem
+ ,bool bDiscardChanges = FALSE
+ );
+
+ //
+ // Sorting
+ // -------
+ //
+
+ //
+ // This function is called to compare 2 items and should return -1, 0
+ // or +1 if the first item is less than, equal to or greater than the
+ // second one. The base class version performs alphabetic comparaison
+ // of item labels (GetText)
+ //
+ virtual int OnCompareItems( const wxTreeItemId& rItem1
+ ,const wxTreeItemId& rItem2
+ );
+
+ //
+ // Sort the children of this item using OnCompareItems
+ //
+ void SortChildren(const wxTreeItemId& rItem);
+
+ //
+ // Helpers
+ // -------
+ //
+
+ //
+ // Determine to which item (if any) belongs the given point (the
+ // coordinates specified are relative to the client area of tree ctrl)
+ // and fill the flags parameter with a bitmask of wxTREE_HITTEST_xxx
+ // constants.
+
+ //
+ // The first function is more portable (because easier to implement
+ // on other platforms), but the second one returns some extra info.
+ //
+ wxTreeItemId HitTest(const wxPoint& rPoint)
+ { int nDummy = 0; return HitTest(rPoint, nDummy); }
+ wxTreeItemId HitTest( const wxPoint& rPoint
+ ,int& rFlags
+ );
+
+ //
+ // Get the bounding rectangle of the item (or of its label only)
+ //
+ bool GetBoundingRect( const wxTreeItemId& rItem
+ ,wxRect& rRect
+ ,bool bTextOnly = FALSE
+ ) const;
+
+ //
+ // Deprecated
// ----------
- // adding/deleting items
- bool DeleteItem(long item);
- long InsertItem(long parent, wxTreeItem& info,
- long insertAfter = wxTREE_INSERT_LAST);
- // If image > -1 and selImage == -1, the same image is used for
- // both selected and unselected items.
- long InsertItem(long parent, const wxString& label,
- int image = -1, int selImage = -1,
- long insertAfter = wxTREE_INSERT_LAST);
-
- // changing item state
- bool ExpandItem(long item) { return ExpandItem(item, wxTREE_EXPAND_EXPAND); }
- bool CollapseItem(long item) { return ExpandItem(item, wxTREE_EXPAND_COLLAPSE); }
- bool ToggleItem(long item) { return ExpandItem(item, wxTREE_EXPAND_TOGGLE); }
- // common interface for {Expand|Collapse|Toggle}Item
- bool ExpandItem(long item, int action);
-
- //
- bool SelectItem(long item);
- bool ScrollTo(long item);
- bool DeleteAllItems();
-
- // Edit the label (tree must have the focus)
- wxTextCtrl* EditLabel(long item, wxClassInfo* textControlClass = CLASSINFO(wxTextCtrl));
-
- // End label editing, optionally cancelling the edit
- bool EndEditLabel(bool cancel);
-
- long HitTest(const wxPoint& point, int& flags);
- // wxImageList *CreateDragImage(long item);
- bool SortChildren(long item);
- bool EnsureVisible(long item);
-
- void Command(wxCommandEvent& event) { ProcessCommand(event); };
+
+#if WXWIN_COMPATIBILITY_2_4
+ // These methods are deprecated and will be removed in future versions of
+ // wxWindows, they're here for compatibility only, don't use them in new
+ // code (the comments indicate why these methods are now useless and how to
+ // replace them)
+ //
+
+ //
+ // Use Expand, Collapse, CollapseAndReset or Toggle
+ //
+ wxDEPRECATED( void ExpandItem( const wxTreeItemId& rItem
+ ,int nAction
+ ) );
+
+ //
+ // Use AddRoot, PrependItem or AppendItem
+ //
+ wxDEPRECATED( wxTreeItemId InsertItem( const wxTreeItemId& pParent
+ ,const wxString& rsText
+ ,int nImage = -1
+ ,int nSelImage = -1
+ ,long lInsertAfter = wxTREE_INSERT_LAST
+ ) );
+
+ //
+ // Use Set/GetImageList and Set/GetStateImageList
+ //
+ wxImageList* GetImageList(int nVal) const
+ { return GetImageList(); }
+ void SetImageList(wxImageList* pImageList, int nVal)
+ { SetImageList(pImageList); }
+
+ //
+ // Use Set/GetItemImage directly
+ //
+ int GetItemSelectedImage(const wxTreeItemId& rItem) const
+ { return GetItemImage(rItem, wxTreeItemIcon_Selected); }
+ void SetItemSelectedImage(const wxTreeItemId& rItem, int nImage)
+ { SetItemImage(rItem, nImage, wxTreeItemIcon_Selected); }
+ //
+ // For this enumeration function you must pass in a "cookie" parameter
+ // which is opaque for the application but is necessary for the library
+ // to make these functions reentrant (i.e. allow more than one
+ // enumeration on one and the same object simultaneously). Of course,
+ // the "cookie" passed to GetFirstChild() and GetNextChild() should be
+ // the same!
+ //
+
+ //
+ // Get the first child of this item
+ //
+ wxDEPRECATED( wxTreeItemId GetFirstChild( const wxTreeItemId& rItem
+ ,long& rCookie
+ ) const );
+
+ //
+ // Get the next child
+ //
+ wxDEPRECATED( wxTreeItemId GetNextChild( const wxTreeItemId& rItem
+ ,long& rCookie
+ ) const );
+#endif // WXWIN_COMPATIBILITY_2_4
+
+ //
+ // Implementation
+ // --------------
+ //
+
+ virtual MRESULT OS2WindowProc( WXUINT uMsg
+ ,WXWPARAM wParam
+ ,WXLPARAM lParam
+ );
+ virtual bool OS2Command( WXUINT uParam
+ ,WXWORD wId
+ );
+// virtual bool OMSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
+
+ //
+ // Override some base class virtuals
+ //
+ virtual bool SetBackgroundColour(const wxColour& rColour);
+ virtual bool SetForegroundColour(const wxColour& rColour);
+
+ //
+ // Get/set the check state for the item (only for wxTR_MULTIPLE)
+ //
+ bool IsItemChecked(const wxTreeItemId& rItem) const;
+ void SetItemCheck( const wxTreeItemId& rItem
+ ,bool bCheck = TRUE
+ );
protected:
- wxTextCtrl* m_textCtrl;
- wxImageList* m_imageListNormal;
- wxImageList* m_imageListState;
+ //
+ // SetImageList helper
+ //
+ void SetAnyImageList( wxImageList* pImageList
+ ,int nWhich
+ );
+
+ //
+ // Refresh a single item
+ //
+ void RefreshItem(const wxTreeItemId& rItem);
+
+ wxImageList* m_pImageListNormal; // images for tree elements
+ wxImageList* m_pImageListState; // special images for app defined states
+ bool m_bOwnsImageListNormal;
+ bool m_bOwnsImageListState;
+
+private:
+
+ //
+ // The common part of all ctors
+ //
+ void Init(void);
+
+ //
+ // Helper functions
+ //
+ inline bool DoGetItem(wxTreeViewItem* pTvItem) const;
+ inline void DoSetItem(wxTreeViewItem* pTvItem);
+
+ inline void DoExpand( const wxTreeItemId& rItem
+ ,int nFlag
+ );
+ wxTreeItemId DoInsertItem( const wxTreeItemId& pParent
+ ,wxTreeItemId hInsertAfter
+ ,const wxString& rsText
+ ,int nImage
+ ,int nSelectedImage
+ ,wxTreeItemData* pData
+ );
+ int DoGetItemImageFromData( const wxTreeItemId& rItem
+ ,wxTreeItemIcon vWhich
+ ) const;
+ void DoSetItemImageFromData( const wxTreeItemId& rItem
+ ,int nImage
+ ,wxTreeItemIcon vWhich
+ ) const;
+ void DoSetItemImages( const wxTreeItemId& rItem
+ ,int nImage
+ ,int nImageSel
+ );
+ void DeleteTextCtrl() { };
+
+ //
+ // support for additional item images which we implement using
+ // wxTreeItemIndirectData technique - see the comments in msw/treectrl.cpp
+ //
+ void SetIndirectItemData( const wxTreeItemId& rItem
+ ,class wxTreeItemIndirectData* pData
+ );
+ bool HasIndirectData(const wxTreeItemId& rItem) const;
+ bool IsDataIndirect(wxTreeItemData* pData) const
+ { return pData && pData->GetId().m_pItem == 0; }
+
+ //
+ // The hash storing the items attributes (indexed by items ids)
+ //
+ wxMapTreeAttr m_vAttrs;
+
+ //
+ // TRUE if the hash above is not empty
+ //
+ bool m_bHasAnyAttr;
+
+ //
+ // Used for dragging
+ //
+ wxDragImage* m_pDragImage;
+
+ // Virtual root item, if wxTR_HIDE_ROOT is set.
+// void* m_pVirtualRoot;
+
+ // the starting item for selection with Shift
+// WXHTREEITEM m_htSelStart;
+//
+ friend class wxTreeItemIndirectData;
+ friend class wxTreeSortHelper;
DECLARE_DYNAMIC_CLASS(wxTreeCtrl)
-};
-
-/*
- wxEVT_COMMAND_TREE_BEGIN_DRAG,
- wxEVT_COMMAND_TREE_BEGIN_RDRAG,
- wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT,
- wxEVT_COMMAND_TREE_END_LABEL_EDIT,
- wxEVT_COMMAND_TREE_DELETE_ITEM,
- wxEVT_COMMAND_TREE_GET_INFO,
- wxEVT_COMMAND_TREE_SET_INFO,
- wxEVT_COMMAND_TREE_ITEM_EXPANDED,
- wxEVT_COMMAND_TREE_ITEM_EXPANDING,
- wxEVT_COMMAND_TREE_ITEM_COLLAPSED,
- wxEVT_COMMAND_TREE_ITEM_COLLAPSING,
- wxEVT_COMMAND_TREE_SEL_CHANGED,
- wxEVT_COMMAND_TREE_SEL_CHANGING,
- wxEVT_COMMAND_TREE_KEY_DOWN
-*/
-
-class WXDLLEXPORT wxTreeEvent: public wxCommandEvent
-{
- DECLARE_DYNAMIC_CLASS(wxTreeEvent)
-
- public:
- wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
-
- int m_code;
- wxTreeItem m_item;
- long m_oldItem;
- wxPoint m_pointDrag;
-
- inline long GetOldItem() const { return m_oldItem; }
- inline wxTreeItem& GetItem() const { return (wxTreeItem&) m_item; }
- inline wxPoint GetPoint() const { return m_pointDrag; }
- inline int GetCode() const { return m_code; }
-};
+ DECLARE_NO_COPY_CLASS(wxTreeCtrl)
+}; // end of CLASS wxTreeCtrl
-typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
-
-#define EVT_TREE_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_BEGIN_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_END_LABEL_EDIT(id, fn) { wxEVT_COMMAND_TREE_END_LABEL_EDIT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_GET_INFO(id, fn) { wxEVT_COMMAND_TREE_GET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_SET_INFO(id, fn) { wxEVT_COMMAND_TREE_SET_INFO, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_ITEM_EXPANDED(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_ITEM_EXPANDING(id, fn) { wxEVT_COMMAND_TREE_ITEM_EXPANDING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_ITEM_COLLAPSED(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_ITEM_COLLAPSING(id, fn) { wxEVT_COMMAND_TREE_ITEM_COLLAPSING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_SEL_CHANGED(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_SEL_CHANGING(id, fn) { wxEVT_COMMAND_TREE_SEL_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
-#define EVT_TREE_KEY_DOWN(id, fn) { wxEVT_COMMAND_TREE_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
+#endif // wxUSE_TREECTRL
#endif
// _WX_TREECTRL_H_