]>
Commit | Line | Data |
---|---|---|
7bf85405 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: controls2.i | |
3 | // Purpose: More control (widget) classes for wxPython | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 6/10/98 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
03e9bead | 13 | %module controls2 |
7bf85405 | 14 | |
03e9bead | 15 | %{ |
7bf85405 RD |
16 | #include "helpers.h" |
17 | #include <wx/listctrl.h> | |
18 | #include <wx/treectrl.h> | |
9c039d08 | 19 | #if 0 |
7bf85405 | 20 | #include <wx/tabctrl.h> |
9c039d08 | 21 | #endif |
7bf85405 RD |
22 | %} |
23 | ||
24 | //---------------------------------------------------------------------- | |
25 | ||
26 | %include typemaps.i | |
27 | %include my_typemaps.i | |
28 | ||
29 | // Import some definitions of other classes, etc. | |
30 | %import _defs.i | |
31 | %import misc.i | |
32 | %import windows.i | |
33 | %import gdi.i | |
34 | %import events.i | |
35 | %import controls.i | |
36 | ||
9c039d08 RD |
37 | %pragma(python) code = "import wxp" |
38 | ||
7bf85405 RD |
39 | //---------------------------------------------------------------------- |
40 | ||
41 | %{ | |
42 | extern wxValidator wxPyDefaultValidator; | |
43 | %} | |
44 | ||
45 | //---------------------------------------------------------------------- | |
46 | ||
47 | class wxListItem { | |
48 | public: | |
49 | long m_mask; // Indicates what fields are valid | |
50 | long m_itemId; // The zero-based item position | |
51 | int m_col; // Zero-based column, if in report mode | |
52 | long m_state; // The state of the item | |
53 | long m_stateMask; // Which flags of m_state are valid (uses same flags) | |
54 | wxString m_text; // The label/header text | |
55 | int m_image; // The zero-based index into an image list | |
56 | long m_data; // App-defined data | |
57 | // wxColour *m_colour; // only wxGLC, not supported by Windows ;-> | |
58 | ||
59 | // For columns only | |
60 | int m_format; // left, right, centre | |
61 | int m_width; // width of column | |
62 | ||
63 | wxListItem(); | |
64 | ~wxListItem(); | |
65 | }; | |
66 | ||
67 | class wxListEvent: public wxCommandEvent { | |
68 | public: | |
69 | int m_code; | |
70 | long m_itemIndex; | |
71 | long m_oldItemIndex; | |
72 | int m_col; | |
73 | bool m_cancelled; | |
74 | wxPoint m_pointDrag; | |
75 | wxListItem m_item; | |
76 | }; | |
77 | ||
78 | ||
79 | ||
80 | ||
81 | class wxListCtrl : public wxControl { | |
82 | public: | |
fb5e0af0 | 83 | #ifdef __WXMSW__ |
7bf85405 RD |
84 | wxListCtrl(wxWindow* parent, wxWindowID id, |
85 | const wxPoint& pos = wxPyDefaultPosition, | |
86 | const wxSize& size = wxPyDefaultSize, | |
87 | long style = wxLC_ICON, | |
88 | const wxValidator& validator = wxPyDefaultValidator, | |
89 | char* name = "listCtrl"); | |
fb5e0af0 RD |
90 | #else |
91 | wxListCtrl(wxWindow* parent, wxWindowID id, | |
92 | const wxPoint& pos = wxPyDefaultPosition, | |
93 | const wxSize& size = wxPyDefaultSize, | |
94 | long style = wxLC_ICON, | |
95 | char* name = "listctrl"); | |
96 | #endif | |
7bf85405 | 97 | |
9c039d08 RD |
98 | %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)" |
99 | ||
7bf85405 RD |
100 | bool Arrange(int flag = wxLIST_ALIGN_DEFAULT); |
101 | bool DeleteItem(long item); | |
102 | bool DeleteAllItems(); | |
103 | bool DeleteColumn(int col); | |
fb5e0af0 | 104 | #ifdef __WXMSW__ |
7bf85405 RD |
105 | bool DeleteAllColumns(void); |
106 | void ClearAll(void); | |
107 | wxTextCtrl* EditLabel(long item); | |
108 | bool EndEditLabel(bool cancel); | |
fb5e0af0 | 109 | #endif |
7bf85405 RD |
110 | bool EnsureVisible(long item); |
111 | long FindItem(long start, const wxString& str, bool partial = FALSE); | |
112 | %name(FindItemData)long FindItem(long start, long data); | |
113 | %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt, | |
114 | int direction); | |
115 | bool GetColumn(int col, wxListItem& item); | |
116 | int GetColumnWidth(int col); | |
117 | int GetCountPerPage(); | |
9c039d08 | 118 | #ifdef __WXMSW__ |
7bf85405 | 119 | wxTextCtrl* GetEditControl(); |
fb5e0af0 | 120 | #endif |
7bf85405 RD |
121 | wxImageList* GetImageList(int which); |
122 | long GetItemData(long item); | |
123 | ||
124 | %addmethods { | |
125 | %new wxListItem* GetItem() { | |
126 | wxListItem* info = new wxListItem; | |
127 | self->GetItem(*info); | |
128 | return info; | |
129 | } | |
130 | %new wxPoint* GetItemPosition(long item) { | |
131 | wxPoint* pos = new wxPoint; | |
132 | self->GetItemPosition(item, *pos); | |
133 | return pos; | |
134 | } | |
135 | %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) { | |
136 | wxRect* rect= new wxRect; | |
137 | self->GetItemRect(item, *rect, code); | |
138 | return rect; | |
139 | } | |
140 | } | |
141 | ||
142 | int GetItemState(long item, long stateMask); | |
143 | int GetItemCount(); | |
144 | int GetItemSpacing(bool isSmall); | |
145 | wxString GetItemText(long item); | |
146 | long GetNextItem(long item, | |
147 | int geometry = wxLIST_NEXT_ALL, | |
148 | int state = wxLIST_STATE_DONTCARE); | |
149 | int GetSelectedItemCount(); | |
fb5e0af0 | 150 | #ifdef __WXMSW__ |
7bf85405 | 151 | wxColour GetTextColour(); |
fb5e0af0 | 152 | #endif |
7bf85405 RD |
153 | long GetTopItem(); |
154 | long HitTest(const wxPoint& point, int& OUTPUT); | |
155 | %name(InsertColumnWithInfo)long InsertColumn(long col, wxListItem& info); | |
156 | long InsertColumn(long col, const wxString& heading, | |
157 | int format = wxLIST_FORMAT_LEFT, | |
158 | int width = -1); | |
159 | ||
160 | long InsertItem(wxListItem& info); | |
161 | %name(InsertStringItem) long InsertItem(long index, const wxString& label); | |
162 | %name(InsertImageItem) long InsertItem(long index, int imageIndex); | |
163 | %name(InsertImageStringItem)long InsertItem(long index, const wxString& label, | |
164 | int imageIndex); | |
165 | ||
166 | bool ScrollList(int dx, int dy); | |
167 | void SetBackgroundColour(const wxColour& col); | |
168 | bool SetColumn(int col, wxListItem& item); | |
169 | bool SetColumnWidth(int col, int width); | |
170 | void SetImageList(wxImageList* imageList, int which); | |
171 | bool SetItem(wxListItem& info); | |
172 | %name(SetItemString)long SetItem(long index, int col, const wxString& label, | |
173 | int imageId = -1); | |
174 | bool SetItemData(long item, long data); | |
175 | bool SetItemImage(long item, int image, int selImage); | |
176 | bool SetItemPosition(long item, const wxPoint& pos); | |
177 | bool SetItemState(long item, long state, long stateMask); | |
178 | void SetItemText(long item, const wxString& text); | |
179 | void SetSingleStyle(long style, bool add = TRUE); | |
fb5e0af0 | 180 | #ifdef __WXMSW__ |
7bf85405 | 181 | void SetTextColour(const wxColour& col); |
fb5e0af0 | 182 | #endif |
7bf85405 RD |
183 | void SetWindowStyleFlag(long style); |
184 | // TODO: bool SortItems(wxListCtrlCompare fn, long data); | |
185 | }; | |
186 | ||
187 | ||
188 | ||
189 | //---------------------------------------------------------------------- | |
190 | ||
191 | ||
192 | enum { | |
193 | wxTREE_MASK_HANDLE, | |
194 | wxTREE_MASK_STATE, | |
195 | wxTREE_MASK_TEXT, | |
196 | wxTREE_MASK_IMAGE, | |
197 | wxTREE_MASK_SELECTED_IMAGE, | |
198 | wxTREE_MASK_CHILDREN, | |
199 | wxTREE_MASK_DATA, | |
200 | ||
201 | wxTREE_STATE_BOLD, | |
202 | wxTREE_STATE_DROPHILITED, | |
203 | wxTREE_STATE_EXPANDED, | |
204 | wxTREE_STATE_EXPANDEDONCE, | |
205 | wxTREE_STATE_FOCUSED, | |
206 | wxTREE_STATE_SELECTED, | |
207 | wxTREE_STATE_CUT, | |
208 | ||
209 | wxTREE_HITTEST_ABOVE, | |
210 | wxTREE_HITTEST_BELOW, | |
211 | wxTREE_HITTEST_NOWHERE, | |
212 | wxTREE_HITTEST_ONITEMBUTTON, | |
213 | wxTREE_HITTEST_ONITEMICON, | |
214 | wxTREE_HITTEST_ONITEMINDENT, | |
215 | wxTREE_HITTEST_ONITEMLABEL, | |
216 | wxTREE_HITTEST_ONITEMRIGHT, | |
217 | wxTREE_HITTEST_ONITEMSTATEICON, | |
218 | wxTREE_HITTEST_TOLEFT, | |
219 | wxTREE_HITTEST_TORIGHT, | |
220 | wxTREE_HITTEST_ONITEM, | |
221 | }; | |
222 | ||
223 | ||
224 | enum { | |
225 | wxTREE_NEXT_CARET, | |
226 | wxTREE_NEXT_CHILD, | |
227 | wxTREE_NEXT_DROPHILITE, | |
228 | wxTREE_NEXT_FIRSTVISIBLE, | |
229 | wxTREE_NEXT_NEXT, | |
230 | wxTREE_NEXT_NEXTVISIBLE, | |
231 | wxTREE_NEXT_PARENT, | |
232 | wxTREE_NEXT_PREVIOUS, | |
233 | wxTREE_NEXT_PREVIOUSVISIBLE, | |
234 | wxTREE_NEXT_ROOT | |
235 | }; | |
236 | ||
237 | enum { | |
238 | wxTREE_EXPAND_EXPAND, | |
239 | wxTREE_EXPAND_COLLAPSE, | |
240 | wxTREE_EXPAND_COLLAPSE_RESET, | |
241 | wxTREE_EXPAND_TOGGLE | |
242 | }; | |
243 | ||
244 | enum { | |
245 | wxTREE_INSERT_LAST, | |
246 | wxTREE_INSERT_FIRST, | |
247 | wxTREE_INSERT_SORT, | |
248 | }; | |
249 | ||
250 | ||
251 | ||
252 | ||
253 | ||
254 | ||
255 | ||
256 | class wxTreeItem { | |
257 | public: | |
258 | long m_mask; | |
259 | long m_itemId; | |
260 | long m_state; | |
261 | long m_stateMask; | |
262 | wxString m_text; | |
263 | int m_image; | |
264 | int m_selectedImage; | |
265 | int m_children; | |
266 | long m_data; | |
267 | ||
268 | wxTreeItem(); | |
269 | ~wxTreeItem(); | |
270 | }; | |
271 | ||
272 | ||
273 | ||
274 | class wxTreeEvent : public wxCommandEvent { | |
275 | public: | |
276 | int m_code; | |
277 | wxTreeItem m_item; | |
278 | long m_oldItem; | |
279 | wxPoint m_pointDrag; | |
280 | }; | |
281 | ||
282 | ||
283 | ||
284 | ||
285 | class wxTreeCtrl : public wxControl { | |
286 | public: | |
fb5e0af0 | 287 | #ifdef __WXMSW__ |
7bf85405 RD |
288 | wxTreeCtrl(wxWindow *parent, wxWindowID id = -1, |
289 | const wxPoint& pos = wxPyDefaultPosition, | |
290 | const wxSize& size = wxPyDefaultSize, | |
291 | long style = wxTR_HAS_BUTTONS, | |
292 | const wxValidator& validator = wxPyDefaultValidator, | |
293 | char* name = "wxTreeCtrl"); | |
fb5e0af0 RD |
294 | #else |
295 | wxTreeCtrl(wxWindow *parent, wxWindowID id = -1, | |
296 | const wxPoint& pos = wxPyDefaultPosition, | |
297 | const wxSize& size = wxPyDefaultSize, | |
298 | long style = wxTR_HAS_BUTTONS, | |
299 | char* name = "wxTreeCtrl"); | |
300 | #endif | |
7bf85405 | 301 | |
9c039d08 RD |
302 | %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)" |
303 | ||
7bf85405 | 304 | bool DeleteAllItems(); |
fb5e0af0 | 305 | #ifdef __WXMSW__ |
7bf85405 | 306 | bool DeleteItem(long item); |
fb5e0af0 RD |
307 | #else |
308 | void DeleteItem(long item); | |
309 | #endif | |
310 | #ifdef __WXMSW__ | |
7bf85405 RD |
311 | wxTextCtrl* EditLabel(long item); |
312 | bool EnsureVisible(long item); | |
313 | bool ExpandItem(long item, int action); | |
314 | long GetChild(long item); | |
fb5e0af0 | 315 | #endif |
7bf85405 | 316 | int GetCount(); |
fb5e0af0 | 317 | #ifdef __WXMSW__ |
7bf85405 RD |
318 | wxTextCtrl* GetEditControl(); |
319 | long GetFirstVisibleItem(); | |
fb5e0af0 | 320 | #endif |
7bf85405 RD |
321 | wxImageList* GetImageList(int which = wxIMAGE_LIST_NORMAL); |
322 | int GetIndent(); | |
323 | long GetItemData(long item); | |
324 | ||
325 | %addmethods { | |
326 | %new wxTreeItem* GetItem() { | |
327 | wxTreeItem* info = new wxTreeItem; | |
328 | self->GetItem(*info); | |
329 | return info; | |
330 | } | |
fb5e0af0 | 331 | #ifdef __WXMSW__ |
7bf85405 RD |
332 | %new wxRect* GetItemRect(long item, int textOnly = FALSE) { |
333 | wxRect* rect = new wxRect; | |
334 | self->GetItemRect(item, *rect, textOnly); | |
335 | return rect; | |
336 | } | |
fb5e0af0 | 337 | #endif |
7bf85405 RD |
338 | } |
339 | ||
fb5e0af0 | 340 | #ifdef __WXMSW__ |
7bf85405 | 341 | int GetItemState(long item, long stateMask); |
fb5e0af0 | 342 | #endif |
7bf85405 | 343 | wxString GetItemText(long item); |
fb5e0af0 | 344 | #ifdef __WXMSW__ |
7bf85405 RD |
345 | long GetNextItem(long item, int code); |
346 | long GetNextVisibleItem(long item); | |
fb5e0af0 | 347 | #endif |
7bf85405 RD |
348 | long GetParent(long item); |
349 | long GetRootItem(); | |
350 | long GetSelection(); | |
351 | long HitTest(const wxPoint& point, int& OUTPUT); // *** check this | |
352 | long InsertItem(long parent, wxTreeItem& info, | |
353 | long insertAfter = wxTREE_INSERT_LAST); | |
354 | %name(InsertItemString) | |
355 | long InsertItem(long parent, const wxString& label, | |
356 | int image = -1, int selImage = -1, | |
357 | long insertAfter = wxTREE_INSERT_LAST); | |
358 | bool ItemHasChildren(long item); | |
fb5e0af0 | 359 | #ifdef __WXMSW__ |
7bf85405 | 360 | bool ScrollTo(long item); |
fb5e0af0 | 361 | #endif |
7bf85405 RD |
362 | bool SelectItem(long item); |
363 | void SetIndent(int indent); | |
364 | void SetImageList(wxImageList* imageList, int which = wxIMAGE_LIST_NORMAL); | |
365 | bool SetItem(wxTreeItem& info); | |
fb5e0af0 | 366 | #ifdef __WXMSW__ |
7bf85405 | 367 | bool SetItemImage(long item, int image, int selImage); |
fb5e0af0 RD |
368 | #else |
369 | void SetItemImage(long item, int image, int selImage); | |
370 | #endif | |
371 | #ifdef __WXMSW__ | |
7bf85405 | 372 | bool SetItemState(long item, long state, long stateMask); |
fb5e0af0 | 373 | #endif |
7bf85405 RD |
374 | void SetItemText(long item, const wxString& text); |
375 | bool SetItemData(long item, long data); | |
fb5e0af0 | 376 | #ifdef __WXMSW__ |
7bf85405 | 377 | bool SortChildren(long item); |
fb5e0af0 | 378 | #endif |
7bf85405 RD |
379 | }; |
380 | ||
381 | //---------------------------------------------------------------------- | |
382 | ||
9c039d08 | 383 | #ifdef SKIPTHIS |
fb5e0af0 | 384 | #ifdef __WXMSW__ |
7bf85405 RD |
385 | class wxTabEvent : public wxCommandEvent { |
386 | public: | |
387 | }; | |
388 | ||
389 | ||
390 | ||
391 | class wxTabCtrl : public wxControl { | |
392 | public: | |
393 | wxTabCtrl(wxWindow* parent, wxWindowID id, | |
394 | const wxPoint& pos = wxPyDefaultPosition, | |
395 | const wxSize& size = wxPyDefaultSize, | |
396 | long style = 0, | |
397 | char* name = "tabCtrl"); | |
398 | ||
9c039d08 RD |
399 | %pragma(python) addtomethod = "__init__:wxp._StdWindowCallbacks(self)" |
400 | ||
7bf85405 RD |
401 | bool DeleteAllItems(); |
402 | bool DeleteItem(int item); | |
403 | wxImageList* GetImageList(); | |
404 | int GetItemCount(); | |
405 | // TODO: void* GetItemData(); | |
406 | int GetItemImage(int item); | |
407 | ||
408 | %addmethods { | |
409 | %new wxRect* GetItemRect(int item) { | |
410 | wxRect* rect = new wxRect; | |
411 | self->GetItemRect(item, *rect); | |
412 | return rect; | |
413 | } | |
414 | } | |
415 | ||
416 | wxString GetItemText(int item); | |
417 | bool GetRowCount(); | |
418 | int GetSelection(); | |
419 | int HitTest(const wxPoint& pt, long& OUTPUT); | |
420 | void InsertItem(int item, const wxString& text, | |
421 | int imageId = -1, void* clientData = NULL); | |
422 | // TODO: bool SetItemData(int item, void* data); | |
423 | bool SetItemImage(int item, int image); | |
424 | void SetImageList(wxImageList* imageList); | |
425 | void SetItemSize(const wxSize& size); | |
426 | bool SetItemText(int item, const wxString& text); | |
427 | void SetPadding(const wxSize& padding); | |
428 | int SetSelection(int item); | |
429 | ||
430 | }; | |
431 | ||
9c039d08 | 432 | #endif |
fb5e0af0 RD |
433 | #endif |
434 | ||
7bf85405 RD |
435 | //---------------------------------------------------------------------- |
436 | ||
437 | ||
438 | ///////////////////////////////////////////////////////////////////////////// | |
439 | // | |
440 | // $Log$ | |
9c039d08 RD |
441 | // Revision 1.4 1998/10/02 06:40:36 RD |
442 | // Version 0.4 of wxPython for MSW. | |
443 | // | |
fb5e0af0 RD |
444 | // Revision 1.3 1998/08/18 19:48:15 RD |
445 | // more wxGTK compatibility things. | |
446 | // | |
447 | // It builds now but there are serious runtime problems... | |
448 | // | |
03e9bead RD |
449 | // Revision 1.2 1998/08/15 07:36:30 RD |
450 | // - Moved the header in the .i files out of the code that gets put into | |
451 | // the .cpp files. It caused CVS conflicts because of the RCS ID being | |
452 | // different each time. | |
453 | // | |
454 | // - A few minor fixes. | |
455 | // | |
7bf85405 RD |
456 | // Revision 1.1 1998/08/09 08:25:49 RD |
457 | // Initial version | |
458 | // | |
459 | // |