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