X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/90c6edd706882b8fd06b6d5359d9682ac0ee858c..ca6911c361b04290fe1f0e64b616249b3b3d71ba:/include/wx/msw/treectrl.h diff --git a/include/wx/msw/treectrl.h b/include/wx/msw/treectrl.h index 5729f58904..a16b068984 100644 --- a/include/wx/msw/treectrl.h +++ b/include/wx/msw/treectrl.h @@ -9,8 +9,8 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_TREECTRL_H_ -#define _WX_TREECTRL_H_ +#ifndef _WX_MSW_TREECTRL_H_ +#define _WX_MSW_TREECTRL_H_ // ---------------------------------------------------------------------------- // headers @@ -30,9 +30,9 @@ #endif // Cygwin // fwd decl -class WXDLLEXPORT wxImageList; -class WXDLLEXPORT wxDragImage; -struct WXDLLEXPORT wxTreeViewItem; +class WXDLLIMPEXP_FWD_CORE wxImageList; +class WXDLLIMPEXP_FWD_CORE wxDragImage; +struct WXDLLIMPEXP_FWD_CORE wxTreeViewItem; #if WXWIN_COMPATIBILITY_2_6 // NB: all the following flags are for compatbility only and will be removed in the @@ -50,7 +50,7 @@ WX_DECLARE_EXPORTED_VOIDPTR_HASH_MAP(wxTreeItemAttr *, wxMapTreeAttr); // wxTreeCtrl // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxTreeCtrl : public wxTreeCtrlBase +class WXDLLIMPEXP_CORE wxTreeCtrl : public wxTreeCtrlBase { public: // creation @@ -180,34 +180,6 @@ public: wxRect& rect, bool textOnly = false) const; - // deprecated - // ---------- - -#if WXWIN_COMPATIBILITY_2_4 - // these methods are deprecated and will be removed in future versions of - // wxWidgets, 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& item, int action) ); - - // use Set/GetImageList and Set/GetStateImageList - // Use base class GetImageList() - wxDEPRECATED( void SetImageList(wxImageList *imageList, int) ); - - // use Set/GetItemImage directly - wxDEPRECATED( int GetItemSelectedImage(const wxTreeItemId& item) const ); - wxDEPRECATED( void SetItemSelectedImage(const wxTreeItemId& item, int image) ); - - // use the versions taking wxTreeItemIdValue cookies - wxDEPRECATED( wxTreeItemId GetFirstChild(const wxTreeItemId& item, - long& cookie) const ); - wxDEPRECATED( wxTreeItemId GetNextChild(const wxTreeItemId& item, - long& cookie) const ); -#endif // WXWIN_COMPATIBILITY_2_4 - - // implementation // -------------- @@ -230,13 +202,8 @@ public: virtual bool SetBackgroundColour(const wxColour &colour); virtual bool SetForegroundColour(const wxColour &colour); - // get/set the check state for the item (only for wxTR_MULTIPLE) - bool IsItemChecked(const wxTreeItemId& item) const; - void SetItemCheck(const wxTreeItemId& item, bool check = true); - - // set/get the item state.image (state == -1 means cycle to the next one) - void SetState(const wxTreeItemId& node, int state); - int GetState(const wxTreeItemId& node); + // returns true if the platform should explicitly apply a theme border + virtual bool CanApplyThemeBorder() const { return false; } protected: // SetImageList helper @@ -248,6 +215,9 @@ protected: // end edit label void DoEndEditLabel(bool discardChanges = false); + virtual int DoGetItemState(const wxTreeItemId& item) const; + virtual void DoSetItemState(const wxTreeItemId& item, int state); + virtual wxTreeItemId DoInsertItem(const wxTreeItemId& parent, size_t pos, const wxString& text, @@ -263,6 +233,28 @@ protected: // obtain the user data for the lParam member of TV_ITEM class wxTreeItemParam *GetItemParam(const wxTreeItemId& item) const; + // update the event to include the items client data and pass it to + // HandleWindowEvent(), return true if it processed it + bool HandleTreeEvent(wxTreeEvent& event) const; + + // pass the event to HandleTreeEvent() and return true if the event was + // either unprocessed or not vetoed + bool IsTreeEventAllowed(wxTreeEvent& event) const + { + return !HandleTreeEvent(event) || event.IsAllowed(); + } + + // generate a wxEVT_KEY_DOWN event from the specified WPARAM/LPARAM values + // having the same meaning as for WM_KEYDOWN, return true if it was + // processed + bool MSWHandleTreeKeyDownEvent(WXWPARAM wParam, WXLPARAM lParam); + + // handle a key event in a multi-selection control, should be only called + // for keys which can be used to change the selection + // + // return true if the key was processed, false otherwise + bool MSWHandleSelectionKey(unsigned vkey); + // data used only while editing the item label: wxTextCtrl *m_textCtrl; // text control in which it is edited @@ -273,21 +265,37 @@ private: void Init(); // helper functions - inline bool DoGetItem(wxTreeViewItem *tvItem) const; - inline void DoSetItem(wxTreeViewItem *tvItem); + bool DoGetItem(wxTreeViewItem *tvItem) const; + void DoSetItem(wxTreeViewItem *tvItem); + + void DoExpand(const wxTreeItemId& item, int flag); - inline void DoExpand(const wxTreeItemId& item, int flag); + void DoSelectItem(const wxTreeItemId& item, bool select = true); + void DoUnselectItem(const wxTreeItemId& item); + void DoToggleItemSelection(const wxTreeItemId& item); + + void DoUnselectAll(); void DeleteTextCtrl(); + // return true if the item is the hidden root one (i.e. it's the root item + // and the tree has wxTR_HIDE_ROOT style) + bool IsHiddenRoot(const wxTreeItemId& item) const; + + // clears/sets the currently focused item + void ClearFocusedItem(); + void SetFocusedItem(const wxTreeItemId& item); + // the hash storing the items attributes (indexed by item ids) wxMapTreeAttr m_attrs; // true if the hash above is not empty bool m_hasAnyAttr; +#if wxUSE_DRAGIMAGE // used for dragging wxDragImage *m_dragImage; +#endif // Virtual root item, if wxTR_HIDE_ROOT is set. void* m_pVirtualRoot; @@ -296,14 +304,26 @@ private: wxTreeItemId m_htSelStart, m_htClickedItem; wxPoint m_ptClick; + // whether dragging has started + bool m_dragStarted; + + // whether focus was lost between subsequent clicks of a single item + bool m_focusLost; + + // set when we are changing selection ourselves (only used in multi + // selection mode) + bool m_changingSelection; + + // whether we need to trigger a state image click event + bool m_triggerStateImageClick; + friend class wxTreeItemIndirectData; friend class wxTreeSortHelper; DECLARE_DYNAMIC_CLASS(wxTreeCtrl) - DECLARE_NO_COPY_CLASS(wxTreeCtrl) + wxDECLARE_NO_COPY_CLASS(wxTreeCtrl); }; #endif // wxUSE_TREECTRL -#endif - // _WX_TREECTRL_H_ +#endif // _WX_MSW_TREECTRL_H_