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