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