git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35780
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
WX_DEFINE_EXPORTED_ARRAY_PTR(wxTreeItemIdValue, wxArrayTreeItemIdsBase);
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
+// and does it without any loss of efficiency
class WXDLLEXPORT wxArrayTreeItemIds : public wxArrayTreeItemIdsBase
{
public:
void Add(const wxTreeItemId& id)
{ wxArrayTreeItemIdsBase::Add(id.m_pItem); }
class WXDLLEXPORT wxArrayTreeItemIds : public wxArrayTreeItemIdsBase
{
public:
void Add(const wxTreeItemId& id)
{ wxArrayTreeItemIdsBase::Add(id.m_pItem); }
+ void Insert(const wxTreeItemId& id, size_t pos)
+ { wxArrayTreeItemIdsBase::Insert(id.m_pItem, pos); }
+ wxTreeItemId Item(size_t i) const
+ { return wxTreeItemId(wxArrayTreeItemIdsBase::Item(i)); }
+ wxTreeItemId operator[](size_t i) const { return Item(i); }
};
// ----------------------------------------------------------------------------
};
// ----------------------------------------------------------------------------
// macros to hide the cast ugliness
// --------------------------------
// macros to hide the cast ugliness
// --------------------------------
-// ptr is the real item id, i.e. wxTreeItemId::m_pItem
-#define HITEM_PTR(ptr) (HTREEITEM)(ptr)
-
-// item here is a wxTreeItemId
-#define HITEM(item) HITEM_PTR((item).m_pItem)
+// get HTREEITEM from wxTreeItemId
+#define HITEM(item) ((HTREEITEM)(((item).m_pItem)))
// the native control doesn't support multiple selections under MSW and we
// have 2 ways to emulate them: either using TVS_CHECKBOXES style and let
// the native control doesn't support multiple selections under MSW and we
// have 2 ways to emulate them: either using TVS_CHECKBOXES style and let
size_t nCount = children.Count();
for ( size_t n = 0; n < nCount; n++ )
{
size_t nCount = children.Count();
for ( size_t n = 0; n < nCount; n++ )
{
- if ( !TreeView_DeleteItem(GetHwnd(), HITEM_PTR(children[n])) )
+ if ( !TreeView_DeleteItem(GetHwnd(), HITEM(children[n])) )
{
wxLogLastError(wxT("TreeView_DeleteItem"));
}
{
wxLogLastError(wxT("TreeView_DeleteItem"));
}
for ( size_t n = 0; n < count; n++ )
{
#if wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
for ( size_t n = 0; n < count; n++ )
{
#if wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
- SetItemCheck(HITEM_PTR(selections[n]), false);
+ SetItemCheck(HITEM(selections[n]), false);
#else // !wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
#else // !wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
- ::UnselectItem(GetHwnd(), HITEM_PTR(selections[n]));
+ ::UnselectItem(GetHwnd(), HITEM(selections[n]));
#endif // wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE/!wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
}
#endif // wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE/!wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
}
size_t count = GetSelections(selections);
if ( count == 0 ||
count > 1 ||
size_t count = GetSelections(selections);
if ( count == 0 ||
count > 1 ||
- HITEM_PTR(selections[0]) != htItem )
+ HITEM(selections[0]) != htItem )
{
// clear the previously selected items, if the
// user clicked outside of the present selection.
{
// clear the previously selected items, if the
// user clicked outside of the present selection.
{
// TreeView_GetItemRect() will return false if item is not visible,
// which may happen perfectly well
{
// TreeView_GetItemRect() will return false if item is not visible,
// which may happen perfectly well
- if ( TreeView_GetItemRect(GetHwnd(), HITEM_PTR(selections[n]),
+ if ( TreeView_GetItemRect(GetHwnd(), HITEM(selections[n]),
&rect, TRUE) )
{
::InvalidateRect(GetHwnd(), &rect, FALSE);
&rect, TRUE) )
{
::InvalidateRect(GetHwnd(), &rect, FALSE);