]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/help/demo.cpp
more type-safety
[wxWidgets.git] / samples / help / demo.cpp
index 1980c9f2652ce2d03d342959bbc348d8809be24b..df29ed2e264fcd8db0c4b86062ce3f2209e55d53 100644 (file)
 // ----------------------------------------------------------------------------
 // headers
 // ----------------------------------------------------------------------------
-#ifdef __GNUG__
-    #pragma implementation "demo.cpp"
-    #pragma interface "demo.cpp"
-#endif
 
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-    #pragma hdrstop
+#   pragma hdrstop
 #endif
 
 // for all others, include the necessary headers (this file is usually all you
 // need because it includes almost all "standard" wxWindows headers
 #ifndef WX_PRECOMP
-    #include "wx/wx.h"
+#   include "wx/wx.h"
 #endif
 
-#include   "wx/helpbase.h"
-#include   "wx/help.h"
+// define this to 1 to use HTML help even under Windows (by default, Windows
+// version will HLP-based help)
+//#define USE_HTML_HELP 1
+#if USE_HTML_HELP
+#   include "wx/helpbase.h"
+#else
+#   include "wx/help.h"
+#endif
 
 // ----------------------------------------------------------------------------
 // ressources
@@ -74,7 +76,8 @@ public:
     void OnHelp(wxCommandEvent& event);
 
 private:
-   wxHelpController  help;
+   wxHelpController m_help;
+
     // any class wishing to process wxWindows events must use this macro
    DECLARE_EVENT_TABLE()
 };
@@ -170,11 +173,13 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
     menuFile->Append(HelpDemo_Help_Help, "&About Help Demo...");
     menuFile->AppendSeparator();
     menuFile->Append(HelpDemo_Help_Search, "&Search help...");
-#ifdef __WXGTK__
+#ifndef __WXMSW__
+#ifndef wxUSE_HTML
     menuFile->AppendSeparator();
     menuFile->Append(HelpDemo_Help_KDE, "Use &KDE");
     menuFile->Append(HelpDemo_Help_GNOME, "Use &GNOME");
     menuFile->Append(HelpDemo_Help_Netscape, "Use &Netscape");
+#endif
 #endif
     menuFile->AppendSeparator();
     menuFile->Append(HelpDemo_Quit, "E&xit");
@@ -199,9 +204,10 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
     // and a static control whose parent is the panel
     (void)new wxStaticText(panel, -1, "Hello, world!", wxPoint(10, 10));
 
-    // initialise the help system
-    help.Initialize("doc");
-   
+    // initialise the help system: this means that we'll use doc.hlp file under
+    // Windows and that the HTML docs are in the subdirectory doc for platforms
+    // using HTML help
+    m_help.Initialize("doc");
 }
 
 
@@ -222,25 +228,25 @@ void MyFrame::OnHelp(wxCommandEvent& event)
    // (on Unix). For WinHelp, we'd need to use different context ids.
 
    case HelpDemo_Help_Classes:
-      help.DisplaySection(1);
+      m_help.DisplaySection(1);
       break;
    case HelpDemo_Help_Functions:
-      help.DisplaySection(2);
+      m_help.DisplaySection(4);
       break;
    case HelpDemo_Help_Help:
-      help.DisplaySection(5);
+      m_help.DisplaySection(5);
       break;
 
    // These three calls are only used by wxExtHelpController
 
    case HelpDemo_Help_KDE:
-      help.SetViewer("kdehelp");
+      m_help.SetViewer("kdehelp");
       break;
    case HelpDemo_Help_GNOME:
-      help.SetViewer("gnome-help-browser");
+      m_help.SetViewer("gnome-help-browser");
       break;
    case HelpDemo_Help_Netscape:
-      help.SetViewer("netscape", wxHELP_NETSCAPE);
+      m_help.SetViewer("netscape", wxHELP_NETSCAPE);
       break;
 
    case HelpDemo_Help_Search:
@@ -250,12 +256,12 @@ void MyFrame::OnHelp(wxCommandEvent& event)
                                        "",
                                        this);
       if(! key.IsEmpty())
-         help.KeywordSearch(key);
+         m_help.KeywordSearch(key);
    }
    break;
    case HelpDemo_Help_Index:
    default:
-      help.DisplayContents();
+      m_help.DisplayContents();
       break;
    }
 }