From b854b7b82e033d1dbd9d300402df50ec5e1e8b74 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 19 Jan 2000 01:01:08 +0000 Subject: [PATCH] it is now possible to add custom buttons into wxHtmlHelpFrame's toolbar git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5519 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/hthelpct.tex | 24 ++++++++++- docs/latex/wx/hthlpfrm.tex | 11 +++++ include/wx/html/helpctrl.h | 10 ++--- include/wx/html/helpfrm.h | 2 + src/html/helpctrl.cpp | 28 ++++++++++++- src/html/helpfrm.cpp | 83 +++++++++++++++++++++----------------- 6 files changed, 112 insertions(+), 46 deletions(-) diff --git a/docs/latex/wx/hthelpct.tex b/docs/latex/wx/hthelpct.tex index ca3d7a8a21..b7f69b237a 100644 --- a/docs/latex/wx/hthelpct.tex +++ b/docs/latex/wx/hthelpct.tex @@ -29,9 +29,18 @@ have the following line in your .rc file: #include "wx/html/msw/wxhtml.rc" \end{verbatim} +\wxheading{Note} + +It is strongly recommended to use preprocessed {\bf .hhp.cached} version of +projects. It can be either created on-the-fly (see +\helpref{SetTempDir}{wxhtmlhelpcontrollersettempdir}) or you can use +{\bf hhp2cached} utility from {\it utils/hhp2cached} to create it and +distribute the cached version together with helpfiles. See {\it samples/html/help} +sample for demonstration of its use. + \wxheading{Derived from} -wxEvtHandler +\helpref{wxEvtHandler}{wxevthandler} \latexignore{\rtfignore{\wxheading{Members}}} @@ -139,6 +148,10 @@ forms are much faster to read. Default value is empty string (empty string means that no cached data are stored). Note that these files are {\it not} deleted when program exits. +Once created these cached files will be used in all subsequent executions +of your application. If cached files become older than corresponding .hhp +file (e.g. if you regenerate documentation) it will be refreshed. + \membersection{wxHtmlHelpController::SetTitleFormat}\label{wxhtmlhelpcontrollersettitleformat} \func{void}{SetTitleFormat}{\param{const wxString\& }{format}} @@ -168,3 +181,12 @@ default wxConfig object if available (for details see Stores controllers setting (position of window etc.) +\membersection{wxHtmlHelpController::CreateHelpFrame}\label{wxhtmlhelpcontrollercreatehelpframe} + +\func{virtual wxHtmlHelpFrame*}{CreateHelpFrame}{\param{wxHtmlHelpData * }{data}} + +This protected virtual method may be overriden so that the controller +uses slightly different frame. See {\it samples/html/helpview} sample for +an example. + + diff --git a/docs/latex/wx/hthlpfrm.tex b/docs/latex/wx/hthlpfrm.tex index db2596e1a6..216d281125 100644 --- a/docs/latex/wx/hthlpfrm.tex +++ b/docs/latex/wx/hthlpfrm.tex @@ -156,3 +156,14 @@ Add books to search choice panel Saves user's settings for this frame (see \helpref{wxHtmlHelpController::WriteCustomization}{wxhtmlhelpcontrollerwritecustomization}) +\membersection{wxHtmlHelpFrame::AddToolbarButtons}\label{wxhtmlhelpframeaddtoolbarbuttons} + +\func{virtual void}{AddToolbarButtons}{\param{wxToolBar *}{toolBar}, \param{int }{style}} + +You may override this virtual method to add more buttons into help frame's +toolbar. {\it toolBar} is pointer to the toolbar and {\it style} is style +flag as passed to Create method. + +wxToolBar::Realize is called immediately after returning from this function. + +See {\it samples/html/helpview} for an example. diff --git a/include/wx/html/helpctrl.h b/include/wx/html/helpctrl.h index 85511c8725..8ea6bf5ad2 100644 --- a/include/wx/html/helpctrl.h +++ b/include/wx/html/helpctrl.h @@ -68,14 +68,12 @@ class WXDLLEXPORT wxHtmlHelpController : public wxEvtHandler virtual void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString); protected: + virtual wxHtmlHelpFrame* CreateHelpFrame(wxHtmlHelpData *data); + virtual void CreateHelpWindow(); - virtual void DestroyHelpWindow() - { - //if (m_Config) WriteCustomization(m_Config, m_ConfigRoot); - if (m_helpFrame) m_helpFrame->Destroy(); - } + virtual void DestroyHelpWindow(); - void OnCloseFrame(wxCloseEvent& evt) { m_helpFrame = NULL; evt.Skip(); } + void OnCloseFrame(wxCloseEvent& evt); wxHtmlHelpData m_helpData; wxHtmlHelpFrame* m_helpFrame; wxConfigBase *m_Config; diff --git a/include/wx/html/helpfrm.h b/include/wx/html/helpfrm.h index 80256d84af..35c9736382 100644 --- a/include/wx/html/helpfrm.h +++ b/include/wx/html/helpfrm.h @@ -162,6 +162,8 @@ class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame void CreateSearch(); // Add books to search choice panel + virtual void AddToolbarButtons(wxToolBar *toolBar, int style); + // Add custom buttons to toolbar virtual void OptionsDialog(); // Displays options dialog (fonts etc.) diff --git a/src/html/helpctrl.cpp b/src/html/helpctrl.cpp index 2137023534..5e68f95352 100644 --- a/src/html/helpctrl.cpp +++ b/src/html/helpctrl.cpp @@ -47,9 +47,25 @@ wxHtmlHelpController::~wxHtmlHelpController() { WriteCustomization(m_Config, m_ConfigRoot); if (m_helpFrame) - m_helpFrame->Close(); + DestroyHelpWindow(); } + +void wxHtmlHelpController::DestroyHelpWindow() +{ + //if (m_Config) WriteCustomization(m_Config, m_ConfigRoot); + if (m_helpFrame) + m_helpFrame->Destroy(); +} + +void wxHtmlHelpController::OnCloseFrame(wxCloseEvent& evt) +{ + evt.Skip(); + + m_helpFrame = NULL; +} + + void wxHtmlHelpController::SetTitleFormat(const wxString& title) { m_titleFormat = title; @@ -77,6 +93,14 @@ bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg) return retval; } + + +wxHtmlHelpFrame *wxHtmlHelpController::CreateHelpFrame(wxHtmlHelpData *data) +{ + return new wxHtmlHelpFrame(data); +} + + void wxHtmlHelpController::CreateHelpWindow() { if (m_helpFrame) { @@ -91,7 +115,7 @@ void wxHtmlHelpController::CreateHelpWindow() m_ConfigRoot = _T("wxWindows/wxHtmlHelpController"); } - m_helpFrame = new wxHtmlHelpFrame(&m_helpData); + m_helpFrame = CreateHelpFrame(&m_helpData); m_helpFrame->PushEventHandler(this); if (m_Config) diff --git a/src/html/helpfrm.cpp b/src/html/helpfrm.cpp index 0291ec72a8..b4cccd4092 100644 --- a/src/html/helpfrm.cpp +++ b/src/html/helpfrm.cpp @@ -177,43 +177,7 @@ bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id, const wxString& ti if (style & wxHF_TOOLBAR) { wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_DOCKABLE); toolBar->SetMargins( 2, 2 ); - - toolBar -> AddTool(wxID_HTML_PANEL, wxBITMAP(wpanel), wxNullBitmap, - FALSE, -1, -1, (wxObject *) NULL, - _("Show/hide navigation panel")); - toolBar -> AddSeparator(); - toolBar -> AddTool(wxID_HTML_BACK, wxBITMAP(wback), wxNullBitmap, - FALSE, -1, -1, (wxObject *) NULL, - _("Go back to the previous HTML page")); - toolBar -> AddTool(wxID_HTML_FORWARD, wxBITMAP(wforward), wxNullBitmap, - FALSE, -1, -1, (wxObject *) NULL, - _("Go forward to the next HTML page")); - toolBar -> AddSeparator(); - - if (style & wxHF_BOOKMARKS) { - m_Bookmarks = new wxComboBox(toolBar, wxID_HTML_BOOKMARKSLIST, wxEmptyString, - wxDefaultPosition, wxSize(300,-1), 0, NULL, wxCB_READONLY | wxCB_SORT); - m_Bookmarks -> Append(_("")); - for (unsigned i = 0; i < m_BookmarksNames.GetCount(); i++) - m_Bookmarks -> Append(m_BookmarksNames[i]); - m_Bookmarks -> SetSelection(0); - toolBar -> AddControl(m_Bookmarks); -#ifdef __WXGTK__ - toolBar -> AddSeparator(); -#endif - toolBar -> AddTool(wxID_HTML_BOOKMARKSADD, wxBITMAP(wbkadd), wxNullBitmap, - FALSE, -1, -1, (wxObject *) NULL, - _("Add current page to bookmarks")); - toolBar -> AddTool(wxID_HTML_BOOKMARKSREMOVE, wxBITMAP(wbkdel), wxNullBitmap, - FALSE, -1, -1, (wxObject *) NULL, - _("Remove current page from bookmarks")); - } - - toolBar -> AddSeparator(); - toolBar -> AddTool(wxID_HTML_OPTIONS, wxBITMAP(woptions), wxNullBitmap, - FALSE, -1, -1, (wxObject *) NULL, - _("Display options dialog")); - + AddToolbarButtons(toolBar, style); toolBar -> Realize(); } @@ -390,6 +354,7 @@ bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id, const wxString& ti wxHtmlHelpFrame::~wxHtmlHelpFrame() { + PopEventHandler(); // wxhtmlhelpcontroller delete m_ContentsImageList; if (m_DataCreated) delete m_Data; @@ -397,6 +362,48 @@ wxHtmlHelpFrame::~wxHtmlHelpFrame() if (m_FixedFonts) delete m_FixedFonts; } + +void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar *toolBar, int style) +{ + toolBar -> AddTool(wxID_HTML_PANEL, wxBITMAP(wpanel), wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Show/hide navigation panel")); + toolBar -> AddSeparator(); + toolBar -> AddTool(wxID_HTML_BACK, wxBITMAP(wback), wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Go back to the previous HTML page")); + toolBar -> AddTool(wxID_HTML_FORWARD, wxBITMAP(wforward), wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Go forward to the next HTML page")); + toolBar -> AddSeparator(); + + if (style & wxHF_BOOKMARKS) { + m_Bookmarks = new wxComboBox(toolBar, wxID_HTML_BOOKMARKSLIST, wxEmptyString, + wxDefaultPosition, wxSize(300,-1), 0, NULL, wxCB_READONLY | wxCB_SORT); + m_Bookmarks -> Append(_("")); + for (unsigned i = 0; i < m_BookmarksNames.GetCount(); i++) + m_Bookmarks -> Append(m_BookmarksNames[i]); + m_Bookmarks -> SetSelection(0); + toolBar -> AddControl(m_Bookmarks); +#ifdef __WXGTK__ + toolBar -> AddSeparator(); +#endif + toolBar -> AddTool(wxID_HTML_BOOKMARKSADD, wxBITMAP(wbkadd), wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Add current page to bookmarks")); + toolBar -> AddTool(wxID_HTML_BOOKMARKSREMOVE, wxBITMAP(wbkdel), wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Remove current page from bookmarks")); + } + + toolBar -> AddSeparator(); + toolBar -> AddTool(wxID_HTML_OPTIONS, wxBITMAP(woptions), wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Display options dialog")); +} + + + bool wxHtmlHelpFrame::Display(const wxString& x) { wxString url = m_Data->FindPageByName(x); @@ -448,6 +455,8 @@ bool wxHtmlHelpFrame::DisplayIndex() return TRUE; } + + bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword) { if (! (m_SearchList && m_SearchButton && m_SearchText && m_SearchChoice)) -- 2.45.2