]> git.saurik.com Git - wxWidgets.git/commitdiff
Help sample should work for .zip help files now.
authorJulian Smart <julian@anthemion.co.uk>
Thu, 9 Mar 2000 23:41:57 +0000 (23:41 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 9 Mar 2000 23:41:57 +0000 (23:41 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6572 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/help/demo.cpp
samples/help/doc.zip
src/html/helpdata.cpp

index 1e071f880c6bedbefbee2e3a72e1cf87923e02a0..ff02c60120e18b685b025c31f74bc839a35963ae 100644 (file)
@@ -35,7 +35,7 @@
 
 // define this to 1 to use HTML help even under Windows (by default, Windows
 // version will use WinHelp).
-// Please also see samples/html/helpview for a more complex help viewer.
+// Please also see samples/html/helpview.
 
 #define USE_HTML_HELP 1
 
@@ -98,6 +98,8 @@ public:
     void OnHtmlHelp(wxCommandEvent& event);
     void OnAdvancedHtmlHelp(wxCommandEvent& event);
 
+    void ShowHelp(int commandId, wxHelpControllerBase& helpController);
+
 private:
    wxHelpController         m_help;
 
@@ -324,7 +326,26 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnHelp(wxCommandEvent& event)
 {
-   switch(event.GetId())
+    ShowHelp(event.GetId(), m_help);
+}
+
+void MyFrame::OnHtmlHelp(wxCommandEvent& event)
+{
+#if USE_HTML_HELP
+    ShowHelp(event.GetId(), m_htmlHelp);
+#endif
+}
+
+void MyFrame::OnAdvancedHtmlHelp(wxCommandEvent& event)
+{
+#if USE_HTML_HELP
+    ShowHelp(event.GetId(), m_advancedHtmlHelp);
+#endif
+}
+
+void MyFrame::ShowHelp(int commandId, wxHelpControllerBase& helpController)
+{
+   switch(commandId)
    {
 
    // Note: For WinHelp, these ids are specified in the map session, mapping
@@ -332,112 +353,58 @@ void MyFrame::OnHelp(wxCommandEvent& event)
    // For HTML and external help, a wxhelp.map file is used.
 
    case HelpDemo_Help_Classes:
-      m_help.DisplaySection(2);
-      break;
-   case HelpDemo_Help_Functions:
-      m_help.DisplaySection(1);
-      break;
-   case HelpDemo_Help_Help:
-      m_help.DisplaySection(3);
-      break;
-
-   // These three calls are only used by wxExtHelpController
-
-   case HelpDemo_Help_KDE:
-      m_help.SetViewer("kdehelp");
-      break;
-   case HelpDemo_Help_GNOME:
-      m_help.SetViewer("gnome-help-browser");
-      break;
-   case HelpDemo_Help_Netscape:
-      m_help.SetViewer("netscape", wxHELP_NETSCAPE);
-      break;
-
-   case HelpDemo_Help_Search:
-   {
-      wxString key = wxGetTextFromUser("Search for?",
-                                       "Search help for keyword",
-                                       "",
-                                       this);
-      if(! key.IsEmpty())
-         m_help.KeywordSearch(key);
-   }
-   break;
-   case HelpDemo_Help_Index:
-   default:
-      m_help.DisplayContents();
-      break;
-   }
-}
+   case HelpDemo_Html_Help_Classes:
+   case HelpDemo_Advanced_Html_Help_Classes:
+      helpController.DisplaySection(2);
 
-void MyFrame::OnHtmlHelp(wxCommandEvent& event)
-{
-#if USE_HTML_HELP
-   switch(event.GetId())
-   {
+      // if (helpController.IsKindOf(CLASSINFO(wxHtmlHelpController)))
+      // ((wxHtmlHelpController&)helpController).Display("Classes"); // An alternative form for this controller
 
-   case HelpDemo_Html_Help_Classes:
-      m_htmlHelp.DisplaySection(2);
       break;
+   case HelpDemo_Help_Functions:
    case HelpDemo_Html_Help_Functions:
-      m_htmlHelp.DisplaySection(1);
+   case HelpDemo_Advanced_Html_Help_Functions:
+      helpController.DisplaySection(1);
       break;
+   case HelpDemo_Help_Help:
    case HelpDemo_Html_Help_Help:
-      m_htmlHelp.DisplaySection(3);
+   case HelpDemo_Advanced_Html_Help_Help:
+      helpController.DisplaySection(3);
       break;
 
+   case HelpDemo_Help_Search:
    case HelpDemo_Html_Help_Search:
+   case HelpDemo_Advanced_Html_Help_Search:
    {
       wxString key = wxGetTextFromUser("Search for?",
                                        "Search help for keyword",
                                        "",
                                        this);
       if(! key.IsEmpty())
-         m_htmlHelp.KeywordSearch(key);
+         helpController.KeywordSearch(key);
    }
    break;
+
+   case HelpDemo_Help_Index:
    case HelpDemo_Html_Help_Index:
-   default:
-      m_htmlHelp.DisplayContents();
+   case HelpDemo_Advanced_Html_Help_Index:
+      helpController.DisplayContents();
       break;
-   }
-#endif
-}
 
-void MyFrame::OnAdvancedHtmlHelp(wxCommandEvent& event)
-{
-#if USE_HTML_HELP
-   switch(event.GetId())
-   {
+   // These three calls are only used by wxExtHelpController
 
-   case HelpDemo_Advanced_Html_Help_Classes:
-      m_advancedHtmlHelp.DisplaySection(2);
-//      m_advancedHtmlHelp.Display("Classes"); // An alternative form
+   case HelpDemo_Help_KDE:
+      helpController.SetViewer("kdehelp");
       break;
-   case HelpDemo_Advanced_Html_Help_Functions:
-      m_advancedHtmlHelp.DisplaySection(1);
-//      m_advancedHtmlHelp.Display("Functions"); // An alternative form
+   case HelpDemo_Help_GNOME:
+      helpController.SetViewer("gnome-help-browser");
       break;
-   case HelpDemo_Advanced_Html_Help_Help:
-      m_advancedHtmlHelp.DisplaySection(3);
-//      m_advancedHtmlHelp.Display("About"); // An alternative form
+   case HelpDemo_Help_Netscape:
+      helpController.SetViewer("netscape", wxHELP_NETSCAPE);
       break;
 
-   case HelpDemo_Advanced_Html_Help_Search:
-   {
-      wxString key = wxGetTextFromUser("Search for?",
-                                       "Search help for keyword",
-                                       "",
-                                       this);
-      if(! key.IsEmpty())
-         m_advancedHtmlHelp.KeywordSearch(key);
-   }
-   break;
-   case HelpDemo_Advanced_Html_Help_Index:
    default:
-      m_advancedHtmlHelp.DisplayContents();
       break;
    }
-#endif
 }
 
index 3ef6d5e9399e18ba757bcb64c2140d2d73ae59e7..72bec9f9c4825c87aeb88f65ab1509a3d709752a 100644 (file)
Binary files a/samples/help/doc.zip and b/samples/help/doc.zip differ
index 4e186d55f0122459aeeae4ecbd725d297566179f..cb5eb0e862144830bebb3a1007ec82566daba95a 100644 (file)
@@ -93,7 +93,7 @@ class HP_TagHandler : public wxHtmlTagHandler
         wxHtmlBookRecord *m_Book;
 
     public:
-        HP_TagHandler(wxHtmlBookRecord *b) : wxHtmlTagHandler() {m_Book = b; m_Items = NULL; m_ItemsCnt = 0; m_Name = m_Page = wxEmptyString; m_Level = 0; }
+        HP_TagHandler(wxHtmlBookRecord *b) : wxHtmlTagHandler() {m_Book = b; m_Items = NULL; m_ItemsCnt = 0; m_Name = m_Page = wxEmptyString; m_Level = 0; m_ID = -1; }
         wxString GetSupportedTags() { return wxT("UL,OBJECT,PARAM"); }
         bool HandleTag(const wxHtmlTag& tag);
         void WriteOut(wxHtmlContentsItem*& array, int& size);