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