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