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