]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/controls2.i
A few tweaks
[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>
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%{
38extern wxValidator wxPyDefaultValidator;
39%}
40
41//----------------------------------------------------------------------
42
43class wxListItem {
44public:
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
63class wxListEvent: public wxCommandEvent {
64public:
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
77class wxListCtrl : public wxControl {
78public:
fb5e0af0 79#ifdef __WXMSW__
7bf85405
RD
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");
fb5e0af0
RD
86#else
87 wxListCtrl(wxWindow* parent, wxWindowID id,
88 const wxPoint& pos = wxPyDefaultPosition,
89 const wxSize& size = wxPyDefaultSize,
90 long style = wxLC_ICON,
91 char* name = "listctrl");
92#endif
7bf85405
RD
93
94 bool Arrange(int flag = wxLIST_ALIGN_DEFAULT);
95 bool DeleteItem(long item);
96 bool DeleteAllItems();
97 bool DeleteColumn(int col);
fb5e0af0 98#ifdef __WXMSW__
7bf85405
RD
99 bool DeleteAllColumns(void);
100 void ClearAll(void);
101 wxTextCtrl* EditLabel(long item);
102 bool EndEditLabel(bool cancel);
fb5e0af0 103#endif
7bf85405
RD
104 bool EnsureVisible(long item);
105 long FindItem(long start, const wxString& str, bool partial = FALSE);
106 %name(FindItemData)long FindItem(long start, long data);
107 %name(FindItemAtPos)long FindItem(long start, const wxPoint& pt,
108 int direction);
109 bool GetColumn(int col, wxListItem& item);
110 int GetColumnWidth(int col);
111 int GetCountPerPage();
fb5e0af0 112#ifdef __WXMSW
7bf85405 113 wxTextCtrl* GetEditControl();
fb5e0af0 114#endif
7bf85405
RD
115 wxImageList* GetImageList(int which);
116 long GetItemData(long item);
117
118 %addmethods {
119 %new wxListItem* GetItem() {
120 wxListItem* info = new wxListItem;
121 self->GetItem(*info);
122 return info;
123 }
124 %new wxPoint* GetItemPosition(long item) {
125 wxPoint* pos = new wxPoint;
126 self->GetItemPosition(item, *pos);
127 return pos;
128 }
129 %new wxRect* GetItemRect(long item, int code = wxLIST_RECT_BOUNDS) {
130 wxRect* rect= new wxRect;
131 self->GetItemRect(item, *rect, code);
132 return rect;
133 }
134 }
135
136 int GetItemState(long item, long stateMask);
137 int GetItemCount();
138 int GetItemSpacing(bool isSmall);
139 wxString GetItemText(long item);
140 long GetNextItem(long item,
141 int geometry = wxLIST_NEXT_ALL,
142 int state = wxLIST_STATE_DONTCARE);
143 int GetSelectedItemCount();
fb5e0af0 144#ifdef __WXMSW__
7bf85405 145 wxColour GetTextColour();
fb5e0af0 146#endif
7bf85405
RD
147 long GetTopItem();
148 long HitTest(const wxPoint& point, int& OUTPUT);
149 %name(InsertColumnWithInfo)long InsertColumn(long col, wxListItem& info);
150 long InsertColumn(long col, const wxString& heading,
151 int format = wxLIST_FORMAT_LEFT,
152 int width = -1);
153
154 long InsertItem(wxListItem& info);
155 %name(InsertStringItem) long InsertItem(long index, const wxString& label);
156 %name(InsertImageItem) long InsertItem(long index, int imageIndex);
157 %name(InsertImageStringItem)long InsertItem(long index, const wxString& label,
158 int imageIndex);
159
160 bool ScrollList(int dx, int dy);
161 void SetBackgroundColour(const wxColour& col);
162 bool SetColumn(int col, wxListItem& item);
163 bool SetColumnWidth(int col, int width);
164 void SetImageList(wxImageList* imageList, int which);
165 bool SetItem(wxListItem& info);
166 %name(SetItemString)long SetItem(long index, int col, const wxString& label,
167 int imageId = -1);
168 bool SetItemData(long item, long data);
169 bool SetItemImage(long item, int image, int selImage);
170 bool SetItemPosition(long item, const wxPoint& pos);
171 bool SetItemState(long item, long state, long stateMask);
172 void SetItemText(long item, const wxString& text);
173 void SetSingleStyle(long style, bool add = TRUE);
fb5e0af0 174#ifdef __WXMSW__
7bf85405 175 void SetTextColour(const wxColour& col);
fb5e0af0 176#endif
7bf85405
RD
177 void SetWindowStyleFlag(long style);
178 // TODO: bool SortItems(wxListCtrlCompare fn, long data);
179};
180
181
182
183//----------------------------------------------------------------------
184
185
186enum {
187 wxTREE_MASK_HANDLE,
188 wxTREE_MASK_STATE,
189 wxTREE_MASK_TEXT,
190 wxTREE_MASK_IMAGE,
191 wxTREE_MASK_SELECTED_IMAGE,
192 wxTREE_MASK_CHILDREN,
193 wxTREE_MASK_DATA,
194
195 wxTREE_STATE_BOLD,
196 wxTREE_STATE_DROPHILITED,
197 wxTREE_STATE_EXPANDED,
198 wxTREE_STATE_EXPANDEDONCE,
199 wxTREE_STATE_FOCUSED,
200 wxTREE_STATE_SELECTED,
201 wxTREE_STATE_CUT,
202
203 wxTREE_HITTEST_ABOVE,
204 wxTREE_HITTEST_BELOW,
205 wxTREE_HITTEST_NOWHERE,
206 wxTREE_HITTEST_ONITEMBUTTON,
207 wxTREE_HITTEST_ONITEMICON,
208 wxTREE_HITTEST_ONITEMINDENT,
209 wxTREE_HITTEST_ONITEMLABEL,
210 wxTREE_HITTEST_ONITEMRIGHT,
211 wxTREE_HITTEST_ONITEMSTATEICON,
212 wxTREE_HITTEST_TOLEFT,
213 wxTREE_HITTEST_TORIGHT,
214 wxTREE_HITTEST_ONITEM,
215};
216
217
218enum {
219 wxTREE_NEXT_CARET,
220 wxTREE_NEXT_CHILD,
221 wxTREE_NEXT_DROPHILITE,
222 wxTREE_NEXT_FIRSTVISIBLE,
223 wxTREE_NEXT_NEXT,
224 wxTREE_NEXT_NEXTVISIBLE,
225 wxTREE_NEXT_PARENT,
226 wxTREE_NEXT_PREVIOUS,
227 wxTREE_NEXT_PREVIOUSVISIBLE,
228 wxTREE_NEXT_ROOT
229};
230
231enum {
232 wxTREE_EXPAND_EXPAND,
233 wxTREE_EXPAND_COLLAPSE,
234 wxTREE_EXPAND_COLLAPSE_RESET,
235 wxTREE_EXPAND_TOGGLE
236};
237
238enum {
239 wxTREE_INSERT_LAST,
240 wxTREE_INSERT_FIRST,
241 wxTREE_INSERT_SORT,
242};
243
244
245
246
247
248
249
250class wxTreeItem {
251public:
252 long m_mask;
253 long m_itemId;
254 long m_state;
255 long m_stateMask;
256 wxString m_text;
257 int m_image;
258 int m_selectedImage;
259 int m_children;
260 long m_data;
261
262 wxTreeItem();
263 ~wxTreeItem();
264};
265
266
267
268class wxTreeEvent : public wxCommandEvent {
269public:
270 int m_code;
271 wxTreeItem m_item;
272 long m_oldItem;
273 wxPoint m_pointDrag;
274};
275
276
277
278
279class wxTreeCtrl : public wxControl {
280public:
fb5e0af0 281#ifdef __WXMSW__
7bf85405
RD
282 wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
283 const wxPoint& pos = wxPyDefaultPosition,
284 const wxSize& size = wxPyDefaultSize,
285 long style = wxTR_HAS_BUTTONS,
286 const wxValidator& validator = wxPyDefaultValidator,
287 char* name = "wxTreeCtrl");
fb5e0af0
RD
288#else
289 wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
290 const wxPoint& pos = wxPyDefaultPosition,
291 const wxSize& size = wxPyDefaultSize,
292 long style = wxTR_HAS_BUTTONS,
293 char* name = "wxTreeCtrl");
294#endif
7bf85405
RD
295
296 bool DeleteAllItems();
fb5e0af0 297#ifdef __WXMSW__
7bf85405 298 bool DeleteItem(long item);
fb5e0af0
RD
299#else
300 void DeleteItem(long item);
301#endif
302#ifdef __WXMSW__
7bf85405
RD
303 wxTextCtrl* EditLabel(long item);
304 bool EnsureVisible(long item);
305 bool ExpandItem(long item, int action);
306 long GetChild(long item);
fb5e0af0 307#endif
7bf85405 308 int GetCount();
fb5e0af0 309#ifdef __WXMSW__
7bf85405
RD
310 wxTextCtrl* GetEditControl();
311 long GetFirstVisibleItem();
fb5e0af0 312#endif
7bf85405
RD
313 wxImageList* GetImageList(int which = wxIMAGE_LIST_NORMAL);
314 int GetIndent();
315 long GetItemData(long item);
316
317 %addmethods {
318 %new wxTreeItem* GetItem() {
319 wxTreeItem* info = new wxTreeItem;
320 self->GetItem(*info);
321 return info;
322 }
fb5e0af0 323#ifdef __WXMSW__
7bf85405
RD
324 %new wxRect* GetItemRect(long item, int textOnly = FALSE) {
325 wxRect* rect = new wxRect;
326 self->GetItemRect(item, *rect, textOnly);
327 return rect;
328 }
fb5e0af0 329#endif
7bf85405
RD
330 }
331
fb5e0af0 332#ifdef __WXMSW__
7bf85405 333 int GetItemState(long item, long stateMask);
fb5e0af0 334#endif
7bf85405 335 wxString GetItemText(long item);
fb5e0af0 336#ifdef __WXMSW__
7bf85405
RD
337 long GetNextItem(long item, int code);
338 long GetNextVisibleItem(long item);
fb5e0af0 339#endif
7bf85405
RD
340 long GetParent(long item);
341 long GetRootItem();
342 long GetSelection();
343 long HitTest(const wxPoint& point, int& OUTPUT); // *** check this
344 long InsertItem(long parent, wxTreeItem& info,
345 long insertAfter = wxTREE_INSERT_LAST);
346 %name(InsertItemString)
347 long InsertItem(long parent, const wxString& label,
348 int image = -1, int selImage = -1,
349 long insertAfter = wxTREE_INSERT_LAST);
350 bool ItemHasChildren(long item);
fb5e0af0 351#ifdef __WXMSW__
7bf85405 352 bool ScrollTo(long item);
fb5e0af0 353#endif
7bf85405
RD
354 bool SelectItem(long item);
355 void SetIndent(int indent);
356 void SetImageList(wxImageList* imageList, int which = wxIMAGE_LIST_NORMAL);
357 bool SetItem(wxTreeItem& info);
fb5e0af0 358#ifdef __WXMSW__
7bf85405 359 bool SetItemImage(long item, int image, int selImage);
fb5e0af0
RD
360#else
361 void SetItemImage(long item, int image, int selImage);
362#endif
363#ifdef __WXMSW__
7bf85405 364 bool SetItemState(long item, long state, long stateMask);
fb5e0af0 365#endif
7bf85405
RD
366 void SetItemText(long item, const wxString& text);
367 bool SetItemData(long item, long data);
fb5e0af0 368#ifdef __WXMSW__
7bf85405 369 bool SortChildren(long item);
fb5e0af0 370#endif
7bf85405
RD
371};
372
373//----------------------------------------------------------------------
374
fb5e0af0 375#ifdef __WXMSW__
7bf85405
RD
376class wxTabEvent : public wxCommandEvent {
377public:
378};
379
380
381
382class wxTabCtrl : public wxControl {
383public:
384 wxTabCtrl(wxWindow* parent, wxWindowID id,
385 const wxPoint& pos = wxPyDefaultPosition,
386 const wxSize& size = wxPyDefaultSize,
387 long style = 0,
388 char* name = "tabCtrl");
389
390 bool DeleteAllItems();
391 bool DeleteItem(int item);
392 wxImageList* GetImageList();
393 int GetItemCount();
394 // TODO: void* GetItemData();
395 int GetItemImage(int item);
396
397 %addmethods {
398 %new wxRect* GetItemRect(int item) {
399 wxRect* rect = new wxRect;
400 self->GetItemRect(item, *rect);
401 return rect;
402 }
403 }
404
405 wxString GetItemText(int item);
406 bool GetRowCount();
407 int GetSelection();
408 int HitTest(const wxPoint& pt, long& OUTPUT);
409 void InsertItem(int item, const wxString& text,
410 int imageId = -1, void* clientData = NULL);
411 // TODO: bool SetItemData(int item, void* data);
412 bool SetItemImage(int item, int image);
413 void SetImageList(wxImageList* imageList);
414 void SetItemSize(const wxSize& size);
415 bool SetItemText(int item, const wxString& text);
416 void SetPadding(const wxSize& padding);
417 int SetSelection(int item);
418
419};
420
fb5e0af0
RD
421#endif
422
7bf85405
RD
423//----------------------------------------------------------------------
424
425
426/////////////////////////////////////////////////////////////////////////////
427//
428// $Log$
fb5e0af0
RD
429// Revision 1.3 1998/08/18 19:48:15 RD
430// more wxGTK compatibility things.
431//
432// It builds now but there are serious runtime problems...
433//
03e9bead
RD
434// Revision 1.2 1998/08/15 07:36:30 RD
435// - Moved the header in the .i files out of the code that gets put into
436// the .cpp files. It caused CVS conflicts because of the RCS ID being
437// different each time.
438//
439// - A few minor fixes.
440//
7bf85405
RD
441// Revision 1.1 1998/08/09 08:25:49 RD
442// Initial version
443//
444//