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
This commit is contained in:
Václav Slavík 2000-01-19 01:01:08 +00:00
parent 6ee654e6bb
commit b854b7b82e
6 changed files with 112 additions and 46 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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;

View File

@ -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.)

View File

@ -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)

View File

@ -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(_("<bookmarks>"));
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(_("<bookmarks>"));
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))