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