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