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