- config = new wxConfig("wxHTMLhelp");
- #if wxUSE_LIBPNG
- wxImage::AddHandler(new wxPNGHandler);
- #endif
- #if wxUSE_LIBJPEG
- wxImage::AddHandler(new wxJPEGHandler);
- #endif
-
- help.UseConfig(config);
- help.SetTempDir("tmp");
- help.AddBook("helpfiles/testing.hhp");
- help.Display("Main page");
- return TRUE;
+ wxInitAllImageHandlers();
+#if wxUSE_STREAMS && wxUSE_ZIPSTREAM && wxUSE_ZLIB
+ wxFileSystem::AddHandler(new wxZipFSHandler);
+#endif
+ SetVendorName(wxT("wxWidgets"));
+ SetAppName(wxT("wxHTMLHelp"));
+
+ // Create the main application window
+ MyFrame *frame = new MyFrame(_("HTML Help Sample"),
+ wxDefaultPosition, wxDefaultSize);
+
+ // Show it and tell the application that it's our main window
+ // @@@ what does it do exactly, in fact? is it necessary here?
+ frame->Show(true);
+ SetTopWindow(frame);
+
+
+ // success: wxApp::OnRun() will be called which will enter the main message
+ // loop and the application will run. If we returned false here, the
+ // application would exit immediately.
+ return true;
+ }
+
+// ----------------------------------------------------------------------------
+// main frame
+// ----------------------------------------------------------------------------
+
+
+// frame constructor
+ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
+ : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size),
+ help(wxHF_DEFAULT_STYLE | wxHF_OPEN_FILES)
+ {
+ // create a menu bar
+ wxMenu *menuFile = new wxMenu;
+
+ menuFile->Append(Minimal_Help, _("&Help"));
+ menuFile->Append(Minimal_Quit, _("E&xit"));
+
+ // now append the freshly created menu to the menu bar...
+ wxMenuBar *menuBar = new wxMenuBar;
+ menuBar->Append(menuFile, _("&File"));
+
+ // ... and attach this menu bar to the frame
+ SetMenuBar(menuBar);
+
+ help.UseConfig(wxConfig::Get());
+ bool ret;
+ help.SetTempDir(wxT("."));
+ ret = help.AddBook(wxFileName(wxT("helpfiles/testing.hhp"), wxPATH_UNIX));
+ if (! ret)
+ wxMessageBox(wxT("Failed adding book helpfiles/testing.hhp"));
+ ret = help.AddBook(wxFileName(wxT("helpfiles/another.hhp"), wxPATH_UNIX));
+ if (! ret)
+ wxMessageBox(_("Failed adding book helpfiles/another.hhp"));