]> git.saurik.com Git - wxWidgets.git/blame_incremental - utils/wxPython/src/controls2.i
Changed the import semantics from "from wxPython import *" to "from
[wxWidgets.git] / utils / wxPython / src / controls2.i
... / ...
CommitLineData
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%{
39extern wxValidator wxPyDefaultValidator;
40%}
41
42//----------------------------------------------------------------------
43
44class wxListItem {
45public:
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
64class wxListEvent: public wxCommandEvent {
65public:
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
78class wxListCtrl : public wxControl {
79public:
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
181class wxTreeItemId {
182public:
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...
196class wxTreeItemData {
197public:
198 wxTreeItemData();
199 ~wxTreeItemData();
200
201 const wxTreeItemId& GetId();
202 void SetId(const wxTreeItemId& id);
203};
204
205
206
207
208class wxTreeEvent : public wxCommandEvent {
209public:
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
223class wxTreeCtrl : public wxControl {
224public:
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 wxTreeItemId HitTest(const wxPoint& point);
322};
323
324
325//----------------------------------------------------------------------
326
327#ifdef SKIPTHIS
328#ifdef __WXMSW__
329class wxTabEvent : public wxCommandEvent {
330public:
331};
332
333
334
335class wxTabCtrl : public wxControl {
336public:
337 wxTabCtrl(wxWindow* parent, wxWindowID id,
338 const wxPoint& pos = wxPyDefaultPosition,
339 const wxSize& size = wxPyDefaultSize,
340 long style = 0,
341 char* name = "tabCtrl");
342
343 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
344
345 bool DeleteAllItems();
346 bool DeleteItem(int item);
347 wxImageList* GetImageList();
348 int GetItemCount();
349 // TODO: void* GetItemData();
350 int GetItemImage(int item);
351
352 %addmethods {
353 %new wxRect* GetItemRect(int item) {
354 wxRect* rect = new wxRect;
355 self->GetItemRect(item, *rect);
356 return rect;
357 }
358 }
359
360 wxString GetItemText(int item);
361 bool GetRowCount();
362 int GetSelection();
363 int HitTest(const wxPoint& pt, long& OUTPUT);
364 void InsertItem(int item, const wxString& text,
365 int imageId = -1, void* clientData = NULL);
366 // TODO: bool SetItemData(int item, void* data);
367 bool SetItemImage(int item, int image);
368 void SetImageList(wxImageList* imageList);
369 void SetItemSize(const wxSize& size);
370 bool SetItemText(int item, const wxString& text);
371 void SetPadding(const wxSize& padding);
372 int SetSelection(int item);
373
374};
375
376#endif
377#endif
378
379//----------------------------------------------------------------------
380
381
382/////////////////////////////////////////////////////////////////////////////
383//
384// $Log$
385// Revision 1.11 1998/12/15 20:41:16 RD
386// Changed the import semantics from "from wxPython import *" to "from
387// wxPython.wx import *" This is for people who are worried about
388// namespace pollution, they can use "from wxPython import wx" and then
389// prefix all the wxPython identifiers with "wx."
390//
391// Added wxTaskbarIcon for wxMSW.
392//
393// Made the events work for wxGrid.
394//
395// Added wxConfig.
396//
397// Added wxMiniFrame for wxGTK, (untested.)
398//
399// Changed many of the args and return values that were pointers to gdi
400// objects to references to reflect changes in the wxWindows API.
401//
402// Other assorted fixes and additions.
403//
404// Revision 1.10 1998/11/25 08:45:23 RD
405//
406// Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
407// Added events for wxGrid
408// Other various fixes and additions
409//
410// Revision 1.9 1998/11/16 00:00:54 RD
411// Generic treectrl for wxPython/GTK compiles...
412//
413// Revision 1.8 1998/11/11 04:40:20 RD
414// wxTreeCtrl now works (sort of) for wxPython-GTK. This is the new
415// TreeCtrl in src/gtk/treectrl.cpp not the old generic one.
416//
417// Revision 1.7 1998/11/11 03:12:25 RD
418//
419// Additions for wxTreeCtrl
420//
421// Revision 1.6 1998/10/20 06:43:55 RD
422// New wxTreeCtrl wrappers (untested)
423// some changes in helpers
424// etc.
425//
426// Revision 1.5 1998/10/07 07:34:33 RD
427// Version 0.4.1 for wxGTK
428//
429// Revision 1.4 1998/10/02 06:40:36 RD
430//
431// Version 0.4 of wxPython for MSW.
432//
433// Revision 1.3 1998/08/18 19:48:15 RD
434// more wxGTK compatibility things.
435//
436// It builds now but there are serious runtime problems...
437//
438// Revision 1.2 1998/08/15 07:36:30 RD
439// - Moved the header in the .i files out of the code that gets put into
440// the .cpp files. It caused CVS conflicts because of the RCS ID being
441// different each time.
442//
443// - A few minor fixes.
444//
445// Revision 1.1 1998/08/09 08:25:49 RD
446// Initial version
447//
448//