X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/696e1ea0b7cee1394693a0e507bbf49c9863952b..259c933b56bf80029a57b6601642cc7a2f63b9e0:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index a350654153..d328e047c7 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -62,6 +62,16 @@ #define TVIS_FOCUSED 0x0001 #endif +#ifndef TV_FIRST + #define TV_FIRST 0x1100 +#endif + +// old headers might miss these messages (comctl32.dll 4.71+ only) +#ifndef TVM_SETBKCOLOR + #define TVM_SETBKCOLOR (TV_FIRST + 29) + #define TVM_SETTEXTCOLOR (TV_FIRST + 30) +#endif + // ---------------------------------------------------------------------------- // private classes // ---------------------------------------------------------------------------- @@ -139,6 +149,8 @@ public: return TRUE; } + size_t GetCount() const { return m_selections.GetCount(); } + private: wxArrayTreeItemIds& m_selections; }; @@ -230,9 +242,7 @@ private: // macros // ---------------------------------------------------------------------------- -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl) -#endif // ---------------------------------------------------------------------------- // variables @@ -486,6 +496,30 @@ size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item, return counter.GetCount() - 1; } +// ---------------------------------------------------------------------------- +// control colours +// ---------------------------------------------------------------------------- + +bool wxTreeCtrl::SetBackgroundColour(const wxColour &colour) +{ + if ( !wxWindowBase::SetBackgroundColour(colour) ) + return FALSE; + + SendMessage(GetHwnd(), TVM_SETBKCOLOR, 0, colour.GetPixel()); + + return TRUE; +} + +bool wxTreeCtrl::SetForegroundColour(const wxColour &colour) +{ + if ( !wxWindowBase::SetForegroundColour(colour) ) + return FALSE; + + SendMessage(GetHwnd(), TVM_SETTEXTCOLOR, 0, colour.GetPixel()); + + return TRUE; +} + // ---------------------------------------------------------------------------- // Item access // ---------------------------------------------------------------------------- @@ -946,7 +980,7 @@ size_t wxTreeCtrl::GetSelections(wxArrayTreeItemIds& selections) const { TraverseSelections selector(this, selections); - return selections.GetCount(); + return selector.GetCount(); } // ---------------------------------------------------------------------------- @@ -1054,6 +1088,30 @@ wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, return DoInsertItem(parent, idPrevious, text, image, selectedImage, data); } +wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, + size_t index, + const wxString& text, + int image, int selectedImage, + wxTreeItemData *data) +{ + // find the item from index + long cookie; + wxTreeItemId idPrev, idCur = GetFirstChild(parent, cookie); + while ( index != 0 && idCur.IsOk() ) + { + index--; + + idPrev = idCur; + idCur = GetNextChild(parent, cookie); + } + + // assert, not check: if the index is invalid, we will append the item + // to the end + wxASSERT_MSG( index == 0, _T("bad index in wxTreeCtrl::InsertItem") ); + + return DoInsertItem(parent, idPrev, text, image, selectedImage, data); +} + wxTreeItemId wxTreeCtrl::AppendItem(const wxTreeItemId& parent, const wxString& text, int image, int selectedImage, @@ -1570,7 +1628,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) } break; -#ifdef NM_CUSTOMDRAW +#if defined(_WIN32_IE) && _WIN32_IE >= 0x300 case NM_CUSTOMDRAW: { LPNMTVCUSTOMDRAW lptvcd = (LPNMTVCUSTOMDRAW)lParam; @@ -1665,7 +1723,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) } } break; -#endif // NM_CUSTOMDRAW +#endif // _WIN32_IE >= 0x300 default: return wxControl::MSWOnNotify(idCtrl, lParam, result);