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