test showing parent/sibling items too (#9903)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55445 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -128,6 +128,9 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
#endif // wxHAS_LAST_VISIBLE
|
#endif // wxHAS_LAST_VISIBLE
|
||||||
MENU_LINK(ShowNextVisible)
|
MENU_LINK(ShowNextVisible)
|
||||||
MENU_LINK(ShowPrevVisible)
|
MENU_LINK(ShowPrevVisible)
|
||||||
|
MENU_LINK(ShowParent)
|
||||||
|
MENU_LINK(ShowPrevSibling)
|
||||||
|
MENU_LINK(ShowNextSibling)
|
||||||
#undef MENU_LINK
|
#undef MENU_LINK
|
||||||
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
@@ -282,6 +285,10 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
|
|||||||
#endif // wxHAS_LAST_VISIBLE
|
#endif // wxHAS_LAST_VISIBLE
|
||||||
item_menu->Append(TreeTest_ShowNextVisible, wxT("Show &next visible"));
|
item_menu->Append(TreeTest_ShowNextVisible, wxT("Show &next visible"));
|
||||||
item_menu->Append(TreeTest_ShowPrevVisible, wxT("Show &previous visible"));
|
item_menu->Append(TreeTest_ShowPrevVisible, wxT("Show &previous visible"));
|
||||||
|
item_menu->AppendSeparator();
|
||||||
|
item_menu->Append(TreeTest_ShowParent, "Show pa&rent");
|
||||||
|
item_menu->Append(TreeTest_ShowPrevSibling, "Show &previous sibling");
|
||||||
|
item_menu->Append(TreeTest_ShowNextSibling, "Show &next sibling");
|
||||||
|
|
||||||
#ifndef NO_MULTIPLE_SELECTION
|
#ifndef NO_MULTIPLE_SELECTION
|
||||||
item_menu->AppendSeparator();
|
item_menu->AppendSeparator();
|
||||||
@@ -773,25 +780,27 @@ void MyFrame::DoShowFirstOrLast(TreeFunc0_t pfn, const wxString& label)
|
|||||||
label, m_treeCtrl->GetItemText(item));
|
label, m_treeCtrl->GetItemText(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::DoShowNextOrPrev(TreeFunc1_t pfn, const wxString& label)
|
void MyFrame::DoShowRelativeItem(TreeFunc1_t pfn, const wxString& label)
|
||||||
{
|
{
|
||||||
wxTreeItemId item = m_treeCtrl->GetSelection();
|
wxTreeItemId item = m_treeCtrl->GetSelection();
|
||||||
|
|
||||||
CHECK_ITEM( item );
|
CHECK_ITEM( item );
|
||||||
|
|
||||||
if ( !m_treeCtrl->IsVisible(item) )
|
if ((pfn == (TreeFunc1_t) &wxTreeCtrl::GetPrevVisible
|
||||||
|
|| pfn == (TreeFunc1_t) &wxTreeCtrl::GetNextVisible)
|
||||||
|
&& !m_treeCtrl->IsVisible(item))
|
||||||
{
|
{
|
||||||
wxLogMessage("The selected item must be visible.");
|
wxLogMessage("The selected item must be visible.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
item = (m_treeCtrl->*pfn)(item);
|
wxTreeItemId new_item = (m_treeCtrl->*pfn)(item);
|
||||||
|
|
||||||
if ( !item.IsOk() )
|
if ( !new_item.IsOk() )
|
||||||
wxLogMessage("There is no %s item", label);
|
wxLogMessage("There is no %s item", label);
|
||||||
else
|
else
|
||||||
wxLogMessage("The %s item is \"%s\"",
|
wxLogMessage("The %s item is \"%s\"",
|
||||||
label, m_treeCtrl->GetItemText(item));
|
label, m_treeCtrl->GetItemText(new_item));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::OnSetFgColour(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnSetFgColour(wxCommandEvent& WXUNUSED(event))
|
||||||
|
@@ -246,9 +246,16 @@ public:
|
|||||||
#endif // wxHAS_LAST_VISIBLE
|
#endif // wxHAS_LAST_VISIBLE
|
||||||
|
|
||||||
void OnShowNextVisible(wxCommandEvent& WXUNUSED(event))
|
void OnShowNextVisible(wxCommandEvent& WXUNUSED(event))
|
||||||
{ DoShowNextOrPrev(&wxTreeCtrl::GetNextVisible, "next visible"); }
|
{ DoShowRelativeItem(&wxTreeCtrl::GetNextVisible, "next visible"); }
|
||||||
void OnShowPrevVisible(wxCommandEvent& WXUNUSED(event))
|
void OnShowPrevVisible(wxCommandEvent& WXUNUSED(event))
|
||||||
{ DoShowNextOrPrev(&wxTreeCtrl::GetPrevVisible, "previous visible"); }
|
{ DoShowRelativeItem(&wxTreeCtrl::GetPrevVisible, "previous visible"); }
|
||||||
|
|
||||||
|
void OnShowParent(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{ DoShowRelativeItem(&wxTreeCtrl::GetItemParent, "parent"); }
|
||||||
|
void OnShowPrevSibling(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{ DoShowRelativeItem(&wxTreeCtrl::GetPrevSibling, "previous sibling"); }
|
||||||
|
void OnShowNextSibling(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{ DoShowRelativeItem(&wxTreeCtrl::GetNextSibling, "next sibling"); }
|
||||||
|
|
||||||
void OnIdle(wxIdleEvent& event);
|
void OnIdle(wxIdleEvent& event);
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
@@ -268,7 +275,7 @@ private:
|
|||||||
void DoShowFirstOrLast(TreeFunc0_t pfn, const wxString& label);
|
void DoShowFirstOrLast(TreeFunc0_t pfn, const wxString& label);
|
||||||
|
|
||||||
typedef wxTreeItemId (wxTreeCtrl::*TreeFunc1_t)(const wxTreeItemId&) const;
|
typedef wxTreeItemId (wxTreeCtrl::*TreeFunc1_t)(const wxTreeItemId&) const;
|
||||||
void DoShowNextOrPrev(TreeFunc1_t pfn, const wxString& label);
|
void DoShowRelativeItem(TreeFunc1_t pfn, const wxString& label);
|
||||||
|
|
||||||
|
|
||||||
wxPanel *m_panel;
|
wxPanel *m_panel;
|
||||||
@@ -337,5 +344,8 @@ enum
|
|||||||
TreeTest_ShowLastVisible,
|
TreeTest_ShowLastVisible,
|
||||||
TreeTest_ShowNextVisible,
|
TreeTest_ShowNextVisible,
|
||||||
TreeTest_ShowPrevVisible,
|
TreeTest_ShowPrevVisible,
|
||||||
|
TreeTest_ShowParent,
|
||||||
|
TreeTest_ShowPrevSibling,
|
||||||
|
TreeTest_ShowNextSibling,
|
||||||
TreeTest_Ctrl = 1000
|
TreeTest_Ctrl = 1000
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user