]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/helpfrm.cpp
compilation fix for wxUSE_RESOURCE_LOADING_IN_MSW == 0
[wxWidgets.git] / src / html / helpfrm.cpp
index 40ce5865f37eb317254654c1debe05380e3869fe..d01ec35ffb694a6f3f7ff00da4f05820303701ba 100644 (file)
     #include "wx/radiobox.h"
 #endif // WXPRECOMP
 
+#ifdef __WXMAC__
+    #include "wx/menu.h"
+    #include "wx/msgdlg.h"
+#endif
+
 #include "wx/html/helpfrm.h"
 #include "wx/html/helpctrl.h"
 #include "wx/textctrl.h"
@@ -113,6 +118,8 @@ class wxHtmlHelpHtmlWindow : public wxHtmlWindow
 
     private:
         wxHtmlHelpFrame *m_Frame;
+
+    DECLARE_NO_COPY_CLASS(wxHtmlHelpHtmlWindow)
 };
 
 
@@ -250,6 +257,25 @@ bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id,
 
     SetIcon(wxArtProvider::GetIcon(wxART_HELP, wxART_HELP_BROWSER));
 
+    // On the Mac, each modeless frame must have a menubar.
+    // TODO: add more menu items, and perhaps add a style to show
+    // the menubar: compulsory on the Mac, optional elsewhere.
+#ifdef __WXMAC__
+    wxMenuBar* menuBar = new wxMenuBar;
+
+    wxMenu* fileMenu = new wxMenu;
+    fileMenu->Append(wxID_HTML_OPENFILE, _("&Open..."));
+    fileMenu->AppendSeparator();
+    fileMenu->Append(wxID_CLOSE, _("&Close"));
+
+    wxMenu* helpMenu = new wxMenu;
+    helpMenu->Append(wxID_ABOUT, _("&About..."));
+
+    menuBar->Append(fileMenu,_("File"));
+    menuBar->Append(helpMenu,_("Help"));
+    SetMenuBar(menuBar);
+#endif
+
     int notebook_page = 0;
 
     CreateStatusBar();
@@ -878,10 +904,15 @@ void wxHtmlHelpFrame::WriteCustomization(wxConfigBase *cfg, const wxString& path
 
     cfg->Write(wxT("hcNavigPanel"), m_Cfg.navig_on);
     cfg->Write(wxT("hcSashPos"), (long)m_Cfg.sashpos);
-    cfg->Write(wxT("hcX"), (long)m_Cfg.x);
-    cfg->Write(wxT("hcY"), (long)m_Cfg.y);
-    cfg->Write(wxT("hcW"), (long)m_Cfg.w);
-    cfg->Write(wxT("hcH"), (long)m_Cfg.h);
+    if ( !IsIconized() )
+    {
+        //  Don't write if iconized as this would make the window
+        //  disappear next time it is shown!
+        cfg->Write(wxT("hcX"), (long)m_Cfg.x);
+        cfg->Write(wxT("hcY"), (long)m_Cfg.y);
+        cfg->Write(wxT("hcW"), (long)m_Cfg.w);
+        cfg->Write(wxT("hcH"), (long)m_Cfg.h);
+    }
     cfg->Write(wxT("hcFixedFace"), m_FixedFace);
     cfg->Write(wxT("hcNormalFace"), m_NormalFace);
     cfg->Write(wxT("hcBaseFontSize"), (long)m_FontSize);
@@ -1015,13 +1046,18 @@ Normal face<br>(and <u>underlined</u>. <i>Italic face.</i> \
     {
         UpdateTestWin();
     }
+    void OnUpdateSpin(wxSpinEvent& WXUNUSED(event))
+    {
+        UpdateTestWin();
+    }
 
     DECLARE_EVENT_TABLE()
+    DECLARE_NO_COPY_CLASS(wxHtmlHelpFrameOptionsDialog)
 };
 
 BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog, wxDialog)
     EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate)
-    EVT_SPINCTRL(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate)
+    EVT_SPINCTRL(-1, wxHtmlHelpFrameOptionsDialog::OnUpdateSpin)
 END_EVENT_TABLE()
 
 
@@ -1120,8 +1156,14 @@ void wxHtmlHelpFrame::OnActivate(wxActivateEvent& event)
 {
     // This saves one mouse click when using the
     // wxHTML for context sensitive help systems
+#ifndef __WXGTK__
+    // NB: wxActivateEvent is a bit broken in wxGTK
+    //     and is sometimes sent when it should not be
     if (event.GetActive() && m_HtmlWin)
         m_HtmlWin->SetFocus();
+#endif
+
+    event.Skip();
 }
 
 void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event)
@@ -1479,6 +1521,19 @@ void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent& evt)
     evt.Skip();
 }
 
+#ifdef __WXMAC__
+void wxHtmlHelpFrame::OnClose(wxCommandEvent& event)
+{
+    Close(TRUE);
+}
+
+void wxHtmlHelpFrame::OnAbout(wxCommandEvent& event)
+{
+    wxMessageBox(wxT("wxWindows HTML Help Viewer (c) 1998-2003, Vaclav Slavik et al"), wxT("HelpView"),
+        wxICON_INFORMATION|wxOK, this);
+}
+#endif
+
 BEGIN_EVENT_TABLE(wxHtmlHelpFrame, wxFrame)
     EVT_ACTIVATE(wxHtmlHelpFrame::OnActivate)
     EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_OPTIONS, wxHtmlHelpFrame::OnToolbar)
@@ -1494,6 +1549,11 @@ BEGIN_EVENT_TABLE(wxHtmlHelpFrame, wxFrame)
     EVT_BUTTON(wxID_HTML_INDEXBUTTONALL, wxHtmlHelpFrame::OnIndexAll)
     EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST, wxHtmlHelpFrame::OnBookmarksSel)
     EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow)
+#ifdef __WXMAC__
+    EVT_MENU(wxID_CLOSE, wxHtmlHelpFrame::OnClose)
+    EVT_MENU(wxID_ABOUT, wxHtmlHelpFrame::OnAbout)
+#endif
+
 END_EVENT_TABLE()
 
 #endif // wxUSE_WXHTML_HELP