X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4c2a39bec10bb23d8c4cdf6c15e391ebc0096e1d..9508a3e9a0b226b39f2a0eb9e12ae517a6e17630:/include/wx/msw/treectrl.h diff --git a/include/wx/msw/treectrl.h b/include/wx/msw/treectrl.h index 8574600564..ad8d31210d 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,17 +30,18 @@ #endif // Cygwin // fwd decl -class WXDLLEXPORT wxImageList; -class WXDLLEXPORT wxDragImage; -struct WXDLLEXPORT wxTreeViewItem; - -// NB: all the following flags are for compatbility only and will be removed in the -// next versions - -// flags for deprecated InsertItem() variant (their values are the same as of -// TVI_FIRST and TVI_LAST) -#define wxTREE_INSERT_FIRST 0xFFFF0001 -#define wxTREE_INSERT_LAST 0xFFFF0002 +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 + // next versions + // flags for deprecated InsertItem() variant (their values are the same as of + // TVI_FIRST and TVI_LAST) + #define wxTREE_INSERT_FIRST 0xFFFF0001 + #define wxTREE_INSERT_LAST 0xFFFF0002 +#endif // hash storing attributes for our items WX_DECLARE_EXPORTED_VOIDPTR_HASH_MAP(wxTreeItemAttr *, wxMapTreeAttr); @@ -49,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 @@ -78,7 +79,7 @@ public: // implement base class pure virtuals // ---------------------------------- - virtual size_t GetCount() const; + virtual unsigned int GetCount() const; virtual unsigned int GetIndent() const; virtual void SetIndent(unsigned int indent); @@ -179,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 - wxDEPRECATED( wxImageList *GetImageList(int) const ); - 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 // -------------- @@ -223,18 +196,14 @@ public: virtual WXLRESULT MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual bool MSWCommand(WXUINT param, WXWORD id); virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); + virtual bool MSWShouldPreProcessMessage(WXMSG* msg); // override some base class virtuals 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 @@ -246,25 +215,8 @@ protected: // end edit label void DoEndEditLabel(bool discardChanges = false); - - // data used only while editing the item label: - wxTextCtrl *m_textCtrl; // text control in which it is edited - wxTreeItemId m_idEdited; // the item being edited - - wxImageList *m_imageListNormal, // images for tree elements - *m_imageListState; // special images for app defined states - bool m_ownsImageListNormal, - m_ownsImageListState; - -private: - // the common part of all ctors - void Init(); - - // helper functions - inline bool DoGetItem(wxTreeViewItem *tvItem) const; - inline void DoSetItem(wxTreeViewItem *tvItem); - - inline void DoExpand(const wxTreeItemId& item, int flag); + virtual int DoGetItemState(const wxTreeItemId& item) const; + virtual void DoSetItemState(const wxTreeItemId& item, int state); virtual wxTreeItemId DoInsertItem(const wxTreeItemId& parent, size_t pos, @@ -276,24 +228,32 @@ private: const wxString& text, int image = -1, int selImage = -1, wxTreeItemData *data = NULL); - virtual wxTreeItemId DoHitTest(const wxPoint& point, int& flags); + virtual wxTreeItemId DoTreeHitTest(const wxPoint& point, int& flags) const; + + // obtain the user data for the lParam member of TV_ITEM + class wxTreeItemParam *GetItemParam(const wxTreeItemId& item) const; - int DoGetItemImageFromData(const wxTreeItemId& item, - wxTreeItemIcon which) const; - void DoSetItemImageFromData(const wxTreeItemId& item, - int image, - wxTreeItemIcon which) const; - void DoSetItemImages(const wxTreeItemId& item, int image, int imageSel); + + // data used only while editing the item label: + wxTextCtrl *m_textCtrl; // text control in which it is edited + wxTreeItemId m_idEdited; // the item being edited + +private: + // the common part of all ctors + void Init(); + + // helper functions + bool DoGetItem(wxTreeViewItem *tvItem) const; + void DoSetItem(wxTreeViewItem *tvItem); + + void DoExpand(const wxTreeItemId& item, int flag); void DeleteTextCtrl(); - // support for additional item images which we implement using - // wxTreeItemIndirectData technique - see the comments in msw/treectrl.cpp - void SetIndirectItemData(const wxTreeItemId& item, - class wxTreeItemIndirectData *data); - bool HasIndirectData(const wxTreeItemId& item) const; - bool IsDataIndirect(wxTreeItemData *data) const - { return data && data->GetId().m_pItem == 0; } + // 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; + // the hash storing the items attributes (indexed by item ids) wxMapTreeAttr m_attrs; @@ -301,8 +261,10 @@ private: // 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; @@ -320,5 +282,4 @@ private: #endif // wxUSE_TREECTRL -#endif - // _WX_TREECTRL_H_ +#endif // _WX_MSW_TREECTRL_H_