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