]>
Commit | Line | Data |
---|---|---|
08127323 | 1 | ///////////////////////////////////////////////////////////////////////////// |
d14a1e28 RD |
2 | // Name: _vscroll.i |
3 | // Purpose: SWIG interface defs for wxVScrolledWindow, wxVListBox, and | |
4 | // wxHtmlListBox | |
08127323 RD |
5 | // |
6 | // Author: Robin Dunn | |
7 | // | |
d14a1e28 | 8 | // Created: 14-Aug-2003 |
08127323 | 9 | // RCS-ID: $Id$ |
d14a1e28 | 10 | // Copyright: (c) 2003 by Total Control Software |
08127323 RD |
11 | // Licence: wxWindows license |
12 | ///////////////////////////////////////////////////////////////////////////// | |
13 | ||
d14a1e28 | 14 | // Not a %module |
08127323 RD |
15 | |
16 | ||
17 | //--------------------------------------------------------------------------- | |
0122b7e3 RD |
18 | |
19 | %{ | |
d14a1e28 | 20 | #include <wx/tipwin.h> |
0122b7e3 RD |
21 | %} |
22 | ||
1fded56b | 23 | //--------------------------------------------------------------------------- |
d14a1e28 | 24 | %newgroup; |
1fded56b | 25 | |
4416b508 | 26 | |
3628e088 RD |
27 | // wxVScrolledWindow |
28 | ||
29 | %{ | |
30 | #include <wx/vscroll.h> | |
3628e088 RD |
31 | %} |
32 | ||
33 | ||
34 | // First, the C++ version | |
35 | %{ | |
36 | class wxPyVScrolledWindow : public wxVScrolledWindow | |
37 | { | |
4617be08 | 38 | DECLARE_ABSTRACT_CLASS(wxPyVScrolledWindow) |
3628e088 RD |
39 | public: |
40 | wxPyVScrolledWindow() : wxVScrolledWindow() {} | |
41 | ||
42 | wxPyVScrolledWindow(wxWindow *parent, | |
43 | wxWindowID id = wxID_ANY, | |
44 | const wxPoint& pos = wxDefaultPosition, | |
45 | const wxSize& size = wxDefaultSize, | |
46 | long style = 0, | |
47 | const wxString& name = wxPyPanelNameStr) | |
48 | : wxVScrolledWindow(parent, id, pos, size, style, name) | |
49 | {} | |
50 | ||
51 | // Overridable virtuals | |
52 | ||
53 | // this function must be overridden in the derived class and it should | |
54 | // return the height of the given line in pixels | |
55 | DEC_PYCALLBACK_COORD_SIZET_constpure(OnGetLineHeight); | |
56 | ||
57 | ||
58 | // this function doesn't have to be overridden but it may be useful to do | |
59 | // it if calculating the lines heights is a relatively expensive operation | |
60 | // as it gives the user code a possibility to calculate several of them at | |
61 | // once | |
62 | // | |
63 | // OnGetLinesHint() is normally called just before OnGetLineHeight() but you | |
64 | // shouldn't rely on the latter being called for all lines in the interval | |
65 | // specified here. It is also possible that OnGetLineHeight() will be | |
66 | // called for the lines outside of this interval, so this is really just a | |
67 | // hint, not a promise. | |
68 | // | |
69 | // finally note that lineMin is inclusive, while lineMax is exclusive, as | |
70 | // usual | |
71 | DEC_PYCALLBACK_VOID_SIZETSIZET_const(OnGetLinesHint); | |
72 | ||
73 | ||
74 | // when the number of lines changes, we try to estimate the total height | |
75 | // of all lines which is a rather expensive operation in terms of lines | |
76 | // access, so if the user code may estimate the average height | |
77 | // better/faster than we do, it should override this function to implement | |
78 | // its own logic | |
79 | // | |
80 | // this function should return the best guess for the total height it may | |
81 | // make | |
82 | DEC_PYCALLBACK_COORD_const(EstimateTotalHeight); | |
83 | ||
84 | ||
85 | // Also expose some other interesting protected methods | |
86 | ||
87 | ||
88 | // find the index of the line we need to show at the top of the window such | |
89 | // that the last (fully or partially) visible line is the given one | |
a72f4631 | 90 | size_t FindFirstFromBottom(size_t lineLast, bool fullyVisible = false) |
3628e088 RD |
91 | { return wxVScrolledWindow::FindFirstFromBottom(lineLast, fullyVisible); } |
92 | ||
93 | // get the total height of the lines between lineMin (inclusive) and | |
94 | // lineMax (exclusive) | |
95 | wxCoord GetLinesHeight(size_t lineMin, size_t lineMax) const | |
96 | { return wxVScrolledWindow::GetLinesHeight(lineMin, lineMax); } | |
97 | ||
98 | ||
99 | PYPRIVATE; | |
100 | }; | |
101 | ||
102 | IMPLEMENT_ABSTRACT_CLASS(wxPyVScrolledWindow, wxVScrolledWindow); | |
103 | ||
104 | IMP_PYCALLBACK_COORD_SIZET_constpure(wxPyVScrolledWindow, wxVScrolledWindow, OnGetLineHeight); | |
105 | IMP_PYCALLBACK_VOID_SIZETSIZET_const(wxPyVScrolledWindow, wxVScrolledWindow, OnGetLinesHint); | |
106 | IMP_PYCALLBACK_COORD_const (wxPyVScrolledWindow, wxVScrolledWindow, EstimateTotalHeight); | |
107 | %} | |
108 | ||
109 | ||
110 | ||
111 | // Now define this class for SWIG | |
112 | ||
113 | /* | |
114 | In the name of this class, "V" may stand for "variable" because it can be | |
115 | used for scrolling lines of variable heights; "virtual" because it is not | |
116 | necessary to know the heights of all lines in advance -- only those which | |
117 | are shown on the screen need to be measured; or, even, "vertical" because | |
118 | this class only supports scrolling in one direction currently (this could | |
119 | and probably will change in the future however). | |
120 | ||
121 | In any case, this is a generalization of the wxScrolledWindow class which | |
122 | can be only used when all lines have the same height. It lacks some other | |
123 | wxScrolledWindow features however, notably it currently lacks support for | |
124 | horizontal scrolling; it can't scroll another window nor only a rectangle | |
125 | of the window and not its entire client area. | |
126 | */ | |
127 | ||
ab1f7d2a RD |
128 | MustHaveApp(wxPyVScrolledWindow); |
129 | ||
1b8c7ba6 RD |
130 | %rename(VScrolledWindow) wxPyVScrolledWindow; |
131 | class wxPyVScrolledWindow : public wxPanel | |
3628e088 RD |
132 | { |
133 | public: | |
2b9048c5 RD |
134 | %pythonAppend wxPyVScrolledWindow "self._setOORInfo(self); self._setCallbackInfo(self, VScrolledWindow)" |
135 | %pythonAppend wxPyVScrolledWindow() "" | |
d14a1e28 | 136 | |
3628e088 RD |
137 | |
138 | wxPyVScrolledWindow(wxWindow *parent, | |
139 | wxWindowID id = wxID_ANY, | |
140 | const wxPoint& pos = wxDefaultPosition, | |
141 | const wxSize& size = wxDefaultSize, | |
142 | long style = 0, | |
143 | const wxString& name = wxPyPanelNameStr); | |
144 | ||
1b8c7ba6 | 145 | %RenameCtor(PreVScrolledWindow, wxPyVScrolledWindow()); |
3628e088 RD |
146 | |
147 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
3628e088 RD |
148 | |
149 | bool Create(wxWindow *parent, | |
150 | wxWindowID id = wxID_ANY, | |
151 | const wxPoint& pos = wxDefaultPosition, | |
152 | const wxSize& size = wxDefaultSize, | |
153 | long style = 0, | |
154 | const wxString& name = wxPyPanelNameStr); | |
155 | ||
156 | ||
157 | // set the number of lines the window contains: the derived class must | |
158 | // provide the heights for all lines with indices up to the one given here | |
159 | // in its OnGetLineHeight() | |
160 | void SetLineCount(size_t count); | |
161 | ||
162 | // scroll to the specified line: it will become the first visible line in | |
163 | // the window | |
164 | // | |
dd9f7fea | 165 | // return True if we scrolled the window, False if nothing was done |
3628e088 RD |
166 | bool ScrollToLine(size_t line); |
167 | ||
168 | // scroll by the specified number of lines/pages | |
169 | virtual bool ScrollLines(int lines); | |
170 | virtual bool ScrollPages(int pages); | |
171 | ||
172 | // redraw the specified line | |
173 | void RefreshLine(size_t line); | |
174 | ||
175 | // redraw all lines in the specified range (inclusive) | |
176 | void RefreshLines(size_t from, size_t to); | |
177 | ||
178 | // return the item at the specified (in physical coordinates) position or | |
179 | // wxNOT_FOUND if none, i.e. if it is below the last item | |
1b8c7ba6 | 180 | %Rename(HitTestXY, int, HitTest(wxCoord x, wxCoord y) const); |
3628e088 RD |
181 | int HitTest(const wxPoint& pt) const; |
182 | ||
183 | // recalculate all our parameters and redisplay all lines | |
184 | virtual void RefreshAll(); | |
185 | ||
186 | ||
187 | // get the number of lines this window contains (previously set by | |
188 | // SetLineCount()) | |
189 | size_t GetLineCount() const; | |
190 | ||
191 | // get the first currently visible line | |
33661156 | 192 | size_t GetVisibleBegin() const; |
3628e088 RD |
193 | |
194 | // get the last currently visible line | |
33661156 | 195 | size_t GetVisibleEnd() const; |
3628e088 RD |
196 | |
197 | // is this line currently visible? | |
198 | bool IsVisible(size_t line) const; | |
199 | ||
88609ec9 RD |
200 | // this is the same as GetVisibleBegin(), exists to match |
201 | // GetLastVisibleLine() and for backwards compatibility only | |
202 | size_t GetFirstVisibleLine() const; | |
203 | ||
204 | // get the last currently visible line | |
205 | // | |
206 | // this function is unsafe as it returns (size_t)-1 (i.e. a huge positive | |
207 | // number) if the control is empty, use GetVisibleEnd() instead, this one | |
208 | // is kept for backwards compatibility | |
209 | size_t GetLastVisibleLine() const; | |
210 | ||
4424b2a1 RD |
211 | // find the index of the line we need to show at the top of the window such |
212 | // that the last (fully or partially) visible line is the given one | |
213 | size_t FindFirstFromBottom(size_t lineLast, bool fullyVisible = false); | |
214 | ||
215 | // get the total height of the lines between lineMin (inclusive) and | |
216 | // lineMax (exclusive) | |
217 | wxCoord GetLinesHeight(size_t lineMin, size_t lineMax) const; | |
3628e088 RD |
218 | }; |
219 | ||
4424b2a1 RD |
220 | |
221 | ||
3628e088 RD |
222 | //--------------------------------------------------------------------------- |
223 | // wxVListBox | |
224 | ||
225 | %{ | |
226 | #include <wx/vlbox.h> | |
3628e088 RD |
227 | %} |
228 | ||
b2dc1044 RD |
229 | MAKE_CONST_WXSTRING(VListBoxNameStr); |
230 | ||
3628e088 RD |
231 | |
232 | // First, the C++ version | |
233 | %{ | |
234 | class wxPyVListBox : public wxVListBox | |
235 | { | |
4617be08 | 236 | DECLARE_ABSTRACT_CLASS(wxPyVListBox) |
3628e088 RD |
237 | public: |
238 | wxPyVListBox() : wxVListBox() {} | |
239 | ||
240 | wxPyVListBox(wxWindow *parent, | |
241 | wxWindowID id = wxID_ANY, | |
242 | const wxPoint& pos = wxDefaultPosition, | |
243 | const wxSize& size = wxDefaultSize, | |
244 | long style = 0, | |
245 | const wxString& name = wxPyVListBoxNameStr) | |
246 | : wxVListBox(parent, id, pos, size, style, name) | |
247 | {} | |
248 | ||
249 | // Overridable virtuals | |
250 | ||
251 | // the derived class must implement this function to actually draw the item | |
252 | // with the given index on the provided DC | |
253 | // virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const = 0; | |
254 | DEC_PYCALLBACK__DCRECTSIZET_constpure(OnDrawItem); | |
255 | ||
256 | ||
257 | // the derived class must implement this method to return the height of the | |
258 | // specified item | |
259 | // virtual wxCoord OnMeasureItem(size_t n) const = 0; | |
260 | DEC_PYCALLBACK_COORD_SIZET_constpure(OnMeasureItem); | |
261 | ||
262 | ||
263 | // this method may be used to draw separators between the lines; note that | |
264 | // the rectangle may be modified, typically to deflate it a bit before | |
265 | // passing to OnDrawItem() | |
266 | // | |
267 | // the base class version doesn't do anything | |
268 | // virtual void OnDrawSeparator(wxDC& dc, wxRect& rect, size_t n) const; | |
8072477d | 269 | DEC_PYCALLBACK__DCRECTSIZET2_const(OnDrawSeparator); |
3628e088 RD |
270 | |
271 | ||
272 | // this method is used to draw the items background and, maybe, a border | |
273 | // around it | |
274 | // | |
275 | // the base class version implements a reasonable default behaviour which | |
276 | // consists in drawing the selected item with the standard background | |
277 | // colour and drawing a border around the item if it is either selected or | |
278 | // current | |
279 | // virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const; | |
280 | DEC_PYCALLBACK__DCRECTSIZET_const(OnDrawBackground); | |
281 | ||
282 | ||
283 | PYPRIVATE; | |
284 | }; | |
285 | ||
286 | IMPLEMENT_ABSTRACT_CLASS(wxPyVListBox, wxVListBox); | |
287 | ||
288 | IMP_PYCALLBACK__DCRECTSIZET_constpure(wxPyVListBox, wxVListBox, OnDrawItem); | |
289 | IMP_PYCALLBACK_COORD_SIZET_constpure (wxPyVListBox, wxVListBox, OnMeasureItem); | |
8072477d | 290 | IMP_PYCALLBACK__DCRECTSIZET2_const (wxPyVListBox, wxVListBox, OnDrawSeparator); |
3628e088 RD |
291 | IMP_PYCALLBACK__DCRECTSIZET_const (wxPyVListBox, wxVListBox, OnDrawBackground); |
292 | ||
293 | %} | |
294 | ||
295 | ||
296 | ||
297 | // Now define this class for SWIG | |
298 | ||
299 | /* | |
300 | This class has two main differences from a regular listbox: it can have an | |
301 | arbitrarily huge number of items because it doesn't store them itself but | |
302 | uses OnDrawItem() callback to draw them and its items can have variable | |
303 | height as determined by OnMeasureItem(). | |
304 | ||
305 | It emits the same events as wxListBox and the same event macros may be used | |
306 | with it. | |
307 | */ | |
ab1f7d2a RD |
308 | MustHaveApp(wxPyVListBox); |
309 | ||
1b8c7ba6 RD |
310 | %rename(VListBox) wxPyVListBox; |
311 | class wxPyVListBox : public wxPyVScrolledWindow | |
3628e088 RD |
312 | { |
313 | public: | |
2b9048c5 RD |
314 | %pythonAppend wxPyVListBox "self._setOORInfo(self);self._setCallbackInfo(self, VListBox)" |
315 | %pythonAppend wxPyVListBox() "" | |
d14a1e28 | 316 | |
3628e088 RD |
317 | |
318 | wxPyVListBox(wxWindow *parent, | |
319 | wxWindowID id = wxID_ANY, | |
320 | const wxPoint& pos = wxDefaultPosition, | |
321 | const wxSize& size = wxDefaultSize, | |
322 | long style = 0, | |
323 | const wxString& name = wxPyVListBoxNameStr); | |
324 | ||
1b8c7ba6 | 325 | %RenameCtor(PreVListBox, wxPyVListBox()); |
3628e088 RD |
326 | |
327 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
3628e088 RD |
328 | |
329 | bool Create(wxWindow *parent, | |
330 | wxWindowID id = wxID_ANY, | |
331 | const wxPoint& pos = wxDefaultPosition, | |
332 | const wxSize& size = wxDefaultSize, | |
333 | long style = 0, | |
334 | const wxString& name = wxPyVListBoxNameStr); | |
335 | ||
336 | // get the number of items in the control | |
337 | size_t GetItemCount() const; | |
338 | ||
339 | // does this control use multiple selection? | |
340 | bool HasMultipleSelection() const; | |
341 | ||
342 | // get the currently selected item or wxNOT_FOUND if there is no selection | |
343 | // | |
344 | // this method is only valid for the single selection listboxes | |
345 | int GetSelection() const; | |
346 | ||
347 | // is this item the current one? | |
348 | bool IsCurrent(size_t item) const; | |
349 | ||
350 | // is this item selected? | |
351 | bool IsSelected(size_t item) const; | |
352 | ||
353 | // get the number of the selected items (maybe 0) | |
354 | // | |
355 | // this method is valid for both single and multi selection listboxes | |
356 | size_t GetSelectedCount() const; | |
357 | ||
3d8a2fd7 RD |
358 | %extend { |
359 | // get the first selected item, returns wxNOT_FOUND if none | |
360 | // | |
361 | // cookie is an opaque parameter which should be passed to | |
362 | // GetNextSelected() later | |
363 | // | |
364 | // this method is only valid for the multi selection listboxes | |
365 | //int GetFirstSelected(unsigned long& cookie) const; | |
366 | PyObject* GetFirstSelected() { | |
367 | unsigned long cookie = 0; | |
368 | int selected = self->GetFirstSelected(cookie); | |
6e6b3557 | 369 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
3d8a2fd7 RD |
370 | PyObject* tup = PyTuple_New(2); |
371 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(selected)); | |
372 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(cookie)); | |
373 | wxPyEndBlockThreads(blocked); | |
374 | return tup; | |
375 | } | |
376 | ||
377 | // get next selection item, return wxNOT_FOUND if no more | |
378 | // | |
379 | // cookie must be the same parameter that was passed to GetFirstSelected() | |
380 | // before | |
381 | // | |
382 | // this method is only valid for the multi selection listboxes | |
383 | // int GetNextSelected(unsigned long& cookie) const; | |
384 | PyObject* GetNextSelected(unsigned long cookie) { | |
385 | int selected = self->GetNextSelected(cookie); | |
6e6b3557 | 386 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
3d8a2fd7 RD |
387 | PyObject* tup = PyTuple_New(2); |
388 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(selected)); | |
389 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(cookie)); | |
390 | wxPyEndBlockThreads(blocked); | |
391 | return tup; | |
392 | } | |
393 | } | |
3628e088 | 394 | |
3d8a2fd7 | 395 | |
3628e088 RD |
396 | // get the margins around each item |
397 | wxPoint GetMargins() const; | |
398 | ||
399 | // get the background colour of selected cells | |
400 | const wxColour& GetSelectionBackground() const; | |
401 | ||
402 | ||
403 | // set the number of items to be shown in the control | |
404 | // | |
405 | // this is just a synonym for wxVScrolledWindow::SetLineCount() | |
406 | void SetItemCount(size_t count); | |
407 | ||
408 | // delete all items from the control | |
409 | void Clear(); | |
410 | ||
411 | // set the selection to the specified item, if it is wxNOT_FOUND the | |
412 | // selection is unset | |
413 | // | |
414 | // this function is only valid for the single selection listboxes | |
415 | void SetSelection(int selection); | |
416 | ||
417 | // selects or deselects the specified item which must be valid (i.e. not | |
418 | // equal to wxNOT_FOUND) | |
419 | // | |
dd9f7fea | 420 | // return True if the items selection status has changed or False |
3628e088 RD |
421 | // otherwise |
422 | // | |
423 | // this function is only valid for the multiple selection listboxes | |
a72f4631 | 424 | bool Select(size_t item, bool select = true); |
3628e088 RD |
425 | |
426 | // selects the items in the specified range whose end points may be given | |
427 | // in any order | |
428 | // | |
dd9f7fea | 429 | // return True if any items selection status has changed, False otherwise |
3628e088 RD |
430 | // |
431 | // this function is only valid for the single selection listboxes | |
432 | bool SelectRange(size_t from, size_t to); | |
433 | ||
434 | // toggle the selection of the specified item (must be valid) | |
435 | // | |
436 | // this function is only valid for the multiple selection listboxes | |
437 | void Toggle(size_t item); | |
438 | ||
439 | // select all items in the listbox | |
440 | // | |
441 | // the return code indicates if any items were affected by this operation | |
dd9f7fea | 442 | // (True) or if nothing has changed (False) |
3628e088 RD |
443 | bool SelectAll(); |
444 | ||
445 | // unselect all items in the listbox | |
446 | // | |
447 | // the return code has the same meaning as for SelectAll() | |
448 | bool DeselectAll(); | |
449 | ||
450 | // set the margins: horizontal margin is the distance between the window | |
451 | // border and the item contents while vertical margin is half of the | |
452 | // distance between items | |
453 | // | |
454 | // by default both margins are 0 | |
455 | void SetMargins(const wxPoint& pt); | |
1b8c7ba6 | 456 | %Rename(SetMarginsXY, void, SetMargins(wxCoord x, wxCoord y)); |
3628e088 RD |
457 | |
458 | // change the background colour of the selected cells | |
459 | void SetSelectionBackground(const wxColour& col); | |
460 | ||
8072477d RD |
461 | virtual void OnDrawSeparator(wxDC& dc, wxRect& rect, size_t n) const; |
462 | virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const; | |
3628e088 RD |
463 | }; |
464 | ||
465 | ||
466 | //--------------------------------------------------------------------------- | |
467 | // wxHtmlListBox | |
468 | ||
469 | %{ | |
470 | #include <wx/htmllbox.h> | |
471 | %} | |
472 | ||
473 | // First, the C++ version | |
474 | %{ | |
475 | class wxPyHtmlListBox : public wxHtmlListBox | |
476 | { | |
4617be08 | 477 | DECLARE_ABSTRACT_CLASS(wxPyHtmlListBox) |
3628e088 RD |
478 | public: |
479 | wxPyHtmlListBox() : wxHtmlListBox() {} | |
480 | ||
481 | wxPyHtmlListBox(wxWindow *parent, | |
482 | wxWindowID id = wxID_ANY, | |
483 | const wxPoint& pos = wxDefaultPosition, | |
484 | const wxSize& size = wxDefaultSize, | |
485 | long style = 0, | |
486 | const wxString& name = wxPyVListBoxNameStr) | |
487 | : wxHtmlListBox(parent, id, pos, size, style, name) | |
488 | {} | |
489 | ||
490 | // Overridable virtuals | |
491 | ||
492 | // this method must be implemented in the derived class and should return | |
493 | // the body (i.e. without <html>) of the HTML for the given item | |
494 | DEC_PYCALLBACK_STRING_SIZET_pure(OnGetItem); | |
495 | ||
496 | // this function may be overridden to decorate HTML returned by OnGetItem() | |
497 | DEC_PYCALLBACK_STRING_SIZET(OnGetItemMarkup); | |
498 | ||
8072477d RD |
499 | // These are from wxVListBox |
500 | DEC_PYCALLBACK__DCRECTSIZET2_const(OnDrawSeparator); | |
501 | DEC_PYCALLBACK__DCRECTSIZET_const(OnDrawBackground); | |
502 | ||
3628e088 RD |
503 | // TODO: |
504 | // // this method allows to customize the selection appearance: it may be used | |
505 | // // to specify the colour of the text which normally has the given colour | |
506 | // // colFg when it is inside the selection | |
507 | // // | |
508 | // // by default, the original colour is not used at all and all text has the | |
509 | // // same (default for this system) colour inside selection | |
510 | // virtual wxColour GetSelectedTextColour(const wxColour& colFg) const; | |
511 | ||
512 | // // this is the same as GetSelectedTextColour() but allows to customize the | |
513 | // // background colour -- this is even more rarely used as you can change it | |
514 | // // globally using SetSelectionBackground() | |
515 | // virtual wxColour GetSelectedTextBgColour(const wxColour& colBg) const; | |
516 | ||
2890ca15 RD |
517 | |
518 | // This method may be overriden to handle clicking on a link in | |
519 | // the listbox. By default, clicking links is ignored. | |
520 | virtual void OnLinkClicked(size_t n, | |
521 | const wxHtmlLinkInfo& link); | |
3628e088 RD |
522 | |
523 | PYPRIVATE; | |
524 | }; | |
525 | ||
526 | ||
527 | IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlListBox, wxHtmlListBox) | |
528 | ||
529 | IMP_PYCALLBACK_STRING_SIZET_pure(wxPyHtmlListBox, wxHtmlListBox, OnGetItem); | |
530 | IMP_PYCALLBACK_STRING_SIZET (wxPyHtmlListBox, wxHtmlListBox, OnGetItemMarkup); | |
8072477d RD |
531 | IMP_PYCALLBACK__DCRECTSIZET2_const (wxPyHtmlListBox, wxHtmlListBox, OnDrawSeparator); |
532 | IMP_PYCALLBACK__DCRECTSIZET_const (wxPyHtmlListBox, wxHtmlListBox, OnDrawBackground); | |
3628e088 | 533 | |
2890ca15 RD |
534 | |
535 | void wxPyHtmlListBox::OnLinkClicked(size_t n, | |
536 | const wxHtmlLinkInfo& link) { | |
537 | bool found; | |
538 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
539 | if ((found = wxPyCBH_findCallback(m_myInst, "OnLinkClicked"))) { | |
540 | PyObject* obj = wxPyConstructObject((void*)&link, wxT("wxHtmlLinkInfo"), 0); | |
541 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(iO)", n, obj)); | |
542 | Py_DECREF(obj); | |
543 | } | |
544 | wxPyEndBlockThreads(blocked); | |
545 | if (! found) | |
546 | wxPyHtmlListBox::OnLinkClicked(n, link); | |
547 | } | |
548 | ||
3628e088 RD |
549 | %} |
550 | ||
551 | ||
552 | ||
553 | // Now define this class for SWIG | |
554 | ||
555 | ||
556 | // wxHtmlListBox is a listbox whose items are wxHtmlCells | |
ab1f7d2a | 557 | MustHaveApp(wxPyHtmlListBox); |
1b8c7ba6 RD |
558 | %rename(HtmlListBox) wxPyHtmlListBox; |
559 | class wxPyHtmlListBox : public wxPyVListBox | |
3628e088 RD |
560 | { |
561 | public: | |
2b9048c5 RD |
562 | %pythonAppend wxPyHtmlListBox "self._setOORInfo(self);self._setCallbackInfo(self, HtmlListBox)" |
563 | %pythonAppend wxPyHtmlListBox() "" | |
d14a1e28 | 564 | |
3628e088 RD |
565 | |
566 | // normal constructor which calls Create() internally | |
567 | wxPyHtmlListBox(wxWindow *parent, | |
568 | wxWindowID id = wxID_ANY, | |
569 | const wxPoint& pos = wxDefaultPosition, | |
570 | const wxSize& size = wxDefaultSize, | |
571 | long style = 0, | |
572 | const wxString& name = wxPyVListBoxNameStr); | |
573 | ||
1b8c7ba6 | 574 | %RenameCtor(PreHtmlListBox, wxPyHtmlListBox()); |
3628e088 RD |
575 | |
576 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
3628e088 RD |
577 | |
578 | bool Create(wxWindow *parent, | |
579 | wxWindowID id = wxID_ANY, | |
580 | const wxPoint& pos = wxDefaultPosition, | |
581 | const wxSize& size = wxDefaultSize, | |
582 | long style = 0, | |
583 | const wxString& name = wxPyVListBoxNameStr); | |
584 | ||
585 | ||
586 | void RefreshAll(); | |
587 | void SetItemCount(size_t count); | |
588 | ||
450d55a0 RD |
589 | // retrieve the file system used by the wxHtmlWinParser: if you use |
590 | // relative paths in your HTML, you should use its ChangePathTo() method | |
591 | wxFileSystem& GetFileSystem(); | |
2890ca15 RD |
592 | |
593 | void OnLinkClicked(size_t n, const wxHtmlLinkInfo& link); | |
3628e088 RD |
594 | }; |
595 | ||
596 | ||
d14a1e28 | 597 | |
3628e088 | 598 | //--------------------------------------------------------------------------- |
4416b508 | 599 | |
771eb7a2 RD |
600 | %init %{ |
601 | // Map renamed classes back to their common name for OOR | |
d14a1e28 RD |
602 | wxPyPtrTypeMap_Add("wxHtmlListBox", "wxPyHtmlListBox"); |
603 | wxPyPtrTypeMap_Add("wxVListBox", "wxPyVListBox"); | |
771eb7a2 RD |
604 | wxPyPtrTypeMap_Add("wxVScrolledWindow", "wxPyVScrolledWindow"); |
605 | %} | |
606 | ||
d14a1e28 | 607 | //--------------------------------------------------------------------------- |