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