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