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