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