X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e47859daebd15efcecb969e612295c868e944d79..f6669958924c3c3833e2932b65598b06073d2e65:/include/wx/treebase.h diff --git a/include/wx/treebase.h b/include/wx/treebase.h index d66739600e..4a6063c2f6 100644 --- a/include/wx/treebase.h +++ b/include/wx/treebase.h @@ -23,6 +23,7 @@ #include "wx/window.h" // for wxClientData #include "wx/event.h" #include "wx/dynarray.h" +#include "wx/itemid.h" #if WXWIN_COMPATIBILITY_2_6 @@ -38,53 +39,19 @@ enum #endif // WXWIN_COMPATIBILITY_2_6 // ---------------------------------------------------------------------------- -// wxTreeItemId identifies an element of the tree. In this implementation, it's -// just a trivial wrapper around Win32 HTREEITEM or a pointer to some private -// data structure in the generic version. It's opaque for the application and -// the only method which can be used by user code is IsOk(). +// wxTreeItemId identifies an element of the tree. It's opaque for the +// application and the only method which can be used by user code is IsOk(). // ---------------------------------------------------------------------------- -// Using this typedef removes an ambiguity when calling Remove() -typedef void *wxTreeItemIdValue; - -class WXDLLIMPEXP_CORE wxTreeItemId +// This is a class and not a typedef because existing code may forward declare +// wxTreeItemId as a class and we don't want to break it without good reason. +class wxTreeItemId : public wxItemId { - friend bool operator==(const wxTreeItemId&, const wxTreeItemId&); public: - // ctors - // 0 is invalid value for HTREEITEM - wxTreeItemId() { m_pItem = 0; } - - // construct wxTreeItemId from the native item id - wxTreeItemId(void *pItem) { m_pItem = pItem; } - - // default copy ctor/assignment operator are ok for us - - // accessors - // is this a valid tree item? - bool IsOk() const { return m_pItem != 0; } - // return true if this item is not valid - bool operator!() const { return !IsOk(); } - - // operations - // invalidate the item - void Unset() { m_pItem = 0; } - - operator bool() const { return IsOk(); } - - wxTreeItemIdValue m_pItem; + wxTreeItemId() : wxItemId() { } + wxTreeItemId(void* pItem) : wxItemId(pItem) { } }; -inline bool operator==(const wxTreeItemId& i1, const wxTreeItemId& i2) -{ - return i1.m_pItem == i2.m_pItem; -} - -inline bool operator!=(const wxTreeItemId& i1, const wxTreeItemId& i2) -{ - return i1.m_pItem != i2.m_pItem; -} - // ---------------------------------------------------------------------------- // wxTreeItemData is some (arbitrary) user class associated with some item. The // main advantage of having this class (compared to old untyped interface) is @@ -119,10 +86,12 @@ protected: wxTreeItemId m_pItem; }; +typedef void *wxTreeItemIdValue; + WX_DEFINE_EXPORTED_ARRAY_PTR(wxTreeItemIdValue, wxArrayTreeItemIdsBase); // this is a wrapper around the array class defined above which allow to wok -// with vaue of natural wxTreeItemId type instead of using wxTreeItemIdValue +// with values of natural wxTreeItemId type instead of using wxTreeItemIdValue // and does it without any loss of efficiency class WXDLLIMPEXP_CORE wxArrayTreeItemIds : public wxArrayTreeItemIdsBase { @@ -252,9 +221,9 @@ public: void SetFont(const wxFont& font) { m_font = font; } // accessors - bool HasTextColour() const { return m_colText.Ok(); } - bool HasBackgroundColour() const { return m_colBack.Ok(); } - bool HasFont() const { return m_font.Ok(); } + bool HasTextColour() const { return m_colText.IsOk(); } + bool HasBackgroundColour() const { return m_colBack.IsOk(); } + bool HasFont() const { return m_font.IsOk(); } const wxColour& GetTextColour() const { return m_colText; } const wxColour& GetBackgroundColour() const { return m_colBack; } @@ -340,30 +309,30 @@ typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&); // tree control events and macros for handling them // ---------------------------------------------------------------------------- -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_GET_INFO; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_SET_INFO; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_KEY_DOWN; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_END_DRAG; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP; -extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREE_ITEM_MENU; +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_BEGIN_DRAG, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_BEGIN_RDRAG, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_END_LABEL_EDIT, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_DELETE_ITEM, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_GET_INFO, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_SET_INFO, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_ITEM_EXPANDED, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_ITEM_EXPANDING, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_ITEM_COLLAPSED, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_ITEM_COLLAPSING, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_SEL_CHANGING, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_KEY_DOWN, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_END_DRAG, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, wxTreeEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREE_ITEM_MENU, wxTreeEvent ); #define wxTreeEventHandler(func) \ - (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxTreeEventFunction, &func) + wxEVENT_HANDLER_CAST(wxTreeEventFunction, func) #define wx__DECLARE_TREEEVT(evt, id, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_ ## evt, id, wxTreeEventHandler(fn))