]>
Commit | Line | Data |
---|---|---|
4b123bb9 HH |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: html.i | |
3 | // Purpose: SWIG definitions of html classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
d14a1e28 | 7 | // Created: 25-Nov-1998 |
4b123bb9 | 8 | // RCS-ID: $Id$ |
d14a1e28 | 9 | // Copyright: (c) 2003 by Total Control Software |
4b123bb9 HH |
10 | // Licence: wxWindows license |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
c8fac2b6 RD |
13 | %define DOCSTRING |
14 | "Classes for a simple HTML rendering window, HTML Help Window, etc." | |
15 | %enddef | |
4b123bb9 | 16 | |
b2eb030f | 17 | %module(package="wx", docstring=DOCSTRING) html |
4b123bb9 HH |
18 | |
19 | %{ | |
d14a1e28 RD |
20 | #include "wx/wxPython/wxPython.h" |
21 | #include "wx/wxPython/pyclasses.h" | |
22 | #include "wx/wxPython/pyistream.h" | |
23 | #include "wx/wxPython/printfw.h" | |
24 | ||
4b123bb9 | 25 | #include <wx/html/htmlwin.h> |
dc2f8a65 | 26 | #include <wx/html/htmprint.h> |
d14a1e28 | 27 | #include <wx/html/helpctrl.h> |
2ef66617 | 28 | #include <wx/html/helpwnd.h> |
42781abb RD |
29 | #include <wx/html/helpfrm.h> |
30 | #include <wx/html/helpdlg.h> | |
4b123bb9 | 31 | |
137b5242 RD |
32 | %} |
33 | ||
b2dc1044 | 34 | |
0f66a9f3 | 35 | //--------------------------------------------------------------------------- |
e166644c | 36 | |
d14a1e28 | 37 | %import windows.i |
54f9ee45 | 38 | %pythoncode { wx = _core } |
99109c0f | 39 | %pythoncode { __docfilter__ = wx.__DocFilter(globals()) } |
d14a1e28 RD |
40 | |
41 | %include _html_rename.i | |
42 | ||
43 | ||
b2dc1044 | 44 | MAKE_CONST_WXSTRING_NOSWIG(EmptyString); |
089142a5 RD |
45 | MAKE_CONST_WXSTRING2(HtmlWindowNameStr, wxT("htmlWindow")) |
46 | MAKE_CONST_WXSTRING2(HtmlPrintoutTitleStr, wxT("Printout")) | |
47 | MAKE_CONST_WXSTRING2(HtmlPrintingTitleStr, wxT("Printing")) | |
b2dc1044 RD |
48 | |
49 | ||
d14a1e28 RD |
50 | // TODO: Split this file into multiple %included files that coresponds to the |
51 | // wx/html include files (more or less.) | |
52 | ||
d14a1e28 RD |
53 | //--------------------------------------------------------------------------- |
54 | %newgroup | |
55 | ||
56 | ||
e166644c | 57 | enum { |
9d8bd15f RD |
58 | wxHTML_ALIGN_LEFT, |
59 | wxHTML_ALIGN_CENTER, | |
60 | wxHTML_ALIGN_RIGHT, | |
61 | wxHTML_ALIGN_BOTTOM, | |
62 | wxHTML_ALIGN_TOP, | |
63 | ||
64 | wxHTML_CLR_FOREGROUND, | |
65 | wxHTML_CLR_BACKGROUND, | |
66 | ||
67 | wxHTML_UNITS_PIXELS, | |
68 | wxHTML_UNITS_PERCENT, | |
69 | ||
70 | wxHTML_INDENT_LEFT, | |
71 | wxHTML_INDENT_RIGHT, | |
72 | wxHTML_INDENT_TOP, | |
73 | wxHTML_INDENT_BOTTOM, | |
74 | ||
75 | wxHTML_INDENT_HORIZONTAL, | |
76 | wxHTML_INDENT_VERTICAL, | |
77 | wxHTML_INDENT_ALL, | |
78 | ||
79 | wxHTML_COND_ISANCHOR, | |
80 | wxHTML_COND_ISIMAGEMAP, | |
81 | wxHTML_COND_USER, | |
4eeb5705 RD |
82 | |
83 | ||
84 | wxHTML_FONT_SIZE_1, | |
85 | wxHTML_FONT_SIZE_2, | |
86 | wxHTML_FONT_SIZE_3, | |
87 | wxHTML_FONT_SIZE_4, | |
88 | wxHTML_FONT_SIZE_5, | |
89 | wxHTML_FONT_SIZE_6, | |
90 | wxHTML_FONT_SIZE_7, | |
e166644c RD |
91 | }; |
92 | ||
93 | ||
c6c593e8 RD |
94 | enum { |
95 | wxHW_SCROLLBAR_NEVER, | |
96 | wxHW_SCROLLBAR_AUTO, | |
3ef86e32 RD |
97 | wxHW_NO_SELECTION, |
98 | wxHW_DEFAULT_STYLE, | |
c6c593e8 RD |
99 | }; |
100 | ||
101 | ||
102 | // enums for wxHtmlWindow::OnOpeningURL | |
103 | enum wxHtmlOpeningStatus | |
104 | { | |
105 | wxHTML_OPEN, | |
106 | wxHTML_BLOCK, | |
107 | wxHTML_REDIRECT | |
108 | }; | |
109 | ||
110 | enum wxHtmlURLType | |
111 | { | |
112 | wxHTML_URL_PAGE, | |
113 | wxHTML_URL_IMAGE, | |
114 | wxHTML_URL_OTHER | |
115 | }; | |
116 | ||
d14a1e28 RD |
117 | |
118 | ||
9c00cfa3 RD |
119 | //--------------------------------------------------------------------------- |
120 | ||
9416aa89 | 121 | class wxHtmlLinkInfo : public wxObject { |
9c00cfa3 | 122 | public: |
137b5242 | 123 | wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString); |
9c00cfa3 RD |
124 | wxString GetHref(); |
125 | wxString GetTarget(); | |
c8bc03c3 RD |
126 | wxMouseEvent* GetEvent(); |
127 | wxHtmlCell* GetHtmlCell(); | |
7a446686 RD |
128 | |
129 | void SetEvent(const wxMouseEvent *e); | |
130 | void SetHtmlCell(const wxHtmlCell * e); | |
9c00cfa3 RD |
131 | }; |
132 | ||
0f66a9f3 RD |
133 | //--------------------------------------------------------------------------- |
134 | ||
9416aa89 | 135 | class wxHtmlTag : public wxObject { |
0f66a9f3 | 136 | public: |
e166644c | 137 | // Never need to create a new tag from Python... |
0f66a9f3 RD |
138 | //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache); |
139 | ||
140 | wxString GetName(); | |
141 | bool HasParam(const wxString& par); | |
a72f4631 | 142 | wxString GetParam(const wxString& par, int with_commas = false); |
0f66a9f3 RD |
143 | |
144 | // Can't do this one as-is, but GetParam should be enough... | |
145 | //int ScanParam(const wxString& par, const char *format, void* param); | |
146 | ||
147 | wxString GetAllParams(); | |
0f66a9f3 RD |
148 | bool HasEnding(); |
149 | int GetBeginPos(); | |
150 | int GetEndPos1(); | |
151 | int GetEndPos2(); | |
152 | }; | |
153 | ||
0f66a9f3 RD |
154 | //--------------------------------------------------------------------------- |
155 | ||
9416aa89 | 156 | class wxHtmlParser : public wxObject { |
0f66a9f3 RD |
157 | public: |
158 | // wxHtmlParser(); This is an abstract base class... | |
159 | ||
160 | void SetFS(wxFileSystem *fs); | |
161 | wxFileSystem* GetFS(); | |
162 | wxObject* Parse(const wxString& source); | |
163 | void InitParser(const wxString& source); | |
164 | void DoneParser(); | |
165 | void DoParsing(int begin_pos, int end_pos); | |
1e4a197e | 166 | void StopParsing(); |
0f66a9f3 | 167 | // wxObject* GetProduct(); |
1e4a197e | 168 | |
0f66a9f3 RD |
169 | void AddTagHandler(wxHtmlTagHandler *handler); |
170 | wxString* GetSource(); | |
dc2f8a65 RD |
171 | void PushTagHandler(wxHtmlTagHandler* handler, wxString tags); |
172 | void PopTagHandler(); | |
0f66a9f3 | 173 | |
c6c593e8 | 174 | // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const; |
0f66a9f3 RD |
175 | |
176 | // void AddText(const char* txt) = 0; | |
177 | // void AddTag(const wxHtmlTag& tag); | |
fdcbb1ce | 178 | |
4725f47e | 179 | |
fdcbb1ce RD |
180 | // Returns HTML source inside the element (i.e. between the starting |
181 | // and ending tag) | |
4725f47e | 182 | wxString GetInnerSource(const wxHtmlTag& tag); |
0f66a9f3 RD |
183 | }; |
184 | ||
185 | ||
186 | //--------------------------------------------------------------------------- | |
187 | ||
188 | class wxHtmlWinParser : public wxHtmlParser { | |
189 | public: | |
1fded56b | 190 | wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL); |
0f66a9f3 RD |
191 | |
192 | void SetDC(wxDC *dc); | |
193 | wxDC* GetDC(); | |
194 | int GetCharHeight(); | |
195 | int GetCharWidth(); | |
1fded56b | 196 | wxPyHtmlWindow* GetWindow(); |
4725f47e RD |
197 | %pythoncode { GetWindow = wx._deprecated(GetWindow) } |
198 | ||
199 | wxHtmlWindowInterface *GetWindowInterface(); | |
d14a1e28 | 200 | |
1fded56b | 201 | // Sets fonts to be used when displaying HTML page. (if size null then default sizes used). |
d14a1e28 | 202 | %extend { |
9cbf6f6e RD |
203 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
204 | int* temp = NULL; | |
205 | if (sizes) temp = int_LIST_helper(sizes); | |
206 | self->SetFonts(normal_face, fixed_face, temp); | |
207 | if (temp) | |
f6bcfd97 | 208 | delete [] temp; |
f6bcfd97 BP |
209 | } |
210 | } | |
0f66a9f3 | 211 | |
385721a8 RD |
212 | // Sets font sizes to be relative to the given size or the system |
213 | // default size; use either specified or default font | |
214 | void SetStandardFonts(int size = -1, | |
215 | const wxString& normal_face = wxPyEmptyString, | |
216 | const wxString& fixed_face = wxPyEmptyString); | |
42781abb RD |
217 | |
218 | ||
0f66a9f3 RD |
219 | wxHtmlContainerCell* GetContainer(); |
220 | wxHtmlContainerCell* OpenContainer(); | |
dc2f8a65 | 221 | wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c); |
0f66a9f3 | 222 | wxHtmlContainerCell* CloseContainer(); |
dc2f8a65 | 223 | |
0f66a9f3 RD |
224 | int GetFontSize(); |
225 | void SetFontSize(int s); | |
226 | int GetFontBold(); | |
227 | void SetFontBold(int x); | |
228 | int GetFontItalic(); | |
229 | void SetFontItalic(int x); | |
230 | int GetFontUnderlined(); | |
231 | void SetFontUnderlined(int x); | |
232 | int GetFontFixed(); | |
233 | void SetFontFixed(int x); | |
234 | int GetAlign(); | |
235 | void SetAlign(int a); | |
c5943253 | 236 | wxColour GetLinkColor(); |
0f66a9f3 | 237 | void SetLinkColor(const wxColour& clr); |
c5943253 | 238 | wxColour GetActualColor(); |
0f66a9f3 | 239 | void SetActualColor(const wxColour& clr); |
85f9dd19 RD |
240 | %pythoncode { |
241 | GetActualColour = GetActualColor | |
242 | SetActualColour = SetActualColor | |
243 | } | |
0f66a9f3 RD |
244 | void SetLink(const wxString& link); |
245 | wxFont* CreateCurrentFont(); | |
9c00cfa3 RD |
246 | wxHtmlLinkInfo GetLink(); |
247 | ||
0f66a9f3 RD |
248 | }; |
249 | ||
250 | ||
0f66a9f3 RD |
251 | //--------------------------------------------------------------------------- |
252 | ||
253 | %{ | |
254 | class wxPyHtmlTagHandler : public wxHtmlTagHandler { | |
4617be08 | 255 | DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler) |
0f66a9f3 RD |
256 | public: |
257 | wxPyHtmlTagHandler() : wxHtmlTagHandler() {}; | |
258 | ||
259 | wxHtmlParser* GetParser() { return m_Parser; } | |
260 | void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); } | |
261 | ||
262 | DEC_PYCALLBACK_STRING__pure(GetSupportedTags); | |
263 | DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag); | |
264 | ||
265 | PYPRIVATE; | |
266 | }; | |
267 | ||
9416aa89 RD |
268 | IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler); |
269 | ||
0f66a9f3 RD |
270 | IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags); |
271 | IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag); | |
0f66a9f3 RD |
272 | %} |
273 | ||
274 | ||
1b8c7ba6 RD |
275 | %rename(HtmlTagHandler) wxPyHtmlTagHandler; |
276 | class wxPyHtmlTagHandler : public wxObject { | |
0f66a9f3 | 277 | public: |
42781abb | 278 | %pythonAppend wxPyHtmlTagHandler "self._setCallbackInfo(self, HtmlTagHandler)" |
0f66a9f3 RD |
279 | wxPyHtmlTagHandler(); |
280 | ||
0122b7e3 | 281 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
0f66a9f3 RD |
282 | |
283 | void SetParser(wxHtmlParser *parser); | |
284 | wxHtmlParser* GetParser(); | |
285 | void ParseInner(const wxHtmlTag& tag); | |
286 | }; | |
287 | ||
288 | ||
289 | //--------------------------------------------------------------------------- | |
290 | ||
291 | %{ | |
292 | class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler { | |
4617be08 | 293 | DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler) |
0f66a9f3 RD |
294 | public: |
295 | wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {}; | |
296 | ||
297 | wxHtmlWinParser* GetParser() { return m_WParser; } | |
298 | void ParseInner(const wxHtmlTag& tag) | |
299 | { wxHtmlWinTagHandler::ParseInner(tag); } | |
300 | ||
301 | DEC_PYCALLBACK_STRING__pure(GetSupportedTags); | |
302 | DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag); | |
303 | ||
304 | PYPRIVATE; | |
305 | }; | |
306 | ||
9416aa89 RD |
307 | IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler); |
308 | ||
0f66a9f3 RD |
309 | IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags); |
310 | IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag); | |
0f66a9f3 RD |
311 | %} |
312 | ||
313 | ||
1b8c7ba6 RD |
314 | %rename(HtmlWinTagHandler) wxPyHtmlWinTagHandler; |
315 | class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler { | |
0f66a9f3 | 316 | public: |
2b9048c5 | 317 | %pythonAppend wxPyHtmlWinTagHandler "self._setCallbackInfo(self, HtmlWinTagHandler)" |
0f66a9f3 RD |
318 | wxPyHtmlWinTagHandler(); |
319 | ||
0122b7e3 | 320 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
0f66a9f3 RD |
321 | |
322 | void SetParser(wxHtmlParser *parser); | |
323 | wxHtmlWinParser* GetParser(); | |
324 | void ParseInner(const wxHtmlTag& tag); | |
325 | }; | |
326 | ||
327 | ||
328 | //--------------------------------------------------------------------------- | |
329 | ||
330 | %{ | |
331 | ||
332 | class wxPyHtmlTagsModule : public wxHtmlTagsModule { | |
333 | public: | |
334 | wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() { | |
335 | m_tagHandlerClass = thc; | |
336 | Py_INCREF(m_tagHandlerClass); | |
337 | RegisterModule(this); | |
338 | wxHtmlWinParser::AddModule(this); | |
339 | } | |
340 | ||
341 | void OnExit() { | |
6e6b3557 | 342 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
0f66a9f3 RD |
343 | Py_DECREF(m_tagHandlerClass); |
344 | m_tagHandlerClass = NULL; | |
dc2f8a65 | 345 | for (size_t x=0; x < m_objArray.GetCount(); x++) { |
0f66a9f3 RD |
346 | PyObject* obj = (PyObject*)m_objArray.Item(x); |
347 | Py_DECREF(obj); | |
348 | } | |
da32eb53 | 349 | wxPyEndBlockThreads(blocked); |
0f66a9f3 RD |
350 | }; |
351 | ||
352 | void FillHandlersTable(wxHtmlWinParser *parser) { | |
353 | // Wave our magic wand... (if it works it's a miracle! ;-) | |
354 | ||
355 | // First, make a new instance of the tag handler | |
6e6b3557 | 356 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
fb757066 RD |
357 | PyObject* arg = PyTuple_New(0); |
358 | PyObject* obj = PyObject_CallObject(m_tagHandlerClass, arg); | |
0f66a9f3 | 359 | Py_DECREF(arg); |
42781abb | 360 | |
0f66a9f3 RD |
361 | // now figure out where it's C++ object is... |
362 | wxPyHtmlWinTagHandler* thPtr; | |
fb757066 | 363 | if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler"))) { |
da32eb53 | 364 | wxPyEndBlockThreads(blocked); |
0f66a9f3 | 365 | return; |
fb757066 | 366 | } |
da32eb53 | 367 | wxPyEndBlockThreads(blocked); |
0f66a9f3 RD |
368 | |
369 | // add it, | |
370 | parser->AddTagHandler(thPtr); | |
371 | ||
372 | // and track it. | |
373 | m_objArray.Add(obj); | |
374 | } | |
375 | ||
376 | private: | |
377 | PyObject* m_tagHandlerClass; | |
378 | wxArrayPtrVoid m_objArray; | |
379 | ||
380 | }; | |
381 | %} | |
382 | ||
383 | ||
384 | ||
385 | %inline %{ | |
386 | void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) { | |
387 | // Dynamically create a new wxModule. Refcounts tagHandlerClass | |
388 | // and adds itself to the wxModules list and to the wxHtmlWinParser. | |
389 | new wxPyHtmlTagsModule(tagHandlerClass); | |
390 | } | |
391 | %} | |
392 | ||
dc2f8a65 | 393 | |
e166644c | 394 | //--------------------------------------------------------------------------- |
f0879a0a RD |
395 | |
396 | %typemap(out) wxHtmlCell* { $result = wxPyMake_wxObject($1, $owner); } | |
397 | %typemap(out) const wxHtmlCell* { $result = wxPyMake_wxObject($1, $owner); } | |
398 | ||
e166644c | 399 | //--------------------------------------------------------------------------- |
d14a1e28 | 400 | %newgroup |
e166644c | 401 | |
dd116e73 RD |
402 | |
403 | // wxHtmlSelection is data holder with information about text selection. | |
404 | // Selection is defined by two positions (beginning and end of the selection) | |
405 | // and two leaf(!) cells at these positions. | |
406 | class wxHtmlSelection | |
407 | { | |
408 | public: | |
409 | wxHtmlSelection(); | |
410 | ~wxHtmlSelection(); | |
411 | ||
412 | void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell, | |
413 | const wxPoint& toPos, const wxHtmlCell *toCell); | |
1b8c7ba6 | 414 | %Rename(SetCells, void, Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell)); |
dd116e73 RD |
415 | |
416 | const wxHtmlCell *GetFromCell() const; | |
417 | const wxHtmlCell *GetToCell() const; | |
418 | ||
419 | // these values are in absolute coordinates: | |
420 | const wxPoint& GetFromPos() const; | |
421 | const wxPoint& GetToPos() const; | |
422 | ||
423 | // these are From/ToCell's private data | |
424 | const wxPoint& GetFromPrivPos() const; | |
425 | const wxPoint& GetToPrivPos() const; | |
426 | void SetFromPrivPos(const wxPoint& pos); | |
427 | void SetToPrivPos(const wxPoint& pos); | |
428 | void ClearPrivPos(); | |
429 | ||
430 | const bool IsEmpty() const; | |
431 | ||
432 | }; | |
433 | ||
434 | ||
435 | enum wxHtmlSelectionState | |
436 | { | |
437 | wxHTML_SEL_OUT, // currently rendered cell is outside the selection | |
438 | wxHTML_SEL_IN, // ... is inside selection | |
439 | wxHTML_SEL_CHANGING // ... is the cell on which selection state changes | |
440 | }; | |
441 | ||
d14a1e28 RD |
442 | |
443 | ||
dd116e73 RD |
444 | // Selection state is passed to wxHtmlCell::Draw so that it can render itself |
445 | // differently e.g. when inside text selection or outside it. | |
446 | class wxHtmlRenderingState | |
447 | { | |
448 | public: | |
449 | wxHtmlRenderingState(); | |
450 | ~wxHtmlRenderingState(); | |
451 | ||
452 | void SetSelectionState(wxHtmlSelectionState s); | |
453 | wxHtmlSelectionState GetSelectionState() const; | |
454 | ||
455 | void SetFgColour(const wxColour& c); | |
456 | const wxColour& GetFgColour() const; | |
457 | void SetBgColour(const wxColour& c); | |
458 | const wxColour& GetBgColour() const; | |
459 | }; | |
460 | ||
461 | ||
d14a1e28 | 462 | |
dd116e73 RD |
463 | // HTML rendering customization. This class is used when rendering wxHtmlCells |
464 | // as a callback: | |
465 | class wxHtmlRenderingStyle | |
466 | { | |
467 | public: | |
468 | virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0; | |
469 | virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0; | |
470 | }; | |
471 | ||
472 | // Standard style: | |
473 | class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle | |
474 | { | |
475 | public: | |
476 | virtual wxColour GetSelectedTextColour(const wxColour& clr); | |
477 | virtual wxColour GetSelectedTextBgColour(const wxColour& clr); | |
478 | }; | |
479 | ||
480 | ||
481 | ||
482 | // Information given to cells when drawing them. Contains rendering state, | |
483 | // selection information and rendering style object that can be used to | |
484 | // customize the output. | |
485 | class wxHtmlRenderingInfo | |
486 | { | |
487 | public: | |
488 | wxHtmlRenderingInfo(); | |
489 | ~wxHtmlRenderingInfo(); | |
490 | ||
491 | void SetSelection(wxHtmlSelection *s); | |
492 | wxHtmlSelection *GetSelection() const; | |
493 | ||
494 | void SetStyle(wxHtmlRenderingStyle *style); | |
495 | wxHtmlRenderingStyle& GetStyle(); | |
496 | ||
497 | wxHtmlRenderingState& GetState(); | |
498 | }; | |
499 | ||
500 | //--------------------------------------------------------------------------- | |
d14a1e28 | 501 | %newgroup |
dd116e73 | 502 | |
3ef86e32 RD |
503 | |
504 | enum | |
505 | { | |
506 | wxHTML_FIND_EXACT = 1, | |
507 | wxHTML_FIND_NEAREST_BEFORE = 2, | |
508 | wxHTML_FIND_NEAREST_AFTER = 4 | |
509 | }; | |
510 | ||
511 | ||
9416aa89 | 512 | class wxHtmlCell : public wxObject { |
e166644c | 513 | public: |
f0879a0a RD |
514 | %typemap(out) wxHtmlCell*; // turn off this typemap |
515 | ||
e166644c | 516 | wxHtmlCell(); |
226de48a | 517 | ~wxHtmlCell(); |
4725f47e | 518 | |
f0879a0a RD |
519 | // Turn it back on again |
520 | %typemap(out) wxHtmlCell* { $result = wxPyMake_wxObject($1, $owner); } | |
521 | ||
e166644c RD |
522 | int GetPosX(); |
523 | int GetPosY(); | |
524 | int GetWidth(); | |
525 | int GetHeight(); | |
526 | int GetDescent(); | |
0d267606 RD |
527 | |
528 | // Returns the maximum possible length of the cell. | |
529 | // Call Layout at least once before using GetMaxTotalWidth() | |
530 | int GetMaxTotalWidth() const; | |
42781abb | 531 | |
2678dd26 RD |
532 | const wxString& GetId() const; |
533 | void SetId(const wxString& id); | |
9c00cfa3 | 534 | wxHtmlLinkInfo* GetLink(int x = 0, int y = 0); |
e166644c | 535 | wxHtmlCell* GetNext(); |
9c00cfa3 | 536 | wxHtmlContainerCell* GetParent(); |
3ef86e32 RD |
537 | wxHtmlCell* GetFirstChild() const; |
538 | ||
4725f47e RD |
539 | // Returns cursor to be used when mouse is over the cell: |
540 | virtual wxCursor GetMouseCursor(wxHtmlWindowInterface *window) const; | |
541 | ||
3ef86e32 RD |
542 | // Returns cursor to be used when mouse is over the cell: |
543 | wxCursor GetCursor() const; | |
4725f47e | 544 | %pythoncode { GetCursor = wx._deprecated(GetCursor) } |
3ef86e32 RD |
545 | |
546 | // Formatting cells are not visible on the screen, they only alter | |
547 | // renderer's state. | |
548 | bool IsFormattingCell() const; | |
549 | ||
550 | ||
9c00cfa3 | 551 | void SetLink(const wxHtmlLinkInfo& link); |
226de48a RD |
552 | |
553 | %disownarg(wxHtmlCell*); | |
e166644c | 554 | void SetNext(wxHtmlCell *cell); |
226de48a | 555 | %cleardisown(wxHtmlCell*); |
4725f47e | 556 | |
9c00cfa3 RD |
557 | void SetParent(wxHtmlContainerCell *p); |
558 | void SetPos(int x, int y); | |
e166644c | 559 | void Layout(int w); |
dd116e73 RD |
560 | void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, |
561 | wxHtmlRenderingInfo& info); | |
562 | void DrawInvisible(wxDC& dc, int x, int y, | |
563 | wxHtmlRenderingInfo& info); | |
e166644c | 564 | const wxHtmlCell* Find(int condition, const void* param); |
dc2f8a65 | 565 | |
4725f47e RD |
566 | |
567 | virtual bool ProcessMouseClick(wxHtmlWindowInterface *window, | |
568 | const wxPoint& pos, | |
569 | const wxMouseEvent& event); | |
570 | ||
1fded56b | 571 | bool AdjustPagebreak(int* INOUT); |
dc2f8a65 | 572 | void SetCanLiveOnPagebreak(bool can); |
9c00cfa3 | 573 | |
3ef86e32 RD |
574 | // Can the line be broken before this cell? |
575 | bool IsLinebreakAllowed() const; | |
576 | ||
dd9f7fea | 577 | // Returns True for simple == terminal cells, i.e. not composite ones. |
3ef86e32 RD |
578 | // This if for internal usage only and may disappear in future versions! |
579 | bool IsTerminalCell() const; | |
580 | ||
581 | // Find a cell inside this cell positioned at the given coordinates | |
582 | // (relative to this's positions). Returns NULL if no such cell exists. | |
583 | // The flag can be used to specify whether to look for terminal or | |
584 | // nonterminal cells or both. In either case, returned cell is deepest | |
585 | // cell in cells tree that contains [x,y]. | |
586 | wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y, | |
587 | unsigned flags = wxHTML_FIND_EXACT) const; | |
588 | ||
589 | // Returns absolute position of the cell on HTML canvas | |
4725f47e RD |
590 | // If rootCell is provided, then it's considered to be the root of the |
591 | // hierarchy and the returned value is relative to it. | |
592 | wxPoint GetAbsPos(wxHtmlCell *rootCell = NULL) const; | |
593 | ||
594 | // Returns root cell of the hierarchy (i.e. grand-grand-...-parent that | |
595 | // doesn't have a parent itself) | |
596 | wxHtmlCell *GetRootCell() const; | |
3ef86e32 RD |
597 | |
598 | // Returns first (last) terminal cell inside this cell. It may return NULL, | |
599 | // but it is rare -- only if there are no terminals in the tree. | |
600 | wxHtmlCell *GetFirstTerminal() const ; | |
601 | wxHtmlCell *GetLastTerminal() const ; | |
602 | ||
603 | // Returns cell's depth, i.e. how far under the root cell it is | |
604 | // (if it is the root, depth is 0) | |
605 | unsigned GetDepth() const; | |
606 | ||
dd9f7fea | 607 | // Returns True if the cell appears before 'cell' in natural order of |
3ef86e32 | 608 | // cells (= as they are read). If cell A is (grand)parent of cell B, |
dd9f7fea | 609 | // then both A.IsBefore(B) and B.IsBefore(A) always return True. |
3ef86e32 RD |
610 | bool IsBefore(wxHtmlCell *cell) const; |
611 | ||
612 | // Converts the cell into text representation. If sel != NULL then | |
613 | // only part of the cell inside the selection is converted. | |
614 | wxString ConvertToText(wxHtmlSelection *sel) const; | |
e166644c RD |
615 | }; |
616 | ||
617 | ||
9416aa89 RD |
618 | class wxHtmlWordCell : public wxHtmlCell |
619 | { | |
620 | public: | |
621 | wxHtmlWordCell(const wxString& word, wxDC& dc); | |
f0879a0a RD |
622 | wxString ConvertToText(wxHtmlSelection *sel) const; |
623 | bool IsLinebreakAllowed() const; | |
624 | void SetPreviousWord(wxHtmlWordCell *cell); | |
9416aa89 RD |
625 | }; |
626 | ||
627 | ||
e166644c RD |
628 | class wxHtmlContainerCell : public wxHtmlCell { |
629 | public: | |
630 | wxHtmlContainerCell(wxHtmlContainerCell *parent); | |
631 | ||
226de48a | 632 | %disownarg(wxHtmlCell*); |
e166644c | 633 | void InsertCell(wxHtmlCell *cell); |
226de48a RD |
634 | %cleardisown(wxHtmlCell*); |
635 | ||
e166644c RD |
636 | void SetAlignHor(int al); |
637 | int GetAlignHor(); | |
638 | void SetAlignVer(int al); | |
639 | int GetAlignVer(); | |
9d8bd15f | 640 | void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS); |
e166644c RD |
641 | int GetIndent(int ind); |
642 | int GetIndentUnits(int ind); | |
643 | void SetAlign(const wxHtmlTag& tag); | |
644 | void SetWidthFloat(int w, int units); | |
1b8c7ba6 | 645 | %Rename(SetWidthFloatFromTag, void, SetWidthFloat(const wxHtmlTag& tag)); |
9d8bd15f | 646 | void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP); |
e166644c | 647 | void SetBackgroundColour(const wxColour& clr); |
1e4a197e | 648 | wxColour GetBackgroundColour(); |
e166644c | 649 | void SetBorder(const wxColour& clr1, const wxColour& clr2); |
dd116e73 RD |
650 | wxHtmlCell* GetFirstChild(); |
651 | %pragma(python) addtoclass = "GetFirstCell = GetFirstChild" | |
e166644c RD |
652 | }; |
653 | ||
654 | ||
655 | ||
9c00cfa3 RD |
656 | class wxHtmlColourCell : public wxHtmlCell { |
657 | public: | |
85f9dd19 | 658 | wxHtmlColourCell(const wxColour& clr, int flags = wxHTML_CLR_FOREGROUND); |
9c00cfa3 RD |
659 | |
660 | }; | |
661 | ||
662 | ||
9416aa89 RD |
663 | class wxHtmlFontCell : public wxHtmlCell |
664 | { | |
665 | public: | |
666 | wxHtmlFontCell(wxFont *font); | |
667 | }; | |
668 | ||
e166644c RD |
669 | |
670 | class wxHtmlWidgetCell : public wxHtmlCell { | |
671 | public: | |
672 | wxHtmlWidgetCell(wxWindow* wnd, int w = 0); | |
673 | ||
674 | }; | |
675 | ||
0f66a9f3 | 676 | |
d14a1e28 RD |
677 | |
678 | ||
0f66a9f3 | 679 | //--------------------------------------------------------------------------- |
1e4a197e RD |
680 | // wxHtmlFilter |
681 | //--------------------------------------------------------------------------- | |
d14a1e28 | 682 | %newgroup |
1e4a197e RD |
683 | |
684 | ||
685 | %{ // here's the C++ version | |
686 | class wxPyHtmlFilter : public wxHtmlFilter { | |
4617be08 | 687 | DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter) |
1e4a197e RD |
688 | public: |
689 | wxPyHtmlFilter() : wxHtmlFilter() {} | |
690 | ||
dd9f7fea | 691 | // returns True if this filter is able to open&read given file |
1e4a197e | 692 | virtual bool CanRead(const wxFSFile& file) const { |
a72f4631 | 693 | bool rval = false; |
1e4a197e | 694 | bool found; |
6e6b3557 | 695 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
1e4a197e | 696 | if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) { |
6d450e1a | 697 | PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false); // cast away const |
1e4a197e RD |
698 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); |
699 | Py_DECREF(obj); | |
700 | } | |
da32eb53 | 701 | wxPyEndBlockThreads(blocked); |
1e4a197e RD |
702 | return rval; |
703 | } | |
704 | ||
705 | ||
706 | // Reads given file and returns HTML document. | |
707 | // Returns empty string if opening failed | |
708 | virtual wxString ReadFile(const wxFSFile& file) const { | |
709 | wxString rval; | |
710 | bool found; | |
6e6b3557 | 711 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
1e4a197e | 712 | if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) { |
6d450e1a | 713 | PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false); // cast away const |
1e4a197e RD |
714 | PyObject* ro; |
715 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj)); | |
716 | Py_DECREF(obj); | |
717 | if (ro) { | |
718 | rval = Py2wxString(ro); | |
719 | Py_DECREF(ro); | |
720 | } | |
721 | } | |
da32eb53 | 722 | wxPyEndBlockThreads(blocked); |
1e4a197e RD |
723 | return rval; |
724 | } | |
725 | ||
726 | PYPRIVATE; | |
727 | }; | |
728 | ||
729 | IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter); | |
730 | %} | |
731 | ||
732 | ||
733 | // And now the version seen by SWIG | |
734 | ||
1b8c7ba6 RD |
735 | %rename(HtmlFilter) wxPyHtmlFilter; |
736 | class wxPyHtmlFilter : public wxObject { | |
1e4a197e | 737 | public: |
2b9048c5 | 738 | %pythonAppend wxPyHtmlFilter "self._setCallbackInfo(self, HtmlFilter)" |
1e4a197e RD |
739 | wxPyHtmlFilter(); |
740 | ||
741 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
1e4a197e RD |
742 | }; |
743 | ||
744 | ||
745 | // TODO: wxHtmlFilterHTML | |
746 | ||
747 | ||
0f66a9f3 | 748 | //--------------------------------------------------------------------------- |
4725f47e RD |
749 | |
750 | ||
751 | class wxHtmlWindowInterface | |
752 | { | |
753 | public: | |
754 | /// Ctor | |
755 | wxHtmlWindowInterface(); | |
756 | virtual ~wxHtmlWindowInterface(); | |
757 | ||
758 | /** | |
759 | Called by the parser to set window's title to given text. | |
760 | */ | |
761 | virtual void SetHTMLWindowTitle(const wxString& title) = 0; | |
762 | ||
763 | // /** | |
764 | // Called when a link is clicked. | |
765 | ||
766 | // @param link information about the clicked link | |
767 | // */ | |
768 | // virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link) = 0; | |
769 | ||
770 | // /** | |
771 | // Called when the parser needs to open another URL (e.g. an image). | |
772 | ||
773 | // @param type Type of the URL request (e.g. image) | |
774 | // @param url URL the parser wants to open | |
775 | // @param redirect If the return value is wxHTML_REDIRECT, then the | |
776 | // URL to redirect to will be stored in this variable | |
777 | // (the pointer must never be NULL) | |
778 | ||
779 | // @return indicator of how to treat the request | |
780 | // */ | |
781 | // virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type, | |
782 | // const wxString& url, | |
783 | // wxString *redirect) const = 0; | |
784 | ||
785 | /** | |
786 | Converts coordinates @a pos relative to given @a cell to | |
787 | physical coordinates in the window. | |
788 | */ | |
789 | virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell, | |
790 | const wxPoint& pos) const = 0; | |
791 | ||
792 | /// Returns the window used for rendering (may be NULL). | |
793 | virtual wxWindow* GetHTMLWindow() = 0; | |
794 | ||
795 | /// Returns background colour to use by default. | |
796 | virtual wxColour GetHTMLBackgroundColour() const = 0; | |
797 | ||
798 | /// Sets window's background to colour @a clr. | |
799 | virtual void SetHTMLBackgroundColour(const wxColour& clr) = 0; | |
800 | ||
801 | /// Sets window's background to given bitmap. | |
802 | virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg) = 0; | |
803 | ||
804 | /// Sets status bar text. | |
805 | virtual void SetHTMLStatusText(const wxString& text) = 0; | |
806 | ||
807 | /// Type of mouse cursor | |
808 | enum HTMLCursor | |
809 | { | |
810 | /// Standard mouse cursor (typically an arrow) | |
811 | HTMLCursor_Default, | |
812 | /// Cursor shown over links | |
813 | HTMLCursor_Link, | |
814 | /// Cursor shown over selectable text | |
815 | HTMLCursor_Text | |
816 | }; | |
817 | ||
818 | /** | |
819 | Returns mouse cursor of given @a type. | |
820 | */ | |
821 | // virtual wxCursor GetHTMLCursor(HTMLCursor type) const = 0; | |
822 | }; | |
823 | ||
824 | ||
825 | //--------------------------------------------------------------------------- | |
826 | // wxHtmlWindow | |
4b123bb9 | 827 | //--------------------------------------------------------------------------- |
d14a1e28 | 828 | %newgroup |
4b123bb9 | 829 | |
4725f47e RD |
830 | // TODO? |
831 | // wxHtmlWindowInterface and wxHtmlWindowMouseHelper | |
832 | ||
833 | ||
0f66a9f3 RD |
834 | %{ |
835 | class wxPyHtmlWindow : public wxHtmlWindow { | |
4617be08 | 836 | DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow) |
0f66a9f3 RD |
837 | public: |
838 | wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1, | |
839 | const wxPoint& pos = wxDefaultPosition, | |
840 | const wxSize& size = wxDefaultSize, | |
3ef86e32 | 841 | long style = wxHW_DEFAULT_STYLE, |
1e4a197e | 842 | const wxString& name = wxPyHtmlWindowNameStr) |
0f66a9f3 | 843 | : wxHtmlWindow(parent, id, pos, size, style, name) {}; |
7b7ac0ab | 844 | wxPyHtmlWindow() : wxHtmlWindow() {}; |
0f66a9f3 | 845 | |
e5d41db0 RD |
846 | bool ScrollToAnchor(const wxString& anchor) { |
847 | return wxHtmlWindow::ScrollToAnchor(anchor); | |
848 | } | |
849 | ||
850 | bool HasAnchor(const wxString& anchor) { | |
851 | const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor); | |
852 | return c!=NULL; | |
853 | } | |
854 | ||
c8bc03c3 | 855 | void OnLinkClicked(const wxHtmlLinkInfo& link); |
9c00cfa3 | 856 | |
e5d41db0 | 857 | wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type, |
c6c593e8 RD |
858 | const wxString& url, |
859 | wxString *redirect) const; | |
860 | ||
9c00cfa3 | 861 | DEC_PYCALLBACK__STRING(OnSetTitle); |
0122b7e3 | 862 | DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover); |
4725f47e RD |
863 | DEC_PYCALLBACK_BOOL_CELLINTINTME(OnCellClicked); |
864 | ||
0f66a9f3 RD |
865 | PYPRIVATE; |
866 | }; | |
867 | ||
cdf14688 | 868 | IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow ); |
9c00cfa3 | 869 | IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle); |
0122b7e3 | 870 | IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover); |
4725f47e | 871 | IMP_PYCALLBACK_BOOL_CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked); |
0122b7e3 | 872 | |
0f66a9f3 | 873 | |
9416aa89 | 874 | void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) { |
19a97bd6 | 875 | bool found; |
6e6b3557 | 876 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
0122b7e3 | 877 | if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) { |
1e4a197e | 878 | PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0); |
1e7ecb7b | 879 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); |
de20db99 | 880 | Py_DECREF(obj); |
9c00cfa3 | 881 | } |
da32eb53 | 882 | wxPyEndBlockThreads(blocked); |
19a97bd6 | 883 | if (! found) |
9c00cfa3 | 884 | wxHtmlWindow::OnLinkClicked(link); |
9c00cfa3 | 885 | } |
0122b7e3 | 886 | |
c6c593e8 RD |
887 | |
888 | wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type, | |
889 | const wxString& url, | |
890 | wxString *redirect) const { | |
891 | bool found; | |
892 | wxHtmlOpeningStatus rval; | |
6e6b3557 | 893 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
c6c593e8 RD |
894 | if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) { |
895 | PyObject* ro; | |
a66212dc RD |
896 | PyObject* s = wx2PyString(url); |
897 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s)); | |
898 | Py_DECREF(s); | |
c6c593e8 RD |
899 | if (PyString_Check(ro) |
900 | #if PYTHON_API_VERSION >= 1009 | |
901 | || PyUnicode_Check(ro) | |
902 | #endif | |
903 | ) { | |
a541c325 | 904 | *redirect = Py2wxString(ro); |
c6c593e8 RD |
905 | rval = wxHTML_REDIRECT; |
906 | } | |
907 | else { | |
908 | PyObject* num = PyNumber_Int(ro); | |
909 | rval = (wxHtmlOpeningStatus)PyInt_AsLong(num); | |
910 | Py_DECREF(num); | |
911 | } | |
912 | Py_DECREF(ro); | |
913 | } | |
da32eb53 | 914 | wxPyEndBlockThreads(blocked); |
c6c593e8 RD |
915 | if (! found) |
916 | rval = wxHtmlWindow::OnOpeningURL(type, url, redirect); | |
917 | return rval; | |
918 | } | |
919 | ||
920 | ||
0f66a9f3 RD |
921 | %} |
922 | ||
923 | ||
95837b4d | 924 | |
ab1f7d2a RD |
925 | MustHaveApp(wxPyHtmlWindow); |
926 | ||
1b8c7ba6 | 927 | %rename(HtmlWindow) wxPyHtmlWindow; |
4725f47e RD |
928 | class wxPyHtmlWindow : public wxScrolledWindow //, |
929 | // public wxHtmlWindowInterface //, | |
930 | // public wxHtmlWindowMouseHelper | |
931 | { | |
0f66a9f3 | 932 | public: |
2b9048c5 RD |
933 | %pythonAppend wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)" |
934 | %pythonAppend wxPyHtmlWindow() "" | |
b39c3fa0 | 935 | %typemap(out) wxPyHtmlWindow*; // turn off this typemap |
42781abb | 936 | |
0f66a9f3 | 937 | wxPyHtmlWindow(wxWindow *parent, int id = -1, |
d14a1e28 RD |
938 | const wxPoint& pos = wxDefaultPosition, |
939 | const wxSize& size = wxDefaultSize, | |
3ef86e32 | 940 | int style=wxHW_DEFAULT_STYLE, |
137b5242 | 941 | const wxString& name = wxPyHtmlWindowNameStr); |
1b8c7ba6 | 942 | %RenameCtor(PreHtmlWindow, wxPyHtmlWindow()); |
7b7ac0ab | 943 | |
b39c3fa0 RD |
944 | // Turn it back on again |
945 | %typemap(out) wxPyHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); } | |
946 | ||
7b7ac0ab | 947 | bool Create(wxWindow *parent, int id = -1, |
d14a1e28 RD |
948 | const wxPoint& pos = wxDefaultPosition, |
949 | const wxSize& size = wxDefaultSize, | |
fc51b8c3 | 950 | int style=wxHW_SCROLLBAR_AUTO, |
137b5242 | 951 | const wxString& name = wxPyHtmlWindowNameStr); |
7b7ac0ab | 952 | |
0f66a9f3 | 953 | |
0122b7e3 | 954 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
0f66a9f3 | 955 | |
42781abb | 956 | |
1e4a197e RD |
957 | // Set HTML page and display it. !! source is HTML document itself, |
958 | // it is NOT address/filename of HTML document. If you want to | |
959 | // specify document location, use LoadPage() istead | |
d6922577 | 960 | // Return value : False if an error occurred, True otherwise |
7a446686 | 961 | bool SetPage(const wxString& source); |
1e4a197e RD |
962 | |
963 | // Load HTML page from given location. Location can be either | |
964 | // a) /usr/wxGTK2/docs/html/wx.htm | |
965 | // b) http://www.somewhere.uk/document.htm | |
966 | // c) ftp://ftp.somesite.cz/pub/something.htm | |
967 | // In case there is no prefix (http:,ftp:), the method | |
968 | // will try to find it itself (1. local file, then http or ftp) | |
969 | // After the page is loaded, the method calls SetPage() to display it. | |
970 | // Note : you can also use path relative to previously loaded page | |
971 | // Return value : same as SetPage | |
7a446686 | 972 | bool LoadPage(const wxString& location); |
1e4a197e | 973 | |
9cbf6f6e | 974 | // Loads HTML page from file |
1fded56b | 975 | bool LoadFile(const wxString& filename); |
9cbf6f6e | 976 | |
1e4a197e | 977 | // Append to current page |
de112a55 | 978 | bool AppendToPage(const wxString& source); |
1e4a197e RD |
979 | |
980 | // Returns full location of opened page | |
0f66a9f3 | 981 | wxString GetOpenedPage(); |
1e4a197e RD |
982 | |
983 | // Returns anchor within opened page | |
7a446686 | 984 | wxString GetOpenedAnchor(); |
1e4a197e RD |
985 | |
986 | // Returns <TITLE> of opened page or empty string otherwise | |
7a446686 RD |
987 | wxString GetOpenedPageTitle(); |
988 | ||
1e4a197e RD |
989 | // Sets frame in which page title will be displayed. Format is format of |
990 | // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s | |
137b5242 | 991 | void SetRelatedFrame(wxFrame* frame, const wxString& format); |
0f66a9f3 | 992 | wxFrame* GetRelatedFrame(); |
1e4a197e RD |
993 | |
994 | // After(!) calling SetRelatedFrame, this sets statusbar slot where messages | |
995 | // will be displayed. Default is -1 = no messages. | |
0f66a9f3 | 996 | void SetRelatedStatusBar(int bar); |
f6bcfd97 | 997 | |
1e4a197e | 998 | // Sets fonts to be used when displaying HTML page. |
d14a1e28 | 999 | %extend { |
9cbf6f6e RD |
1000 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
1001 | int* temp = NULL; | |
1002 | if (sizes) temp = int_LIST_helper(sizes); | |
1003 | self->SetFonts(normal_face, fixed_face, temp); | |
1004 | if (temp) | |
f6bcfd97 | 1005 | delete [] temp; |
f6bcfd97 BP |
1006 | } |
1007 | } | |
1008 | ||
385721a8 RD |
1009 | // Sets font sizes to be relative to the given size or the system |
1010 | // default size; use either specified or default font | |
1011 | void SetStandardFonts(int size = -1, | |
1012 | const wxString& normal_face = wxPyEmptyString, | |
1013 | const wxString& fixed_face = wxPyEmptyString); | |
42781abb | 1014 | |
36c8c471 | 1015 | DocDeclStr( |
793b53a0 | 1016 | void, SetLabel(const wxString& title), |
d07d2bc9 | 1017 | "", ""); |
1e4a197e RD |
1018 | |
1019 | // Sets space between text and window borders. | |
0f66a9f3 | 1020 | void SetBorders(int b); |
1e4a197e | 1021 | |
3136b082 RD |
1022 | // Sets the bitmap to use for background (currnetly it will be tiled, |
1023 | // when/if we have CSS support we could add other possibilities...) | |
1024 | void SetBackgroundImage(const wxBitmap& bmpBg); | |
1025 | ||
1e4a197e RD |
1026 | // Saves custom settings into cfg config. it will use the path 'path' |
1027 | // if given, otherwise it will save info into currently selected path. | |
1028 | // saved values : things set by SetFonts, SetBorders. | |
137b5242 RD |
1029 | void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); |
1030 | void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
1e4a197e RD |
1031 | |
1032 | // Goes to previous/next page (in browsing history) | |
dd9f7fea | 1033 | // Returns True if successful, False otherwise |
0f66a9f3 RD |
1034 | bool HistoryBack(); |
1035 | bool HistoryForward(); | |
7a446686 RD |
1036 | bool HistoryCanBack(); |
1037 | bool HistoryCanForward(); | |
1e4a197e RD |
1038 | |
1039 | // Resets History | |
0f66a9f3 | 1040 | void HistoryClear(); |
1e4a197e RD |
1041 | |
1042 | // Returns pointer to conteiners/cells structure. | |
a65c6e14 | 1043 | wxHtmlContainerCell* GetInternalRepresentation(); |
1e4a197e RD |
1044 | |
1045 | // Returns a pointer to the parser. | |
e166644c RD |
1046 | wxHtmlWinParser* GetParser(); |
1047 | ||
e5d41db0 RD |
1048 | bool ScrollToAnchor(const wxString& anchor); |
1049 | bool HasAnchor(const wxString& anchor); | |
1050 | ||
1e4a197e RD |
1051 | //Adds input filter |
1052 | static void AddFilter(wxPyHtmlFilter *filter); | |
1053 | ||
927d7cfa RD |
1054 | // Helper functions to select parts of page: |
1055 | void SelectWord(const wxPoint& pos); | |
1056 | void SelectLine(const wxPoint& pos); | |
1057 | void SelectAll(); | |
1e4a197e | 1058 | |
31ad423e RD |
1059 | // Convert selection to text: |
1060 | wxString SelectionToText(); | |
1061 | ||
1062 | // Converts current page to text: | |
1063 | wxString ToText(); | |
42781abb | 1064 | |
a7a01418 RD |
1065 | void OnLinkClicked(const wxHtmlLinkInfo& link); |
1066 | void OnSetTitle(const wxString& title); | |
1067 | void OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y); | |
4725f47e | 1068 | bool OnCellClicked(wxHtmlCell *cell, |
a7a01418 RD |
1069 | wxCoord x, wxCoord y, |
1070 | const wxMouseEvent& event); | |
4725f47e RD |
1071 | wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type, |
1072 | const wxString& url, | |
1073 | wxString *redirect) const; | |
a7a01418 RD |
1074 | %MAKE_BASE_FUNC(HtmlWindow, OnLinkClicked); |
1075 | %MAKE_BASE_FUNC(HtmlWindow, OnSetTitle); | |
1076 | %MAKE_BASE_FUNC(HtmlWindow, OnCellMouseHover); | |
1077 | %MAKE_BASE_FUNC(HtmlWindow, OnCellClicked); | |
880715c9 RD |
1078 | |
1079 | static wxVisualAttributes | |
1080 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
4725f47e RD |
1081 | |
1082 | /// Type of mouse cursor | |
1083 | enum HTMLCursor | |
1084 | { | |
1085 | /// Standard mouse cursor (typically an arrow) | |
1086 | HTMLCursor_Default, | |
1087 | /// Cursor shown over links | |
1088 | HTMLCursor_Link, | |
1089 | /// Cursor shown over selectable text | |
1090 | HTMLCursor_Text | |
1091 | }; | |
1092 | ||
1093 | // Returns standard HTML cursor as used by wxHtmlWindow | |
1094 | static wxCursor GetDefaultHTMLCursor(HTMLCursor type); | |
1095 | ||
1096 | ||
1097 | // private: | |
1098 | // // wxHtmlWindowInterface methods: | |
1099 | // virtual void SetHTMLWindowTitle(const wxString& title); | |
1100 | // virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link); | |
1101 | // virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type, | |
1102 | // const wxString& url, | |
1103 | // wxString *redirect) const; | |
1104 | // virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell, | |
1105 | // const wxPoint& pos) const; | |
1106 | // virtual wxWindow* GetHTMLWindow(); | |
1107 | // virtual wxColour GetHTMLBackgroundColour() const; | |
1108 | // virtual void SetHTMLBackgroundColour(const wxColour& clr); | |
1109 | // virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg); | |
1110 | // virtual void SetHTMLStatusText(const wxString& text); | |
1111 | // virtual wxCursor GetHTMLCursor(HTMLCursor type) const; | |
1112 | ||
4b123bb9 HH |
1113 | }; |
1114 | ||
5ca24bf4 | 1115 | |
5ca24bf4 | 1116 | |
d14a1e28 | 1117 | |
dc2f8a65 RD |
1118 | //--------------------------------------------------------------------------- |
1119 | //--------------------------------------------------------------------------- | |
d14a1e28 | 1120 | %newgroup |
dc2f8a65 RD |
1121 | |
1122 | ||
ab1f7d2a RD |
1123 | MustHaveApp(wxHtmlDCRenderer); |
1124 | ||
9416aa89 | 1125 | class wxHtmlDCRenderer : public wxObject { |
dc2f8a65 RD |
1126 | public: |
1127 | wxHtmlDCRenderer(); | |
1128 | ~wxHtmlDCRenderer(); | |
1129 | ||
1130 | void SetDC(wxDC *dc, int maxwidth); | |
1131 | void SetSize(int width, int height); | |
1132 | void SetHtmlText(const wxString& html, | |
137b5242 | 1133 | const wxString& basepath = wxPyEmptyString, |
a72f4631 | 1134 | bool isdir = true); |
1fded56b | 1135 | // Sets fonts to be used when displaying HTML page. (if size null then default sizes used). |
d14a1e28 | 1136 | %extend { |
9cbf6f6e RD |
1137 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
1138 | int* temp = NULL; | |
1139 | if (sizes) temp = int_LIST_helper(sizes); | |
1140 | self->SetFonts(normal_face, fixed_face, temp); | |
1141 | if (temp) | |
1142 | delete [] temp; | |
1143 | } | |
1144 | } | |
7acd3625 | 1145 | |
385721a8 RD |
1146 | // Sets font sizes to be relative to the given size or the system |
1147 | // default size; use either specified or default font | |
1148 | void SetStandardFonts(int size = -1, | |
1149 | const wxString& normal_face = wxPyEmptyString, | |
1150 | const wxString& fixed_face = wxPyEmptyString); | |
42781abb | 1151 | |
020303e6 | 1152 | int Render(int x, int y, int from = 0, int dont_render = false, int maxHeight = INT_MAX, |
3ef86e32 RD |
1153 | //int *known_pagebreaks = NULL, int number_of_pages = 0 |
1154 | int* choices=NULL, int LCOUNT = 0 | |
1155 | ); | |
dc2f8a65 RD |
1156 | int GetTotalHeight(); |
1157 | // returns total height of the html document | |
1158 | // (compare Render's return value with this) | |
1159 | }; | |
1160 | ||
d14a1e28 | 1161 | |
dc2f8a65 RD |
1162 | enum { |
1163 | wxPAGE_ODD, | |
1164 | wxPAGE_EVEN, | |
1165 | wxPAGE_ALL | |
1166 | }; | |
1167 | ||
1168 | ||
ab1f7d2a RD |
1169 | MustHaveApp(wxHtmlPrintout); |
1170 | ||
dc2f8a65 RD |
1171 | class wxHtmlPrintout : public wxPyPrintout { |
1172 | public: | |
137b5242 | 1173 | wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr); |
f3d9dc1d | 1174 | //~wxHtmlPrintout(); wxPrintPreview object takes ownership... |
dc2f8a65 RD |
1175 | |
1176 | void SetHtmlText(const wxString& html, | |
137b5242 | 1177 | const wxString &basepath = wxPyEmptyString, |
a72f4631 | 1178 | bool isdir = true); |
dc2f8a65 RD |
1179 | void SetHtmlFile(const wxString &htmlfile); |
1180 | void SetHeader(const wxString& header, int pg = wxPAGE_ALL); | |
1181 | void SetFooter(const wxString& footer, int pg = wxPAGE_ALL); | |
42781abb | 1182 | |
1fded56b | 1183 | // Sets fonts to be used when displaying HTML page. (if size null then default sizes used). |
d14a1e28 | 1184 | %extend { |
9cbf6f6e RD |
1185 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
1186 | int* temp = NULL; | |
1187 | if (sizes) temp = int_LIST_helper(sizes); | |
1188 | self->SetFonts(normal_face, fixed_face, temp); | |
1189 | if (temp) | |
1190 | delete [] temp; | |
1191 | } | |
1192 | } | |
7acd3625 | 1193 | |
385721a8 RD |
1194 | // Sets font sizes to be relative to the given size or the system |
1195 | // default size; use either specified or default font | |
1196 | void SetStandardFonts(int size = -1, | |
1197 | const wxString& normal_face = wxPyEmptyString, | |
1198 | const wxString& fixed_face = wxPyEmptyString); | |
42781abb | 1199 | |
dc2f8a65 RD |
1200 | void SetMargins(float top = 25.2, float bottom = 25.2, |
1201 | float left = 25.2, float right = 25.2, | |
1202 | float spaces = 5); | |
3ef86e32 RD |
1203 | |
1204 | // Adds input filter | |
1205 | static void AddFilter(wxHtmlFilter *filter); | |
1206 | ||
1207 | // Cleanup | |
1208 | static void CleanUpStatics(); | |
dc2f8a65 RD |
1209 | }; |
1210 | ||
1211 | ||
1212 | ||
ab1f7d2a RD |
1213 | MustHaveApp(wxHtmlEasyPrinting); |
1214 | ||
9416aa89 | 1215 | class wxHtmlEasyPrinting : public wxObject { |
dc2f8a65 | 1216 | public: |
137b5242 | 1217 | wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr, |
3ef86e32 | 1218 | wxWindow *parentWindow = NULL); |
dc2f8a65 RD |
1219 | ~wxHtmlEasyPrinting(); |
1220 | ||
1221 | void PreviewFile(const wxString &htmlfile); | |
137b5242 | 1222 | void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString); |
dc2f8a65 | 1223 | void PrintFile(const wxString &htmlfile); |
137b5242 | 1224 | void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString); |
7aada1e0 | 1225 | // void PrinterSetup(); |
dc2f8a65 RD |
1226 | void PageSetup(); |
1227 | void SetHeader(const wxString& header, int pg = wxPAGE_ALL); | |
1228 | void SetFooter(const wxString& footer, int pg = wxPAGE_ALL); | |
1229 | ||
d14a1e28 | 1230 | %extend { |
9cbf6f6e RD |
1231 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
1232 | int* temp = NULL; | |
1233 | if (sizes) temp = int_LIST_helper(sizes); | |
1234 | self->SetFonts(normal_face, fixed_face, temp); | |
1235 | if (temp) | |
1236 | delete [] temp; | |
1237 | } | |
1238 | } | |
1239 | ||
385721a8 RD |
1240 | // Sets font sizes to be relative to the given size or the system |
1241 | // default size; use either specified or default font | |
1242 | void SetStandardFonts(int size = -1, | |
1243 | const wxString& normal_face = wxPyEmptyString, | |
1244 | const wxString& fixed_face = wxPyEmptyString); | |
42781abb | 1245 | |
dc2f8a65 RD |
1246 | wxPrintData *GetPrintData() {return m_PrintData;} |
1247 | wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;} | |
1248 | ||
1249 | }; | |
1250 | ||
1251 | ||
0f66a9f3 RD |
1252 | //--------------------------------------------------------------------------- |
1253 | //--------------------------------------------------------------------------- | |
d14a1e28 | 1254 | %newgroup |
5ca24bf4 | 1255 | |
4b123bb9 | 1256 | |
d14a1e28 RD |
1257 | class wxHtmlBookRecord { |
1258 | public: | |
1259 | wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath, | |
1260 | const wxString& title, const wxString& start); | |
4b123bb9 | 1261 | |
d14a1e28 RD |
1262 | wxString GetBookFile(); |
1263 | wxString GetTitle(); | |
1264 | wxString GetStart(); | |
1265 | wxString GetBasePath(); | |
1266 | ||
1267 | void SetContentsRange(int start, int end); | |
1268 | int GetContentsStart(); | |
1269 | int GetContentsEnd(); | |
4b123bb9 | 1270 | |
d14a1e28 RD |
1271 | void SetTitle(const wxString& title); |
1272 | void SetBasePath(const wxString& path); | |
1273 | void SetStart(const wxString& start); | |
1274 | ||
1275 | wxString GetFullPath(const wxString &page) const; | |
1276 | }; | |
1277 | ||
1278 | //--------------------------------------------------------------------------- | |
2f91e3df KO |
1279 | // WXWIN_COMPATIBILITY_2_4 |
1280 | #if 0 | |
d14a1e28 RD |
1281 | struct wxHtmlContentsItem |
1282 | { | |
1283 | %extend { | |
1284 | int GetLevel() { return self->m_Level; } | |
1285 | int GetID() { return self->m_ID; } | |
1286 | wxString GetName() { return self->m_Name; } | |
1287 | wxString GetPage() { return self->m_Page; } | |
1288 | wxHtmlBookRecord* GetBook() { return self->m_Book; } | |
1289 | } | |
1290 | }; | |
2f91e3df | 1291 | #endif |
d14a1e28 RD |
1292 | //--------------------------------------------------------------------------- |
1293 | ||
1294 | class wxHtmlSearchStatus | |
1295 | { | |
1296 | public: | |
1297 | //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword, | |
1298 | // const wxString& book = wxPyEmptyString); | |
1299 | bool Search(); | |
1300 | bool IsActive(); | |
1301 | int GetCurIndex(); | |
1302 | int GetMaxIndex(); | |
1303 | const wxString& GetName(); | |
d14a1e28 RD |
1304 | }; |
1305 | ||
1306 | //--------------------------------------------------------------------------- | |
1307 | ||
1308 | class wxHtmlHelpData { | |
1309 | public: | |
1310 | wxHtmlHelpData(); | |
1311 | ~wxHtmlHelpData(); | |
1312 | ||
1313 | void SetTempDir(const wxString& path); | |
1314 | bool AddBook(const wxString& book); | |
1315 | // bool AddBookParam(const wxString& title, const wxString& contfile, | |
1316 | // const wxString& indexfile=wxPyEmptyString, | |
1317 | // const wxString& deftopic=wxPyEmptyString, | |
1318 | // const wxString& path=wxPyEmptyString); | |
1319 | ||
1320 | wxString FindPageByName(const wxString& page); | |
1321 | wxString FindPageById(int id); | |
1322 | ||
1323 | // TODO: this one needs fixed... | |
1324 | const wxHtmlBookRecArray& GetBookRecArray(); | |
1325 | ||
d14a1e28 RD |
1326 | }; |
1327 | ||
1328 | //--------------------------------------------------------------------------- | |
1329 | ||
42781abb RD |
1330 | enum { |
1331 | wxHF_TOOLBAR, | |
1332 | wxHF_CONTENTS, | |
1333 | wxHF_INDEX, | |
1334 | wxHF_SEARCH, | |
1335 | wxHF_BOOKMARKS, | |
1336 | wxHF_OPEN_FILES, | |
1337 | wxHF_PRINT, | |
1338 | wxHF_FLAT_TOOLBAR, | |
1339 | wxHF_MERGE_BOOKS, | |
1340 | wxHF_ICONS_BOOK, | |
1341 | wxHF_ICONS_BOOK_CHAPTER, | |
1342 | wxHF_ICONS_FOLDER, | |
1343 | wxHF_DEFAULT_STYLE, | |
1344 | ||
1345 | wxHF_EMBEDDED, | |
1346 | wxHF_DIALOG, | |
1347 | wxHF_FRAME, | |
1348 | wxHF_MODAL, | |
1349 | }; | |
1350 | ||
1351 | enum { | |
1352 | wxID_HTML_PANEL, | |
1353 | wxID_HTML_BACK, | |
1354 | wxID_HTML_FORWARD, | |
1355 | wxID_HTML_UPNODE, | |
1356 | wxID_HTML_UP, | |
1357 | wxID_HTML_DOWN, | |
1358 | wxID_HTML_PRINT, | |
1359 | wxID_HTML_OPENFILE, | |
1360 | wxID_HTML_OPTIONS, | |
1361 | wxID_HTML_BOOKMARKSLIST, | |
1362 | wxID_HTML_BOOKMARKSADD, | |
1363 | wxID_HTML_BOOKMARKSREMOVE, | |
1364 | wxID_HTML_TREECTRL, | |
1365 | wxID_HTML_INDEXPAGE, | |
1366 | wxID_HTML_INDEXLIST, | |
1367 | wxID_HTML_INDEXTEXT, | |
1368 | wxID_HTML_INDEXBUTTON, | |
1369 | wxID_HTML_INDEXBUTTONALL, | |
1370 | wxID_HTML_NOTEBOOK, | |
1371 | wxID_HTML_SEARCHPAGE, | |
1372 | wxID_HTML_SEARCHTEXT, | |
1373 | wxID_HTML_SEARCHLIST, | |
1374 | wxID_HTML_SEARCHBUTTON, | |
1375 | wxID_HTML_SEARCHCHOICE, | |
1376 | wxID_HTML_COUNTINFO | |
4725f47e | 1377 | }; |
42781abb RD |
1378 | |
1379 | ||
1380 | ||
1381 | MustHaveApp(wxHtmlHelpWindow); | |
1382 | ||
1383 | class wxHtmlHelpWindow : public wxWindow | |
1384 | { | |
1385 | public: | |
1386 | %pythonAppend wxHtmlHelpWindow "self._setOORInfo(self)" | |
1387 | %pythonAppend wxHtmlHelpWindow() "" | |
1388 | %typemap(out) wxHtmlHelpWindow*; // turn off this typemap | |
1389 | ||
1390 | wxHtmlHelpWindow(wxWindow* parent, wxWindowID wxWindowID, | |
1391 | const wxPoint& pos = wxDefaultPosition, | |
1392 | const wxSize& size = wxDefaultSize, | |
1393 | int style = wxTAB_TRAVERSAL|wxNO_BORDER, | |
1394 | int helpStyle = wxHF_DEFAULT_STYLE, | |
1395 | wxHtmlHelpData* data = NULL); | |
1396 | %RenameCtor(PreHtmlHelpWindow, wxHtmlHelpWindow(wxHtmlHelpData* data = NULL)); | |
4725f47e | 1397 | |
42781abb RD |
1398 | // Turn it back on again |
1399 | %typemap(out) wxHtmlHelpWindow* { $result = wxPyMake_wxObject($1, $owner); } | |
1400 | ||
1401 | bool Create(wxWindow* parent, wxWindowID id, | |
1402 | const wxPoint& pos = wxDefaultPosition, | |
1403 | const wxSize& size = wxDefaultSize, | |
1404 | int style = wxTAB_TRAVERSAL|wxNO_BORDER, | |
1405 | int helpStyle = wxHF_DEFAULT_STYLE); | |
1406 | ||
1407 | wxHtmlHelpData* GetData(); | |
1408 | wxHtmlHelpController* GetController() const; | |
214c4fbe RD |
1409 | |
1410 | %disownarg( wxHtmlHelpController* controller ); | |
42781abb | 1411 | void SetController(wxHtmlHelpController* controller); |
214c4fbe | 1412 | %cleardisown( wxHtmlHelpController* controller ); |
42781abb RD |
1413 | |
1414 | // Displays page x. If not found it will offect the user a choice of | |
1415 | // searching books. | |
1416 | // Looking for the page runs in these steps: | |
1417 | // 1. try to locate file named x (if x is for example "doc/howto.htm") | |
1418 | // 2. try to open starting page of book x | |
1419 | // 3. try to find x in contents (if x is for example "How To ...") | |
1420 | // 4. try to find x in index (if x is for example "How To ...") | |
1421 | bool Display(const wxString& x); | |
1422 | ||
1423 | // Alternative version that works with numeric ID. | |
1424 | // (uses extension to MS format, <param name="ID" value=id>, see docs) | |
1425 | %Rename(DisplayID, bool, Display(int id)); | |
1426 | ||
1427 | // Displays help window and focuses contents. | |
1428 | bool DisplayContents(); | |
1429 | ||
1430 | // Displays help window and focuses index. | |
1431 | bool DisplayIndex(); | |
1432 | ||
1433 | // Searches for keyword. Returns true and display page if found, return | |
1434 | // false otherwise | |
1435 | // Syntax of keyword is Altavista-like: | |
1436 | // * words are separated by spaces | |
1437 | // (but "\"hello world\"" is only one world "hello world") | |
1438 | // * word may be pretended by + or - | |
1439 | // (+ : page must contain the word ; - : page can't contain the word) | |
1440 | // * if there is no + or - before the word, + is default | |
1441 | bool KeywordSearch(const wxString& keyword, | |
1442 | wxHelpSearchMode mode = wxHELP_SEARCH_ALL); | |
1443 | ||
1444 | void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString); | |
1445 | ||
1446 | // Saves custom settings into cfg config. it will use the path 'path' | |
1447 | // if given, otherwise it will save info into currently selected path. | |
1448 | // saved values : things set by SetFonts, SetBorders. | |
1449 | void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString); | |
1450 | void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString); | |
1451 | ||
1452 | // call this to let wxHtmlHelpWindow know page changed | |
1453 | void NotifyPageChanged(); | |
1454 | ||
1455 | // Refreshes Contents and Index tabs | |
1456 | void RefreshLists(); | |
1457 | ||
1458 | // Gets the HTML window | |
1459 | wxHtmlWindow* GetHtmlWindow() const; | |
1460 | ||
1461 | // Gets the splitter window | |
1462 | wxSplitterWindow* GetSplitterWindow(); | |
1463 | ||
1464 | // Gets the toolbar | |
1465 | wxToolBar* GetToolBar() const; | |
1466 | ||
1467 | // Gets the configuration data | |
1468 | wxHtmlHelpFrameCfg& GetCfgData(); | |
1469 | ||
1470 | // Gets the tree control | |
1471 | wxTreeCtrl *GetTreeCtrl() const; | |
1472 | ||
1473 | }; | |
1474 | ||
1475 | ||
1476 | class wxHtmlWindowEvent: public wxNotifyEvent | |
1477 | { | |
1478 | public: | |
1479 | wxHtmlWindowEvent(wxEventType commandType = wxEVT_NULL, int id = 0): | |
1480 | wxNotifyEvent(commandType, id); | |
1481 | ||
1482 | void SetURL(const wxString& url); | |
1483 | const wxString& GetURL() const; | |
1484 | }; | |
1485 | ||
1486 | ||
1487 | ||
ab1f7d2a RD |
1488 | MustHaveApp(wxHtmlHelpFrame); |
1489 | ||
d14a1e28 RD |
1490 | class wxHtmlHelpFrame : public wxFrame { |
1491 | public: | |
2b9048c5 | 1492 | %pythonAppend wxHtmlHelpFrame "self._setOORInfo(self)" |
42781abb RD |
1493 | %pythonAppend wxHtmlHelpFrame() "" |
1494 | %typemap(out) wxHtmlHelpFrame*; // turn off this typemap | |
1495 | ||
d14a1e28 RD |
1496 | wxHtmlHelpFrame(wxWindow* parent, int wxWindowID, |
1497 | const wxString& title = wxPyEmptyString, | |
1498 | int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL); | |
42781abb RD |
1499 | %RenameCtor(PreHtmlHelpFrame, wxHtmlHelpFrame(wxHtmlHelpData* data = NULL)); |
1500 | ||
1501 | // Turn it back on again | |
1502 | %typemap(out) wxHtmlHelpFrame* { $result = wxPyMake_wxObject($1, $owner); } | |
4725f47e | 1503 | |
42781abb RD |
1504 | bool Create(wxWindow* parent, wxWindowID id, |
1505 | const wxString& title = wxPyEmptyString, | |
1506 | int style = wxHF_DEFAULT_STYLE); | |
d14a1e28 RD |
1507 | |
1508 | wxHtmlHelpData* GetData(); | |
1509 | void SetTitleFormat(const wxString& format); | |
42781abb RD |
1510 | |
1511 | void AddGrabIfNeeded(); | |
1512 | ||
1513 | /// Returns the help controller associated with the window. | |
1514 | wxHtmlHelpController* GetController() const; | |
1515 | ||
1516 | /// Sets the help controller associated with the window. | |
214c4fbe | 1517 | %disownarg( wxHtmlHelpController* controller ); |
42781abb | 1518 | void SetController(wxHtmlHelpController* controller); |
214c4fbe | 1519 | %cleardisown( wxHtmlHelpController* controller ); |
42781abb RD |
1520 | |
1521 | /// Returns the help window. | |
1522 | wxHtmlHelpWindow* GetHelpWindow() const; | |
1523 | ||
1524 | %pythoncode { | |
1525 | %# For compatibility from before the refactor | |
1526 | def Display(self, x): | |
1527 | return self.GetHelpWindow().Display(x) | |
1528 | def DisplayID(self, x): | |
1529 | return self.GetHelpWindow().DisplayID(id) | |
1530 | def DisplayContents(self): | |
1531 | return self.GetHelpWindow().DisplayContents() | |
1532 | def DisplayIndex(self): | |
1533 | return self.GetHelpWindow().DisplayIndex() | |
1534 | ||
1535 | def KeywordSearch(self, keyword): | |
1536 | return self.GetHelpWindow().KeywordSearch(keyword) | |
4725f47e | 1537 | |
42781abb RD |
1538 | def UseConfig(self, config, rootpath=""): |
1539 | return self.GetHelpWindow().UseConfig(config, rootpath) | |
1540 | def ReadCustomization(self, config, rootpath=""): | |
1541 | return self.GetHelpWindow().ReadCustomization(config, rootpath) | |
1542 | def WriteCustomization(self, config, rootpath=""): | |
1543 | return self.GetHelpWindow().WriteCustomization(config, rootpath) | |
1544 | %} | |
1545 | }; | |
1546 | ||
1547 | ||
1548 | ||
1549 | MustHaveApp(wxHtmlHelpDialog); | |
1550 | ||
1551 | class wxHtmlHelpDialog : public wxDialog | |
1552 | { | |
1553 | public: | |
1554 | %pythonAppend wxHtmlHelpDialog "self._setOORInfo(self)" | |
1555 | %pythonAppend wxHtmlHelpDialog() "" | |
1556 | %typemap(out) wxHtmlHelpDialog*; // turn off this typemap | |
1557 | ||
1558 | wxHtmlHelpDialog(wxWindow* parent, wxWindowID wxWindowID, | |
1559 | const wxString& title = wxPyEmptyString, | |
1560 | int style = wxHF_DEFAULT_STYLE, wxHtmlHelpData* data = NULL); | |
1561 | %RenameCtor(PreHtmlHelpDialog, wxHtmlHelpDialog(wxHtmlHelpData* data = NULL)); | |
1562 | ||
1563 | // Turn it back on again | |
1564 | %typemap(out) wxHtmlHelpDialog* { $result = wxPyMake_wxObject($1, $owner); } | |
4725f47e | 1565 | |
42781abb RD |
1566 | bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxPyEmptyString, |
1567 | int style = wxHF_DEFAULT_STYLE); | |
1568 | ||
1569 | /// Returns the data associated with this dialog. | |
1570 | wxHtmlHelpData* GetData(); | |
1571 | ||
1572 | /// Returns the controller that created this dialog. | |
1573 | wxHtmlHelpController* GetController() const; | |
1574 | ||
1575 | /// Sets the controller associated with this dialog. | |
214c4fbe | 1576 | %disownarg( wxHtmlHelpController* controller ); |
42781abb | 1577 | void SetController(wxHtmlHelpController* controller); |
214c4fbe | 1578 | %cleardisown( wxHtmlHelpController* controller ); |
42781abb RD |
1579 | |
1580 | /// Returns the help window. | |
1581 | wxHtmlHelpWindow* GetHelpWindow() const; | |
1582 | ||
1583 | // Sets format of title of the frame. Must contain exactly one "%s" | |
1584 | // (for title of displayed HTML page) | |
1585 | void SetTitleFormat(const wxString& format); | |
1586 | ||
1587 | // Override to add custom buttons to the toolbar | |
1588 | // virtual void AddToolbarButtons(wxToolBar* WXUNUSED(toolBar), int WXUNUSED(style)) {}; | |
1589 | ||
d14a1e28 RD |
1590 | }; |
1591 | ||
1592 | ||
1593 | //--------------------------------------------------------------------------- | |
1594 | ||
1595 | ||
42781abb RD |
1596 | // TODO: Make virtual methods of this class overridable in Python. |
1597 | ||
1598 | MustHaveApp(wxHelpControllerBase); | |
1599 | ||
1600 | class wxHelpControllerBase: public wxObject | |
1601 | { | |
1602 | public: | |
1603 | // wxHelpControllerBase(wxWindow* parentWindow = NULL); | |
1604 | // ~wxHelpControllerBase(); | |
1605 | ||
1606 | %nokwargs Initialize; | |
1607 | virtual bool Initialize(const wxString& file, int server ); | |
1608 | virtual bool Initialize(const wxString& file); | |
1609 | ||
1610 | virtual void SetViewer(const wxString& viewer, long flags = 0); | |
1611 | ||
1612 | // If file is "", reloads file given in Initialize | |
1613 | virtual bool LoadFile(const wxString& file = wxEmptyString) /* = 0 */; | |
1614 | ||
1615 | // Displays the contents | |
1616 | virtual bool DisplayContents(void) /* = 0 */; | |
1617 | ||
1618 | %nokwargs DisplaySection; | |
1619 | ||
1620 | // Display the given section | |
1621 | virtual bool DisplaySection(int sectionNo) /* = 0 */; | |
1622 | ||
1623 | // Display the section using a context id | |
1624 | virtual bool DisplayContextPopup(int contextId); | |
1625 | ||
1626 | // Display the text in a popup, if possible | |
1627 | virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos); | |
1628 | ||
1629 | // By default, uses KeywordSection to display a topic. Implementations | |
1630 | // may override this for more specific behaviour. | |
1631 | virtual bool DisplaySection(const wxString& section); | |
1632 | ||
1633 | virtual bool DisplayBlock(long blockNo) /* = 0 */; | |
1634 | virtual bool KeywordSearch(const wxString& k, | |
1635 | wxHelpSearchMode mode = wxHELP_SEARCH_ALL) /* = 0 */; | |
1636 | ||
1637 | /// Allows one to override the default settings for the help frame. | |
1638 | virtual void SetFrameParameters(const wxString& title, | |
1639 | const wxSize& size, | |
1640 | const wxPoint& pos = wxDefaultPosition, | |
1641 | bool newFrameEachTime = false); | |
1642 | ||
1643 | /// Obtains the latest settings used by the help frame and the help | |
1644 | /// frame. | |
1645 | virtual wxFrame *GetFrameParameters(wxSize *size = NULL, | |
1646 | wxPoint *pos = NULL, | |
1647 | bool *newFrameEachTime = NULL); | |
1648 | ||
1649 | virtual bool Quit() /* = 0 */; | |
1650 | ||
1651 | virtual void OnQuit(); | |
1652 | ||
1653 | /// Set the window that can optionally be used for the help window's parent. | |
1654 | virtual void SetParentWindow(wxWindow* win); | |
1655 | ||
1656 | /// Get the window that can optionally be used for the help window's parent. | |
1657 | virtual wxWindow* GetParentWindow() const; | |
80667df3 | 1658 | |
d14a1e28 RD |
1659 | }; |
1660 | ||
1661 | ||
42781abb RD |
1662 | |
1663 | ||
ab1f7d2a RD |
1664 | MustHaveApp(wxHtmlHelpController); |
1665 | ||
42781abb | 1666 | class wxHtmlHelpController : public wxHelpControllerBase |
3b03eb99 | 1667 | { |
d14a1e28 | 1668 | public: |
3b03eb99 | 1669 | // %pythonAppend wxHtmlHelpController "self._setOORInfo(self)" |
42781abb RD |
1670 | |
1671 | wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE, wxWindow* parentWindow = NULL); | |
d14a1e28 RD |
1672 | ~wxHtmlHelpController(); |
1673 | ||
42781abb RD |
1674 | wxHtmlHelpWindow* GetHelpWindow(); |
1675 | void SetHelpWindow(wxHtmlHelpWindow* helpWindow); | |
1676 | ||
80667df3 RD |
1677 | wxHtmlHelpFrame* GetFrame(); |
1678 | wxHtmlHelpDialog* GetDialog(); | |
1679 | ||
d14a1e28 RD |
1680 | void SetTitleFormat(const wxString& format); |
1681 | void SetTempDir(const wxString& path); | |
a72f4631 | 1682 | bool AddBook(const wxString& book, int show_wait_msg = false); |
d14a1e28 | 1683 | void Display(const wxString& x); |
1b8c7ba6 | 1684 | %Rename(DisplayID, void, Display(int id)); |
d14a1e28 RD |
1685 | void DisplayContents(); |
1686 | void DisplayIndex(); | |
1687 | bool KeywordSearch(const wxString& keyword); | |
1688 | void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString); | |
1689 | void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
1690 | void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
42781abb RD |
1691 | |
1692 | void MakeModalIfNeeded(); | |
1693 | wxWindow* FindTopLevelWindow(); | |
d14a1e28 RD |
1694 | }; |
1695 | ||
1696 | ||
42781abb RD |
1697 | /* |
1698 | * wxHtmlModalHelp | |
1699 | * A convenience class particularly for use on wxMac, | |
1700 | * where you can only show modal dialogs from a modal | |
1701 | * dialog. | |
1702 | * | |
1703 | * Use like this: | |
1704 | * | |
1705 | * wxHtmlModalHelp help(parent, filename, topic); | |
1706 | * | |
1707 | * If topic is empty, the help contents is displayed. | |
1708 | */ | |
1709 | ||
1710 | class wxHtmlModalHelp | |
1711 | { | |
1712 | public: | |
1713 | wxHtmlModalHelp(wxWindow* parent, const wxString& helpFile, | |
1714 | const wxString& topic = wxEmptyString, | |
1715 | int style = wxHF_DEFAULT_STYLE | wxHF_DIALOG | wxHF_MODAL); | |
1716 | }; | |
d14a1e28 RD |
1717 | |
1718 | ||
1719 | //--------------------------------------------------------------------------- | |
1720 | %init %{ | |
1721 | wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler"); | |
9416aa89 | 1722 | wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler"); |
d14a1e28 RD |
1723 | wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow"); |
1724 | wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter"); | |
4b123bb9 | 1725 | %} |
d14a1e28 RD |
1726 | //--------------------------------------------------------------------------- |
1727 | //--------------------------------------------------------------------------- | |
4b123bb9 | 1728 | |
e166644c | 1729 | |
e166644c | 1730 |