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