]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/controls2.i
211ce72b14ade95b906c93376c3d92230f7e8cb2
[wxWidgets.git] / utils / wxPython / src / controls2.i
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
13 %module controls2
14
15 %{
16 #include "helpers.h"
17 #include <wx/listctrl.h>
18 #include <wx/treectrl.h>
19 %}
20
21 //----------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 // Import some definitions of other classes, etc.
27 %import _defs.i
28 %import misc.i
29 %import windows.i
30 %import gdi.i
31 %import events.i
32 %import controls.i
33
34 %pragma(python) code = "import wx"
35
36 //----------------------------------------------------------------------
37
38 %{
39 extern wxValidator wxPyDefaultValidator;
40 %}
41
42 //----------------------------------------------------------------------
43
44 class wxListItem {
45 public:
46 long m_mask; // Indicates what fields are valid
47 long m_itemId; // The zero-based item position
48 int m_col; // Zero-based column, if in report mode
49 long m_state; // The state of the item
50 long m_stateMask; // Which flags of m_state are valid (uses same flags)
51 wxString m_text; // The label/header text
52 int m_image; // The zero-based index into an image list
53 long m_data; // App-defined data
54 // wxColour *m_colour; // only wxGLC, not supported by Windows ;->
55
56 // For columns only
57 int m_format; // left, right, centre
58 int m_width; // width of column
59
60 wxListItem();
61 ~wxListItem();
62 };
63
64 class wxListEvent: public wxCommandEvent {
65 public:
66 int m_code;
67 long m_itemIndex;
68 long m_oldItemIndex;
69 int m_col;
70 bool m_cancelled;
71 wxPoint m_pointDrag;
72 wxListItem m_item;
73 };
74
75
76
77
78 class wxListCtrl : public wxControl {
79 public:
80 wxListCtrl(wxWindow* parent, wxWindowID id,
81 const wxPoint& pos = wxPyDefaultPosition,
82 const wxSize& size = wxPyDefaultSize,
83 long style = wxLC_ICON,
84 const wxValidator& validator = wxPyDefaultValidator,
85 char* name = "listCtrl");
86
87 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
88
89 bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
90 bool DeleteItem(long item);
91 bool DeleteAllItems();
92 bool DeleteColumn(int col);
93 #ifdef __WXMSW__
94 bool DeleteAllColumns(void);
95 void ClearAll(void);
96 wxTextCtrl* EditLabel(long item);
97 bool EndEditLabel(bool cancel);
98 #endif
99 bool EnsureVisible(long item);
100 long FindItem(long start, const wxString& str, bool partial = FALSE);
101 %name(FindItemData)long FindItem(long start, long data);
102 %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt,
103 int direction);
104 bool GetColumn(int col, wxListItem& item);
105 int GetColumnWidth(int col);
106 int GetCountPerPage();
107 #ifdef __WXMSW__
108 wxTextCtrl* GetEditControl();
109 #endif
110 wxImageList* GetImageList(int which);
111 long GetItemData(long item);
112
113 %addmethods {
114 %new wxListItem* GetItem() {
115 wxListItem* info = new wxListItem;
116 self->GetItem(*info);
117 return info;
118 }
119 %new wxPoint* GetItemPosition(long item) {
120 wxPoint* pos = new wxPoint;
121 self->GetItemPosition(item, *pos);
122 return pos;
123 }
124 %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
125 wxRect* rect= new wxRect;
126 self->GetItemRect(item, *rect, code);
127 return rect;
128 }
129 }
130
131 int GetItemState(long item, long stateMask);
132 int GetItemCount();
133 int GetItemSpacing(bool isSmall);
134 wxString GetItemText(long item);
135 long GetNextItem(long item,
136 int geometry = wxLIST_NEXT_ALL,
137 int state = wxLIST_STATE_DONTCARE);
138 int GetSelectedItemCount();
139 #ifdef __WXMSW__
140 wxColour GetTextColour();
141 #endif
142 long GetTopItem();
143 long HitTest(const wxPoint& point, int& OUTPUT);
144 %name(InsertColumnWithInfo)long InsertColumn(long col, wxListItem& info);
145 long InsertColumn(long col, const wxString& heading,
146 int format = wxLIST_FORMAT_LEFT,
147 int width = -1);
148
149 long InsertItem(wxListItem& info);
150 %name(InsertStringItem) long InsertItem(long index, const wxString& label);
151 %name(InsertImageItem) long InsertItem(long index, int imageIndex);
152 %name(InsertImageStringItem)long InsertItem(long index, const wxString& label,
153 int imageIndex);
154
155 bool ScrollList(int dx, int dy);
156 void SetBackgroundColour(const wxColour& col);
157 bool SetColumn(int col, wxListItem& item);
158 bool SetColumnWidth(int col, int width);
159 void SetImageList(wxImageList* imageList, int which);
160 bool SetItem(wxListItem& info);
161 %name(SetItemString)long SetItem(long index, int col, const wxString& label,
162 int imageId = -1);
163 bool SetItemData(long item, long data);
164 bool SetItemImage(long item, int image, int selImage);
165 bool SetItemPosition(long item, const wxPoint& pos);
166 bool SetItemState(long item, long state, long stateMask);
167 void SetItemText(long item, const wxString& text);
168 void SetSingleStyle(long style, bool add = TRUE);
169 #ifdef __WXMSW__
170 void SetTextColour(const wxColour& col);
171 #endif
172 void SetWindowStyleFlag(long style);
173 // TODO: bool SortItems(wxListCtrlCompare fn, long data);
174 };
175
176
177
178 //----------------------------------------------------------------------
179
180
181 class wxTreeItemId {
182 public:
183 wxTreeItemId();
184 ~wxTreeItemId();
185 bool IsOk() const { return m_itemId != 0; }
186
187 // %addmethods {
188 // long GetId() { return (long)(*self); }
189 // }
190 };
191
192
193
194 // **** This isn't very useful yet. This needs to be specialized to enable
195 // derived Python classes...
196 class wxTreeItemData {
197 public:
198 wxTreeItemData();
199 ~wxTreeItemData();
200
201 const wxTreeItemId& GetId();
202 void SetId(const wxTreeItemId& id);
203 };
204
205
206
207
208 class wxTreeEvent : public wxCommandEvent {
209 public:
210 wxTreeItemId GetItem();
211 wxTreeItemId GetOldItem();
212 wxPoint GetPoint();
213 int GetCode();
214 void Veto();
215 };
216
217
218 // These are for the GetFirstChild/GetNextChild methods below
219 %typemap(python, in) long& INOUT = long* INOUT;
220 %typemap(python, argout) long& INOUT = long* INOUT;
221
222
223 class wxTreeCtrl : public wxControl {
224 public:
225 #ifdef __WXMSW__
226 wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
227 const wxPoint& pos = wxPyDefaultPosition,
228 const wxSize& size = wxPyDefaultSize,
229 long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
230 const wxValidator& validator = wxPyDefaultValidator,
231 char* name = "wxTreeCtrl");
232
233 #else
234 wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
235 const wxPoint& pos = wxPyDefaultPosition,
236 const wxSize& size = wxPyDefaultSize,
237 long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
238 //const wxValidator& validator = wxPyDefaultValidator,
239 char* name = "wxTreeCtrl");
240 #endif
241 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
242
243 size_t GetCount();
244 unsigned int GetIndent();
245 void SetIndent(unsigned int indent);
246 wxImageList *GetImageList();
247 wxImageList *GetStateImageList();
248 void SetImageList(wxImageList *imageList);
249 void SetStateImageList(wxImageList *imageList);
250
251 wxString GetItemText(const wxTreeItemId& item);
252 int GetItemImage(const wxTreeItemId& item);
253 int GetItemSelectedImage(const wxTreeItemId& item);
254 wxTreeItemData *GetItemData(const wxTreeItemId& item);
255
256 void SetItemText(const wxTreeItemId& item, const wxString& text);
257 void SetItemImage(const wxTreeItemId& item, int image);
258 void SetItemSelectedImage(const wxTreeItemId& item, int image);
259 void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
260
261 bool IsVisible(const wxTreeItemId& item);
262 bool ItemHasChildren(const wxTreeItemId& item);
263 bool IsExpanded(const wxTreeItemId& item);
264 bool IsSelected(const wxTreeItemId& item);
265
266 wxTreeItemId GetRootItem();
267 wxTreeItemId GetSelection();
268 wxTreeItemId GetParent(const wxTreeItemId& item);
269
270 wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT);
271 wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT);
272 wxTreeItemId GetNextSibling(const wxTreeItemId& item);
273 wxTreeItemId GetPrevSibling(const wxTreeItemId& item);
274 wxTreeItemId GetFirstVisibleItem();
275 wxTreeItemId GetNextVisible(const wxTreeItemId& item);
276 wxTreeItemId GetPrevVisible(const wxTreeItemId& item);
277
278
279 wxTreeItemId AddRoot(const wxString& text,
280 int image = -1, int selectedImage = -1,
281 wxTreeItemData *data = NULL);
282 wxTreeItemId PrependItem(const wxTreeItemId& parent,
283 const wxString& text,
284 int image = -1, int selectedImage = -1,
285 wxTreeItemData *data = NULL);
286 wxTreeItemId InsertItem(const wxTreeItemId& parent,
287 const wxTreeItemId& idPrevious,
288 const wxString& text,
289 int image = -1, int selectedImage = -1,
290 wxTreeItemData *data = NULL);
291 wxTreeItemId AppendItem(const wxTreeItemId& parent,
292 const wxString& text,
293 int image = -1, int selectedImage = -1,
294 wxTreeItemData *data = NULL);
295
296 void Delete(const wxTreeItemId& item);
297 void DeleteAllItems();
298
299 void Expand(const wxTreeItemId& item);
300 void Collapse(const wxTreeItemId& item);
301 void CollapseAndReset(const wxTreeItemId& item);
302 void Toggle(const wxTreeItemId& item);
303
304 void Unselect();
305 void SelectItem(const wxTreeItemId& item);
306 void EnsureVisible(const wxTreeItemId& item);
307 void ScrollTo(const wxTreeItemId& item);
308
309 wxTextCtrl* EditLabel(const wxTreeItemId& item);
310 // **** figure out how to do this
311 // wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl));
312 wxTextCtrl* GetEditControl();
313 void EndEditLabel(const wxTreeItemId& item, bool discardChanges = FALSE);
314
315 // void SortChildren(const wxTreeItemId& item);
316 // **** And this too
317 // wxTreeItemCmpFunc *cmpFunction = NULL);
318
319 void SetItemBold(const wxTreeItemId& item, bool bold = TRUE);
320 bool IsBold(const wxTreeItemId& item) const;
321 #ifdef __WXMSW__
322 wxTreeItemId HitTest(const wxPoint& point);
323 #endif
324 };
325
326
327 //----------------------------------------------------------------------
328
329 #ifdef SKIPTHIS
330 #ifdef __WXMSW__
331 class wxTabEvent : public wxCommandEvent {
332 public:
333 };
334
335
336
337 class wxTabCtrl : public wxControl {
338 public:
339 wxTabCtrl(wxWindow* parent, wxWindowID id,
340 const wxPoint& pos = wxPyDefaultPosition,
341 const wxSize& size = wxPyDefaultSize,
342 long style = 0,
343 char* name = "tabCtrl");
344
345 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
346
347 bool DeleteAllItems();
348 bool DeleteItem(int item);
349 wxImageList* GetImageList();
350 int GetItemCount();
351 // TODO: void* GetItemData();
352 int GetItemImage(int item);
353
354 %addmethods {
355 %new wxRect* GetItemRect(int item) {
356 wxRect* rect = new wxRect;
357 self->GetItemRect(item, *rect);
358 return rect;
359 }
360 }
361
362 wxString GetItemText(int item);
363 bool GetRowCount();
364 int GetSelection();
365 int HitTest(const wxPoint& pt, long& OUTPUT);
366 void InsertItem(int item, const wxString& text,
367 int imageId = -1, void* clientData = NULL);
368 // TODO: bool SetItemData(int item, void* data);
369 bool SetItemImage(int item, int image);
370 void SetImageList(wxImageList* imageList);
371 void SetItemSize(const wxSize& size);
372 bool SetItemText(int item, const wxString& text);
373 void SetPadding(const wxSize& padding);
374 int SetSelection(int item);
375
376 };
377
378 #endif
379 #endif
380
381 //----------------------------------------------------------------------
382
383
384 /////////////////////////////////////////////////////////////////////////////
385 //
386 // $Log$
387 // Revision 1.12 1998/12/16 22:10:52 RD
388 // Tweaks needed to be able to build wxPython with wxGTK.
389 //
390 // Revision 1.11 1998/12/15 20:41:16 RD
391 // Changed the import semantics from "from wxPython import *" to "from
392 // wxPython.wx import *" This is for people who are worried about
393 // namespace pollution, they can use "from wxPython import wx" and then
394 // prefix all the wxPython identifiers with "wx."
395 //
396 // Added wxTaskbarIcon for wxMSW.
397 //
398 // Made the events work for wxGrid.
399 //
400 // Added wxConfig.
401 //
402 // Added wxMiniFrame for wxGTK, (untested.)
403 //
404 // Changed many of the args and return values that were pointers to gdi
405 // objects to references to reflect changes in the wxWindows API.
406 //
407 // Other assorted fixes and additions.
408 //
409 // Revision 1.10 1998/11/25 08:45:23 RD
410 //
411 // Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
412 // Added events for wxGrid
413 // Other various fixes and additions
414 //
415 // Revision 1.9 1998/11/16 00:00:54 RD
416 // Generic treectrl for wxPython/GTK compiles...
417 //
418 // Revision 1.8 1998/11/11 04:40:20 RD
419 // wxTreeCtrl now works (sort of) for wxPython-GTK. This is the new
420 // TreeCtrl in src/gtk/treectrl.cpp not the old generic one.
421 //
422 // Revision 1.7 1998/11/11 03:12:25 RD
423 //
424 // Additions for wxTreeCtrl
425 //
426 // Revision 1.6 1998/10/20 06:43:55 RD
427 // New wxTreeCtrl wrappers (untested)
428 // some changes in helpers
429 // etc.
430 //
431 // Revision 1.5 1998/10/07 07:34:33 RD
432 // Version 0.4.1 for wxGTK
433 //
434 // Revision 1.4 1998/10/02 06:40:36 RD
435 //
436 // Version 0.4 of wxPython for MSW.
437 //
438 // Revision 1.3 1998/08/18 19:48:15 RD
439 // more wxGTK compatibility things.
440 //
441 // It builds now but there are serious runtime problems...
442 //
443 // Revision 1.2 1998/08/15 07:36:30 RD
444 // - Moved the header in the .i files out of the code that gets put into
445 // the .cpp files. It caused CVS conflicts because of the RCS ID being
446 // different each time.
447 //
448 // - A few minor fixes.
449 //
450 // Revision 1.1 1998/08/09 08:25:49 RD
451 // Initial version
452 //
453 //