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