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