]> git.saurik.com Git - wxWidgets.git/blob - include/wx/html/helpfrm.h
Respect wxListItem::m_mask in general list control Set/GetItem() and allow
[wxWidgets.git] / include / wx / html / helpfrm.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: helpfrm.h
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
7 // RCS-ID: $Id$
8 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_HELPFRM_H_
13 #define _WX_HELPFRM_H_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "helpfrm.h"
17 #endif
18
19 #include "wx/defs.h"
20
21 #if wxUSE_WXHTML_HELP
22
23 #include "wx/helpbase.h"
24 #include "wx/html/helpdata.h"
25 #include "wx/window.h"
26 #include "wx/frame.h"
27 #include "wx/config.h"
28 #include "wx/splitter.h"
29 #include "wx/notebook.h"
30 #include "wx/listbox.h"
31 #include "wx/choice.h"
32 #include "wx/combobox.h"
33 #include "wx/checkbox.h"
34 #include "wx/stattext.h"
35 #include "wx/html/htmlwin.h"
36 #include "wx/html/htmprint.h"
37
38 class WXDLLIMPEXP_CORE wxButton;
39 class WXDLLIMPEXP_CORE wxTextCtrl;
40 class WXDLLIMPEXP_CORE wxTreeEvent;
41 class WXDLLIMPEXP_CORE wxTreeCtrl;
42
43
44 // style flags for the Help Frame
45 #define wxHF_TOOLBAR 0x0001
46 #define wxHF_CONTENTS 0x0002
47 #define wxHF_INDEX 0x0004
48 #define wxHF_SEARCH 0x0008
49 #define wxHF_BOOKMARKS 0x0010
50 #define wxHF_OPEN_FILES 0x0020
51 #define wxHF_PRINT 0x0040
52 #define wxHF_FLAT_TOOLBAR 0x0080
53 #define wxHF_MERGE_BOOKS 0x0100
54 #define wxHF_ICONS_BOOK 0x0200
55 #define wxHF_ICONS_BOOK_CHAPTER 0x0400
56 #define wxHF_ICONS_FOLDER 0x0000 // this is 0 since it is default
57 #define wxHF_DEFAULT_STYLE (wxHF_TOOLBAR | wxHF_CONTENTS | \
58 wxHF_INDEX | wxHF_SEARCH | \
59 wxHF_BOOKMARKS | wxHF_PRINT)
60 //compatibility:
61 #define wxHF_OPENFILES wxHF_OPEN_FILES
62 #define wxHF_FLATTOOLBAR wxHF_FLAT_TOOLBAR
63 #define wxHF_DEFAULTSTYLE wxHF_DEFAULT_STYLE
64
65
66 struct wxHtmlHelpFrameCfg
67 {
68 int x, y, w, h;
69 long sashpos;
70 bool navig_on;
71 };
72
73 struct wxHtmlHelpMergedIndexItem;
74 class wxHtmlHelpMergedIndex;
75
76 class WXDLLIMPEXP_CORE wxHelpControllerBase;
77
78 class WXDLLIMPEXP_HTML wxHtmlHelpFrame : public wxFrame
79 {
80 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame)
81
82 public:
83 wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); }
84 wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID,
85 const wxString& title = wxEmptyString,
86 int style = wxHF_DEFAULT_STYLE, wxHtmlHelpData* data = NULL);
87 bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString,
88 int style = wxHF_DEFAULT_STYLE);
89 ~wxHtmlHelpFrame();
90
91 wxHtmlHelpData* GetData() { return m_Data; }
92 wxHelpControllerBase* GetController() const { return m_helpController; }
93 void SetController(wxHelpControllerBase* controller) { m_helpController = controller; }
94
95 // Sets format of title of the frame. Must contain exactly one "%s"
96 // (for title of displayed HTML page)
97 void SetTitleFormat(const wxString& format);
98
99 // Displays page x. If not found it will offect the user a choice of
100 // searching books.
101 // Looking for the page runs in these steps:
102 // 1. try to locate file named x (if x is for example "doc/howto.htm")
103 // 2. try to open starting page of book x
104 // 3. try to find x in contents (if x is for example "How To ...")
105 // 4. try to find x in index (if x is for example "How To ...")
106 bool Display(const wxString& x);
107
108 // Alternative version that works with numeric ID.
109 // (uses extension to MS format, <param name="ID" value=id>, see docs)
110 bool Display(const int id);
111
112 // Displays help window and focuses contents.
113 bool DisplayContents();
114
115 // Displays help window and focuses index.
116 bool DisplayIndex();
117
118 // Searches for keyword. Returns true and display page if found, return
119 // false otherwise
120 // Syntax of keyword is Altavista-like:
121 // * words are separated by spaces
122 // (but "\"hello world\"" is only one world "hello world")
123 // * word may be pretended by + or -
124 // (+ : page must contain the word ; - : page can't contain the word)
125 // * if there is no + or - before the word, + is default
126 bool KeywordSearch(const wxString& keyword,
127 wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
128
129 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
130 {
131 m_Config = config;
132 m_ConfigRoot = rootpath;
133 ReadCustomization(config, rootpath);
134 }
135
136 // Saves custom settings into cfg config. it will use the path 'path'
137 // if given, otherwise it will save info into currently selected path.
138 // saved values : things set by SetFonts, SetBorders.
139 void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
140 void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
141
142 // call this to let wxHtmlHelpFrame know page changed
143 void NotifyPageChanged();
144
145 // Refreshes Contents and Index tabs
146 void RefreshLists();
147
148 protected:
149 void Init(wxHtmlHelpData* data = NULL);
150
151 // Adds items to m_Contents tree control
152 void CreateContents();
153
154 // Adds items to m_IndexList
155 void CreateIndex();
156
157 // Add books to search choice panel
158 void CreateSearch();
159
160 // Updates "merged index" structure that combines indexes of all books
161 // into better searchable structure
162 void UpdateMergedIndex();
163
164 // Add custom buttons to toolbar
165 virtual void AddToolbarButtons(wxToolBar *toolBar, int style);
166
167 // Displays options dialog (fonts etc.)
168 virtual void OptionsDialog();
169
170 void OnToolbar(wxCommandEvent& event);
171 void OnContentsSel(wxTreeEvent& event);
172 void OnIndexSel(wxCommandEvent& event);
173 void OnIndexFind(wxCommandEvent& event);
174 void OnIndexAll(wxCommandEvent& event);
175 void OnSearchSel(wxCommandEvent& event);
176 void OnSearch(wxCommandEvent& event);
177 void OnBookmarksSel(wxCommandEvent& event);
178 void OnCloseWindow(wxCloseEvent& event);
179 void OnActivate(wxActivateEvent& event);
180
181 #ifdef __WXMAC__
182 void OnClose(wxCommandEvent& event);
183 void OnAbout(wxCommandEvent& event);
184 #endif
185
186 // Images:
187 enum {
188 IMG_Book = 0,
189 IMG_Folder,
190 IMG_Page
191 };
192
193 protected:
194 wxHtmlHelpData* m_Data;
195 bool m_DataCreated; // m_Data created by frame, or supplied?
196 wxString m_TitleFormat; // title of the help frame
197 // below are various pointers to GUI components
198 wxHtmlWindow *m_HtmlWin;
199 wxSplitterWindow *m_Splitter;
200 wxPanel *m_NavigPan;
201 wxNotebook *m_NavigNotebook;
202 wxTreeCtrl *m_ContentsBox;
203 wxTextCtrl *m_IndexText;
204 wxButton *m_IndexButton;
205 wxButton *m_IndexButtonAll;
206 wxListBox *m_IndexList;
207 wxTextCtrl *m_SearchText;
208 wxButton *m_SearchButton;
209 wxListBox *m_SearchList;
210 wxChoice *m_SearchChoice;
211 wxStaticText *m_IndexCountInfo;
212 wxCheckBox *m_SearchCaseSensitive;
213 wxCheckBox *m_SearchWholeWords;
214
215 wxComboBox *m_Bookmarks;
216 wxArrayString m_BookmarksNames, m_BookmarksPages;
217
218 wxHtmlHelpFrameCfg m_Cfg;
219
220 wxConfigBase *m_Config;
221 wxString m_ConfigRoot;
222
223 // pagenumbers of controls in notebook (usually 0,1,2)
224 int m_ContentsPage;
225 int m_IndexPage;
226 int m_SearchPage;
227
228 // lists of available fonts (used in options dialog)
229 wxArrayString *m_NormalFonts, *m_FixedFonts;
230 int m_FontSize; // 0,1,2 = small,medium,big
231 wxString m_NormalFace, m_FixedFace;
232
233 bool m_UpdateContents;
234
235 #if wxUSE_PRINTING_ARCHITECTURE
236 wxHtmlEasyPrinting *m_Printer;
237 #endif
238 wxHashTable *m_PagesHash;
239 wxHelpControllerBase* m_helpController;
240
241 int m_hfStyle;
242
243 private:
244 void DisplayIndexItem(const wxHtmlHelpMergedIndexItem *it);
245 wxHtmlHelpMergedIndex *m_mergedIndex;
246
247 DECLARE_EVENT_TABLE()
248 DECLARE_NO_COPY_CLASS(wxHtmlHelpFrame)
249 };
250
251 #endif // wxUSE_WXHTML_HELP
252
253 #endif