From df1496e3eb11e87e15a29fd04c068cd6cd3b607e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 14 Jun 2006 18:32:26 +0000 Subject: [PATCH] context help for notebook pages tests added git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39727 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/notebook/notebook.cpp | 50 ++++++++++++++++++++++++++++++++++- samples/notebook/notebook.h | 7 +++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/samples/notebook/notebook.cpp b/samples/notebook/notebook.cpp index a3d0d45d72..6adfd7ef7c 100644 --- a/samples/notebook/notebook.cpp +++ b/samples/notebook/notebook.cpp @@ -34,6 +34,10 @@ IMPLEMENT_APP(MyApp) bool MyApp::OnInit() { +#if wxUSE_HELP + wxHelpProvider::Set( new wxSimpleHelpProvider ); +#endif + // Create the main window MyFrame *frame = new MyFrame(); @@ -54,6 +58,10 @@ wxPanel *CreateUserCreatedPage(wxBookCtrlBase *parent) { wxPanel *panel = new wxPanel(parent); +#if wxUSE_HELP + panel->SetHelpText( wxT( "Panel with a Button" ) ); +#endif + (void) new wxButton( panel, wxID_ANY, wxT("Button"), wxPoint(10, 10), wxDefaultSize ); @@ -64,6 +72,10 @@ wxPanel *CreateRadioButtonsPage(wxBookCtrlBase *parent) { wxPanel *panel = new wxPanel(parent); +#if wxUSE_HELP + panel->SetHelpText( wxT( "Panel with some Radio Buttons" ) ); +#endif + wxString animals[] = { wxT("Fox"), wxT("Hare"), wxT("Rabbit"), wxT("Sabre-toothed tiger"), wxT("T Rex") }; @@ -89,6 +101,10 @@ wxPanel *CreateVetoPage(wxBookCtrlBase *parent) { wxPanel *panel = new wxPanel(parent); +#if wxUSE_HELP + panel->SetHelpText( wxT( "An empty panel" ) ); +#endif + (void) new wxStaticText( panel, wxID_ANY, wxT("This page intentionally left blank"), wxPoint(10, 10) ); @@ -99,6 +115,10 @@ wxPanel *CreateBigButtonPage(wxBookCtrlBase *parent) { wxPanel *panel = new wxPanel(parent); +#if wxUSE_HELP + panel->SetHelpText( wxT( "Panel with a maximized button" ) ); +#endif + wxButton *buttonBig = new wxButton(panel, wxID_ANY, wxT("Maximized button")); wxBoxSizer *sizerPanel = new wxBoxSizer(wxVERTICAL); @@ -113,6 +133,10 @@ wxPanel *CreateInsertPage(wxBookCtrlBase *parent) { wxPanel *panel = new wxPanel(parent); +#if wxUSE_HELP + panel->SetHelpText( wxT( "Maroon panel" ) ); +#endif + panel->SetBackgroundColour( wxColour( wxT("MAROON") ) ); (void) new wxStaticText( panel, wxID_ANY, wxT("This page has been inserted, not added."), wxPoint(10, 10) ); @@ -179,8 +203,12 @@ wxPanel *CreatePage(wxBookCtrlBase *parent, const wxString&pageName) } MyFrame::MyFrame() - : wxFrame(NULL, wxID_ANY, wxString(wxT("wxWidgets book controls sample"))) + : wxFrame(NULL, wxID_ANY, wxString(wxT("wxWidgets book controls sample"))) { +#if wxUSE_HELP + SetExtraStyle(wxFRAME_EX_CONTEXTHELP); +#endif // wxUSE_HELP + #if wxUSE_NOTEBOOK m_type = Type_Notebook; #elif wxUSE_CHOICEBOOK @@ -239,6 +267,9 @@ MyFrame::MyFrame() #endif wxMenu *menuOperations = new wxMenu; +#if wxUSE_HELP + menuOperations->Append(ID_CONTEXT_HELP, wxT("&Context help\tCtrl-F1")); +#endif // wxUSE_HELP menuOperations->Append(ID_HITTEST, wxT("&Hit test\tCtrl-H")); wxMenu *menuFile = new wxMenu; @@ -487,6 +518,9 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(ID_DELETE_LAST_PAGE, MyFrame::OnDeleteLastPage) EVT_MENU(ID_NEXT_PAGE, MyFrame::OnNextPage) +#if wxUSE_HELP + EVT_MENU(ID_CONTEXT_HELP, MyFrame::OnContextHelp) +#endif // wxUSE_HELP EVT_MENU(ID_HITTEST, MyFrame::OnHitTest) // Book controls @@ -520,6 +554,16 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_IDLE(MyFrame::OnIdle) END_EVENT_TABLE() +#if wxUSE_HELP + +void MyFrame::OnContextHelp(wxCommandEvent& WXUNUSED(event)) +{ + // launches local event loop + wxContextHelp ch( this ); +} + +#endif // wxUSE_HELP + void MyFrame::AddFlagStrIfFlagPresent(wxString & flagStr, long flags, long flag, const wxChar * flagName) const { if( (flags & flag) == flag ) @@ -603,6 +647,10 @@ wxPanel *MyFrame::CreateNewPage() const { wxPanel *panel = new wxPanel(m_bookCtrl, wxID_ANY ); +#if wxUSE_HELP + panel->SetHelpText( wxT( "Panel with \"First\" and \"Second\" buttons" ) ); +#endif + (void) new wxButton(panel, wxID_ANY, wxT("First button"), wxPoint(10, 10)); (void) new wxButton(panel, wxID_ANY, wxT("Second button"), wxPoint(50, 100)); diff --git a/samples/notebook/notebook.h b/samples/notebook/notebook.h index 776edf7d14..68b732e7b4 100644 --- a/samples/notebook/notebook.h +++ b/samples/notebook/notebook.h @@ -52,6 +52,10 @@ public: void OnAddSubPage(wxCommandEvent& event); void OnAddPageBefore(wxCommandEvent& event); +#if wxUSE_HELP + void OnContextHelp(wxCommandEvent& event); +#endif // wxUSE_HELP + void OnHitTest(wxCommandEvent& event); void OnBookCtrl(wxBookCtrlBaseEvent& event); @@ -144,6 +148,9 @@ enum ID_COMMANDS ID_ADD_PAGE_BEFORE, ID_ADD_SUB_PAGE, +#if wxUSE_HELP + ID_CONTEXT_HELP, +#endif // wxUSE_HELP ID_HITTEST }; -- 2.45.2