]> git.saurik.com Git - wxWidgets.git/blame - include/wx/html/helpfrm.h
Fixing font utilities
[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__
97494971 16#pragma interface "helpfrm.h"
8ec2b484
HH
17#endif
18
19#include "wx/defs.h"
20
3379ed37 21#if wxUSE_WXHTML_HELP
8ec2b484 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"
2f7adba0 36class WXDLLEXPORT wxButton;
8ec2b484 37
d5bb85a0 38
8ec2b484 39// style flags for the Help Frame
576507e2
VS
40#define wxHF_TOOLBAR 0x0001
41#define wxHF_CONTENTS 0x0002
42#define wxHF_INDEX 0x0004
43#define wxHF_SEARCH 0x0008
44#define wxHF_BOOKMARKS 0x0010
45#define wxHF_OPEN_FILES 0x0020
46#define wxHF_PRINT 0x0040
47#define wxHF_FLAT_TOOLBAR 0x0080
48#define wxHF_MERGE_BOOKS 0x0100
49#define wxHF_ICONS_BOOK 0x0200
50#define wxHF_ICONS_BOOK_CHAPTER 0x0400
51#define wxHF_ICONS_FOLDER 0x0000 // this is 0 since it is default
52#define wxHF_DEFAULT_STYLE (wxHF_TOOLBAR | wxHF_CONTENTS | \
53 wxHF_INDEX | wxHF_SEARCH | \
54 wxHF_BOOKMARKS | wxHF_PRINT)
55//compatibility:
56#define wxHF_OPENFILES wxHF_OPEN_FILES
57#define wxHF_FLATTOOLBAR wxHF_FLAT_TOOLBAR
58#define wxHF_DEFAULTSTYLE wxHF_DEFAULT_STYLE
8ec2b484 59
d5bb85a0 60
97494971 61struct wxHtmlHelpFrameCfg
b31ba288 62{
68364659 63 int x, y, w, h;
d5bb85a0
VS
64 long sashpos;
65 bool navig_on;
97494971 66};
d5bb85a0
VS
67
68
b4414c1f 69class WXDLLEXPORT wxHelpControllerBase;
b31ba288 70
8ec2b484
HH
71class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame
72{
97494971
VS
73 DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame)
74
75public:
76 wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); }
77 wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID,
78 const wxString& title = wxEmptyString,
576507e2 79 int style = wxHF_DEFAULT_STYLE, wxHtmlHelpData* data = NULL);
97494971 80 bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString,
576507e2 81 int style = wxHF_DEFAULT_STYLE);
97494971
VS
82 ~wxHtmlHelpFrame();
83
84 wxHtmlHelpData* GetData() { return m_Data; }
85 wxHelpControllerBase* GetController() const { return m_helpController; }
86 void SetController(wxHelpControllerBase* controller) { m_helpController = controller; }
87
88 // Sets format of title of the frame. Must contain exactly one "%s"
89 // (for title of displayed HTML page)
90 void SetTitleFormat(const wxString& format);
91
92 // Displays page x. If not found it will offect the user a choice of
93 // searching books.
94 // Looking for the page runs in these steps:
95 // 1. try to locate file named x (if x is for example "doc/howto.htm")
96 // 2. try to open starting page of book x
97 // 3. try to find x in contents (if x is for example "How To ...")
98 // 4. try to find x in index (if x is for example "How To ...")
99 bool Display(const wxString& x);
100
101 // Alternative version that works with numeric ID.
102 // (uses extension to MS format, <param name="ID" value=id>, see docs)
103 bool Display(const int id);
104
105 // Displays help window and focuses contents.
106 bool DisplayContents();
107
108 // Displays help window and focuses index.
109 bool DisplayIndex();
110
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 bool KeywordSearch(const wxString& keyword);
120
121 void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
122 {
123 m_Config = config;
124 m_ConfigRoot = rootpath;
125 ReadCustomization(config, rootpath);
126 }
127
128 // Saves custom settings into cfg config. it will use the path 'path'
129 // if given, otherwise it will save info into currently selected path.
130 // saved values : things set by SetFonts, SetBorders.
131 void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
132 void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
133
134 // call this to let wxHtmlHelpFrame know page changed
135 void NotifyPageChanged();
136
137protected:
138 void Init(wxHtmlHelpData* data = NULL);
139
140 // Refreshes Contents and Index tabs
141 void RefreshLists();
142
143 // Adds items to m_Contents tree control
144 void CreateContents();
145
146 // Adds items to m_IndexList
147 void CreateIndex();
148
149 // Add books to search choice panel
150 void CreateSearch();
151
152 // Add custom buttons to toolbar
153 virtual void AddToolbarButtons(wxToolBar *toolBar, int style);
154
155 // Displays options dialog (fonts etc.)
156 virtual void OptionsDialog();
157
158 void OnToolbar(wxCommandEvent& event);
159 void OnContentsSel(wxTreeEvent& event);
160 void OnIndexSel(wxCommandEvent& event);
161 void OnIndexFind(wxCommandEvent& event);
162 void OnIndexAll(wxCommandEvent& event);
163 void OnSearchSel(wxCommandEvent& event);
164 void OnSearch(wxCommandEvent& event);
165 void OnBookmarksSel(wxCommandEvent& event);
166 void OnCloseWindow(wxCloseEvent& event);
167
168 // Images:
169 enum {
170 IMG_Book = 0,
171 IMG_Folder,
172 IMG_Page,
173 IMG_RootFolder
174 };
175
176protected:
177 wxHtmlHelpData* m_Data;
178 bool m_DataCreated; // m_Data created by frame, or supplied?
179 wxString m_TitleFormat; // title of the help frame
180 // below are various pointers to GUI components
181 wxHtmlWindow *m_HtmlWin;
182 wxSplitterWindow *m_Splitter;
183 wxNotebook *m_NavigPan;
184 wxTreeCtrl *m_ContentsBox;
185 wxTextCtrl *m_IndexText;
186 wxButton *m_IndexButton;
187 wxButton *m_IndexButtonAll;
188 wxListBox *m_IndexList;
189 wxTextCtrl *m_SearchText;
190 wxButton *m_SearchButton;
191 wxListBox *m_SearchList;
192 wxChoice *m_SearchChoice;
193 wxStaticText *m_IndexCountInfo;
194 wxCheckBox *m_SearchCaseSensitive;
195 wxCheckBox *m_SearchWholeWords;
196
197 wxComboBox *m_Bookmarks;
198 wxArrayString m_BookmarksNames, m_BookmarksPages;
199
200 wxHtmlHelpFrameCfg m_Cfg;
201
202 wxConfigBase *m_Config;
203 wxString m_ConfigRoot;
204
205 // pagenumbers of controls in notebook (usually 0,1,2)
206 int m_ContentsPage;
207 int m_IndexPage;
208 int m_SearchPage;
209
210 // lists of available fonts (used in options dialog)
211 wxArrayString *m_NormalFonts, *m_FixedFonts;
212 int m_FontSize; // 0,1,2 = small,medium,big
213 wxString m_NormalFace, m_FixedFace;
214
215 bool m_UpdateContents;
0646614d
VS
216
217#if wxUSE_PRINTING_ARCHITECTURE
97494971 218 wxHtmlEasyPrinting *m_Printer;
0646614d 219#endif
97494971
VS
220 wxHashTable *m_PagesHash;
221 wxHelpControllerBase* m_helpController;
3379ed37 222
576507e2 223 int m_hfStyle;
d5bb85a0 224
97494971 225 DECLARE_EVENT_TABLE()
8ec2b484
HH
226};
227
3379ed37 228#endif // wxUSE_WXHTML_HELP
8ec2b484
HH
229
230#endif