X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9dfbf520eb3f8ed03416c72222bb4ee74b8fcb0e..8c3c31d4a544271ae70be958f050f70bab440597:/src/msw/treectrl.cpp?ds=sidebyside diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index c3eb0e1d4f..2e4440df70 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -47,10 +47,12 @@ #include "wx/treectrl.h" #ifdef __GNUWIN32__ +#ifndef wxUSE_NORLANDER_HEADERS #include "wx/msw/gnuwin32/extra.h" #endif +#endif -#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) +#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) || defined(wxUSE_NORLANDER_HEADERS) #include #endif @@ -195,15 +197,21 @@ bool wxTreeCtrl::Create(wxWindow *parent, if ( m_windowStyle & wxTR_LINES_AT_ROOT ) wstyle |= TVS_LINESATROOT; +#if !defined( __GNUWIN32__ ) && !defined(wxUSE_NORLANDER_HEADERS) // we emulate the multiple selection tree controls by using checkboxes: set // up the image list we need for this if we do have multiple selections if ( m_windowStyle & wxTR_MULTIPLE ) wstyle |= TVS_CHECKBOXES; +#endif // Create the tree control. if ( !MSWCreateControl(WC_TREEVIEW, wstyle) ) return FALSE; + // the treectrl with any other background looks ugly because the items + // background is white anyhow + SetBackgroundColour(*wxWHITE); + // VZ: this is some experimental code which may be used to get the // TVS_CHECKBOXES style functionality for comctl32.dll < 4.71. // AFAIK, the standard DLL does about the same thing anyhow. @@ -337,15 +345,14 @@ void wxTreeCtrl::SetStateImageList(wxImageList *imageList) SetAnyImageList(m_imageListState = imageList, TVSIL_STATE); } -size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item, - bool recursively) const +// internal class for counting tree items + +class TraverseCounter : public wxTreeTraversal { - class TraverseCounter : public wxTreeTraversal - { - public: +public: TraverseCounter(const wxTreeCtrl *tree, const wxTreeItemId& root, - bool recursively) + bool recursively) : wxTreeTraversal(tree) { m_count = 0; @@ -362,9 +369,15 @@ size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item, size_t GetCount() const { return m_count; } - private: +private: size_t m_count; - } counter(this, item, recursively); +}; + + +size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item, + bool recursively) const +{ + TraverseCounter counter(this, item, recursively); return counter.GetCount(); } @@ -637,11 +650,11 @@ void wxTreeCtrl::SetItemCheck(const wxTreeItemId& item, bool check) DoSetItem(&tvItem); } -size_t wxTreeCtrl::GetSelections(wxArrayTreeItemIds& selections) const +// internal class for getting the selected + +class TraverseSelections : public wxTreeTraversal { - class TraverseSelections : public wxTreeTraversal - { - public: +public: TraverseSelections(const wxTreeCtrl *tree, wxArrayTreeItemIds& selections) : wxTreeTraversal(tree), m_selections(selections) @@ -661,9 +674,13 @@ size_t wxTreeCtrl::GetSelections(wxArrayTreeItemIds& selections) const return TRUE; } - private: +private: wxArrayTreeItemIds& m_selections; - } selector(this, selections); +}; + +size_t wxTreeCtrl::GetSelections(wxArrayTreeItemIds& selections) const +{ + TraverseSelections selector(this, selections); return selections.GetCount(); }