]>
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> |
4b123bb9 | 28 | |
137b5242 RD |
29 | %} |
30 | ||
b2dc1044 | 31 | |
0f66a9f3 | 32 | //--------------------------------------------------------------------------- |
e166644c | 33 | |
d14a1e28 | 34 | %import windows.i |
54f9ee45 | 35 | %pythoncode { wx = _core } |
99109c0f | 36 | %pythoncode { __docfilter__ = wx.__DocFilter(globals()) } |
d14a1e28 RD |
37 | |
38 | %include _html_rename.i | |
39 | ||
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 | ||
50 | //--------------------------------------------------------------------------- | |
51 | //--------------------------------------------------------------------------- | |
52 | %newgroup | |
53 | ||
54 | ||
e166644c | 55 | enum { |
9d8bd15f RD |
56 | wxHTML_ALIGN_LEFT, |
57 | wxHTML_ALIGN_CENTER, | |
58 | wxHTML_ALIGN_RIGHT, | |
59 | wxHTML_ALIGN_BOTTOM, | |
60 | wxHTML_ALIGN_TOP, | |
61 | ||
62 | wxHTML_CLR_FOREGROUND, | |
63 | wxHTML_CLR_BACKGROUND, | |
64 | ||
65 | wxHTML_UNITS_PIXELS, | |
66 | wxHTML_UNITS_PERCENT, | |
67 | ||
68 | wxHTML_INDENT_LEFT, | |
69 | wxHTML_INDENT_RIGHT, | |
70 | wxHTML_INDENT_TOP, | |
71 | wxHTML_INDENT_BOTTOM, | |
72 | ||
73 | wxHTML_INDENT_HORIZONTAL, | |
74 | wxHTML_INDENT_VERTICAL, | |
75 | wxHTML_INDENT_ALL, | |
76 | ||
77 | wxHTML_COND_ISANCHOR, | |
78 | wxHTML_COND_ISIMAGEMAP, | |
79 | wxHTML_COND_USER, | |
4eeb5705 RD |
80 | |
81 | ||
82 | wxHTML_FONT_SIZE_1, | |
83 | wxHTML_FONT_SIZE_2, | |
84 | wxHTML_FONT_SIZE_3, | |
85 | wxHTML_FONT_SIZE_4, | |
86 | wxHTML_FONT_SIZE_5, | |
87 | wxHTML_FONT_SIZE_6, | |
88 | wxHTML_FONT_SIZE_7, | |
e166644c RD |
89 | }; |
90 | ||
91 | ||
c6c593e8 RD |
92 | enum { |
93 | wxHW_SCROLLBAR_NEVER, | |
94 | wxHW_SCROLLBAR_AUTO, | |
3ef86e32 RD |
95 | wxHW_NO_SELECTION, |
96 | wxHW_DEFAULT_STYLE, | |
c6c593e8 RD |
97 | }; |
98 | ||
99 | ||
100 | // enums for wxHtmlWindow::OnOpeningURL | |
101 | enum wxHtmlOpeningStatus | |
102 | { | |
103 | wxHTML_OPEN, | |
104 | wxHTML_BLOCK, | |
105 | wxHTML_REDIRECT | |
106 | }; | |
107 | ||
108 | enum wxHtmlURLType | |
109 | { | |
110 | wxHTML_URL_PAGE, | |
111 | wxHTML_URL_IMAGE, | |
112 | wxHTML_URL_OTHER | |
113 | }; | |
114 | ||
d14a1e28 RD |
115 | |
116 | ||
9c00cfa3 RD |
117 | //--------------------------------------------------------------------------- |
118 | ||
9416aa89 | 119 | class wxHtmlLinkInfo : public wxObject { |
9c00cfa3 | 120 | public: |
137b5242 | 121 | wxHtmlLinkInfo(const wxString& href, const wxString& target = wxPyEmptyString); |
9c00cfa3 RD |
122 | wxString GetHref(); |
123 | wxString GetTarget(); | |
c8bc03c3 RD |
124 | wxMouseEvent* GetEvent(); |
125 | wxHtmlCell* GetHtmlCell(); | |
7a446686 RD |
126 | |
127 | void SetEvent(const wxMouseEvent *e); | |
128 | void SetHtmlCell(const wxHtmlCell * e); | |
9c00cfa3 RD |
129 | }; |
130 | ||
0f66a9f3 RD |
131 | //--------------------------------------------------------------------------- |
132 | ||
9416aa89 | 133 | class wxHtmlTag : public wxObject { |
0f66a9f3 | 134 | public: |
e166644c | 135 | // Never need to create a new tag from Python... |
0f66a9f3 RD |
136 | //wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache); |
137 | ||
138 | wxString GetName(); | |
139 | bool HasParam(const wxString& par); | |
a72f4631 | 140 | wxString GetParam(const wxString& par, int with_commas = false); |
0f66a9f3 RD |
141 | |
142 | // Can't do this one as-is, but GetParam should be enough... | |
143 | //int ScanParam(const wxString& par, const char *format, void* param); | |
144 | ||
145 | wxString GetAllParams(); | |
0f66a9f3 RD |
146 | bool HasEnding(); |
147 | int GetBeginPos(); | |
148 | int GetEndPos1(); | |
149 | int GetEndPos2(); | |
150 | }; | |
151 | ||
0f66a9f3 RD |
152 | //--------------------------------------------------------------------------- |
153 | ||
9416aa89 | 154 | class wxHtmlParser : public wxObject { |
0f66a9f3 RD |
155 | public: |
156 | // wxHtmlParser(); This is an abstract base class... | |
157 | ||
158 | void SetFS(wxFileSystem *fs); | |
159 | wxFileSystem* GetFS(); | |
160 | wxObject* Parse(const wxString& source); | |
161 | void InitParser(const wxString& source); | |
162 | void DoneParser(); | |
163 | void DoParsing(int begin_pos, int end_pos); | |
1e4a197e | 164 | void StopParsing(); |
0f66a9f3 | 165 | // wxObject* GetProduct(); |
1e4a197e | 166 | |
0f66a9f3 RD |
167 | void AddTagHandler(wxHtmlTagHandler *handler); |
168 | wxString* GetSource(); | |
dc2f8a65 RD |
169 | void PushTagHandler(wxHtmlTagHandler* handler, wxString tags); |
170 | void PopTagHandler(); | |
0f66a9f3 | 171 | |
c6c593e8 | 172 | // virtual wxFSFile *OpenURL(wxHtmlURLType type, const wxString& url) const; |
0f66a9f3 RD |
173 | |
174 | // void AddText(const char* txt) = 0; | |
175 | // void AddTag(const wxHtmlTag& tag); | |
176 | }; | |
177 | ||
178 | ||
179 | //--------------------------------------------------------------------------- | |
180 | ||
181 | class wxHtmlWinParser : public wxHtmlParser { | |
182 | public: | |
1fded56b | 183 | wxHtmlWinParser(wxPyHtmlWindow *wnd = NULL); |
0f66a9f3 RD |
184 | |
185 | void SetDC(wxDC *dc); | |
186 | wxDC* GetDC(); | |
187 | int GetCharHeight(); | |
188 | int GetCharWidth(); | |
1fded56b | 189 | wxPyHtmlWindow* GetWindow(); |
d14a1e28 | 190 | |
1fded56b | 191 | // Sets fonts to be used when displaying HTML page. (if size null then default sizes used). |
d14a1e28 | 192 | %extend { |
9cbf6f6e RD |
193 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
194 | int* temp = NULL; | |
195 | if (sizes) temp = int_LIST_helper(sizes); | |
196 | self->SetFonts(normal_face, fixed_face, temp); | |
197 | if (temp) | |
f6bcfd97 | 198 | delete [] temp; |
f6bcfd97 BP |
199 | } |
200 | } | |
0f66a9f3 | 201 | |
385721a8 RD |
202 | // Sets font sizes to be relative to the given size or the system |
203 | // default size; use either specified or default font | |
204 | void SetStandardFonts(int size = -1, | |
205 | const wxString& normal_face = wxPyEmptyString, | |
206 | const wxString& fixed_face = wxPyEmptyString); | |
207 | ||
7acd3625 | 208 | |
0f66a9f3 RD |
209 | wxHtmlContainerCell* GetContainer(); |
210 | wxHtmlContainerCell* OpenContainer(); | |
dc2f8a65 | 211 | wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c); |
0f66a9f3 | 212 | wxHtmlContainerCell* CloseContainer(); |
dc2f8a65 | 213 | |
0f66a9f3 RD |
214 | int GetFontSize(); |
215 | void SetFontSize(int s); | |
216 | int GetFontBold(); | |
217 | void SetFontBold(int x); | |
218 | int GetFontItalic(); | |
219 | void SetFontItalic(int x); | |
220 | int GetFontUnderlined(); | |
221 | void SetFontUnderlined(int x); | |
222 | int GetFontFixed(); | |
223 | void SetFontFixed(int x); | |
224 | int GetAlign(); | |
225 | void SetAlign(int a); | |
c5943253 | 226 | wxColour GetLinkColor(); |
0f66a9f3 | 227 | void SetLinkColor(const wxColour& clr); |
c5943253 | 228 | wxColour GetActualColor(); |
0f66a9f3 | 229 | void SetActualColor(const wxColour& clr); |
0f66a9f3 RD |
230 | void SetLink(const wxString& link); |
231 | wxFont* CreateCurrentFont(); | |
9c00cfa3 RD |
232 | wxHtmlLinkInfo GetLink(); |
233 | ||
0f66a9f3 RD |
234 | }; |
235 | ||
236 | ||
0f66a9f3 RD |
237 | //--------------------------------------------------------------------------- |
238 | ||
239 | %{ | |
240 | class wxPyHtmlTagHandler : public wxHtmlTagHandler { | |
9416aa89 | 241 | DECLARE_DYNAMIC_CLASS(wxPyHtmlTagHandler); |
0f66a9f3 RD |
242 | public: |
243 | wxPyHtmlTagHandler() : wxHtmlTagHandler() {}; | |
244 | ||
245 | wxHtmlParser* GetParser() { return m_Parser; } | |
246 | void ParseInner(const wxHtmlTag& tag) { wxHtmlTagHandler::ParseInner(tag); } | |
247 | ||
248 | DEC_PYCALLBACK_STRING__pure(GetSupportedTags); | |
249 | DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag); | |
250 | ||
251 | PYPRIVATE; | |
252 | }; | |
253 | ||
9416aa89 RD |
254 | IMPLEMENT_DYNAMIC_CLASS(wxPyHtmlTagHandler, wxHtmlTagHandler); |
255 | ||
0f66a9f3 RD |
256 | IMP_PYCALLBACK_STRING__pure(wxPyHtmlTagHandler, wxHtmlTagHandler, GetSupportedTags); |
257 | IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlTagHandler, wxHtmlTagHandler, HandleTag); | |
0f66a9f3 RD |
258 | %} |
259 | ||
260 | ||
1b8c7ba6 RD |
261 | %rename(HtmlTagHandler) wxPyHtmlTagHandler; |
262 | class wxPyHtmlTagHandler : public wxObject { | |
0f66a9f3 | 263 | public: |
2b9048c5 | 264 | %pythonAppend wxPyHtmlTagHandler "self._setCallbackInfo(self, HtmlTagHandler)" |
0f66a9f3 RD |
265 | wxPyHtmlTagHandler(); |
266 | ||
0122b7e3 | 267 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
0f66a9f3 RD |
268 | |
269 | void SetParser(wxHtmlParser *parser); | |
270 | wxHtmlParser* GetParser(); | |
271 | void ParseInner(const wxHtmlTag& tag); | |
272 | }; | |
273 | ||
274 | ||
275 | //--------------------------------------------------------------------------- | |
276 | ||
277 | %{ | |
278 | class wxPyHtmlWinTagHandler : public wxHtmlWinTagHandler { | |
9416aa89 | 279 | DECLARE_DYNAMIC_CLASS(wxPyHtmlWinTagHandler); |
0f66a9f3 RD |
280 | public: |
281 | wxPyHtmlWinTagHandler() : wxHtmlWinTagHandler() {}; | |
282 | ||
283 | wxHtmlWinParser* GetParser() { return m_WParser; } | |
284 | void ParseInner(const wxHtmlTag& tag) | |
285 | { wxHtmlWinTagHandler::ParseInner(tag); } | |
286 | ||
287 | DEC_PYCALLBACK_STRING__pure(GetSupportedTags); | |
288 | DEC_PYCALLBACK_BOOL_TAG_pure(HandleTag); | |
289 | ||
290 | PYPRIVATE; | |
291 | }; | |
292 | ||
9416aa89 RD |
293 | IMPLEMENT_DYNAMIC_CLASS( wxPyHtmlWinTagHandler, wxHtmlWinTagHandler); |
294 | ||
0f66a9f3 RD |
295 | IMP_PYCALLBACK_STRING__pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, GetSupportedTags); |
296 | IMP_PYCALLBACK_BOOL_TAG_pure(wxPyHtmlWinTagHandler, wxHtmlWinTagHandler, HandleTag); | |
0f66a9f3 RD |
297 | %} |
298 | ||
299 | ||
1b8c7ba6 RD |
300 | %rename(HtmlWinTagHandler) wxPyHtmlWinTagHandler; |
301 | class wxPyHtmlWinTagHandler : public wxPyHtmlTagHandler { | |
0f66a9f3 | 302 | public: |
2b9048c5 | 303 | %pythonAppend wxPyHtmlWinTagHandler "self._setCallbackInfo(self, HtmlWinTagHandler)" |
0f66a9f3 RD |
304 | wxPyHtmlWinTagHandler(); |
305 | ||
0122b7e3 | 306 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
0f66a9f3 RD |
307 | |
308 | void SetParser(wxHtmlParser *parser); | |
309 | wxHtmlWinParser* GetParser(); | |
310 | void ParseInner(const wxHtmlTag& tag); | |
311 | }; | |
312 | ||
313 | ||
314 | //--------------------------------------------------------------------------- | |
315 | ||
316 | %{ | |
317 | ||
318 | class wxPyHtmlTagsModule : public wxHtmlTagsModule { | |
319 | public: | |
320 | wxPyHtmlTagsModule(PyObject* thc) : wxHtmlTagsModule() { | |
321 | m_tagHandlerClass = thc; | |
322 | Py_INCREF(m_tagHandlerClass); | |
323 | RegisterModule(this); | |
324 | wxHtmlWinParser::AddModule(this); | |
325 | } | |
326 | ||
327 | void OnExit() { | |
da32eb53 | 328 | bool blocked = wxPyBeginBlockThreads(); |
0f66a9f3 RD |
329 | Py_DECREF(m_tagHandlerClass); |
330 | m_tagHandlerClass = NULL; | |
dc2f8a65 | 331 | for (size_t x=0; x < m_objArray.GetCount(); x++) { |
0f66a9f3 RD |
332 | PyObject* obj = (PyObject*)m_objArray.Item(x); |
333 | Py_DECREF(obj); | |
334 | } | |
da32eb53 | 335 | wxPyEndBlockThreads(blocked); |
0f66a9f3 RD |
336 | }; |
337 | ||
338 | void FillHandlersTable(wxHtmlWinParser *parser) { | |
339 | // Wave our magic wand... (if it works it's a miracle! ;-) | |
340 | ||
341 | // First, make a new instance of the tag handler | |
da32eb53 | 342 | bool blocked = wxPyBeginBlockThreads(); |
fb757066 RD |
343 | PyObject* arg = PyTuple_New(0); |
344 | PyObject* obj = PyObject_CallObject(m_tagHandlerClass, arg); | |
0f66a9f3 | 345 | Py_DECREF(arg); |
fb757066 | 346 | |
0f66a9f3 RD |
347 | // now figure out where it's C++ object is... |
348 | wxPyHtmlWinTagHandler* thPtr; | |
fb757066 | 349 | if (! wxPyConvertSwigPtr(obj, (void **)&thPtr, wxT("wxPyHtmlWinTagHandler"))) { |
da32eb53 | 350 | wxPyEndBlockThreads(blocked); |
0f66a9f3 | 351 | return; |
fb757066 | 352 | } |
da32eb53 | 353 | wxPyEndBlockThreads(blocked); |
0f66a9f3 RD |
354 | |
355 | // add it, | |
356 | parser->AddTagHandler(thPtr); | |
357 | ||
358 | // and track it. | |
359 | m_objArray.Add(obj); | |
360 | } | |
361 | ||
362 | private: | |
363 | PyObject* m_tagHandlerClass; | |
364 | wxArrayPtrVoid m_objArray; | |
365 | ||
366 | }; | |
367 | %} | |
368 | ||
369 | ||
370 | ||
371 | %inline %{ | |
372 | void wxHtmlWinParser_AddTagHandler(PyObject* tagHandlerClass) { | |
373 | // Dynamically create a new wxModule. Refcounts tagHandlerClass | |
374 | // and adds itself to the wxModules list and to the wxHtmlWinParser. | |
375 | new wxPyHtmlTagsModule(tagHandlerClass); | |
376 | } | |
377 | %} | |
378 | ||
dc2f8a65 | 379 | |
e166644c RD |
380 | //--------------------------------------------------------------------------- |
381 | //--------------------------------------------------------------------------- | |
d14a1e28 | 382 | %newgroup |
e166644c | 383 | |
dd116e73 RD |
384 | |
385 | // wxHtmlSelection is data holder with information about text selection. | |
386 | // Selection is defined by two positions (beginning and end of the selection) | |
387 | // and two leaf(!) cells at these positions. | |
388 | class wxHtmlSelection | |
389 | { | |
390 | public: | |
391 | wxHtmlSelection(); | |
392 | ~wxHtmlSelection(); | |
393 | ||
394 | void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell, | |
395 | const wxPoint& toPos, const wxHtmlCell *toCell); | |
1b8c7ba6 | 396 | %Rename(SetCells, void, Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell)); |
dd116e73 RD |
397 | |
398 | const wxHtmlCell *GetFromCell() const; | |
399 | const wxHtmlCell *GetToCell() const; | |
400 | ||
401 | // these values are in absolute coordinates: | |
402 | const wxPoint& GetFromPos() const; | |
403 | const wxPoint& GetToPos() const; | |
404 | ||
405 | // these are From/ToCell's private data | |
406 | const wxPoint& GetFromPrivPos() const; | |
407 | const wxPoint& GetToPrivPos() const; | |
408 | void SetFromPrivPos(const wxPoint& pos); | |
409 | void SetToPrivPos(const wxPoint& pos); | |
410 | void ClearPrivPos(); | |
411 | ||
412 | const bool IsEmpty() const; | |
413 | ||
414 | }; | |
415 | ||
416 | ||
417 | enum wxHtmlSelectionState | |
418 | { | |
419 | wxHTML_SEL_OUT, // currently rendered cell is outside the selection | |
420 | wxHTML_SEL_IN, // ... is inside selection | |
421 | wxHTML_SEL_CHANGING // ... is the cell on which selection state changes | |
422 | }; | |
423 | ||
d14a1e28 RD |
424 | |
425 | ||
dd116e73 RD |
426 | // Selection state is passed to wxHtmlCell::Draw so that it can render itself |
427 | // differently e.g. when inside text selection or outside it. | |
428 | class wxHtmlRenderingState | |
429 | { | |
430 | public: | |
431 | wxHtmlRenderingState(); | |
432 | ~wxHtmlRenderingState(); | |
433 | ||
434 | void SetSelectionState(wxHtmlSelectionState s); | |
435 | wxHtmlSelectionState GetSelectionState() const; | |
436 | ||
437 | void SetFgColour(const wxColour& c); | |
438 | const wxColour& GetFgColour() const; | |
439 | void SetBgColour(const wxColour& c); | |
440 | const wxColour& GetBgColour() const; | |
441 | }; | |
442 | ||
443 | ||
d14a1e28 | 444 | |
dd116e73 RD |
445 | // HTML rendering customization. This class is used when rendering wxHtmlCells |
446 | // as a callback: | |
447 | class wxHtmlRenderingStyle | |
448 | { | |
449 | public: | |
450 | virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0; | |
451 | virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0; | |
452 | }; | |
453 | ||
454 | // Standard style: | |
455 | class wxDefaultHtmlRenderingStyle : public wxHtmlRenderingStyle | |
456 | { | |
457 | public: | |
458 | virtual wxColour GetSelectedTextColour(const wxColour& clr); | |
459 | virtual wxColour GetSelectedTextBgColour(const wxColour& clr); | |
460 | }; | |
461 | ||
462 | ||
463 | ||
464 | // Information given to cells when drawing them. Contains rendering state, | |
465 | // selection information and rendering style object that can be used to | |
466 | // customize the output. | |
467 | class wxHtmlRenderingInfo | |
468 | { | |
469 | public: | |
470 | wxHtmlRenderingInfo(); | |
471 | ~wxHtmlRenderingInfo(); | |
472 | ||
473 | void SetSelection(wxHtmlSelection *s); | |
474 | wxHtmlSelection *GetSelection() const; | |
475 | ||
476 | void SetStyle(wxHtmlRenderingStyle *style); | |
477 | wxHtmlRenderingStyle& GetStyle(); | |
478 | ||
479 | wxHtmlRenderingState& GetState(); | |
480 | }; | |
481 | ||
482 | //--------------------------------------------------------------------------- | |
d14a1e28 | 483 | %newgroup |
dd116e73 | 484 | |
3ef86e32 RD |
485 | |
486 | enum | |
487 | { | |
488 | wxHTML_FIND_EXACT = 1, | |
489 | wxHTML_FIND_NEAREST_BEFORE = 2, | |
490 | wxHTML_FIND_NEAREST_AFTER = 4 | |
491 | }; | |
492 | ||
493 | ||
9416aa89 | 494 | class wxHtmlCell : public wxObject { |
e166644c RD |
495 | public: |
496 | wxHtmlCell(); | |
497 | ||
e166644c RD |
498 | int GetPosX(); |
499 | int GetPosY(); | |
500 | int GetWidth(); | |
501 | int GetHeight(); | |
502 | int GetDescent(); | |
0d267606 RD |
503 | |
504 | // Returns the maximum possible length of the cell. | |
505 | // Call Layout at least once before using GetMaxTotalWidth() | |
506 | int GetMaxTotalWidth() const; | |
507 | ||
2678dd26 RD |
508 | const wxString& GetId() const; |
509 | void SetId(const wxString& id); | |
9c00cfa3 | 510 | wxHtmlLinkInfo* GetLink(int x = 0, int y = 0); |
e166644c | 511 | wxHtmlCell* GetNext(); |
9c00cfa3 | 512 | wxHtmlContainerCell* GetParent(); |
3ef86e32 RD |
513 | wxHtmlCell* GetFirstChild() const; |
514 | ||
515 | // Returns cursor to be used when mouse is over the cell: | |
516 | wxCursor GetCursor() const; | |
517 | ||
518 | // Formatting cells are not visible on the screen, they only alter | |
519 | // renderer's state. | |
520 | bool IsFormattingCell() const; | |
521 | ||
522 | ||
9c00cfa3 | 523 | void SetLink(const wxHtmlLinkInfo& link); |
e166644c | 524 | void SetNext(wxHtmlCell *cell); |
9c00cfa3 RD |
525 | void SetParent(wxHtmlContainerCell *p); |
526 | void SetPos(int x, int y); | |
e166644c | 527 | void Layout(int w); |
dd116e73 RD |
528 | void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, |
529 | wxHtmlRenderingInfo& info); | |
530 | void DrawInvisible(wxDC& dc, int x, int y, | |
531 | wxHtmlRenderingInfo& info); | |
e166644c | 532 | const wxHtmlCell* Find(int condition, const void* param); |
dc2f8a65 | 533 | |
1fded56b | 534 | bool AdjustPagebreak(int* INOUT); |
dc2f8a65 | 535 | void SetCanLiveOnPagebreak(bool can); |
9c00cfa3 | 536 | |
3ef86e32 RD |
537 | // Can the line be broken before this cell? |
538 | bool IsLinebreakAllowed() const; | |
539 | ||
dd9f7fea | 540 | // Returns True for simple == terminal cells, i.e. not composite ones. |
3ef86e32 RD |
541 | // This if for internal usage only and may disappear in future versions! |
542 | bool IsTerminalCell() const; | |
543 | ||
544 | // Find a cell inside this cell positioned at the given coordinates | |
545 | // (relative to this's positions). Returns NULL if no such cell exists. | |
546 | // The flag can be used to specify whether to look for terminal or | |
547 | // nonterminal cells or both. In either case, returned cell is deepest | |
548 | // cell in cells tree that contains [x,y]. | |
549 | wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y, | |
550 | unsigned flags = wxHTML_FIND_EXACT) const; | |
551 | ||
552 | // Returns absolute position of the cell on HTML canvas | |
553 | wxPoint GetAbsPos() const; | |
554 | ||
555 | // Returns first (last) terminal cell inside this cell. It may return NULL, | |
556 | // but it is rare -- only if there are no terminals in the tree. | |
557 | wxHtmlCell *GetFirstTerminal() const ; | |
558 | wxHtmlCell *GetLastTerminal() const ; | |
559 | ||
560 | // Returns cell's depth, i.e. how far under the root cell it is | |
561 | // (if it is the root, depth is 0) | |
562 | unsigned GetDepth() const; | |
563 | ||
dd9f7fea | 564 | // Returns True if the cell appears before 'cell' in natural order of |
3ef86e32 | 565 | // cells (= as they are read). If cell A is (grand)parent of cell B, |
dd9f7fea | 566 | // then both A.IsBefore(B) and B.IsBefore(A) always return True. |
3ef86e32 RD |
567 | bool IsBefore(wxHtmlCell *cell) const; |
568 | ||
569 | // Converts the cell into text representation. If sel != NULL then | |
570 | // only part of the cell inside the selection is converted. | |
571 | wxString ConvertToText(wxHtmlSelection *sel) const; | |
e166644c RD |
572 | }; |
573 | ||
574 | ||
9416aa89 RD |
575 | class wxHtmlWordCell : public wxHtmlCell |
576 | { | |
577 | public: | |
578 | wxHtmlWordCell(const wxString& word, wxDC& dc); | |
579 | }; | |
580 | ||
581 | ||
e166644c RD |
582 | class wxHtmlContainerCell : public wxHtmlCell { |
583 | public: | |
584 | wxHtmlContainerCell(wxHtmlContainerCell *parent); | |
585 | ||
586 | void InsertCell(wxHtmlCell *cell); | |
587 | void SetAlignHor(int al); | |
588 | int GetAlignHor(); | |
589 | void SetAlignVer(int al); | |
590 | int GetAlignVer(); | |
9d8bd15f | 591 | void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS); |
e166644c RD |
592 | int GetIndent(int ind); |
593 | int GetIndentUnits(int ind); | |
594 | void SetAlign(const wxHtmlTag& tag); | |
595 | void SetWidthFloat(int w, int units); | |
1b8c7ba6 | 596 | %Rename(SetWidthFloatFromTag, void, SetWidthFloat(const wxHtmlTag& tag)); |
9d8bd15f | 597 | void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP); |
e166644c | 598 | void SetBackgroundColour(const wxColour& clr); |
1e4a197e | 599 | wxColour GetBackgroundColour(); |
e166644c | 600 | void SetBorder(const wxColour& clr1, const wxColour& clr2); |
dd116e73 RD |
601 | wxHtmlCell* GetFirstChild(); |
602 | %pragma(python) addtoclass = "GetFirstCell = GetFirstChild" | |
e166644c RD |
603 | }; |
604 | ||
605 | ||
606 | ||
9c00cfa3 RD |
607 | class wxHtmlColourCell : public wxHtmlCell { |
608 | public: | |
609 | wxHtmlColourCell(wxColour clr, int flags = wxHTML_CLR_FOREGROUND); | |
610 | ||
611 | }; | |
612 | ||
613 | ||
9416aa89 RD |
614 | class wxHtmlFontCell : public wxHtmlCell |
615 | { | |
616 | public: | |
617 | wxHtmlFontCell(wxFont *font); | |
618 | }; | |
619 | ||
e166644c RD |
620 | |
621 | class wxHtmlWidgetCell : public wxHtmlCell { | |
622 | public: | |
623 | wxHtmlWidgetCell(wxWindow* wnd, int w = 0); | |
624 | ||
625 | }; | |
626 | ||
0f66a9f3 | 627 | |
d14a1e28 RD |
628 | |
629 | ||
0f66a9f3 | 630 | //--------------------------------------------------------------------------- |
1e4a197e RD |
631 | // wxHtmlFilter |
632 | //--------------------------------------------------------------------------- | |
d14a1e28 | 633 | %newgroup |
1e4a197e RD |
634 | |
635 | ||
636 | %{ // here's the C++ version | |
637 | class wxPyHtmlFilter : public wxHtmlFilter { | |
638 | DECLARE_ABSTRACT_CLASS(wxPyHtmlFilter); | |
639 | public: | |
640 | wxPyHtmlFilter() : wxHtmlFilter() {} | |
641 | ||
dd9f7fea | 642 | // returns True if this filter is able to open&read given file |
1e4a197e | 643 | virtual bool CanRead(const wxFSFile& file) const { |
a72f4631 | 644 | bool rval = false; |
1e4a197e | 645 | bool found; |
da32eb53 | 646 | bool blocked = wxPyBeginBlockThreads(); |
1e4a197e | 647 | if ((found = wxPyCBH_findCallback(m_myInst, "CanRead"))) { |
6d450e1a | 648 | PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false); // cast away const |
1e4a197e RD |
649 | rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); |
650 | Py_DECREF(obj); | |
651 | } | |
da32eb53 | 652 | wxPyEndBlockThreads(blocked); |
1e4a197e RD |
653 | return rval; |
654 | } | |
655 | ||
656 | ||
657 | // Reads given file and returns HTML document. | |
658 | // Returns empty string if opening failed | |
659 | virtual wxString ReadFile(const wxFSFile& file) const { | |
660 | wxString rval; | |
661 | bool found; | |
da32eb53 | 662 | bool blocked = wxPyBeginBlockThreads(); |
1e4a197e | 663 | if ((found = wxPyCBH_findCallback(m_myInst, "ReadFile"))) { |
6d450e1a | 664 | PyObject* obj = wxPyMake_wxObject((wxFSFile*)&file,false); // cast away const |
1e4a197e RD |
665 | PyObject* ro; |
666 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(O)", obj)); | |
667 | Py_DECREF(obj); | |
668 | if (ro) { | |
669 | rval = Py2wxString(ro); | |
670 | Py_DECREF(ro); | |
671 | } | |
672 | } | |
da32eb53 | 673 | wxPyEndBlockThreads(blocked); |
1e4a197e RD |
674 | return rval; |
675 | } | |
676 | ||
677 | PYPRIVATE; | |
678 | }; | |
679 | ||
680 | IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlFilter, wxHtmlFilter); | |
681 | %} | |
682 | ||
683 | ||
684 | // And now the version seen by SWIG | |
685 | ||
1b8c7ba6 RD |
686 | %rename(HtmlFilter) wxPyHtmlFilter; |
687 | class wxPyHtmlFilter : public wxObject { | |
1e4a197e | 688 | public: |
2b9048c5 | 689 | %pythonAppend wxPyHtmlFilter "self._setCallbackInfo(self, HtmlFilter)" |
1e4a197e RD |
690 | wxPyHtmlFilter(); |
691 | ||
692 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
1e4a197e RD |
693 | }; |
694 | ||
695 | ||
696 | // TODO: wxHtmlFilterHTML | |
697 | ||
698 | ||
0f66a9f3 | 699 | //--------------------------------------------------------------------------- |
1e4a197e | 700 | // wxHtmlWindow |
4b123bb9 | 701 | //--------------------------------------------------------------------------- |
d14a1e28 | 702 | %newgroup |
4b123bb9 | 703 | |
0f66a9f3 RD |
704 | %{ |
705 | class wxPyHtmlWindow : public wxHtmlWindow { | |
cdf14688 | 706 | DECLARE_ABSTRACT_CLASS(wxPyHtmlWindow); |
0f66a9f3 RD |
707 | public: |
708 | wxPyHtmlWindow(wxWindow *parent, wxWindowID id = -1, | |
709 | const wxPoint& pos = wxDefaultPosition, | |
710 | const wxSize& size = wxDefaultSize, | |
3ef86e32 | 711 | long style = wxHW_DEFAULT_STYLE, |
1e4a197e | 712 | const wxString& name = wxPyHtmlWindowNameStr) |
0f66a9f3 | 713 | : wxHtmlWindow(parent, id, pos, size, style, name) {}; |
7b7ac0ab | 714 | wxPyHtmlWindow() : wxHtmlWindow() {}; |
0f66a9f3 | 715 | |
e5d41db0 RD |
716 | bool ScrollToAnchor(const wxString& anchor) { |
717 | return wxHtmlWindow::ScrollToAnchor(anchor); | |
718 | } | |
719 | ||
720 | bool HasAnchor(const wxString& anchor) { | |
721 | const wxHtmlCell *c = m_Cell->Find(wxHTML_COND_ISANCHOR, &anchor); | |
722 | return c!=NULL; | |
723 | } | |
724 | ||
c8bc03c3 RD |
725 | void OnLinkClicked(const wxHtmlLinkInfo& link); |
726 | void base_OnLinkClicked(const wxHtmlLinkInfo& link); | |
9c00cfa3 | 727 | |
e5d41db0 | 728 | wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type, |
c6c593e8 RD |
729 | const wxString& url, |
730 | wxString *redirect) const; | |
731 | ||
9c00cfa3 | 732 | DEC_PYCALLBACK__STRING(OnSetTitle); |
0122b7e3 RD |
733 | DEC_PYCALLBACK__CELLINTINT(OnCellMouseHover); |
734 | DEC_PYCALLBACK__CELLINTINTME(OnCellClicked); | |
0f66a9f3 RD |
735 | PYPRIVATE; |
736 | }; | |
737 | ||
cdf14688 | 738 | IMPLEMENT_ABSTRACT_CLASS( wxPyHtmlWindow, wxHtmlWindow ); |
9c00cfa3 | 739 | IMP_PYCALLBACK__STRING(wxPyHtmlWindow, wxHtmlWindow, OnSetTitle); |
0122b7e3 RD |
740 | IMP_PYCALLBACK__CELLINTINT(wxPyHtmlWindow, wxHtmlWindow, OnCellMouseHover); |
741 | IMP_PYCALLBACK__CELLINTINTME(wxPyHtmlWindow, wxHtmlWindow, OnCellClicked); | |
742 | ||
0f66a9f3 | 743 | |
9416aa89 | 744 | void wxPyHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) { |
19a97bd6 | 745 | bool found; |
da32eb53 | 746 | bool blocked = wxPyBeginBlockThreads(); |
0122b7e3 | 747 | if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) { |
1e4a197e | 748 | PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0); |
1e7ecb7b | 749 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(O)", obj)); |
de20db99 | 750 | Py_DECREF(obj); |
9c00cfa3 | 751 | } |
da32eb53 | 752 | wxPyEndBlockThreads(blocked); |
19a97bd6 | 753 | if (! found) |
9c00cfa3 | 754 | wxHtmlWindow::OnLinkClicked(link); |
9c00cfa3 | 755 | } |
c8bc03c3 | 756 | void wxPyHtmlWindow::base_OnLinkClicked(const wxHtmlLinkInfo& link) { |
9c00cfa3 RD |
757 | wxHtmlWindow::OnLinkClicked(link); |
758 | } | |
0122b7e3 | 759 | |
c6c593e8 RD |
760 | |
761 | wxHtmlOpeningStatus wxPyHtmlWindow::OnOpeningURL(wxHtmlURLType type, | |
762 | const wxString& url, | |
763 | wxString *redirect) const { | |
764 | bool found; | |
765 | wxHtmlOpeningStatus rval; | |
da32eb53 | 766 | bool blocked = wxPyBeginBlockThreads(); |
c6c593e8 RD |
767 | if ((found = wxPyCBH_findCallback(m_myInst, "OnOpeningURL"))) { |
768 | PyObject* ro; | |
a66212dc RD |
769 | PyObject* s = wx2PyString(url); |
770 | ro = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(iO)", type, s)); | |
771 | Py_DECREF(s); | |
c6c593e8 RD |
772 | if (PyString_Check(ro) |
773 | #if PYTHON_API_VERSION >= 1009 | |
774 | || PyUnicode_Check(ro) | |
775 | #endif | |
776 | ) { | |
a541c325 | 777 | *redirect = Py2wxString(ro); |
c6c593e8 RD |
778 | rval = wxHTML_REDIRECT; |
779 | } | |
780 | else { | |
781 | PyObject* num = PyNumber_Int(ro); | |
782 | rval = (wxHtmlOpeningStatus)PyInt_AsLong(num); | |
783 | Py_DECREF(num); | |
784 | } | |
785 | Py_DECREF(ro); | |
786 | } | |
da32eb53 | 787 | wxPyEndBlockThreads(blocked); |
c6c593e8 RD |
788 | if (! found) |
789 | rval = wxHtmlWindow::OnOpeningURL(type, url, redirect); | |
790 | return rval; | |
791 | } | |
792 | ||
793 | ||
0f66a9f3 RD |
794 | %} |
795 | ||
796 | ||
95837b4d | 797 | |
ab1f7d2a RD |
798 | MustHaveApp(wxPyHtmlWindow); |
799 | ||
1b8c7ba6 RD |
800 | %rename(HtmlWindow) wxPyHtmlWindow; |
801 | class wxPyHtmlWindow : public wxScrolledWindow { | |
0f66a9f3 | 802 | public: |
2b9048c5 RD |
803 | %pythonAppend wxPyHtmlWindow "self._setCallbackInfo(self, HtmlWindow); self._setOORInfo(self)" |
804 | %pythonAppend wxPyHtmlWindow() "" | |
b39c3fa0 | 805 | %typemap(out) wxPyHtmlWindow*; // turn off this typemap |
d14a1e28 | 806 | |
0f66a9f3 | 807 | wxPyHtmlWindow(wxWindow *parent, int id = -1, |
d14a1e28 RD |
808 | const wxPoint& pos = wxDefaultPosition, |
809 | const wxSize& size = wxDefaultSize, | |
3ef86e32 | 810 | int style=wxHW_DEFAULT_STYLE, |
137b5242 | 811 | const wxString& name = wxPyHtmlWindowNameStr); |
1b8c7ba6 | 812 | %RenameCtor(PreHtmlWindow, wxPyHtmlWindow()); |
7b7ac0ab | 813 | |
b39c3fa0 RD |
814 | // Turn it back on again |
815 | %typemap(out) wxPyHtmlWindow* { $result = wxPyMake_wxObject($1, $owner); } | |
816 | ||
7b7ac0ab | 817 | bool Create(wxWindow *parent, int id = -1, |
d14a1e28 RD |
818 | const wxPoint& pos = wxDefaultPosition, |
819 | const wxSize& size = wxDefaultSize, | |
fc51b8c3 | 820 | int style=wxHW_SCROLLBAR_AUTO, |
137b5242 | 821 | const wxString& name = wxPyHtmlWindowNameStr); |
7b7ac0ab | 822 | |
0f66a9f3 | 823 | |
0122b7e3 | 824 | void _setCallbackInfo(PyObject* self, PyObject* _class); |
0f66a9f3 | 825 | |
d14a1e28 | 826 | |
1e4a197e RD |
827 | // Set HTML page and display it. !! source is HTML document itself, |
828 | // it is NOT address/filename of HTML document. If you want to | |
829 | // specify document location, use LoadPage() istead | |
dd9f7fea | 830 | // Return value : False if an error occured, True otherwise |
7a446686 | 831 | bool SetPage(const wxString& source); |
1e4a197e RD |
832 | |
833 | // Load HTML page from given location. Location can be either | |
834 | // a) /usr/wxGTK2/docs/html/wx.htm | |
835 | // b) http://www.somewhere.uk/document.htm | |
836 | // c) ftp://ftp.somesite.cz/pub/something.htm | |
837 | // In case there is no prefix (http:,ftp:), the method | |
838 | // will try to find it itself (1. local file, then http or ftp) | |
839 | // After the page is loaded, the method calls SetPage() to display it. | |
840 | // Note : you can also use path relative to previously loaded page | |
841 | // Return value : same as SetPage | |
7a446686 | 842 | bool LoadPage(const wxString& location); |
1e4a197e | 843 | |
9cbf6f6e | 844 | // Loads HTML page from file |
1fded56b | 845 | bool LoadFile(const wxString& filename); |
9cbf6f6e | 846 | |
1e4a197e | 847 | // Append to current page |
de112a55 | 848 | bool AppendToPage(const wxString& source); |
1e4a197e RD |
849 | |
850 | // Returns full location of opened page | |
0f66a9f3 | 851 | wxString GetOpenedPage(); |
1e4a197e RD |
852 | |
853 | // Returns anchor within opened page | |
7a446686 | 854 | wxString GetOpenedAnchor(); |
1e4a197e RD |
855 | |
856 | // Returns <TITLE> of opened page or empty string otherwise | |
7a446686 RD |
857 | wxString GetOpenedPageTitle(); |
858 | ||
1e4a197e RD |
859 | // Sets frame in which page title will be displayed. Format is format of |
860 | // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s | |
137b5242 | 861 | void SetRelatedFrame(wxFrame* frame, const wxString& format); |
0f66a9f3 | 862 | wxFrame* GetRelatedFrame(); |
1e4a197e RD |
863 | |
864 | // After(!) calling SetRelatedFrame, this sets statusbar slot where messages | |
865 | // will be displayed. Default is -1 = no messages. | |
0f66a9f3 | 866 | void SetRelatedStatusBar(int bar); |
f6bcfd97 | 867 | |
1e4a197e | 868 | // Sets fonts to be used when displaying HTML page. |
d14a1e28 | 869 | %extend { |
9cbf6f6e RD |
870 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
871 | int* temp = NULL; | |
872 | if (sizes) temp = int_LIST_helper(sizes); | |
873 | self->SetFonts(normal_face, fixed_face, temp); | |
874 | if (temp) | |
f6bcfd97 | 875 | delete [] temp; |
f6bcfd97 BP |
876 | } |
877 | } | |
878 | ||
385721a8 RD |
879 | // Sets font sizes to be relative to the given size or the system |
880 | // default size; use either specified or default font | |
881 | void SetStandardFonts(int size = -1, | |
882 | const wxString& normal_face = wxPyEmptyString, | |
883 | const wxString& fixed_face = wxPyEmptyString); | |
7acd3625 | 884 | |
36c8c471 RD |
885 | DocDeclStr( |
886 | void, SetTitle(const wxString& title), | |
d07d2bc9 | 887 | "", ""); |
1e4a197e RD |
888 | |
889 | // Sets space between text and window borders. | |
0f66a9f3 | 890 | void SetBorders(int b); |
1e4a197e RD |
891 | |
892 | // Saves custom settings into cfg config. it will use the path 'path' | |
893 | // if given, otherwise it will save info into currently selected path. | |
894 | // saved values : things set by SetFonts, SetBorders. | |
137b5242 RD |
895 | void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); |
896 | void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
1e4a197e RD |
897 | |
898 | // Goes to previous/next page (in browsing history) | |
dd9f7fea | 899 | // Returns True if successful, False otherwise |
0f66a9f3 RD |
900 | bool HistoryBack(); |
901 | bool HistoryForward(); | |
7a446686 RD |
902 | bool HistoryCanBack(); |
903 | bool HistoryCanForward(); | |
1e4a197e RD |
904 | |
905 | // Resets History | |
0f66a9f3 | 906 | void HistoryClear(); |
1e4a197e RD |
907 | |
908 | // Returns pointer to conteiners/cells structure. | |
a65c6e14 | 909 | wxHtmlContainerCell* GetInternalRepresentation(); |
1e4a197e RD |
910 | |
911 | // Returns a pointer to the parser. | |
e166644c RD |
912 | wxHtmlWinParser* GetParser(); |
913 | ||
e5d41db0 RD |
914 | bool ScrollToAnchor(const wxString& anchor); |
915 | bool HasAnchor(const wxString& anchor); | |
916 | ||
1e4a197e RD |
917 | //Adds input filter |
918 | static void AddFilter(wxPyHtmlFilter *filter); | |
919 | ||
927d7cfa RD |
920 | // Helper functions to select parts of page: |
921 | void SelectWord(const wxPoint& pos); | |
922 | void SelectLine(const wxPoint& pos); | |
923 | void SelectAll(); | |
1e4a197e | 924 | |
31ad423e RD |
925 | // Convert selection to text: |
926 | wxString SelectionToText(); | |
927 | ||
928 | // Converts current page to text: | |
929 | wxString ToText(); | |
927d7cfa | 930 | |
c8bc03c3 | 931 | void base_OnLinkClicked(const wxHtmlLinkInfo& link); |
137b5242 | 932 | void base_OnSetTitle(const wxString& title); |
0122b7e3 RD |
933 | void base_OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y); |
934 | void base_OnCellClicked(wxHtmlCell *cell, | |
935 | wxCoord x, wxCoord y, | |
936 | const wxMouseEvent& event); | |
880715c9 RD |
937 | |
938 | static wxVisualAttributes | |
939 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
4b123bb9 HH |
940 | }; |
941 | ||
5ca24bf4 | 942 | |
5ca24bf4 | 943 | |
d14a1e28 | 944 | |
dc2f8a65 RD |
945 | //--------------------------------------------------------------------------- |
946 | //--------------------------------------------------------------------------- | |
d14a1e28 | 947 | %newgroup |
dc2f8a65 RD |
948 | |
949 | ||
ab1f7d2a RD |
950 | MustHaveApp(wxHtmlDCRenderer); |
951 | ||
9416aa89 | 952 | class wxHtmlDCRenderer : public wxObject { |
dc2f8a65 RD |
953 | public: |
954 | wxHtmlDCRenderer(); | |
955 | ~wxHtmlDCRenderer(); | |
956 | ||
957 | void SetDC(wxDC *dc, int maxwidth); | |
958 | void SetSize(int width, int height); | |
959 | void SetHtmlText(const wxString& html, | |
137b5242 | 960 | const wxString& basepath = wxPyEmptyString, |
a72f4631 | 961 | bool isdir = true); |
1fded56b | 962 | // Sets fonts to be used when displaying HTML page. (if size null then default sizes used). |
d14a1e28 | 963 | %extend { |
9cbf6f6e RD |
964 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
965 | int* temp = NULL; | |
966 | if (sizes) temp = int_LIST_helper(sizes); | |
967 | self->SetFonts(normal_face, fixed_face, temp); | |
968 | if (temp) | |
969 | delete [] temp; | |
970 | } | |
971 | } | |
7acd3625 | 972 | |
385721a8 RD |
973 | // Sets font sizes to be relative to the given size or the system |
974 | // default size; use either specified or default font | |
975 | void SetStandardFonts(int size = -1, | |
976 | const wxString& normal_face = wxPyEmptyString, | |
977 | const wxString& fixed_face = wxPyEmptyString); | |
7acd3625 | 978 | |
020303e6 | 979 | int Render(int x, int y, int from = 0, int dont_render = false, int maxHeight = INT_MAX, |
3ef86e32 RD |
980 | //int *known_pagebreaks = NULL, int number_of_pages = 0 |
981 | int* choices=NULL, int LCOUNT = 0 | |
982 | ); | |
dc2f8a65 RD |
983 | int GetTotalHeight(); |
984 | // returns total height of the html document | |
985 | // (compare Render's return value with this) | |
986 | }; | |
987 | ||
d14a1e28 | 988 | |
dc2f8a65 RD |
989 | enum { |
990 | wxPAGE_ODD, | |
991 | wxPAGE_EVEN, | |
992 | wxPAGE_ALL | |
993 | }; | |
994 | ||
995 | ||
ab1f7d2a RD |
996 | MustHaveApp(wxHtmlPrintout); |
997 | ||
dc2f8a65 RD |
998 | class wxHtmlPrintout : public wxPyPrintout { |
999 | public: | |
137b5242 | 1000 | wxHtmlPrintout(const wxString& title = wxPyHtmlPrintoutTitleStr); |
f3d9dc1d | 1001 | //~wxHtmlPrintout(); wxPrintPreview object takes ownership... |
dc2f8a65 RD |
1002 | |
1003 | void SetHtmlText(const wxString& html, | |
137b5242 | 1004 | const wxString &basepath = wxPyEmptyString, |
a72f4631 | 1005 | bool isdir = true); |
dc2f8a65 RD |
1006 | void SetHtmlFile(const wxString &htmlfile); |
1007 | void SetHeader(const wxString& header, int pg = wxPAGE_ALL); | |
1008 | void SetFooter(const wxString& footer, int pg = wxPAGE_ALL); | |
d14a1e28 | 1009 | |
1fded56b | 1010 | // Sets fonts to be used when displaying HTML page. (if size null then default sizes used). |
d14a1e28 | 1011 | %extend { |
9cbf6f6e RD |
1012 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
1013 | int* temp = NULL; | |
1014 | if (sizes) temp = int_LIST_helper(sizes); | |
1015 | self->SetFonts(normal_face, fixed_face, temp); | |
1016 | if (temp) | |
1017 | delete [] temp; | |
1018 | } | |
1019 | } | |
7acd3625 | 1020 | |
385721a8 RD |
1021 | // Sets font sizes to be relative to the given size or the system |
1022 | // default size; use either specified or default font | |
1023 | void SetStandardFonts(int size = -1, | |
1024 | const wxString& normal_face = wxPyEmptyString, | |
1025 | const wxString& fixed_face = wxPyEmptyString); | |
7acd3625 | 1026 | |
dc2f8a65 RD |
1027 | void SetMargins(float top = 25.2, float bottom = 25.2, |
1028 | float left = 25.2, float right = 25.2, | |
1029 | float spaces = 5); | |
3ef86e32 RD |
1030 | |
1031 | // Adds input filter | |
1032 | static void AddFilter(wxHtmlFilter *filter); | |
1033 | ||
1034 | // Cleanup | |
1035 | static void CleanUpStatics(); | |
dc2f8a65 RD |
1036 | }; |
1037 | ||
1038 | ||
1039 | ||
ab1f7d2a RD |
1040 | MustHaveApp(wxHtmlEasyPrinting); |
1041 | ||
9416aa89 | 1042 | class wxHtmlEasyPrinting : public wxObject { |
dc2f8a65 | 1043 | public: |
137b5242 | 1044 | wxHtmlEasyPrinting(const wxString& name = wxPyHtmlPrintingTitleStr, |
3ef86e32 | 1045 | wxWindow *parentWindow = NULL); |
dc2f8a65 RD |
1046 | ~wxHtmlEasyPrinting(); |
1047 | ||
1048 | void PreviewFile(const wxString &htmlfile); | |
137b5242 | 1049 | void PreviewText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString); |
dc2f8a65 | 1050 | void PrintFile(const wxString &htmlfile); |
137b5242 | 1051 | void PrintText(const wxString &htmltext, const wxString& basepath = wxPyEmptyString); |
7aada1e0 | 1052 | // void PrinterSetup(); |
dc2f8a65 RD |
1053 | void PageSetup(); |
1054 | void SetHeader(const wxString& header, int pg = wxPAGE_ALL); | |
1055 | void SetFooter(const wxString& footer, int pg = wxPAGE_ALL); | |
1056 | ||
d14a1e28 | 1057 | %extend { |
9cbf6f6e RD |
1058 | void SetFonts(wxString normal_face, wxString fixed_face, PyObject* sizes=NULL) { |
1059 | int* temp = NULL; | |
1060 | if (sizes) temp = int_LIST_helper(sizes); | |
1061 | self->SetFonts(normal_face, fixed_face, temp); | |
1062 | if (temp) | |
1063 | delete [] temp; | |
1064 | } | |
1065 | } | |
1066 | ||
385721a8 RD |
1067 | // Sets font sizes to be relative to the given size or the system |
1068 | // default size; use either specified or default font | |
1069 | void SetStandardFonts(int size = -1, | |
1070 | const wxString& normal_face = wxPyEmptyString, | |
1071 | const wxString& fixed_face = wxPyEmptyString); | |
7acd3625 | 1072 | |
dc2f8a65 RD |
1073 | wxPrintData *GetPrintData() {return m_PrintData;} |
1074 | wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;} | |
1075 | ||
1076 | }; | |
1077 | ||
1078 | ||
0f66a9f3 RD |
1079 | //--------------------------------------------------------------------------- |
1080 | //--------------------------------------------------------------------------- | |
d14a1e28 | 1081 | %newgroup |
5ca24bf4 | 1082 | |
4b123bb9 | 1083 | |
d14a1e28 RD |
1084 | class wxHtmlBookRecord { |
1085 | public: | |
1086 | wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath, | |
1087 | const wxString& title, const wxString& start); | |
4b123bb9 | 1088 | |
d14a1e28 RD |
1089 | wxString GetBookFile(); |
1090 | wxString GetTitle(); | |
1091 | wxString GetStart(); | |
1092 | wxString GetBasePath(); | |
1093 | ||
1094 | void SetContentsRange(int start, int end); | |
1095 | int GetContentsStart(); | |
1096 | int GetContentsEnd(); | |
4b123bb9 | 1097 | |
d14a1e28 RD |
1098 | void SetTitle(const wxString& title); |
1099 | void SetBasePath(const wxString& path); | |
1100 | void SetStart(const wxString& start); | |
1101 | ||
1102 | wxString GetFullPath(const wxString &page) const; | |
1103 | }; | |
1104 | ||
1105 | //--------------------------------------------------------------------------- | |
0f66a9f3 | 1106 | |
d14a1e28 RD |
1107 | struct wxHtmlContentsItem |
1108 | { | |
1109 | %extend { | |
1110 | int GetLevel() { return self->m_Level; } | |
1111 | int GetID() { return self->m_ID; } | |
1112 | wxString GetName() { return self->m_Name; } | |
1113 | wxString GetPage() { return self->m_Page; } | |
1114 | wxHtmlBookRecord* GetBook() { return self->m_Book; } | |
1115 | } | |
1116 | }; | |
1117 | ||
1118 | //--------------------------------------------------------------------------- | |
1119 | ||
1120 | class wxHtmlSearchStatus | |
1121 | { | |
1122 | public: | |
1123 | //wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword, | |
1124 | // const wxString& book = wxPyEmptyString); | |
1125 | bool Search(); | |
1126 | bool IsActive(); | |
1127 | int GetCurIndex(); | |
1128 | int GetMaxIndex(); | |
1129 | const wxString& GetName(); | |
1130 | wxHtmlContentsItem* GetContentsItem(); | |
1131 | }; | |
1132 | ||
1133 | //--------------------------------------------------------------------------- | |
1134 | ||
1135 | class wxHtmlHelpData { | |
1136 | public: | |
1137 | wxHtmlHelpData(); | |
1138 | ~wxHtmlHelpData(); | |
1139 | ||
1140 | void SetTempDir(const wxString& path); | |
1141 | bool AddBook(const wxString& book); | |
1142 | // bool AddBookParam(const wxString& title, const wxString& contfile, | |
1143 | // const wxString& indexfile=wxPyEmptyString, | |
1144 | // const wxString& deftopic=wxPyEmptyString, | |
1145 | // const wxString& path=wxPyEmptyString); | |
1146 | ||
1147 | wxString FindPageByName(const wxString& page); | |
1148 | wxString FindPageById(int id); | |
1149 | ||
1150 | // TODO: this one needs fixed... | |
1151 | const wxHtmlBookRecArray& GetBookRecArray(); | |
1152 | ||
1153 | wxHtmlContentsItem* GetContents(); | |
1154 | int GetContentsCnt(); | |
1155 | wxHtmlContentsItem* GetIndex(); | |
1156 | int GetIndexCnt(); | |
1157 | }; | |
1158 | ||
1159 | //--------------------------------------------------------------------------- | |
1160 | ||
ab1f7d2a RD |
1161 | MustHaveApp(wxHtmlHelpFrame); |
1162 | ||
d14a1e28 RD |
1163 | class wxHtmlHelpFrame : public wxFrame { |
1164 | public: | |
2b9048c5 | 1165 | %pythonAppend wxHtmlHelpFrame "self._setOORInfo(self)" |
d14a1e28 RD |
1166 | |
1167 | wxHtmlHelpFrame(wxWindow* parent, int wxWindowID, | |
1168 | const wxString& title = wxPyEmptyString, | |
1169 | int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL); | |
1170 | ||
1171 | wxHtmlHelpData* GetData(); | |
1172 | void SetTitleFormat(const wxString& format); | |
1173 | void Display(const wxString& x); | |
1b8c7ba6 | 1174 | %Rename(DisplayID, void, Display(int id)); |
d14a1e28 RD |
1175 | void DisplayContents(); |
1176 | void DisplayIndex(); | |
1177 | bool KeywordSearch(const wxString& keyword); | |
1178 | void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString); | |
1179 | void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
1180 | void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
1181 | }; | |
1182 | ||
1183 | ||
1184 | //--------------------------------------------------------------------------- | |
1185 | ||
1186 | ||
1187 | enum { | |
1188 | wxHF_TOOLBAR, | |
1189 | wxHF_FLATTOOLBAR, | |
1190 | wxHF_CONTENTS, | |
1191 | wxHF_INDEX, | |
1192 | wxHF_SEARCH, | |
1193 | wxHF_BOOKMARKS, | |
1194 | wxHF_OPENFILES, | |
1195 | wxHF_PRINT, | |
1196 | wxHF_DEFAULTSTYLE, | |
1197 | }; | |
1198 | ||
1199 | ||
ab1f7d2a RD |
1200 | MustHaveApp(wxHtmlHelpController); |
1201 | ||
3b03eb99 RD |
1202 | class wxHtmlHelpController : public wxObject // wxHelpControllerBase |
1203 | { | |
d14a1e28 | 1204 | public: |
3b03eb99 | 1205 | // %pythonAppend wxHtmlHelpController "self._setOORInfo(self)" |
d14a1e28 RD |
1206 | |
1207 | wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE); | |
1208 | ~wxHtmlHelpController(); | |
1209 | ||
1210 | void SetTitleFormat(const wxString& format); | |
1211 | void SetTempDir(const wxString& path); | |
a72f4631 | 1212 | bool AddBook(const wxString& book, int show_wait_msg = false); |
d14a1e28 | 1213 | void Display(const wxString& x); |
1b8c7ba6 | 1214 | %Rename(DisplayID, void, Display(int id)); |
d14a1e28 RD |
1215 | void DisplayContents(); |
1216 | void DisplayIndex(); | |
1217 | bool KeywordSearch(const wxString& keyword); | |
1218 | void UseConfig(wxConfigBase *config, const wxString& rootpath = wxPyEmptyString); | |
1219 | void ReadCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
1220 | void WriteCustomization(wxConfigBase *cfg, wxString path = wxPyEmptyString); | |
1221 | wxHtmlHelpFrame* GetFrame(); | |
1222 | }; | |
1223 | ||
1224 | ||
1225 | ||
1226 | ||
1227 | //--------------------------------------------------------------------------- | |
1228 | %init %{ | |
1229 | wxPyPtrTypeMap_Add("wxHtmlTagHandler", "wxPyHtmlTagHandler"); | |
9416aa89 | 1230 | wxPyPtrTypeMap_Add("wxHtmlWinTagHandler", "wxPyHtmlWinTagHandler"); |
d14a1e28 RD |
1231 | wxPyPtrTypeMap_Add("wxHtmlWindow", "wxPyHtmlWindow"); |
1232 | wxPyPtrTypeMap_Add("wxHtmlFilter", "wxPyHtmlFilter"); | |
4b123bb9 | 1233 | %} |
d14a1e28 RD |
1234 | //--------------------------------------------------------------------------- |
1235 | //--------------------------------------------------------------------------- | |
4b123bb9 | 1236 | |
e166644c | 1237 | |
e166644c | 1238 |