+ return false;
+ }
+ }
+ }
+ return AddBook(wxFileName(actualFilename));
+}
+
+bool wxHtmlHelpController::LoadFile(const wxString& WXUNUSED(file))
+{
+ // Don't reload the file or we'll have it appear again, presumably.
+ return true;
+}
+
+bool wxHtmlHelpController::DisplaySection(int sectionNo)
+{
+ return Display(sectionNo);
+}
+
+bool wxHtmlHelpController::DisplayTextPopup(const wxString& text, const wxPoint& WXUNUSED(pos))
+{
+#if wxUSE_TIPWINDOW
+ static wxTipWindow* s_tipWindow = NULL;
+
+ if (s_tipWindow)
+ {
+ // Prevent s_tipWindow being nulled in OnIdle,
+ // thereby removing the chance for the window to be closed by ShowHelp
+ s_tipWindow->SetTipWindowPtr(NULL);
+ s_tipWindow->Close();
+ }
+ s_tipWindow = NULL;
+
+ if ( !text.empty() )
+ {
+ s_tipWindow = new wxTipWindow(wxTheApp->GetTopWindow(), text, 100, & s_tipWindow);
+
+ return true;
+ }
+#else
+ wxUnusedVar(text);
+#endif // wxUSE_TIPWINDOW
+
+ return false;
+}
+
+void wxHtmlHelpController::SetHelpWindow(wxHtmlHelpWindow* helpWindow)
+{
+ m_helpWindow = helpWindow;
+ if (helpWindow)
+ helpWindow->SetController(this);
+}
+
+void wxHtmlHelpController::SetFrameParameters(const wxString& titleFormat,
+ const wxSize& size,
+ const wxPoint& pos,
+ bool WXUNUSED(newFrameEachTime))
+{
+ SetTitleFormat(titleFormat);
+ wxHtmlHelpFrame* frame = wxDynamicCast(FindTopLevelWindow(), wxHtmlHelpFrame);
+ wxHtmlHelpDialog* dialog = wxDynamicCast(FindTopLevelWindow(), wxHtmlHelpDialog);
+ if (frame)
+ frame->SetSize(pos.x, pos.y, size.x, size.y);
+ else if (dialog)
+ dialog->SetSize(pos.x, pos.y, size.x, size.y);
+}
+
+wxFrame* wxHtmlHelpController::GetFrameParameters(wxSize *size,
+ wxPoint *pos,
+ bool *newFrameEachTime)
+{
+ if (newFrameEachTime)
+ (* newFrameEachTime) = false;
+
+ wxHtmlHelpFrame* frame = wxDynamicCast(FindTopLevelWindow(), wxHtmlHelpFrame);
+ wxHtmlHelpDialog* dialog = wxDynamicCast(FindTopLevelWindow(), wxHtmlHelpDialog);
+ if (frame)
+ {
+ if (size)
+ (* size) = frame->GetSize();
+ if (pos)
+ (* pos) = frame->GetPosition();
+ return frame;
+ }
+ else if (dialog)
+ {
+ if (size)
+ (* size) = dialog->GetSize();
+ if (pos)
+ (* pos) = dialog->GetPosition();
+ return NULL;
+ }
+ return NULL;
+}
+
+bool wxHtmlHelpController::Quit()
+{
+ DestroyHelpWindow();
+ return true;
+}
+
+// Make the help controller's frame 'modal' if
+// needed
+void wxHtmlHelpController::MakeModalIfNeeded()
+{
+ if ((m_FrameStyle & wxHF_EMBEDDED) == 0)
+ {
+ wxHtmlHelpFrame* frame = wxDynamicCast(FindTopLevelWindow(), wxHtmlHelpFrame);
+ wxHtmlHelpDialog* dialog = wxDynamicCast(FindTopLevelWindow(), wxHtmlHelpDialog);
+ if (frame)
+ frame->AddGrabIfNeeded();
+ else if (dialog && (m_FrameStyle & wxHF_MODAL))
+ {
+ dialog->ShowModal();
+ }
+ }
+}
+
+bool wxHtmlHelpController::Display(const wxString& x)
+{
+ CreateHelpWindow();
+ bool success = m_helpWindow->Display(x);
+ MakeModalIfNeeded();
+ return success;
+}
+
+bool wxHtmlHelpController::Display(int id)
+{
+ CreateHelpWindow();
+ bool success = m_helpWindow->Display(id);
+ MakeModalIfNeeded();
+ return success;
+}
+
+bool wxHtmlHelpController::DisplayContents()
+{
+ CreateHelpWindow();
+ bool success = m_helpWindow->DisplayContents();
+ MakeModalIfNeeded();
+ return success;
+}
+
+bool wxHtmlHelpController::DisplayIndex()
+{
+ CreateHelpWindow();
+ bool success = m_helpWindow->DisplayIndex();
+ MakeModalIfNeeded();
+ return success;
+}
+
+bool wxHtmlHelpController::KeywordSearch(const wxString& keyword,
+ wxHelpSearchMode mode)
+{
+ CreateHelpWindow();
+ bool success = m_helpWindow->KeywordSearch(keyword, mode);
+ MakeModalIfNeeded();
+ return success;
+}
+
+/*
+ * wxHtmlModalHelp
+ * A convenience class, to use like this:
+ *
+ * wxHtmlModalHelp help(parent, helpFile, topic);
+ */
+
+wxHtmlModalHelp::wxHtmlModalHelp(wxWindow* parent, const wxString& helpFile, const wxString& topic, int style)
+{
+ // Force some mandatory styles
+ style |= wxHF_DIALOG | wxHF_MODAL;
+
+ wxHtmlHelpController controller(style, parent);
+ controller.Initialize(helpFile);
+
+ if (topic.IsEmpty())
+ controller.DisplayContents();
+ else
+ controller.DisplaySection(topic);
+}
+
+#endif // wxUSE_WXHTML_HELP
+