]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_listbox.i
new port constants
[wxWidgets.git] / wxPython / src / _listbox.i
CommitLineData
d14a1e28
RD
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>
d14a1e28
RD
20%}
21
b2dc1044
RD
22MAKE_CONST_WXSTRING(ListBoxNameStr);
23
24
d14a1e28
RD
25//---------------------------------------------------------------------------
26%newgroup
27
ab1f7d2a
RD
28MustHaveApp(wxListBox);
29
d14a1e28
RD
30class wxListBox : public wxControlWithItems
31{
32public:
2b9048c5
RD
33 %pythonAppend wxListBox "self._setOORInfo(self)"
34 %pythonAppend wxListBox() ""
d14a1e28 35
1dc0f664
DS
36 wxListBox(wxWindow* parent,
37 wxWindowID id = -1,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
40 const wxArrayString& choices = wxPyEmptyStringArray,
41 long style = 0,
42 const wxValidator& validator = wxDefaultValidator,
43 const wxString& name = wxPyListBoxNameStr);
44
45// wxListBox(wxWindow* parent,
46// wxWindowID id = -1,
47// const wxPoint& pos = wxDefaultPosition,
48// const wxSize& size = wxDefaultSize,
49// int n = 0,
50// const wxString choices[] = NULL,
51// long style = 0,
52// const wxValidator& validator = wxDefaultValidator,
53// const wxString& name = wxPyListBoxNameStr);
1b8c7ba6 54 %RenameCtor(PreListBox, wxListBox());
d14a1e28 55
1dc0f664
DS
56 bool Create(wxWindow* parent,
57 wxWindowID id = -1,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 const wxArrayString& choices = wxPyEmptyStringArray,
61 long style = 0,
62 const wxValidator& validator = wxDefaultValidator,
63 const wxString& name = wxPyListBoxNameStr);
64
65// bool Create(wxWindow *parent,
66// wxWindowID id = -1,
67// const wxPoint& pos = wxDefaultPosition,
68// const wxSize& size = wxDefaultSize,
69// int n = 0,
70// const wxString choices[] = NULL,
71// long style = 0,
72// const wxValidator& validator = wxDefaultValidator,
73// const wxString& name = wxPyListBoxNameStr);
d14a1e28
RD
74
75 // all generic methods are in wxControlWithItems...
76
1dc0f664
DS
77 %extend
78 {
79 void Insert(const wxString& item, int pos, PyObject* clientData = NULL)
80 {
81 if (clientData)
82 {
d14a1e28
RD
83 wxPyClientData* data = new wxPyClientData(clientData);
84 self->Insert(item, pos, data);
1dc0f664
DS
85 }
86 else
d14a1e28
RD
87 self->Insert(item, pos);
88 }
89 }
90
3f5ec806 91 void InsertItems(const wxArrayString& items, unsigned int pos);
d14a1e28
RD
92 void Set(const wxArrayString& items/*, void **clientData = NULL */);
93
94 // multiple selection logic
95 virtual bool IsSelected(int n) const;
a72f4631 96 virtual void SetSelection(int n, bool select = true);
d14a1e28 97 virtual void Select(int n);
1dc0f664 98
d14a1e28
RD
99 void Deselect(int n);
100 void DeselectAll(int itemToLeaveSelected = -1);
101
a72f4631 102 virtual bool SetStringSelection(const wxString& s, bool select = true);
d14a1e28
RD
103
104 // works for single as well as multiple selection listboxes (unlike
105 // GetSelection which only works for listboxes with single selection)
106 //virtual int GetSelections(wxArrayInt& aSelections) const;
ffb4a474
RD
107 %extend {
108 PyObject* GetSelections() {
109 wxPyBlock_t blocked = wxPyBeginBlockThreads();
214c4fbe
RD
110 wxArrayInt lst;
111 self->GetSelections(lst);
112 PyObject *tup = PyTuple_New(lst.GetCount());
1dc0f664
DS
113 for (size_t i=0; i<lst.GetCount(); i++)
114 {
214c4fbe
RD
115 PyTuple_SetItem(tup, i, PyInt_FromLong(lst[i]));
116 }
ffb4a474 117 wxPyEndBlockThreads(blocked);
214c4fbe
RD
118 return tup;
119 }
d14a1e28
RD
120 }
121
122 // set the specified item at the first visible item or scroll to max
123 // range.
124 void SetFirstItem(int n);
1b8c7ba6 125 %Rename(SetFirstItemStr, void, SetFirstItem(const wxString& s));
d14a1e28 126
1dc0f664
DS
127 // ensures that the given item is visible scrolling the listbox
128 // if necessary
d14a1e28
RD
129 virtual void EnsureVisible(int n);
130
131 // a combination of Append() and EnsureVisible(): appends the item to the
132 // listbox and ensures that it is visible i.e. not scrolled out of view
133 void AppendAndEnsureVisible(const wxString& s);
134
dd9f7fea 135 // return True if this listbox is sorted
d14a1e28 136 bool IsSorted() const;
8492b560 137
d344366c
RD
138 // return the index of the item at this position or wxNOT_FOUND
139 int HitTest(const wxPoint& pt) const;
8492b560 140
1dc0f664
DS
141 %extend
142 {
143 void SetItemForegroundColour(int item, const wxColour& c)
144 {
8492b560
RD
145 %#ifdef __WXMSW__
146 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
147 self->GetItem(item)->SetTextColour(c);
148 %#endif
149 }
1dc0f664
DS
150 void SetItemBackgroundColour(int item, const wxColour& c)
151 {
8492b560
RD
152 %#ifdef __WXMSW__
153 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
154 self->GetItem(item)->SetBackgroundColour(c);
155 %#endif
156 }
1dc0f664
DS
157 void SetItemFont(int item, const wxFont& f)
158 {
8492b560
RD
159 %#ifdef __WXMSW__
160 if (self->GetWindowStyle() & wxLB_OWNERDRAW)
161 self->GetItem(item)->SetFont(f);
162 %#endif
163 }
164 }
1dc0f664 165
174051f6
RD
166 static wxVisualAttributes
167 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
d14a1e28
RD
168};
169
170
171//---------------------------------------------------------------------------
172%newgroup
173
174
ab1f7d2a
RD
175MustHaveApp(wxCheckListBox);
176
d14a1e28
RD
177// wxCheckListBox: a listbox whose items may be checked
178class wxCheckListBox : public wxListBox
179{
180public:
2b9048c5
RD
181 %pythonAppend wxCheckListBox "self._setOORInfo(self)"
182 %pythonAppend wxCheckListBox() ""
d14a1e28 183
1dc0f664
DS
184 wxCheckListBox(wxWindow *parent,
185 wxWindowID id = -1,
186 const wxPoint& pos = wxDefaultPosition,
187 const wxSize& size = wxDefaultSize,
188 const wxArrayString& choices = wxPyEmptyStringArray,
189 long style = 0,
190 const wxValidator& validator = wxDefaultValidator,
191 const wxString& name = wxPyListBoxNameStr);
1b8c7ba6 192 %RenameCtor(PreCheckListBox, wxCheckListBox());
d14a1e28 193
1dc0f664
DS
194 bool Create(wxWindow *parent,
195 wxWindowID id = -1,
196 const wxPoint& pos = wxDefaultPosition,
197 const wxSize& size = wxDefaultSize,
198 const wxArrayString& choices = wxPyEmptyStringArray,
199 long style = 0,
200 const wxValidator& validator = wxDefaultValidator,
201 const wxString& name = wxPyListBoxNameStr);
d14a1e28 202
3f5ec806
RD
203 bool IsChecked(unsigned int index);
204 void Check(unsigned int index, int check = true);
d14a1e28 205
8dfc6457 206#if defined(__WXMSW__) || defined(__WXGTK__)
d14a1e28
RD
207 int GetItemHeight();
208#endif
d14a1e28
RD
209};
210
211//---------------------------------------------------------------------------