#define TVM_SETTEXTCOLOR (TV_FIRST + 30)
#endif
-// a macro to hide the cast ugliness
-#define HITEM(item) (HTREEITEM)((item).m_pItem)
+// 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)
// 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
m_textCtrl = NULL;
m_hasAnyAttr = false;
m_dragImage = NULL;
- m_htSelStart = 0;
m_pVirtualRoot = NULL;
// initialize the global array of events now as it can't be done statically
case wxTreeItemIcon_Normal:
{
const int imageNormalOld = GetItemImage(item);
- const int imageSelOld = GetItemSelectedImage(item);
+ const int imageSelOld =
+ GetItemImage(item, wxTreeItemIcon_Selected);
// always set the normal image
imageNormal = image;
// the wxTreeItemIndirectData GetItemXXXImage() will use it to
// get the images
imageNormal = GetItemImage(item);
- imageSel = GetItemSelectedImage(item);
+ imageSel = GetItemImage(item, wxTreeItemIcon_Selected);
// if it doesn't have it yet, add it
wxTreeItemIndirectData *data = new
wxColour wxTreeCtrl::GetItemTextColour(const wxTreeItemId& item) const
{
- wxMapTreeAttr::const_iterator it = m_attrs.find(item);
+ wxMapTreeAttr::const_iterator it = m_attrs.find(item.m_pItem);
return it == m_attrs.end() ? wxNullColour : it->second->GetTextColour();
}
wxColour wxTreeCtrl::GetItemBackgroundColour(const wxTreeItemId& item) const
{
- wxMapTreeAttr::const_iterator it = m_attrs.find(item);
+ wxMapTreeAttr::const_iterator it = m_attrs.find(item.m_pItem);
return it == m_attrs.end() ? wxNullColour : it->second->GetBackgroundColour();
}
wxFont wxTreeCtrl::GetItemFont(const wxTreeItemId& item) const
{
- wxMapTreeAttr::const_iterator it = m_attrs.find(item);
+ wxMapTreeAttr::const_iterator it = m_attrs.find(item.m_pItem);
return it == m_attrs.end() ? wxNullFont : it->second->GetFont();
}
const wxColour& col)
{
wxTreeItemAttr *attr;
- wxMapTreeAttr::iterator it = m_attrs.find(item);
+ wxMapTreeAttr::iterator it = m_attrs.find(item.m_pItem);
if ( it == m_attrs.end() )
{
m_hasAnyAttr = true;
- m_attrs[item] =
+ m_attrs[item.m_pItem] =
attr = new wxTreeItemAttr;
}
else
const wxColour& col)
{
wxTreeItemAttr *attr;
- wxMapTreeAttr::iterator it = m_attrs.find(item);
+ wxMapTreeAttr::iterator it = m_attrs.find(item.m_pItem);
if ( it == m_attrs.end() )
{
m_hasAnyAttr = true;
- m_attrs[item] =
+ m_attrs[item.m_pItem] =
attr = new wxTreeItemAttr;
}
else // already in the hash
void wxTreeCtrl::SetItemFont(const wxTreeItemId& item, const wxFont& font)
{
wxTreeItemAttr *attr;
- wxMapTreeAttr::iterator it = m_attrs.find(item);
+ wxMapTreeAttr::iterator it = m_attrs.find(item.m_pItem);
if ( it == m_attrs.end() )
{
m_hasAnyAttr = true;
- m_attrs[item] =
+ m_attrs[item.m_pItem] =
attr = new wxTreeItemAttr;
}
else // already in the hash
wxTreeItemId wxTreeCtrl::GetSelection() const
{
- wxCHECK_MSG( !(m_windowStyle & wxTR_MULTIPLE), NULL,
+ wxCHECK_MSG( !(m_windowStyle & wxTR_MULTIPLE), wxTreeItemId(),
wxT("this only works with single selection controls") );
return wxTreeItemId(TreeView_GetSelection(GetHwnd()));
return TVI_ROOT;
}
- return DoInsertItem(wxTreeItemId(), 0,
+ return DoInsertItem(wxTreeItemId(), wxTreeItemId(),
text, image, selectedImage, data);
}
size_t nCount = children.Count();
for ( size_t n = 0; n < nCount; n++ )
{
- if ( !TreeView_DeleteItem(GetHwnd(), HITEM(children[n])) )
+ if ( !TreeView_DeleteItem(GetHwnd(), HITEM_PTR(children[n])) )
{
wxLogLastError(wxT("TreeView_DeleteItem"));
}
DoExpand(item, TVE_TOGGLE);
}
+#if WXWIN_COMPATIBILITY_2_4
void wxTreeCtrl::ExpandItem(const wxTreeItemId& item, int action)
{
DoExpand(item, action);
}
+#endif
void wxTreeCtrl::Unselect()
{
for ( size_t n = 0; n < count; n++ )
{
#if wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
- SetItemCheck(selections[n], false);
+ SetItemCheck(HITEM_PTR(selections[n]), false);
#else // !wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
- ::UnselectItem(GetHwnd(), HITEM(selections[n]));
+ ::UnselectItem(GetHwnd(), HITEM_PTR(selections[n]));
#endif // wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE/!wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
}
}
::SetFocus(GetHwnd(), htItem);
// reset on any click without Shift
- m_htSelStart = 0;
+ m_htSelStart.Unset();
processed = true;
}
size_t count = GetSelections(selections);
if ( count == 0 ||
count > 1 ||
- HITEM(selections[0]) != htItem )
+ HITEM_PTR(selections[0]) != htItem )
{
// clear the previously selected items, if the
// user clicked outside of the present selection.
}
// reset on any click without Shift
- m_htSelStart = 0;
+ m_htSelStart.Unset();
}
}
break;
{
// TreeView_GetItemRect() will return false if item is not visible,
// which may happen perfectly well
- if ( TreeView_GetItemRect(GetHwnd(), HITEM(selections[n]),
+ if ( TreeView_GetItemRect(GetHwnd(), HITEM_PTR(selections[n]),
&rect, true) )
{
::InvalidateRect(GetHwnd(), &rect, false);