]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/windows3.i
reSWIGged
[wxWidgets.git] / wxPython / src / windows3.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: windows3.i
3 // Purpose: SWIG definitions of MORE window classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 22-Dec-1998
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %module windows3
14
15 %{
16 #include "helpers.h"
17 #include <wx/sashwin.h>
18 #include <wx/laywin.h>
19 #include <wx/popupwin.h>
20 #include <wx/tipwin.h>
21 %}
22
23 //----------------------------------------------------------------------
24
25 %include typemaps.i
26 %include my_typemaps.i
27
28 // Import some definitions of other classes, etc.
29 %import _defs.i
30 %import misc.i
31 %import gdi.i
32 %import windows.i
33 %import windows2.i
34 %import mdi.i
35 %import events.i
36
37 %pragma(python) code = "import wx"
38
39 //----------------------------------------------------------------------
40
41 %{
42 // Put some wx default wxChar* values into wxStrings.
43 static const wxChar* wxSashNameStr = wxT("sashWindow");
44 DECLARE_DEF_STRING(SashNameStr);
45 static const wxChar* wxSashLayoutNameStr = wxT("layoutWindow");
46 DECLARE_DEF_STRING(SashLayoutNameStr);
47 %}
48 //---------------------------------------------------------------------------
49
50 enum wxSashEdgePosition {
51 wxSASH_TOP = 0,
52 wxSASH_RIGHT,
53 wxSASH_BOTTOM,
54 wxSASH_LEFT,
55 wxSASH_NONE = 100
56 };
57
58 enum {
59 wxEVT_SASH_DRAGGED,
60 wxSW_3D,
61 wxSW_3DSASH,
62 wxSW_3DBORDER,
63 wxSW_BORDER
64 };
65
66 enum wxSashDragStatus
67 {
68 wxSASH_STATUS_OK,
69 wxSASH_STATUS_OUT_OF_RANGE
70 };
71
72
73 class wxSashEvent : public wxCommandEvent {
74 public:
75 wxSashEvent(int id = 0, wxSashEdgePosition edge = wxSASH_NONE);
76
77 void SetEdge(wxSashEdgePosition edge);
78 wxSashEdgePosition GetEdge();
79 void SetDragRect(const wxRect& rect);
80 wxRect GetDragRect();
81 void SetDragStatus(wxSashDragStatus status);
82 wxSashDragStatus GetDragStatus();
83 };
84
85
86
87 class wxSashWindow: public wxWindow {
88 public:
89 wxSashWindow(wxWindow* parent, wxWindowID id,
90 const wxPoint& pos = wxDefaultPosition,
91 const wxSize& size = wxDefaultSize,
92 long style = wxCLIP_CHILDREN | wxSW_3D,
93 const wxString& name = wxPySashNameStr);
94 %name(wxPreSashWindow)wxSashWindow();
95
96 bool Create(wxWindow* parent, wxWindowID id,
97 const wxPoint& pos = wxDefaultPosition,
98 const wxSize& size = wxDefaultSize,
99 long style = wxCLIP_CHILDREN | wxSW_3D,
100 const wxString& name = wxPySashNameStr);
101
102 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
103 %pragma(python) addtomethod = "wxPreSashWindow:val._setOORInfo(val)"
104
105 bool GetSashVisible(wxSashEdgePosition edge);
106 int GetDefaultBorderSize();
107 int GetEdgeMargin(wxSashEdgePosition edge);
108 int GetExtraBorderSize();
109 int GetMaximumSizeX();
110 int GetMaximumSizeY();
111 int GetMinimumSizeX();
112 int GetMinimumSizeY();
113 bool HasBorder(wxSashEdgePosition edge);
114 void SetDefaultBorderSize(int width);
115 void SetExtraBorderSize(int width);
116 void SetMaximumSizeX(int min);
117 void SetMaximumSizeY(int min);
118 void SetMinimumSizeX(int min);
119 void SetMinimumSizeY(int min);
120 void SetSashVisible(wxSashEdgePosition edge, bool visible);
121 void SetSashBorder(wxSashEdgePosition edge, bool hasBorder);
122
123 };
124
125
126 //---------------------------------------------------------------------------
127
128 enum wxLayoutOrientation {
129 wxLAYOUT_HORIZONTAL,
130 wxLAYOUT_VERTICAL
131 };
132
133 enum wxLayoutAlignment {
134 wxLAYOUT_NONE,
135 wxLAYOUT_TOP,
136 wxLAYOUT_LEFT,
137 wxLAYOUT_RIGHT,
138 wxLAYOUT_BOTTOM,
139 };
140
141
142 enum {
143 wxEVT_QUERY_LAYOUT_INFO,
144 wxEVT_CALCULATE_LAYOUT,
145 };
146
147
148 class wxQueryLayoutInfoEvent: public wxEvent {
149 public:
150 wxQueryLayoutInfoEvent(wxWindowID id = 0);
151
152 void SetRequestedLength(int length);
153 int GetRequestedLength();
154 void SetFlags(int flags);
155 int GetFlags();
156 void SetSize(const wxSize& size);
157 wxSize GetSize();
158 void SetOrientation(wxLayoutOrientation orient);
159 wxLayoutOrientation GetOrientation();
160 void SetAlignment(wxLayoutAlignment align);
161 wxLayoutAlignment GetAlignment();
162 };
163
164
165
166 class wxCalculateLayoutEvent: public wxEvent {
167 public:
168 wxCalculateLayoutEvent(wxWindowID id = 0);
169
170 void SetFlags(int flags);
171 int GetFlags();
172 void SetRect(const wxRect& rect);
173 wxRect GetRect();
174 };
175
176
177 class wxSashLayoutWindow: public wxSashWindow {
178 public:
179 wxSashLayoutWindow(wxWindow* parent, wxWindowID id,
180 const wxPoint& pos = wxDefaultPosition,
181 const wxSize& size = wxDefaultSize,
182 long style = wxCLIP_CHILDREN | wxSW_3D,
183 const wxString& name = wxPySashLayoutNameStr);
184 %name(wxPreSashLayoutWindow)wxSashLayoutWindow();
185
186 bool Create(wxWindow* parent, wxWindowID id,
187 const wxPoint& pos = wxDefaultPosition,
188 const wxSize& size = wxDefaultSize,
189 long style = wxCLIP_CHILDREN | wxSW_3D,
190 const wxString& name = wxPySashLayoutNameStr);
191
192 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
193 %pragma(python) addtomethod = "wxPreSashLayoutWindow:val._setOORInfo(val)"
194
195 wxLayoutAlignment GetAlignment();
196 wxLayoutOrientation GetOrientation();
197 void SetAlignment(wxLayoutAlignment alignment);
198 void SetDefaultSize(const wxSize& size);
199 void SetOrientation(wxLayoutOrientation orientation);
200 };
201
202 //---------------------------------------------------------------------------
203
204 class wxLayoutAlgorithm : public wxObject {
205 public:
206 wxLayoutAlgorithm();
207 ~wxLayoutAlgorithm();
208
209 bool LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* rect = NULL);
210 bool LayoutFrame(wxFrame* frame, wxWindow* mainWindow = NULL);
211 bool LayoutWindow(wxWindow* parent, wxWindow* mainWindow = NULL);
212 };
213
214
215 //---------------------------------------------------------------------------
216 #ifndef __WXMAC__
217
218 // wxPopupWindow: a special kind of top level window used for popup menus,
219 // combobox popups and such.
220 class wxPopupWindow : public wxWindow {
221 public:
222 wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE);
223 %name(wxPrePopupWindow)wxPopupWindow();
224
225 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
226 %pragma(python) addtomethod = "wxPrePopupWindow:val._setOORInfo(val)"
227
228 bool Create(wxWindow *parent, int flags = wxBORDER_NONE);
229
230 // the point must be given in screen coordinates!
231 void Position(const wxPoint& ptOrigin,
232 const wxSize& size);
233 };
234
235
236 %{
237 class wxPyPopupTransientWindow : public wxPopupTransientWindow
238 {
239 public:
240 wxPyPopupTransientWindow() : wxPopupTransientWindow() {}
241 wxPyPopupTransientWindow(wxWindow* parent, int style = wxBORDER_NONE)
242 : wxPopupTransientWindow(parent, style) {}
243
244 DEC_PYCALLBACK_BOOL_ME(ProcessLeftDown);
245 DEC_PYCALLBACK__(OnDismiss);
246 DEC_PYCALLBACK_BOOL_(CanDismiss);
247 PYPRIVATE;
248 };
249
250 IMP_PYCALLBACK_BOOL_ME(wxPyPopupTransientWindow, wxPopupTransientWindow, ProcessLeftDown);
251 IMP_PYCALLBACK__(wxPyPopupTransientWindow, wxPopupTransientWindow, OnDismiss);
252 IMP_PYCALLBACK_BOOL_(wxPyPopupTransientWindow, wxPopupTransientWindow, CanDismiss);
253 %}
254
255
256
257 // wxPopupTransientWindow: a wxPopupWindow which disappears automatically
258 // when the user clicks mouse outside it or if it loses focus in any other way
259 %name(wxPopupTransientWindow) class wxPyPopupTransientWindow : public wxPopupWindow
260 {
261 public:
262 wxPyPopupTransientWindow(wxWindow *parent, int style = wxBORDER_NONE);
263 %name(wxPrePopupTransientWindow)wxPyPopupTransientWindow();
264
265 void _setCallbackInfo(PyObject* self, PyObject* _class);
266 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPopupTransientWindow)"
267
268 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
269 %pragma(python) addtomethod = "wxPrePopupTransientWindow:val._setOORInfo(val)"
270
271 // popup the window (this will show it too) and keep focus at winFocus
272 // (or itself if it's NULL), dismiss the popup if we lose focus
273 virtual void Popup(wxWindow *focus = NULL);
274
275 // hide the window
276 virtual void Dismiss();
277 };
278
279 //---------------------------------------------------------------------------
280
281 class wxTipWindow : public wxPyPopupTransientWindow
282 {
283 public:
284 %addmethods {
285 wxTipWindow(wxWindow *parent,
286 const wxString* text,
287 wxCoord maxLength = 100,
288 wxRect* rectBound = NULL) {
289 wxString tmp = *text;
290 return new wxTipWindow(parent, tmp, maxLength, NULL, rectBound);
291 }
292 }
293
294 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
295
296 // If rectBound is not NULL, the window will disappear automatically when
297 // the mouse leave the specified rect: note that rectBound should be in the
298 // screen coordinates!
299 void SetBoundingRect(const wxRect& rectBound);
300
301 // Hide and destroy the window
302 void Close();
303 };
304
305 #endif // ! __WXMAC__
306
307 //---------------------------------------------------------------------------
308
309 #ifdef __WXMAC__
310
311 %import frames.i
312
313 class wxTipWindow : public wxFrame
314 {
315 public:
316 %addmethods {
317 wxTipWindow(wxWindow *parent,
318 const wxString* text,
319 wxCoord maxLength = 100,
320 wxRect* rectBound = NULL) {
321 wxString tmp = *text;
322 return new wxTipWindow(parent, tmp, maxLength, NULL, rectBound);
323 }
324 }
325
326 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
327
328 // If rectBound is not NULL, the window will disappear automatically when
329 // the mouse leave the specified rect: note that rectBound should be in the
330 // screen coordinates!
331 void SetBoundingRect(const wxRect& rectBound);
332
333 // Hide and destroy the window
334 void Close();
335 };
336
337 #endif // __WXMAC__
338
339 //---------------------------------------------------------------------------
340 // wxVScrolledWindow
341
342 %{
343 #include <wx/vscroll.h>
344 DECLARE_DEF_STRING(PanelNameStr);
345 %}
346
347
348 // First, the C++ version
349 %{
350 class wxPyVScrolledWindow : public wxVScrolledWindow
351 {
352 DECLARE_ABSTRACT_CLASS(wxPyVScrolledWindow);
353 public:
354 wxPyVScrolledWindow() : wxVScrolledWindow() {}
355
356 wxPyVScrolledWindow(wxWindow *parent,
357 wxWindowID id = wxID_ANY,
358 const wxPoint& pos = wxDefaultPosition,
359 const wxSize& size = wxDefaultSize,
360 long style = 0,
361 const wxString& name = wxPyPanelNameStr)
362 : wxVScrolledWindow(parent, id, pos, size, style, name)
363 {}
364
365 // Overridable virtuals
366
367 // this function must be overridden in the derived class and it should
368 // return the height of the given line in pixels
369 DEC_PYCALLBACK_COORD_SIZET_constpure(OnGetLineHeight);
370
371
372 // this function doesn't have to be overridden but it may be useful to do
373 // it if calculating the lines heights is a relatively expensive operation
374 // as it gives the user code a possibility to calculate several of them at
375 // once
376 //
377 // OnGetLinesHint() is normally called just before OnGetLineHeight() but you
378 // shouldn't rely on the latter being called for all lines in the interval
379 // specified here. It is also possible that OnGetLineHeight() will be
380 // called for the lines outside of this interval, so this is really just a
381 // hint, not a promise.
382 //
383 // finally note that lineMin is inclusive, while lineMax is exclusive, as
384 // usual
385 DEC_PYCALLBACK_VOID_SIZETSIZET_const(OnGetLinesHint);
386
387
388 // when the number of lines changes, we try to estimate the total height
389 // of all lines which is a rather expensive operation in terms of lines
390 // access, so if the user code may estimate the average height
391 // better/faster than we do, it should override this function to implement
392 // its own logic
393 //
394 // this function should return the best guess for the total height it may
395 // make
396 DEC_PYCALLBACK_COORD_const(EstimateTotalHeight);
397
398
399 // Also expose some other interesting protected methods
400
401
402 // find the index of the line we need to show at the top of the window such
403 // that the last (fully or partially) visible line is the given one
404 size_t FindFirstFromBottom(size_t lineLast, bool fullyVisible = false)
405 { return wxVScrolledWindow::FindFirstFromBottom(lineLast, fullyVisible); }
406
407 // get the total height of the lines between lineMin (inclusive) and
408 // lineMax (exclusive)
409 wxCoord GetLinesHeight(size_t lineMin, size_t lineMax) const
410 { return wxVScrolledWindow::GetLinesHeight(lineMin, lineMax); }
411
412
413 PYPRIVATE;
414 };
415
416 IMPLEMENT_ABSTRACT_CLASS(wxPyVScrolledWindow, wxVScrolledWindow);
417
418 IMP_PYCALLBACK_COORD_SIZET_constpure(wxPyVScrolledWindow, wxVScrolledWindow, OnGetLineHeight);
419 IMP_PYCALLBACK_VOID_SIZETSIZET_const(wxPyVScrolledWindow, wxVScrolledWindow, OnGetLinesHint);
420 IMP_PYCALLBACK_COORD_const (wxPyVScrolledWindow, wxVScrolledWindow, EstimateTotalHeight);
421 %}
422
423
424
425 // Now define this class for SWIG
426
427 /*
428 In the name of this class, "V" may stand for "variable" because it can be
429 used for scrolling lines of variable heights; "virtual" because it is not
430 necessary to know the heights of all lines in advance -- only those which
431 are shown on the screen need to be measured; or, even, "vertical" because
432 this class only supports scrolling in one direction currently (this could
433 and probably will change in the future however).
434
435 In any case, this is a generalization of the wxScrolledWindow class which
436 can be only used when all lines have the same height. It lacks some other
437 wxScrolledWindow features however, notably it currently lacks support for
438 horizontal scrolling; it can't scroll another window nor only a rectangle
439 of the window and not its entire client area.
440 */
441
442 %name(wxVScrolledWindow) class wxPyVScrolledWindow : public wxPanel
443 {
444 public:
445
446 wxPyVScrolledWindow(wxWindow *parent,
447 wxWindowID id = wxID_ANY,
448 const wxPoint& pos = wxDefaultPosition,
449 const wxSize& size = wxDefaultSize,
450 long style = 0,
451 const wxString& name = wxPyPanelNameStr);
452
453 %name(wxPreVScrolledWindow)wxPyVScrolledWindow();
454
455 void _setCallbackInfo(PyObject* self, PyObject* _class);
456 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxVScrolledWindow)"
457 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
458 %pragma(python) addtomethod = "wxPreVScrolledWindow:val._setOORInfo(val)"
459
460 bool Create(wxWindow *parent,
461 wxWindowID id = wxID_ANY,
462 const wxPoint& pos = wxDefaultPosition,
463 const wxSize& size = wxDefaultSize,
464 long style = 0,
465 const wxString& name = wxPyPanelNameStr);
466
467
468 // set the number of lines the window contains: the derived class must
469 // provide the heights for all lines with indices up to the one given here
470 // in its OnGetLineHeight()
471 void SetLineCount(size_t count);
472
473 // scroll to the specified line: it will become the first visible line in
474 // the window
475 //
476 // return true if we scrolled the window, false if nothing was done
477 bool ScrollToLine(size_t line);
478
479 // scroll by the specified number of lines/pages
480 virtual bool ScrollLines(int lines);
481 virtual bool ScrollPages(int pages);
482
483 // redraw the specified line
484 void RefreshLine(size_t line);
485
486 // redraw all lines in the specified range (inclusive)
487 void RefreshLines(size_t from, size_t to);
488
489 // return the item at the specified (in physical coordinates) position or
490 // wxNOT_FOUND if none, i.e. if it is below the last item
491 %name(HitTestXT) int HitTest(wxCoord x, wxCoord y) const;
492 int HitTest(const wxPoint& pt) const;
493
494 // recalculate all our parameters and redisplay all lines
495 virtual void RefreshAll();
496
497
498 // get the number of lines this window contains (previously set by
499 // SetLineCount())
500 size_t GetLineCount() const;
501
502 // get the first currently visible line
503 size_t GetFirstVisibleLine() const;
504
505 // get the last currently visible line
506 size_t GetLastVisibleLine() const;
507
508 // is this line currently visible?
509 bool IsVisible(size_t line) const;
510
511 };
512
513 //---------------------------------------------------------------------------
514 // wxVListBox
515
516 %{
517 #include <wx/vlbox.h>
518 DECLARE_DEF_STRING(VListBoxNameStr);
519 %}
520
521
522 // First, the C++ version
523 %{
524 class wxPyVListBox : public wxVListBox
525 {
526 DECLARE_ABSTRACT_CLASS(wxPyVListBox);
527 public:
528 wxPyVListBox() : wxVListBox() {}
529
530 wxPyVListBox(wxWindow *parent,
531 wxWindowID id = wxID_ANY,
532 const wxPoint& pos = wxDefaultPosition,
533 const wxSize& size = wxDefaultSize,
534 long style = 0,
535 const wxString& name = wxPyVListBoxNameStr)
536 : wxVListBox(parent, id, pos, size, style, name)
537 {}
538
539 // Overridable virtuals
540
541 // the derived class must implement this function to actually draw the item
542 // with the given index on the provided DC
543 // virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const = 0;
544 DEC_PYCALLBACK__DCRECTSIZET_constpure(OnDrawItem);
545
546
547 // the derived class must implement this method to return the height of the
548 // specified item
549 // virtual wxCoord OnMeasureItem(size_t n) const = 0;
550 DEC_PYCALLBACK_COORD_SIZET_constpure(OnMeasureItem);
551
552
553 // this method may be used to draw separators between the lines; note that
554 // the rectangle may be modified, typically to deflate it a bit before
555 // passing to OnDrawItem()
556 //
557 // the base class version doesn't do anything
558 // virtual void OnDrawSeparator(wxDC& dc, wxRect& rect, size_t n) const;
559 DEC_PYCALLBACK__DCRECTSIZET_constpure(OnDrawSeparator);
560
561
562 // this method is used to draw the items background and, maybe, a border
563 // around it
564 //
565 // the base class version implements a reasonable default behaviour which
566 // consists in drawing the selected item with the standard background
567 // colour and drawing a border around the item if it is either selected or
568 // current
569 // virtual void OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const;
570 DEC_PYCALLBACK__DCRECTSIZET_const(OnDrawBackground);
571
572
573 PYPRIVATE;
574 };
575
576 IMPLEMENT_ABSTRACT_CLASS(wxPyVListBox, wxVListBox);
577
578 IMP_PYCALLBACK__DCRECTSIZET_constpure(wxPyVListBox, wxVListBox, OnDrawItem);
579 IMP_PYCALLBACK_COORD_SIZET_constpure (wxPyVListBox, wxVListBox, OnMeasureItem);
580 IMP_PYCALLBACK__DCRECTSIZET_constpure(wxPyVListBox, wxVListBox, OnDrawSeparator);
581 IMP_PYCALLBACK__DCRECTSIZET_const (wxPyVListBox, wxVListBox, OnDrawBackground);
582
583 %}
584
585
586
587 // Now define this class for SWIG
588
589 /*
590 This class has two main differences from a regular listbox: it can have an
591 arbitrarily huge number of items because it doesn't store them itself but
592 uses OnDrawItem() callback to draw them and its items can have variable
593 height as determined by OnMeasureItem().
594
595 It emits the same events as wxListBox and the same event macros may be used
596 with it.
597 */
598 %name(wxVListBox) class wxPyVListBox : public wxPyVScrolledWindow
599 {
600 public:
601
602 wxPyVListBox(wxWindow *parent,
603 wxWindowID id = wxID_ANY,
604 const wxPoint& pos = wxDefaultPosition,
605 const wxSize& size = wxDefaultSize,
606 long style = 0,
607 const wxString& name = wxPyVListBoxNameStr);
608
609 %name(wxPreVListBox) wxPyVListBox();
610
611 void _setCallbackInfo(PyObject* self, PyObject* _class);
612 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxVListBox)"
613 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
614 %pragma(python) addtomethod = "wxPreVListBox:val._setOORInfo(val)"
615
616
617 bool Create(wxWindow *parent,
618 wxWindowID id = wxID_ANY,
619 const wxPoint& pos = wxDefaultPosition,
620 const wxSize& size = wxDefaultSize,
621 long style = 0,
622 const wxString& name = wxPyVListBoxNameStr);
623
624 // get the number of items in the control
625 size_t GetItemCount() const;
626
627 // does this control use multiple selection?
628 bool HasMultipleSelection() const;
629
630 // get the currently selected item or wxNOT_FOUND if there is no selection
631 //
632 // this method is only valid for the single selection listboxes
633 int GetSelection() const;
634
635 // is this item the current one?
636 bool IsCurrent(size_t item) const;
637
638 // is this item selected?
639 bool IsSelected(size_t item) const;
640
641 // get the number of the selected items (maybe 0)
642 //
643 // this method is valid for both single and multi selection listboxes
644 size_t GetSelectedCount() const;
645
646 // get the first selected item, returns wxNOT_FOUND if none
647 //
648 // cookie is an opaque parameter which should be passed to
649 // GetNextSelected() later
650 //
651 // this method is only valid for the multi selection listboxes
652 int GetFirstSelected(unsigned long& cookie) const;
653
654 // get next selection item, return wxNOT_FOUND if no more
655 //
656 // cookie must be the same parameter that was passed to GetFirstSelected()
657 // before
658 //
659 // this method is only valid for the multi selection listboxes
660 int GetNextSelected(unsigned long& cookie) const;
661
662 // get the margins around each item
663 wxPoint GetMargins() const;
664
665 // get the background colour of selected cells
666 const wxColour& GetSelectionBackground() const;
667
668
669 // set the number of items to be shown in the control
670 //
671 // this is just a synonym for wxVScrolledWindow::SetLineCount()
672 void SetItemCount(size_t count);
673
674 // delete all items from the control
675 void Clear();
676
677 // set the selection to the specified item, if it is wxNOT_FOUND the
678 // selection is unset
679 //
680 // this function is only valid for the single selection listboxes
681 void SetSelection(int selection);
682
683 // selects or deselects the specified item which must be valid (i.e. not
684 // equal to wxNOT_FOUND)
685 //
686 // return true if the items selection status has changed or false
687 // otherwise
688 //
689 // this function is only valid for the multiple selection listboxes
690 bool Select(size_t item, bool select = true);
691
692 // selects the items in the specified range whose end points may be given
693 // in any order
694 //
695 // return true if any items selection status has changed, false otherwise
696 //
697 // this function is only valid for the single selection listboxes
698 bool SelectRange(size_t from, size_t to);
699
700 // toggle the selection of the specified item (must be valid)
701 //
702 // this function is only valid for the multiple selection listboxes
703 void Toggle(size_t item);
704
705 // select all items in the listbox
706 //
707 // the return code indicates if any items were affected by this operation
708 // (true) or if nothing has changed (false)
709 bool SelectAll();
710
711 // unselect all items in the listbox
712 //
713 // the return code has the same meaning as for SelectAll()
714 bool DeselectAll();
715
716 // set the margins: horizontal margin is the distance between the window
717 // border and the item contents while vertical margin is half of the
718 // distance between items
719 //
720 // by default both margins are 0
721 void SetMargins(const wxPoint& pt);
722 %name(SetMarginsXY) void SetMargins(wxCoord x, wxCoord y);
723
724 // change the background colour of the selected cells
725 void SetSelectionBackground(const wxColour& col);
726
727 };
728
729
730 //---------------------------------------------------------------------------
731 // wxHtmlListBox
732
733 %{
734 #include <wx/htmllbox.h>
735 %}
736
737 // First, the C++ version
738 %{
739 class wxPyHtmlListBox : public wxHtmlListBox
740 {
741 DECLARE_ABSTRACT_CLASS(wxPyHtmlListBox);
742 public:
743 wxPyHtmlListBox() : wxHtmlListBox() {}
744
745 wxPyHtmlListBox(wxWindow *parent,
746 wxWindowID id = wxID_ANY,
747 const wxPoint& pos = wxDefaultPosition,
748 const wxSize& size = wxDefaultSize,
749 long style = 0,
750 const wxString& name = wxPyVListBoxNameStr)
751 : wxHtmlListBox(parent, id, pos, size, style, name)
752 {}
753
754 // Overridable virtuals
755
756 // this method must be implemented in the derived class and should return
757 // the body (i.e. without <html>) of the HTML for the given item
758 DEC_PYCALLBACK_STRING_SIZET_pure(OnGetItem);
759
760 // this function may be overridden to decorate HTML returned by OnGetItem()
761 DEC_PYCALLBACK_STRING_SIZET(OnGetItemMarkup);
762
763 // TODO:
764 // // this method allows to customize the selection appearance: it may be used
765 // // to specify the colour of the text which normally has the given colour
766 // // colFg when it is inside the selection
767 // //
768 // // by default, the original colour is not used at all and all text has the
769 // // same (default for this system) colour inside selection
770 // virtual wxColour GetSelectedTextColour(const wxColour& colFg) const;
771
772 // // this is the same as GetSelectedTextColour() but allows to customize the
773 // // background colour -- this is even more rarely used as you can change it
774 // // globally using SetSelectionBackground()
775 // virtual wxColour GetSelectedTextBgColour(const wxColour& colBg) const;
776
777
778 PYPRIVATE;
779 };
780
781
782 IMPLEMENT_ABSTRACT_CLASS(wxPyHtmlListBox, wxHtmlListBox)
783
784 IMP_PYCALLBACK_STRING_SIZET_pure(wxPyHtmlListBox, wxHtmlListBox, OnGetItem);
785 IMP_PYCALLBACK_STRING_SIZET (wxPyHtmlListBox, wxHtmlListBox, OnGetItemMarkup);
786
787 %}
788
789
790
791 // Now define this class for SWIG
792
793
794 // wxHtmlListBox is a listbox whose items are wxHtmlCells
795 %name(wxHtmlListBox) class wxPyHtmlListBox : public wxPyVListBox
796 {
797 public:
798
799 // normal constructor which calls Create() internally
800 wxPyHtmlListBox(wxWindow *parent,
801 wxWindowID id = wxID_ANY,
802 const wxPoint& pos = wxDefaultPosition,
803 const wxSize& size = wxDefaultSize,
804 long style = 0,
805 const wxString& name = wxPyVListBoxNameStr);
806
807 %name(wxPreHtmlListBox) wxPyHtmlListBox();
808
809 void _setCallbackInfo(PyObject* self, PyObject* _class);
810 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxHtmlListBox)"
811 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
812 %pragma(python) addtomethod = "wxPreHtmlListBox:val._setOORInfo(val)"
813
814 bool Create(wxWindow *parent,
815 wxWindowID id = wxID_ANY,
816 const wxPoint& pos = wxDefaultPosition,
817 const wxSize& size = wxDefaultSize,
818 long style = 0,
819 const wxString& name = wxPyVListBoxNameStr);
820
821
822 void RefreshAll();
823 void SetItemCount(size_t count);
824
825 };
826
827
828 //---------------------------------------------------------------------------
829 //---------------------------------------------------------------------------
830
831 %init %{
832 // Map renamed classes back to their common name for OOR
833 wxPyPtrTypeMap_Add("wxHtmlListBox", "wxPyHtmlListBox");
834 wxPyPtrTypeMap_Add("wxVListBox", "wxPyVListBox");
835 wxPyPtrTypeMap_Add("wxVScrolledWindow", "wxPyVScrolledWindow");
836 %}
837
838 //----------------------------------------------------------------------