1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtmlHelpFrame
4 // Notes: Based on htmlhelp.cpp, implementing a monolithic
5 // HTML Help controller class, by Vaclav Slavik
6 // Author: Harm van der Heijden and Vaclav Slavik
8 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_HELPFRM_H_
13 #define _WX_HELPFRM_H_
24 #include "wx/window.h"
26 #include "wx/config.h"
27 #include "wx/splitter.h"
28 #include "wx/notebook.h"
29 #include "wx/listbox.h"
30 #include "wx/choice.h"
31 #include "wx/html/htmlwin.h"
33 // style flags for the Help Frame
34 const int wxHF_TOOLBAR
= 1;
35 const int wxHF_CONTENTS
= 2;
36 const int wxHF_INDEX
= 4;
37 const int wxHF_SEARCH
= 8;
38 const int wxHF_DEFAULTSTYLE
= -1;
42 wxID_HTML_PANEL
= wxID_HIGHEST
+ 1,
52 wxID_HTML_SEARCHBUTTON
,
53 wxID_HTML_SEARCHCHOICE
,
54 wxID_HTML_HELPFRAME
// the id of wxHtmlHelpController's helpframe
57 class WXDLLEXPORT wxHtmlHelpFrameCfg
60 wxHtmlHelpFrameCfg() {};
64 int style
; // flags given to wxHtmlHelpFrame ctor
68 class WXDLLEXPORT wxHtmlHelpFrame
: public wxFrame
70 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame
)
73 wxHtmlHelpFrame(wxHtmlHelpData
* data
= NULL
) { Init(data
); }
74 wxHtmlHelpFrame(wxWindow
* parent
, int wxWindowID
,
75 const wxString
& title
= wxEmptyString
,
76 int style
= wxHF_DEFAULTSTYLE
, wxHtmlHelpData
* data
= NULL
);
77 bool Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
= wxEmptyString
,
78 int style
= wxHF_DEFAULTSTYLE
);
81 wxHtmlHelpData
* GetData() { return m_Data
; }
83 void SetTitleFormat(const wxString
& format
) {
85 m_HtmlWin
->SetRelatedFrame(this, format
);
86 m_TitleFormat
= format
;
88 // Sets format of title of the frame. Must contain exactly one "%s"
89 // (for title of displayed HTML page)
91 bool Display(const wxString
& x
);
92 // Displays page x. If not found it will offect the user a choice of
94 // Looking for the page runs in these steps:
95 // 1. try to locate file named x (if x is for example "doc/howto.htm")
96 // 2. try to open starting page of book x
97 // 3. try to find x in contents (if x is for example "How To ...")
98 // 4. try to find x in index (if x is for example "How To ...")
99 bool Display(const int id
);
100 // Alternative version that works with numeric ID.
101 // (uses extension to MS format, <param name="ID" value=id>, see docs)
103 bool DisplayContents();
104 // Displays help window and focuses contents.
107 // Displays help window and focuses index.
109 bool KeywordSearch(const wxString
& keyword
);
110 // Searches for keyword. Returns TRUE and display page if found, return
112 // Syntax of keyword is Altavista-like:
113 // * words are separated by spaces
114 // (but "\"hello world\"" is only one world "hello world")
115 // * word may be pretended by + or -
116 // (+ : page must contain the word ; - : page can't contain the word)
117 // * if there is no + or - before the word, + is default
118 void RefreshLists(bool show_progress
= FALSE
);
119 // Refreshes Contents and Index tabs
120 void CreateContents(bool show_progress
= FALSE
);
121 // Adds items to m_Contents tree control
122 void CreateIndex(bool show_progress
= FALSE
);
123 // Adds items to m_IndexList
125 // Add books to search choice panel
126 void UseConfig(wxConfigBase
*config
, const wxString
& rootpath
= wxEmptyString
) {
127 m_Config
= config
; m_ConfigRoot
= rootpath
;
128 ReadCustomization(config
, rootpath
);
130 void ReadCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
131 // saves custom settings into cfg config. it will use the path 'path'
132 // if given, otherwise it will save info into currently selected path.
133 // saved values : things set by SetFonts, SetBorders.
134 void WriteCustomization(wxConfigBase
*cfg
, const wxString
& path
= wxEmptyString
);
136 void OnToolbar(wxCommandEvent
& event
);
137 void OnContentsSel(wxTreeEvent
& event
);
138 void OnIndexSel(wxCommandEvent
& event
);
139 void OnSearchSel(wxCommandEvent
& event
);
140 void OnSearch(wxCommandEvent
& event
);
141 void OnCloseWindow(wxCloseEvent
& event
);
151 wxHtmlHelpData
* m_Data
;
152 bool m_DataCreated
; // m_Data created by frame, or supplied?
153 wxString m_TitleFormat
; // title of the help frame
154 // below are various pointers to GUI components
155 wxHtmlWindow
*m_HtmlWin
;
156 wxSplitterWindow
*m_Splitter
;
157 wxNotebook
*m_NavigPan
;
158 wxTreeCtrl
*m_ContentsBox
;
159 wxImageList
*m_ContentsImageList
;
160 wxListBox
*m_IndexBox
;
161 wxTextCtrl
*m_SearchText
;
162 wxButton
*m_SearchButton
;
163 wxListBox
*m_SearchList
;
164 wxChoice
*m_SearchChoice
;
166 wxHtmlHelpFrameCfg m_Cfg
;
167 wxConfigBase
*m_Config
;
168 wxString m_ConfigRoot
;
170 // pagenumbers of controls in notebook (usually 0,1,2)
176 void Init(wxHtmlHelpData
* data
= NULL
);
178 DECLARE_EVENT_TABLE()