Took anonymous class out of wxHtmlHelpFrame; corrected some typos
[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 // Created:
8 // RCS-ID:
9 // Copyright: (c) Harm van der Heijden and Vaclav Slavik
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WX_HELPFRM_H_
14 #define _WX_HELPFRM_H_
15
16 #ifdef __GNUG__
17 #pragma interface "helpfrm.h"
18 #endif
19
20 #include "wx/defs.h"
21
22 #if wxUSE_HTML
23
24 #include "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/html/htmlwin.h"
33
34 // style flags for the Help Frame
35 const int wxHF_TOOLBAR = 1;
36 const int wxHF_CONTENTS = 2;
37 const int wxHF_INDEX = 4;
38 const int wxHF_SEARCH = 8;
39 const int wxHF_DEFAULTSTYLE = -1;
40
41 // Command IDs :
42 enum {
43 wxID_HTML_PANEL = wxID_HIGHEST + 1,
44 wxID_HTML_BACK,
45 wxID_HTML_FORWARD,
46 wxID_HTML_TREECTRL,
47 wxID_HTML_INDEXPAGE,
48 wxID_HTML_INDEXLIST,
49 wxID_HTML_NOTEBOOK,
50 wxID_HTML_SEARCHPAGE,
51 wxID_HTML_SEARCHTEXT,
52 wxID_HTML_SEARCHLIST,
53 wxID_HTML_SEARCHBUTTON,
54 wxID_HTML_SEARCHCHOICE,
55 wxID_HTML_HELPFRAME // the id of wxHtmlHelpController's helpframe
56 };
57
58 class WXDLLEXPORT wxHtmlHelpFrameCfg
59 {
60 public:
61 wxHtmlHelpFrameCfg() {};
62 long x, y, w, h;
63 long sashpos;
64 bool navig_on;
65 int style; // flags given to wxHtmlHelpFrame ctor
66 wxString titleformat;
67 };
68
69 class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame
70 {
71 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame)
72
73 public:
74 wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); }
75 wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
76 const wxString& title = wxEmptyString,
77 int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
78 bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString,
79 int style = wxHF_DEFAULTSTYLE);
80 ~wxHtmlHelpFrame();
81
82 wxHtmlHelpData* GetData() { return m_Data; }
83
84 void SetTitleFormat(const wxString& format) {
85 if (m_HtmlWin)
86 m_HtmlWin->SetRelatedFrame(this, format);
87 m_TitleFormat = format;
88 }
89 // Sets format of title of the frame. Must contain exactly one "%s"
90 // (for title of displayed HTML page)
91
92 bool Display(const wxString& x);
93 // Displays page x. If not found it will offect the user a choice of
94 // searching books.
95 // Looking for the page runs in these steps:
96 // 1. try to locate file named x (if x is for example "doc/howto.htm")
97 // 2. try to open starting page of book x
98 // 3. try to find x in contents (if x is for example "How To ...")
99 // 4. try to find x in index (if x is for example "How To ...")
100 bool Display(const int id);
101 // Alternative version that works with numeric ID.
102 // (uses extension to MS format, <param name="ID" value=id>, see docs)
103
104 bool DisplayContents();
105 // Displays help window and focuses contents.
106
107 bool DisplayIndex();
108 // Displays help window and focuses index.
109
110 bool KeywordSearch(const wxString& keyword);
111 // Searches for keyword. Returns TRUE and display page if found, return
112 // FALSE otherwise
113 // Syntax of keyword is Altavista-like:
114 // * words are separated by spaces
115 // (but "\"hello world\"" is only one world "hello world")
116 // * word may be pretended by + or -
117 // (+ : page must contain the word ; - : page can't contain the word)
118 // * if there is no + or - before the word, + is default
119 void RefreshLists(bool show_progress = FALSE);
120 // Refreshes Contents and Index tabs
121 void CreateContents(bool show_progress = FALSE);
122 // Adds items to m_Contents tree control
123 void CreateIndex(bool show_progress = FALSE);
124 // Adds items to m_IndexList
125 void CreateSearch();
126 // Add books to search choice panel
127 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString) {
128 m_Config = config; m_ConfigRoot = rootpath;
129 ReadCustomization(config, rootpath);
130 }
131 void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
132 // saves custom settings into cfg config. it will use the path 'path'
133 // if given, otherwise it will save info into currently selected path.
134 // saved values : things set by SetFonts, SetBorders.
135 void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
136 // ...
137 void OnToolbar(wxCommandEvent& event);
138 void OnContentsSel(wxTreeEvent& event);
139 void OnIndexSel(wxCommandEvent& event);
140 void OnSearchSel(wxCommandEvent& event);
141 void OnSearch(wxCommandEvent& event);
142 void OnCloseWindow(wxCloseEvent& event);
143
144 // Images:
145 enum {
146 IMG_Book = 0,
147 IMG_Folder,
148 IMG_Page
149 };
150
151 protected:
152 wxHtmlHelpData* m_Data;
153 bool m_DataCreated; // m_Data created by frame, or supplied?
154 wxString m_TitleFormat; // title of the help frame
155 // below are various pointers to GUI components
156 wxHtmlWindow *m_HtmlWin;
157 wxSplitterWindow *m_Splitter;
158 wxNotebook *m_NavigPan;
159 wxTreeCtrl *m_ContentsBox;
160 wxImageList *m_ContentsImageList;
161 wxListBox *m_IndexBox;
162 wxTextCtrl *m_SearchText;
163 wxButton *m_SearchButton;
164 wxListBox *m_SearchList;
165 wxChoice *m_SearchChoice;
166
167 wxHtmlHelpFrameCfg m_Cfg;
168 wxConfigBase *m_Config;
169 wxString m_ConfigRoot;
170
171 // pagenumbers of controls in notebook (usually 0,1,2)
172 int m_ContentsPage;
173 int m_IndexPage;
174 int m_SearchPage;
175
176 protected:
177 void Init(wxHtmlHelpData* data = NULL);
178
179 DECLARE_EVENT_TABLE()
180 };
181
182 #endif
183
184 #endif