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