]> git.saurik.com Git - wxWidgets.git/commitdiff
context help for notebook pages tests added
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 14 Jun 2006 18:32:26 +0000 (18:32 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 14 Jun 2006 18:32:26 +0000 (18:32 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39727 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/notebook/notebook.cpp
samples/notebook/notebook.h

index a3d0d45d72d84eb52ca04133373a9b76cdf3fb70..6adfd7ef7c6dea25bc75b802321ce1e093bba583 100644 (file)
@@ -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));
 
index 776edf7d14435065f3cd26a1dea52ecf3b595a4a..68b732e7b4db6251b7dde612f8e9a2b917c75c65 100644 (file)
@@ -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
 };