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