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