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