]>
Commit | Line | Data |
---|---|---|
0f66a9f3 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: htmlhelp.i | |
3 | // Purpose: SWIG definitions of html classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 25-nov-1998 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | ||
14 | %module htmlhelp | |
15 | ||
16 | %{ | |
17 | #include "helpers.h" | |
18 | #include <wx/html/htmlwin.h> | |
2f90df85 | 19 | #include <wx/html/helpctrl.h> |
0f66a9f3 RD |
20 | #include <wx/image.h> |
21 | #include <wx/fs_zip.h> | |
22 | #include <wx/fs_inet.h> | |
23 | #include <wx/wfstream.h> | |
0f66a9f3 RD |
24 | %} |
25 | ||
26 | //--------------------------------------------------------------------------- | |
27 | ||
28 | %include typemaps.i | |
29 | %include my_typemaps.i | |
30 | ||
31 | %extern wx.i | |
32 | %extern windows.i | |
2f90df85 | 33 | %extern frames.i |
0f66a9f3 RD |
34 | %extern _defs.i |
35 | %extern events.i | |
36 | %extern controls.i | |
37 | %extern controls2.i | |
38 | ||
39 | %extern utils.i | |
40 | ||
41 | %extern html.i | |
42 | ||
43 | //--------------------------------------------------------------------------- | |
44 | ||
45 | enum { | |
46 | wxID_HTML_PANEL, | |
47 | wxID_HTML_BACK, | |
48 | wxID_HTML_FORWARD, | |
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, | |
dc2f8a65 RD |
56 | wxID_HTML_SEARCHBUTTON, |
57 | wxID_HTML_SEARCHCHOICE, | |
58 | wxID_HTML_HELPFRAME | |
59 | ||
0f66a9f3 RD |
60 | }; |
61 | ||
2f90df85 RD |
62 | //--------------------------------------------------------------------------- |
63 | ||
64 | class wxHtmlHelpFrameCfg | |
65 | { | |
0f66a9f3 | 66 | public: |
2f90df85 RD |
67 | wxHtmlHelpFrameCfg(); |
68 | ||
69 | long x, y, w, h; | |
70 | long sashpos; | |
71 | bool navig_on; | |
2f90df85 RD |
72 | }; |
73 | ||
74 | ||
75 | //--------------------------------------------------------------------------- | |
76 | ||
77 | class wxHtmlBookRecord { | |
78 | public: | |
79 | wxHtmlBookRecord(const wxString& basepath, const wxString& title, | |
80 | const wxString& start); | |
81 | ||
82 | wxString GetTitle(); | |
83 | wxString GetStart(); | |
84 | wxString GetBasePath(); | |
85 | ||
86 | void SetContentsRange(int start, int end); | |
87 | int GetContentsStart(); | |
88 | int GetContentsEnd(); | |
89 | }; | |
90 | ||
91 | //--------------------------------------------------------------------------- | |
92 | ||
93 | typedef struct | |
94 | { | |
95 | short int m_Level; | |
96 | int m_ID; | |
97 | char* m_Name; | |
98 | char* m_Page; | |
99 | wxHtmlBookRecord *m_Book; | |
100 | } wxHtmlContentsItem; | |
101 | ||
102 | //--------------------------------------------------------------------------- | |
103 | ||
104 | class wxHtmlSearchStatus | |
105 | { | |
106 | public: | |
107 | //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword, | |
108 | // const wxString& book = wxEmptyString); | |
109 | bool Search(); | |
110 | bool IsActive(); | |
111 | int GetCurIndex(); | |
112 | int GetMaxIndex(); | |
113 | const wxString& GetName(); | |
114 | wxHtmlContentsItem* GetContentsItem(); | |
115 | }; | |
0f66a9f3 | 116 | |
2f90df85 | 117 | //--------------------------------------------------------------------------- |
0f66a9f3 | 118 | |
2f90df85 RD |
119 | class wxHtmlHelpData { |
120 | public: | |
121 | wxHtmlHelpData(); | |
122 | ~wxHtmlHelpData(); | |
0f66a9f3 RD |
123 | |
124 | void SetTempDir(const wxString& path); | |
2f90df85 RD |
125 | bool AddBook(const wxString& book); |
126 | bool AddBookParam(const wxString& title, const wxString& contfile, | |
127 | const wxString& indexfile=wxEmptyString, | |
128 | const wxString& deftopic=wxEmptyString, | |
129 | const wxString& path=wxEmptyString); | |
0f66a9f3 | 130 | |
2f90df85 RD |
131 | wxString FindPageByName(const wxString& page); |
132 | wxString FindPageById(int id); | |
0f66a9f3 | 133 | |
2f90df85 RD |
134 | // **** this one needs fixed... |
135 | const wxHtmlBookRecArray& GetBookRecArray(); | |
0f66a9f3 | 136 | |
2f90df85 RD |
137 | wxHtmlContentsItem* GetContents(); |
138 | int GetContentsCnt(); | |
139 | wxHtmlContentsItem* GetIndex(); | |
140 | int GetIndexCnt(); | |
141 | }; | |
0f66a9f3 | 142 | |
2f90df85 | 143 | //--------------------------------------------------------------------------- |
0f66a9f3 | 144 | |
2f90df85 RD |
145 | class wxHtmlHelpFrame : public wxFrame { |
146 | public: | |
147 | wxHtmlHelpFrame(wxWindow* parent, int wxWindowID, | |
148 | const wxString& title = wxEmptyString, | |
149 | int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL); | |
0f66a9f3 | 150 | |
2f90df85 RD |
151 | wxHtmlHelpData* GetData(); |
152 | void SetTitleFormat(const wxString& format); | |
153 | void Display(const wxString& x); | |
154 | %name(DisplayID) void Display(int id); | |
155 | void DisplayContents(); | |
156 | void DisplayIndex(); | |
157 | bool KeywordSearch(const wxString& keyword); | |
0f66a9f3 | 158 | void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString); |
2f90df85 RD |
159 | void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); |
160 | void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); | |
161 | }; | |
0f66a9f3 | 162 | |
2f90df85 RD |
163 | |
164 | //--------------------------------------------------------------------------- | |
165 | ||
166 | class wxHtmlHelpController : public wxEvtHandler { | |
167 | public: | |
168 | wxHtmlHelpController(); | |
169 | ~wxHtmlHelpController(); | |
170 | ||
171 | void SetTitleFormat(const wxString& format); | |
172 | void SetTempDir(const wxString& path); | |
173 | bool AddBook(const wxString& book, int show_wait_msg = FALSE); | |
174 | void Display(const wxString& x); | |
175 | %name(DisplayID) void Display(int id); | |
176 | void DisplayContents(); | |
177 | void DisplayIndex(); | |
178 | bool KeywordSearch(const wxString& keyword); | |
179 | void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString); | |
0f66a9f3 | 180 | void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); |
0f66a9f3 | 181 | void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); |
2f90df85 | 182 | wxHtmlHelpFrame* GetFrame(); |
0f66a9f3 RD |
183 | }; |
184 | ||
2f90df85 RD |
185 | //--------------------------------------------------------------------------- |
186 | ||
187 | ||
188 | ||
189 | ||
190 | ||
191 | ||
192 | ||
193 | ||
194 | ||
195 | ||
196 | ||
197 | ||
198 | ||
199 | ||
200 | ||
201 | #ifdef DO_WE_NEED_TO_KEEP_THIS | |
0f66a9f3 RD |
202 | class wxHtmlHelpSystem : public wxHtmlHelpController { |
203 | public: | |
204 | wxHtmlHelpSystem() {}; | |
205 | ~wxHtmlHelpSystem() {}; | |
206 | ||
207 | bool AddBookParam(const wxString& title, const wxString& contfile, | |
208 | const wxString& indexfile=wxEmptyString, const wxString& deftopic=wxEmptyString, | |
209 | const wxString& path=wxEmptyString, bool show_wait_msg=FALSE); | |
210 | // Alternative to AddBook(wxString& hhpfile) | |
211 | wxToolBar* CreateToolBar(wxFrame* frame); | |
212 | // creates a dockable toolbar for the frame, containing hide/show, back and forward buttons | |
213 | wxTreeCtrl* CreateContentsTree(wxWindow* parent); | |
214 | // creates a treecontrol with imagelist for books, folders etc and id wxID_HTML_TREECTRL | |
215 | wxListBox* CreateIndexList(wxWindow* parent); | |
216 | // creates a listbox with the right id | |
217 | virtual void CreateHelpWindow(); | |
218 | // Slightly different version than in wxHtmlHelpController; uses helpers above | |
219 | // Do nothing if the window already exists | |
220 | void SetControls(wxFrame* frame, wxHtmlWindow* htmlwin, | |
221 | wxTreeCtrl* contents=NULL, wxListBox* index=NULL, | |
222 | wxListBox* searchlist=NULL); | |
223 | // alternative for CreateHelpWindow(), sets frame, htmlwindow, contents tree, index | |
224 | // listbox and searchlist listbox. If null, their functionality won't be used | |
225 | ||
226 | // Some extra accessor functions | |
227 | wxFrame* GetFrame() { return m_Frame; } | |
228 | wxHtmlWindow* GetHtmlWindow() { return m_HtmlWin; } | |
229 | wxTreeCtrl* GetContentsTree() { return m_ContentsBox; } | |
230 | wxListBox* GetIndexList() { return m_IndexBox; } | |
231 | wxListBox* GetSearchList() { return m_SearchList; } | |
232 | wxImageList* GetContentsImageList() { return m_ContentsImageList; } | |
233 | // public interface for wxHtmlHelpControllers handlers, so wxPython can call them | |
234 | void OnToolbar(wxCommandEvent& event); | |
235 | void OnContentsSel(wxTreeEvent& event) {wxHtmlHelpController::OnContentsSel(event);} | |
236 | void OnIndexSel(wxCommandEvent& event) {wxHtmlHelpController::OnIndexSel(event);} | |
237 | void OnSearchSel(wxCommandEvent& event) {wxHtmlHelpController::OnSearchSel(event);} | |
238 | void OnSearch(wxCommandEvent& event) {wxHtmlHelpController::OnSearch(event);} | |
239 | void OnCloseWindow(wxCloseEvent& event); | |
240 | ||
241 | // some more protected functions that should be accessible from wxPython | |
242 | void RefreshLists(); | |
243 | void CreateContents() { if (!m_IndexBox) return; wxHtmlHelpController::CreateContents(); } | |
244 | // Adds items to m_Contents tree control | |
245 | void CreateIndex() { if (! m_ContentsBox) return; wxHtmlHelpController::CreateIndex(); } | |
246 | // Adds items to m_IndexList | |
247 | }; | |
248 | ||
249 | // just for fun, an Altavista-like search engine (the gems that Vaclav has hidden in wxHtml...) | |
250 | // but not for wxMSW because it's not DLL exported | |
251 | //#ifndef __WXMSW__ | |
252 | #ifdef THIS_IS_NOT_DEFINED_OKAY | |
253 | class wxSearchEngine | |
254 | { | |
255 | public: | |
256 | wxSearchEngine() : wxObject() {m_Keyword = NULL;} | |
257 | ~wxSearchEngine() {if (m_Keyword) free(m_Keyword);} | |
258 | ||
259 | void LookFor(const wxString& keyword); | |
260 | // Sets the keyword we will be searching for | |
261 | ||
262 | bool Scan(wxInputStream *stream); | |
263 | // Scans the stream for the keyword. | |
264 | // Returns TRUE if the stream contains keyword, fALSE otherwise | |
265 | %addmethods { | |
266 | bool ScanFile(const wxString& filename) { | |
267 | if (filename.IsEmpty()) | |
268 | return false; | |
269 | wxFileInputStream istr(filename); | |
270 | return self->Scan(&istr); | |
271 | } | |
272 | } | |
273 | }; | |
274 | #endif | |
2f90df85 | 275 | #endif |
0f66a9f3 | 276 | //--------------------------------------------------------------------------- |