]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_listbox.i
Source cleaning: whitespaces, tabs, -1/wxID_ANY/wxNOT_FOUND/wxDefaultCoord, TRUE...
[wxWidgets.git] / wxPython / src / _listbox.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _listbox.i
3 // Purpose: SWIG interface defs for wxListBox and wxCheckListBox
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 10-June-1998
8 // RCS-ID: $Id$
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17
18 %{
19 #include <wx/checklst.h>
20
21 %}
22
23 MAKE_CONST_WXSTRING(ListBoxNameStr);
24
25
26 //---------------------------------------------------------------------------
27 %newgroup
28
29 MustHaveApp(wxListBox);
30
31 class wxListBox : public wxControlWithItems
32 {
33 public:
34 %pythonAppend wxListBox "self._setOORInfo(self)"
35 %pythonAppend wxListBox() ""
36
37 wxListBox(wxWindow* parent, wxWindowID id=-1,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
40 //int choices=0, wxString* choices_array = NULL,
41 const wxArrayString& choices = wxPyEmptyStringArray,
42 long style = 0,
43 const wxValidator& validator = wxDefaultValidator,
44 const wxString& name = wxPyListBoxNameStr);
45 %name(PreListBox)wxListBox();
46
47 bool Create(wxWindow* parent, wxWindowID id=-1,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize,
50 //int choices=0, wxString* choices_array = NULL,
51 const wxArrayString& choices = wxPyEmptyStringArray,
52 long style = 0,
53 const wxValidator& validator = wxDefaultValidator,
54 const wxString& name = wxPyListBoxNameStr);
55
56 // all generic methods are in wxControlWithItems...
57
58 %extend {
59 void Insert(const wxString& item, int pos, PyObject* clientData=NULL) {
60 if (clientData) {
61 wxPyClientData* data = new wxPyClientData(clientData);
62 self->Insert(item, pos, data);
63 } else
64 self->Insert(item, pos);
65 }
66 }
67
68 void InsertItems(const wxArrayString& items, int pos);
69 void Set(const wxArrayString& items/*, void **clientData = NULL */);
70
71 // multiple selection logic
72 virtual bool IsSelected(int n) const;
73 virtual void SetSelection(int n, bool select = True);
74 virtual void Select(int n);
75 void Deselect(int n);
76 void DeselectAll(int itemToLeaveSelected = -1);
77
78 virtual bool SetStringSelection(const wxString& s, bool select = True);
79
80 // works for single as well as multiple selection listboxes (unlike
81 // GetSelection which only works for listboxes with single selection)
82 //virtual int GetSelections(wxArrayInt& aSelections) const;
83 %extend {
84 PyObject* GetSelections() {
85 wxArrayInt lst;
86 self->GetSelections(lst);
87 PyObject *tup = PyTuple_New(lst.GetCount());
88 for(size_t i=0; i<lst.GetCount(); i++) {
89 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
90 }
91 return tup;
92 }
93 }
94
95 // set the specified item at the first visible item or scroll to max
96 // range.
97 void SetFirstItem(int n);
98 %name(SetFirstItemStr) void SetFirstItem(const wxString& s);
99
100 // ensures that the given item is visible scrolling the listbox if
101 // necessary
102 virtual void EnsureVisible(int n);
103
104 // a combination of Append() and EnsureVisible(): appends the item to the
105 // listbox and ensures that it is visible i.e. not scrolled out of view
106 void AppendAndEnsureVisible(const wxString& s);
107
108 // return True if this listbox is sorted
109 bool IsSorted() const;
110
111
112 %extend {
113 void SetItemForegroundColour(int item, const wxColour& c) {
114 %#ifdef __WXMSW__
115 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
116 self->GetItem(item)->SetTextColour(c);
117 %#endif
118 }
119 void SetItemBackgroundColour(int item, const wxColour& c) {
120 %#ifdef __WXMSW__
121 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
122 self->GetItem(item)->SetBackgroundColour(c);
123 %#endif
124 }
125 void SetItemFont(int item, const wxFont& f) {
126 %#ifdef __WXMSW__
127 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
128 self->GetItem(item)->SetFont(f);
129 %#endif
130 }
131 }
132
133 static wxVisualAttributes
134 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
135 };
136
137
138 //---------------------------------------------------------------------------
139 %newgroup
140
141
142 MustHaveApp(wxCheckListBox);
143
144 // wxCheckListBox: a listbox whose items may be checked
145 class wxCheckListBox : public wxListBox
146 {
147 public:
148 %pythonAppend wxCheckListBox "self._setOORInfo(self)"
149 %pythonAppend wxCheckListBox() ""
150
151 wxCheckListBox(wxWindow *parent, wxWindowID id=-1,
152 const wxPoint& pos = wxDefaultPosition,
153 const wxSize& size = wxDefaultSize,
154 //int choices = 0, wxString* choices_array = NULL,
155 const wxArrayString& choices = wxPyEmptyStringArray,
156 long style = 0,
157 const wxValidator& validator = wxDefaultValidator,
158 const wxString& name = wxPyListBoxNameStr);
159 %name(PreCheckListBox)wxCheckListBox();
160
161 bool Create(wxWindow *parent, wxWindowID id=-1,
162 const wxPoint& pos = wxDefaultPosition,
163 const wxSize& size = wxDefaultSize,
164 //int choices = 0, wxString* choices_array = NULL,
165 const wxArrayString& choices = wxPyEmptyStringArray,
166 long style = 0,
167 const wxValidator& validator = wxDefaultValidator,
168 const wxString& name = wxPyListBoxNameStr);
169
170 bool IsChecked(int index);
171 void Check(int index, int check = True);
172
173 #if defined(__WXMSW__) || defined(__WXGTK__)
174 int GetItemHeight();
175 #endif
176
177 // return the index of the item at this position or wxNOT_FOUND
178 int HitTest(const wxPoint& pt) const;
179 %name(HitTestXY)int HitTest(wxCoord x, wxCoord y) const;
180 };
181
182 //---------------------------------------------------------------------------