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