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