made wxTreeCtrl::GetNextVisible() behave in the same way in Win32 as in the generic version and implemented GetPrevVisible() in the generic version
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49085 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -111,6 +111,13 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
MENU_LINK(DecSpacing)
|
||||
MENU_LINK(ToggleIcon)
|
||||
MENU_LINK(SelectRoot)
|
||||
|
||||
MENU_LINK(ShowFirstVisible)
|
||||
#ifdef wxHAS_LAST_VISIBLE
|
||||
MENU_LINK(ShowLastVisible)
|
||||
#endif // wxHAS_LAST_VISIBLE
|
||||
MENU_LINK(ShowNextVisible)
|
||||
MENU_LINK(ShowPrevVisible)
|
||||
#undef MENU_LINK
|
||||
|
||||
END_EVENT_TABLE()
|
||||
@@ -140,7 +147,7 @@ BEGIN_EVENT_TABLE(MyTreeCtrl, wxTreeCtrl)
|
||||
EVT_TREE_KEY_DOWN(TreeTest_Ctrl, MyTreeCtrl::OnTreeKeyDown)
|
||||
EVT_TREE_ITEM_ACTIVATED(TreeTest_Ctrl, MyTreeCtrl::OnItemActivated)
|
||||
|
||||
// so many differents ways to handle right mouse button clicks...
|
||||
// so many different ways to handle right mouse button clicks...
|
||||
EVT_CONTEXT_MENU(MyTreeCtrl::OnContextMenu)
|
||||
// EVT_TREE_ITEM_MENU is the preferred event for creating context menus
|
||||
// on a tree control, because it includes the point of the click or item,
|
||||
@@ -254,6 +261,13 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
|
||||
item_menu->Append(TreeTest_ClearBold, wxT("Make item ¬ bold"));
|
||||
item_menu->AppendSeparator();
|
||||
item_menu->Append(TreeTest_ToggleIcon, wxT("Toggle the item's &icon"));
|
||||
item_menu->AppendSeparator();
|
||||
item_menu->Append(TreeTest_ShowFirstVisible, wxT("Show &first visible"));
|
||||
#ifdef wxHAS_LAST_VISIBLE
|
||||
item_menu->Append(TreeTest_ShowLastVisible, wxT("Show &last visible"));
|
||||
#endif // wxHAS_LAST_VISIBLE
|
||||
item_menu->Append(TreeTest_ShowNextVisible, wxT("Show &next visible"));
|
||||
item_menu->Append(TreeTest_ShowPrevVisible, wxT("Show &previous visible"));
|
||||
|
||||
#ifndef NO_MULTIPLE_SELECTION
|
||||
item_menu->AppendSeparator();
|
||||
@@ -701,6 +715,38 @@ void MyFrame::OnToggleIcon(wxCommandEvent& WXUNUSED(event))
|
||||
m_treeCtrl->DoToggleIcon(item);
|
||||
}
|
||||
|
||||
void MyFrame::DoShowFirstOrLast(TreeFunc0_t pfn, const wxString& label)
|
||||
{
|
||||
const wxTreeItemId item = (m_treeCtrl->*pfn)();
|
||||
|
||||
if ( !item.IsOk() )
|
||||
wxLogMessage("There is no %s item", label);
|
||||
else
|
||||
wxLogMessage("The %s item is \"%s\"",
|
||||
label, m_treeCtrl->GetItemText(item));
|
||||
}
|
||||
|
||||
void MyFrame::DoShowNextOrPrev(TreeFunc1_t pfn, const wxString& label)
|
||||
{
|
||||
wxTreeItemId item = m_treeCtrl->GetSelection();
|
||||
|
||||
CHECK_ITEM( item );
|
||||
|
||||
if ( !m_treeCtrl->IsVisible(item) )
|
||||
{
|
||||
wxLogMessage("The selected item must be visible.");
|
||||
return;
|
||||
}
|
||||
|
||||
item = (m_treeCtrl->*pfn)(item);
|
||||
|
||||
if ( !item.IsOk() )
|
||||
wxLogMessage("There is no %s item", label);
|
||||
else
|
||||
wxLogMessage("The %s item is \"%s\"",
|
||||
label, m_treeCtrl->GetItemText(item));
|
||||
}
|
||||
|
||||
void MyFrame::OnSetFgColour(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxColour col = wxGetColourFromUser(this, m_treeCtrl->GetForegroundColour());
|
||||
|
@@ -225,6 +225,18 @@ public:
|
||||
|
||||
void OnToggleIcon(wxCommandEvent& event);
|
||||
|
||||
void OnShowFirstVisible(wxCommandEvent& WXUNUSED(event))
|
||||
{ DoShowFirstOrLast(&wxTreeCtrl::GetFirstVisibleItem, "first visible"); }
|
||||
#ifdef wxHAS_LAST_VISIBLE // we don't have it currently but may add later
|
||||
void OnShowLastVisible(wxCommandEvent& WXUNUSED(event))
|
||||
{ DoShowFirstOrLast(&wxTreeCtrl::GetLastVisibleItem, "last visible"); }
|
||||
#endif // wxHAS_LAST_VISIBLE
|
||||
|
||||
void OnShowNextVisible(wxCommandEvent& WXUNUSED(event))
|
||||
{ DoShowNextOrPrev(&wxTreeCtrl::GetNextVisible, "next visible"); }
|
||||
void OnShowPrevVisible(wxCommandEvent& WXUNUSED(event))
|
||||
{ DoShowNextOrPrev(&wxTreeCtrl::GetPrevVisible, "previous visible"); }
|
||||
|
||||
void OnIdle(wxIdleEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
|
||||
@@ -238,6 +250,14 @@ private:
|
||||
void CreateTreeWithDefStyle();
|
||||
void CreateTree(long style);
|
||||
|
||||
// common parts of OnShowFirst/LastVisible() and OnShowNext/PrevVisible()
|
||||
typedef wxTreeItemId (wxTreeCtrl::*TreeFunc0_t)() const;
|
||||
void DoShowFirstOrLast(TreeFunc0_t pfn, const wxString& label);
|
||||
|
||||
typedef wxTreeItemId (wxTreeCtrl::*TreeFunc1_t)(const wxTreeItemId&) const;
|
||||
void DoShowNextOrPrev(TreeFunc1_t pfn, const wxString& label);
|
||||
|
||||
|
||||
wxPanel *m_panel;
|
||||
MyTreeCtrl *m_treeCtrl;
|
||||
#if wxUSE_LOG
|
||||
@@ -297,5 +317,9 @@ enum
|
||||
TreeTest_Select,
|
||||
TreeTest_Unselect,
|
||||
TreeTest_SelectRoot,
|
||||
TreeTest_ShowFirstVisible,
|
||||
TreeTest_ShowLastVisible,
|
||||
TreeTest_ShowNextVisible,
|
||||
TreeTest_ShowPrevVisible,
|
||||
TreeTest_Ctrl = 1000
|
||||
};
|
||||
|
Reference in New Issue
Block a user