diff --git a/samples/treectrl/treectrl.cpp b/samples/treectrl/treectrl.cpp index 0a62c84082..fd8e25c69d 100644 --- a/samples/treectrl/treectrl.cpp +++ b/samples/treectrl/treectrl.cpp @@ -26,6 +26,7 @@ #ifndef WX_PRECOMP #include "wx/wx.h" + #include "wx/colordlg.h" #endif #include "wx/log.h" @@ -62,10 +63,11 @@ return; \ } +#define MENU_LINK(name) EVT_MENU(TreeTest_##name, MyFrame::On##name) + BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_SIZE(MyFrame::OnSize) -#define MENU_LINK(name) EVT_MENU(TreeTest_##name, MyFrame::On##name) MENU_LINK(Quit) MENU_LINK(About) MENU_LINK(TogButtons) @@ -76,6 +78,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) MENU_LINK(TogRootLines) MENU_LINK(TogBorder) MENU_LINK(TogFullHighlight) + MENU_LINK(SetFgColour) + MENU_LINK(SetBgColour) MENU_LINK(Dump) #ifndef NO_MULTIPLE_SELECTION MENU_LINK(DumpSelected) @@ -193,6 +197,9 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h) #endif // NO_MULTIPLE_SELECTION style_menu->Append(TreeTest_ToggleImages, wxT("Toggle show ima&ges")); style_menu->Append(TreeTest_SetImageSize, wxT("Set image si&ze...")); + style_menu->AppendSeparator(); + style_menu->Append(TreeTest_SetFgColour, wxT("Set &foreground colour...")); + style_menu->Append(TreeTest_SetBgColour, wxT("Set &background colour...")); tree_menu->Append(TreeTest_Recreate, "&Recreate the tree"); tree_menu->Append(TreeTest_CollapseAndReset, "C&ollapse and reset"); @@ -251,8 +258,6 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h) #endif wxSUNKEN_BORDER); -// m_treeCtrl->SetBackgroundColour( *wxLIGHT_GREY ); - m_textCtrl = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxSUNKEN_BORDER); @@ -564,6 +569,20 @@ void MyFrame::OnToggleIcon(wxCommandEvent& WXUNUSED(event)) m_treeCtrl->DoToggleIcon(item); } +void MyFrame::OnSetFgColour(wxCommandEvent& WXUNUSED(event)) +{ + wxColour col = wxGetColourFromUser(this, m_treeCtrl->GetForegroundColour()); + if ( col.Ok() ) + m_treeCtrl->SetForegroundColour(col); +} + +void MyFrame::OnSetBgColour(wxCommandEvent& WXUNUSED(event)) +{ + wxColour col = wxGetColourFromUser(this, m_treeCtrl->GetBackgroundColour()); + if ( col.Ok() ) + m_treeCtrl->SetBackgroundColour(col); +} + // MyTreeCtrl implementation #if USE_GENERIC_TREECTRL IMPLEMENT_DYNAMIC_CLASS(MyTreeCtrl, wxGenericTreeCtrl) diff --git a/samples/treectrl/treectrl.h b/samples/treectrl/treectrl.h index 25f6e73645..9892db42c5 100644 --- a/samples/treectrl/treectrl.h +++ b/samples/treectrl/treectrl.h @@ -155,6 +155,9 @@ public: void OnTogBorder(wxCommandEvent& event) { TogStyle(wxTR_ROW_LINES); } void OnTogFullHighlight(wxCommandEvent& event) { TogStyle(wxTR_FULL_ROW_HIGHLIGHT); } + void OnSetFgColour(wxCommandEvent& event); + void OnSetBgColour(wxCommandEvent& event); + void OnDump(wxCommandEvent& event); #ifndef NO_MULTIPLE_SELECTION void OnDumpSelected(wxCommandEvent& event); @@ -225,6 +228,8 @@ enum TreeTest_TogRootLines, TreeTest_TogBorder, TreeTest_TogFullHighlight, + TreeTest_SetFgColour, + TreeTest_SetBgColour, TreeTest_Dump, TreeTest_DumpSelected, TreeTest_Count,