]> git.saurik.com Git - wxWidgets.git/blob - include/wx/html/helpfrm.h
Added MSWPositionForWxMenu() method which is used to translate wxWindows
[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
74 class WXDLLIMPEXP_CORE wxHelpControllerBase;
75
76 class WXDLLIMPEXP_HTML wxHtmlHelpFrame : public wxFrame
77 {
78 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame)
79
80 public:
81 wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); }
82 wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID,
83 const wxString& title = wxEmptyString,
84 int style = wxHF_DEFAULT_STYLE, wxHtmlHelpData* data = NULL);
85 bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString,
86 int style = wxHF_DEFAULT_STYLE);
87 ~wxHtmlHelpFrame();
88
89 wxHtmlHelpData* GetData() { return m_Data; }
90 wxHelpControllerBase* GetController() const { return m_helpController; }
91 void SetController(wxHelpControllerBase* controller) { m_helpController = controller; }
92
93 // Sets format of title of the frame. Must contain exactly one "%s"
94 // (for title of displayed HTML page)
95 void SetTitleFormat(const wxString& format);
96
97 // Displays page x. If not found it will offect the user a choice of
98 // searching books.
99 // Looking for the page runs in these steps:
100 // 1. try to locate file named x (if x is for example "doc/howto.htm")
101 // 2. try to open starting page of book x
102 // 3. try to find x in contents (if x is for example "How To ...")
103 // 4. try to find x in index (if x is for example "How To ...")
104 bool Display(const wxString& x);
105
106 // Alternative version that works with numeric ID.
107 // (uses extension to MS format, <param name="ID" value=id>, see docs)
108 bool Display(const int id);
109
110 // Displays help window and focuses contents.
111 bool DisplayContents();
112
113 // Displays help window and focuses index.
114 bool DisplayIndex();
115
116 // Searches for keyword. Returns TRUE and display page if found, return
117 // FALSE otherwise
118 // Syntax of keyword is Altavista-like:
119 // * words are separated by spaces
120 // (but "\"hello world\"" is only one world "hello world")
121 // * word may be pretended by + or -
122 // (+ : page must contain the word ; - : page can't contain the word)
123 // * if there is no + or - before the word, + is default
124 bool KeywordSearch(const wxString& keyword,
125 wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
126
127 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
128 {
129 m_Config = config;
130 m_ConfigRoot = rootpath;
131 ReadCustomization(config, rootpath);
132 }
133
134 // Saves custom settings into cfg config. it will use the path 'path'
135 // if given, otherwise it will save info into currently selected path.
136 // saved values : things set by SetFonts, SetBorders.
137 void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
138 void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
139
140 // call this to let wxHtmlHelpFrame know page changed
141 void NotifyPageChanged();
142
143 // Refreshes Contents and Index tabs
144 void RefreshLists();
145
146 protected:
147 void Init(wxHtmlHelpData* data = NULL);
148
149 // Adds items to m_Contents tree control
150 void CreateContents();
151
152 // Adds items to m_IndexList
153 void CreateIndex();
154
155 // Add books to search choice panel
156 void CreateSearch();
157
158 // Add custom buttons to toolbar
159 virtual void AddToolbarButtons(wxToolBar *toolBar, int style);
160
161 // Displays options dialog (fonts etc.)
162 virtual void OptionsDialog();
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 void OnActivate(wxActivateEvent& event);
174
175 #ifdef __WXMAC__
176 void OnClose(wxCommandEvent& event);
177 void OnAbout(wxCommandEvent& event);
178 #endif
179
180 // Images:
181 enum {
182 IMG_Book = 0,
183 IMG_Folder,
184 IMG_Page
185 };
186
187 protected:
188 wxHtmlHelpData* m_Data;
189 bool m_DataCreated; // m_Data created by frame, or supplied?
190 wxString m_TitleFormat; // title of the help frame
191 // below are various pointers to GUI components
192 wxHtmlWindow *m_HtmlWin;
193 wxSplitterWindow *m_Splitter;
194 wxPanel *m_NavigPan;
195 wxNotebook *m_NavigNotebook;
196 wxTreeCtrl *m_ContentsBox;
197 wxTextCtrl *m_IndexText;
198 wxButton *m_IndexButton;
199 wxButton *m_IndexButtonAll;
200 wxListBox *m_IndexList;
201 wxTextCtrl *m_SearchText;
202 wxButton *m_SearchButton;
203 wxListBox *m_SearchList;
204 wxChoice *m_SearchChoice;
205 wxStaticText *m_IndexCountInfo;
206 wxCheckBox *m_SearchCaseSensitive;
207 wxCheckBox *m_SearchWholeWords;
208
209 wxComboBox *m_Bookmarks;
210 wxArrayString m_BookmarksNames, m_BookmarksPages;
211
212 wxHtmlHelpFrameCfg m_Cfg;
213
214 wxConfigBase *m_Config;
215 wxString m_ConfigRoot;
216
217 // pagenumbers of controls in notebook (usually 0,1,2)
218 int m_ContentsPage;
219 int m_IndexPage;
220 int m_SearchPage;
221
222 // lists of available fonts (used in options dialog)
223 wxArrayString *m_NormalFonts, *m_FixedFonts;
224 int m_FontSize; // 0,1,2 = small,medium,big
225 wxString m_NormalFace, m_FixedFace;
226
227 bool m_UpdateContents;
228
229 #if wxUSE_PRINTING_ARCHITECTURE
230 wxHtmlEasyPrinting *m_Printer;
231 #endif
232 wxHashTable *m_PagesHash;
233 wxHelpControllerBase* m_helpController;
234
235 int m_hfStyle;
236
237 DECLARE_EVENT_TABLE()
238 DECLARE_NO_COPY_CLASS(wxHtmlHelpFrame)
239 };
240
241 #endif // wxUSE_WXHTML_HELP
242
243 #endif