// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef _WX_TREECTRL_H_
-#define _WX_TREECTRL_H_
+#ifndef _WX_MSW_TREECTRL_H_
+#define _WX_MSW_TREECTRL_H_
// ----------------------------------------------------------------------------
// headers
void DeleteTextCtrl();
+ // return true if the item is the hidden root one (i.e. it's the root item
+ // and the tree has wxTR_HIDE_ROOT style)
+ bool IsHiddenRoot(const wxTreeItemId& item) const;
+
+
// the hash storing the items attributes (indexed by item ids)
wxMapTreeAttr m_attrs;
#endif // wxUSE_TREECTRL
-#endif
- // _WX_TREECTRL_H_
+#endif // _WX_MSW_TREECTRL_H_
virtual bool OnVisit(const wxTreeItemId& item)
{
+ const wxTreeCtrl * const tree = GetTree();
+
// can't visit a virtual node.
- if ( (GetTree()->GetRootItem() == item) && (GetTree()->GetWindowStyle() & wxTR_HIDE_ROOT))
+ if ( (tree->GetRootItem() == item) && tree->HasFlag(wxTR_HIDE_ROOT) )
{
return true;
}
#if wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
- if ( GetTree()->IsItemChecked(item) )
+ if ( tree->IsItemChecked(item) )
#else
- if ( ::IsItemSelected(GetHwndOf(GetTree()), HITEM(item)) )
+ if ( ::IsItemSelected(GetHwndOf(tree), HITEM(item)) )
#endif
{
m_selections.Add(item);
// Item access
// ----------------------------------------------------------------------------
+bool wxTreeCtrl::IsHiddenRoot(const wxTreeItemId& item) const
+{
+ return HITEM(item) == TVI_ROOT && HasFlag(wxTR_HIDE_ROOT);
+}
+
wxString wxTreeCtrl::GetItemText(const wxTreeItemId& item) const
{
wxCHECK_MSG( item.IsOk(), wxEmptyString, wxT("invalid tree item") );
{
wxCHECK_MSG( item.IsOk(), -1, wxT("invalid tree item") );
- if ( (HITEM(item) == TVI_ROOT) && (m_windowStyle & wxTR_HIDE_ROOT) )
+ if ( IsHiddenRoot(item) )
{
// no images for hidden root item
return -1;
wxT("invalid image index"));
- if ( (HITEM(item) == TVI_ROOT) && (m_windowStyle & wxTR_HIDE_ROOT) )
+ if ( IsHiddenRoot(item) )
{
// no images for hidden root item
return;
wxTreeItemData *data)
{
- if ( m_windowStyle & wxTR_HIDE_ROOT )
+ if ( HasFlag(wxTR_HIDE_ROOT) )
{
// create a virtual root item, the parent for all the others
wxTreeItemParam *param = new wxTreeItemParam;
wxT("Unknown flag in wxTreeCtrl::DoExpand") );
// A hidden root can be neither expanded nor collapsed.
- wxCHECK_RET( !(m_windowStyle & wxTR_HIDE_ROOT) || (HITEM(item) != TVI_ROOT),
+ wxCHECK_RET( !IsHiddenRoot(item),
wxT("Can't expand/collapse hidden root node!") );
// TreeView_Expand doesn't send TVN_ITEMEXPAND(ING) messages, so we must
void wxTreeCtrl::EnsureVisible(const wxTreeItemId& item)
{
+ wxCHECK_RET( !IsHiddenRoot(item), _T("can't show hidden root item") );
+
// no error return
TreeView_EnsureVisible(GetHwnd(), HITEM(item));
}