]> git.saurik.com Git - wxWidgets.git/blame - include/wx/html/helpfrm.h
restored previously removed inline
[wxWidgets.git] / include / wx / html / helpfrm.h
CommitLineData
8ec2b484
HH
1/////////////////////////////////////////////////////////////////////////////
2// Name: helpfrm.h
3// Purpose: wxHtmlHelpFrame
f42b1601 4// Notes: Based on htmlhelp.cpp, implementing a monolithic
8ec2b484
HH
5// HTML Help controller class, by Vaclav Slavik
6// Author: Harm van der Heijden and Vaclav Slavik
69941f05 7// RCS-ID: $Id$
8ec2b484
HH
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#ifdef __GNUG__
69941f05 16#pragma interface
8ec2b484
HH
17#endif
18
19#include "wx/defs.h"
20
21#if wxUSE_HTML
22
16a12a3d 23#include "wx/html/helpdata.h"
8ec2b484
HH
24#include "wx/window.h"
25#include "wx/frame.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"
382e6efe 31#include "wx/combobox.h"
c4971147 32#include "wx/checkbox.h"
240c2873 33#include "wx/stattext.h"
8ec2b484 34#include "wx/html/htmlwin.h"
0646614d 35#include "wx/html/htmprint.h"
8ec2b484 36
d5bb85a0 37
8ec2b484 38// style flags for the Help Frame
d5bb85a0
VS
39#define wxHF_TOOLBAR 0x0001
40#define wxHF_CONTENTS 0x0002
41#define wxHF_INDEX 0x0004
42#define wxHF_SEARCH 0x0008
382e6efe 43#define wxHF_BOOKMARKS 0x0010
0646614d
VS
44#define wxHF_OPENFILES 0x0020
45#define wxHF_PRINT 0x0040
f6bcfd97
BP
46#define wxHF_FLATTOOLBAR 0x0080
47#define wxHF_DEFAULTSTYLE (wxHF_TOOLBAR | wxHF_CONTENTS | wxHF_INDEX | \
48 wxHF_SEARCH | wxHF_BOOKMARKS | wxHF_PRINT)
d5bb85a0 49
8ec2b484
HH
50
51// Command IDs :
d5bb85a0
VS
52enum
53{
8ec2b484
HH
54 wxID_HTML_PANEL = wxID_HIGHEST + 1,
55 wxID_HTML_BACK,
56 wxID_HTML_FORWARD,
0646614d
VS
57 wxID_HTML_UPNODE,
58 wxID_HTML_UP,
59 wxID_HTML_DOWN,
60 wxID_HTML_PRINT,
61 wxID_HTML_OPENFILE,
83efdf33 62 wxID_HTML_OPTIONS,
382e6efe
VS
63 wxID_HTML_BOOKMARKSLIST,
64 wxID_HTML_BOOKMARKSADD,
65 wxID_HTML_BOOKMARKSREMOVE,
8ec2b484
HH
66 wxID_HTML_TREECTRL,
67 wxID_HTML_INDEXPAGE,
68 wxID_HTML_INDEXLIST,
f0b6a33f
VS
69 wxID_HTML_INDEXTEXT,
70 wxID_HTML_INDEXBUTTON,
71 wxID_HTML_INDEXBUTTONALL,
8ec2b484
HH
72 wxID_HTML_NOTEBOOK,
73 wxID_HTML_SEARCHPAGE,
74 wxID_HTML_SEARCHTEXT,
75 wxID_HTML_SEARCHLIST,
76 wxID_HTML_SEARCHBUTTON,
77 wxID_HTML_SEARCHCHOICE,
240c2873 78 wxID_HTML_COUNTINFO,
8ec2b484 79 wxID_HTML_HELPFRAME // the id of wxHtmlHelpController's helpframe
d5bb85a0
VS
80}
81;
8ec2b484 82
d5bb85a0
VS
83
84typedef struct
b31ba288 85{
68364659 86 int x, y, w, h;
d5bb85a0
VS
87 long sashpos;
88 bool navig_on;
89}
90wxHtmlHelpFrameCfg;
91
92
b4414c1f 93class WXDLLEXPORT wxHelpControllerBase;
b31ba288 94
8ec2b484
HH
95class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame
96{
d5bb85a0
VS
97 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame)
98
99 public:
100 wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); }
f5b9cde2 101 wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID,
d5bb85a0
VS
102 const wxString& title = wxEmptyString,
103 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
104 bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString,
105 int style = wxHF_DEFAULTSTYLE);
106 ~wxHtmlHelpFrame();
107
108 wxHtmlHelpData* GetData() { return m_Data; }
b4414c1f
JS
109 wxHelpControllerBase* GetController() const { return m_helpController; }
110 void SetController(wxHelpControllerBase* controller) { m_helpController = controller; }
d5bb85a0 111
721ab905 112 void SetTitleFormat(const wxString& format);
d5bb85a0
VS
113 // Sets format of title of the frame. Must contain exactly one "%s"
114 // (for title of displayed HTML page)
115
116 bool Display(const wxString& x);
117 // Displays page x. If not found it will offect the user a choice of
118 // searching books.
119 // Looking for the page runs in these steps:
120 // 1. try to locate file named x (if x is for example "doc/howto.htm")
121 // 2. try to open starting page of book x
122 // 3. try to find x in contents (if x is for example "How To ...")
123 // 4. try to find x in index (if x is for example "How To ...")
124 bool Display(const int id);
125 // Alternative version that works with numeric ID.
126 // (uses extension to MS format, <param name="ID" value=id>, see docs)
127
128 bool DisplayContents();
129 // Displays help window and focuses contents.
130
131 bool DisplayIndex();
132 // Displays help window and focuses index.
133
134 bool KeywordSearch(const wxString& keyword);
135 // Searches for keyword. Returns TRUE and display page if found, return
136 // FALSE otherwise
137 // Syntax of keyword is Altavista-like:
138 // * words are separated by spaces
139 // (but "\"hello world\"" is only one world "hello world")
140 // * word may be pretended by + or -
141 // (+ : page must contain the word ; - : page can't contain the word)
142 // * if there is no + or - before the word, + is default
83efdf33 143
d5bb85a0 144 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
83efdf33
VS
145 {
146 m_Config = config;
147 m_ConfigRoot = rootpath;
148 ReadCustomization(config, rootpath);
149 }
150
d5bb85a0
VS
151 void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
152 // saves custom settings into cfg config. it will use the path 'path'
153 // if given, otherwise it will save info into currently selected path.
154 // saved values : things set by SetFonts, SetBorders.
155 void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
156 // ...
0646614d
VS
157
158 void NotifyPageChanged();
159 // call this to let wxHtmlHelpFrame know page changed
83efdf33 160
052e12db
VS
161 protected:
162 void Init(wxHtmlHelpData* data = NULL);
163
164 void RefreshLists();
165 // Refreshes Contents and Index tabs
166
167 void CreateContents();
168 // Adds items to m_Contents tree control
169
170 void CreateIndex();
171 // Adds items to m_IndexList
172
173 void CreateSearch();
174 // Add books to search choice panel
175
b854b7b8
VS
176 virtual void AddToolbarButtons(wxToolBar *toolBar, int style);
177 // Add custom buttons to toolbar
052e12db 178
83efdf33
VS
179 virtual void OptionsDialog();
180 // Displays options dialog (fonts etc.)
181
d5bb85a0
VS
182 void OnToolbar(wxCommandEvent& event);
183 void OnContentsSel(wxTreeEvent& event);
184 void OnIndexSel(wxCommandEvent& event);
f0b6a33f
VS
185 void OnIndexFind(wxCommandEvent& event);
186 void OnIndexAll(wxCommandEvent& event);
d5bb85a0
VS
187 void OnSearchSel(wxCommandEvent& event);
188 void OnSearch(wxCommandEvent& event);
382e6efe 189 void OnBookmarksSel(wxCommandEvent& event);
d5bb85a0
VS
190 void OnCloseWindow(wxCloseEvent& event);
191
192 // Images:
193 enum {
194 IMG_Book = 0,
195 IMG_Folder,
5c172c17
VS
196 IMG_Page,
197 IMG_RootFolder
d5bb85a0
VS
198 };
199
200 protected:
201 wxHtmlHelpData* m_Data;
202 bool m_DataCreated; // m_Data created by frame, or supplied?
203 wxString m_TitleFormat; // title of the help frame
204 // below are various pointers to GUI components
205 wxHtmlWindow *m_HtmlWin;
206 wxSplitterWindow *m_Splitter;
207 wxNotebook *m_NavigPan;
208 wxTreeCtrl *m_ContentsBox;
f0b6a33f
VS
209 wxTextCtrl *m_IndexText;
210 wxButton *m_IndexButton;
211 wxButton *m_IndexButtonAll;
212 wxListBox *m_IndexList;
d5bb85a0
VS
213 wxTextCtrl *m_SearchText;
214 wxButton *m_SearchButton;
215 wxListBox *m_SearchList;
216 wxChoice *m_SearchChoice;
240c2873 217 wxStaticText *m_IndexCountInfo;
c4971147
VS
218 wxCheckBox *m_SearchCaseSensitive;
219 wxCheckBox *m_SearchWholeWords;
d5bb85a0 220
382e6efe
VS
221 wxComboBox *m_Bookmarks;
222 wxArrayString m_BookmarksNames, m_BookmarksPages;
223
d5bb85a0
VS
224 wxHtmlHelpFrameCfg m_Cfg;
225
226 wxConfigBase *m_Config;
227 wxString m_ConfigRoot;
228
229 // pagenumbers of controls in notebook (usually 0,1,2)
230 int m_ContentsPage;
231 int m_IndexPage;
232 int m_SearchPage;
83efdf33
VS
233
234 // lists of available fonts (used in options dialog)
235 wxArrayString *m_NormalFonts, *m_FixedFonts;
236 int m_FontSize; // 0,1,2 = small,medium,big
237 wxString m_NormalFace, m_FixedFace;
0646614d
VS
238
239 bool m_UpdateContents;
240
241#if wxUSE_PRINTING_ARCHITECTURE
242 wxHtmlEasyPrinting *m_Printer;
243#endif
244 wxHashTable *m_PagesHash;
b4414c1f 245 wxHelpControllerBase* m_helpController;
d5bb85a0 246
d5bb85a0 247 DECLARE_EVENT_TABLE()
8ec2b484
HH
248};
249
052e12db 250#endif // wxUSE_HTML
8ec2b484
HH
251
252#endif