+// 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