]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/windows2.i
wxPython 2.1b1:
[wxWidgets.git] / utils / wxPython / src / windows2.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: windows2.i
3 // Purpose: SWIG definitions of MORE window classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 6/2/98
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %module windows2
14
15 %{
16 #include "helpers.h"
17 #include <wx/grid.h>
18 #include <wx/notebook.h>
19 #include <wx/splitter.h>
20 #ifdef __WXMSW__
21 #include <wx/msw/taskbar.h>
22 #endif
23 %}
24
25 //----------------------------------------------------------------------
26
27 %include typemaps.i
28 %include my_typemaps.i
29
30 // Import some definitions of other classes, etc.
31 %import _defs.i
32 %import misc.i
33 %import gdi.i
34 %import windows.i
35 %import controls.i
36 %import events.i
37
38 %pragma(python) code = "import wx"
39
40 //---------------------------------------------------------------------------
41
42
43 enum {
44 wxGRID_TEXT_CTRL,
45 wxGRID_HSCROLL,
46 wxGRID_VSCROLL
47 };
48
49 class wxGridCell {
50 public:
51 wxGridCell();
52 ~wxGridCell();
53
54 wxString& GetTextValue();
55 void SetTextValue(const wxString& str);
56 wxFont& GetFont();
57 void SetFont(wxFont& f);
58 wxColour& GetTextColour();
59 void SetTextColour(const wxColour& colour);
60 wxColour& GetBackgroundColour();
61 void SetBackgroundColour(const wxColour& colour);
62 wxBrush& GetBackgroundBrush();
63 int GetAlignment();
64 void SetAlignment(int align);
65 wxBitmap* GetCellBitmap();
66 void SetCellBitmap(wxBitmap* bitmap);
67 };
68
69
70
71
72 class wxGrid : public wxPanel {
73 public:
74 wxGrid(wxWindow* parent, wxWindowID id,
75 const wxPoint& pos=wxPyDefaultPosition,
76 const wxSize& size=wxPyDefaultSize,
77 long style=0,
78 char* name="grid");
79
80 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
81 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnSelectCell', wxEVT_GRID_SELECT_CELL)"
82 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnCreateCell', wxEVT_GRID_CREATE_CELL)"
83 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnChangeLabels', wxEVT_GRID_CHANGE_LABELS)"
84 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnChangeSelectionLabel', wxEVT_GRID_CHANGE_SEL_LABEL)"
85 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnCellChange', wxEVT_GRID_CELL_CHANGE)"
86 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnCellLeftClick', wxEVT_GRID_CELL_LCLICK)"
87 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnCellRightClick', wxEVT_GRID_CELL_RCLICK)"
88 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnLabelLeftClick', wxEVT_GRID_LABEL_LCLICK)"
89 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnLabelRightClick', wxEVT_GRID_LABEL_RCLICK)"
90
91
92 void AdjustScrollbars();
93 bool AppendCols(int n=1, bool updateLabels=TRUE);
94 bool AppendRows(int n=1, bool updateLabels=TRUE);
95 void BeginBatch();
96 bool CellHitTest(int x, int y, int *OUTPUT, int *OUTPUT);
97
98 %addmethods {
99 // TODO: For now we are just ignoring the initial cellValues
100 // and widths. Add support for loading them from
101 // Python sequence objects.
102 bool CreateGrid(int rows, int cols,
103 //PyObject* cellValues = NULL,
104 //PyObject* widths = NULL,
105 short defaultWidth = wxGRID_DEFAULT_CELL_WIDTH,
106 short defaultHeight = wxGRID_DEFAULT_CELL_HEIGHT) {
107 return self->CreateGrid(rows, cols, NULL, NULL,
108 defaultWidth, defaultHeight);
109 }
110 }
111
112 bool CurrentCellVisible();
113 bool DeleteCols(int pos=0, int n=1, bool updateLabels=TRUE);
114 bool DeleteRows(int pos=0, int n=1, bool updateLabels=TRUE);
115 void EndBatch();
116
117 int GetBatchCount();
118 wxGridCell* GetCell(int row, int col);
119 int GetCellAlignment(int row, int col);
120 %name(GetDefCellAlignment)int GetCellAlignment();
121 wxColour& GetCellBackgroundColour(int row, int col);
122 %name(GetDefCellBackgroundColour) wxColour& GetCellBackgroundColour();
123
124 //wxGridCell *** GetCells();
125 %addmethods {
126 PyObject* GetCells() {
127 int row, col;
128 PyObject* rows = PyList_New(0);
129 for (row=0; row < self->GetRows(); row++) {
130 PyObject* rowList = PyList_New(0);
131 for (col=0; col < self->GetCols(); col++) {
132 wxGridCell* cell = self->GetCell(row, col);
133
134 #ifdef WXP_WITH_THREAD
135 PyEval_RestoreThread(wxPyEventThreadState);
136 wxPyInEvent = true;
137 #endif
138 PyObject* pyCell = wxPyConstructObject(cell, "wxGridCell");
139 #ifdef WXP_WITH_THREAD
140 PyEval_SaveThread();
141 wxPyInEvent = false;
142 #endif
143
144 if (PyList_Append(rowList, pyCell) == -1)
145 return NULL;
146 }
147 if (PyList_Append(rows, rowList) == -1)
148 return NULL;
149 }
150 return rows;
151 }
152 }
153 wxColour& GetCellTextColour(int row, int col);
154 %name(GetDefCellTextColour)wxColour& GetCellTextColour();
155 wxFont& GetCellTextFont(int row, int col);
156 %name(GetDefCellTextFont)wxFont& GetCellTextFont();
157 wxString& GetCellValue(int row, int col);
158 int GetCols();
159 int GetColumnWidth(int col);
160 wxRect GetCurrentRect();
161 int GetCursorColumn();
162 int GetCursorRow();
163 bool GetEditable();
164 wxScrollBar * GetHorizScrollBar();
165 int GetLabelAlignment(int orientation);
166 wxColour& GetLabelBackgroundColour();
167 int GetLabelSize(int orientation);
168 wxColour& GetLabelTextColour();
169 wxFont& GetLabelTextFont();
170 wxString& GetLabelValue(int orientation, int pos);
171 int GetRowHeight(int row);
172 int GetRows();
173 int GetScrollPosX();
174 int GetScrollPosY();
175 wxTextCtrl* GetTextItem();
176 wxScrollBar* GetVertScrollBar();
177
178 bool InsertCols(int pos=0, int n=1, bool updateLabels=TRUE);
179 bool InsertRows(int pos=0, int n=1, bool updateLabels=TRUE);
180
181 void OnActivate(bool active);
182
183 void SetCellAlignment(int alignment, int row, int col);
184 %name(SetDefCellAlignment)void SetCellAlignment(int alignment);
185 void SetCellBackgroundColour(const wxColour& colour, int row, int col);
186 %name(SetDefCellBackgroundColour)
187 void SetCellBackgroundColour(const wxColour& colour);
188 void SetCellTextColour(const wxColour& colour, int row, int col);
189 %name(SetDefCellTextColour)void SetCellTextColour(const wxColour& colour);
190 void SetCellTextFont(wxFont& font, int row, int col);
191 %name(SetDefCellTextFont)void SetCellTextFont(wxFont& font);
192 void SetCellValue(const wxString& val, int row, int col);
193 void SetColumnWidth(int col, int width);
194 void SetDividerPen(wxPen& pen);
195 void SetEditable(bool editable);
196 void SetGridCursor(int row, int col);
197 void SetLabelAlignment(int orientation, int alignment);
198 void SetLabelBackgroundColour(const wxColour& value);
199 void SetLabelSize(int orientation, int size);
200 void SetLabelTextColour(const wxColour& value);
201 void SetLabelTextFont(wxFont& font);
202 void SetLabelValue(int orientation, const wxString& value, int pos);
203 void SetRowHeight(int row, int height);
204
205 void UpdateDimensions();
206
207 bool GetEditInPlace();
208 void SetEditInPlace(int edit = TRUE);
209
210 };
211
212
213 class wxGridEvent : public wxEvent {
214 public:
215 int m_row;
216 int m_col;
217 int m_x;
218 int m_y;
219 bool m_control;
220 bool m_shift;
221 wxGridCell* m_cell;
222 };
223
224
225 enum {
226 wxEVT_GRID_SELECT_CELL,
227 wxEVT_GRID_CREATE_CELL,
228 wxEVT_GRID_CHANGE_LABELS,
229 wxEVT_GRID_CHANGE_SEL_LABEL,
230 wxEVT_GRID_CELL_CHANGE,
231 wxEVT_GRID_CELL_LCLICK,
232 wxEVT_GRID_CELL_RCLICK,
233 wxEVT_GRID_LABEL_LCLICK,
234 wxEVT_GRID_LABEL_RCLICK,
235 };
236
237
238 //---------------------------------------------------------------------------
239
240 class wxNotebookEvent : public wxNotifyEvent {
241 public:
242 int GetSelection();
243 int GetOldSelection();
244 void SetOldSelection(int page);
245 void SetSelection(int page);
246 };
247
248
249
250 class wxNotebook : public wxControl {
251 public:
252 wxNotebook(wxWindow *parent,
253 wxWindowID id,
254 const wxPoint& pos = wxPyDefaultPosition,
255 const wxSize& size = wxPyDefaultSize,
256 long style = 0,
257 char* name = "notebook");
258
259 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
260
261 int GetPageCount();
262 int SetSelection(int nPage);
263 void AdvanceSelection(bool bForward = TRUE);
264 int GetSelection();
265 bool SetPageText(int nPage, const wxString& strText);
266 wxString GetPageText(int nPage) const;
267 void SetImageList(wxImageList* imageList);
268 wxImageList* GetImageList();
269 int GetPageImage(int nPage);
270 bool SetPageImage(int nPage, int nImage);
271 int GetRowCount();
272
273 // LINK ERROR: void SetPageSize(const wxSize& size);
274 // LINK ERROR: void SetPadding(const wxSize& padding);
275 bool DeletePage(int nPage);
276 bool RemovePage(int nPage);
277 bool DeleteAllPages();
278 bool AddPage(/*wxNotebookPage*/ wxWindow *pPage,
279 const wxString& strText,
280 int bSelect = FALSE,
281 int imageId = -1);
282 #ifdef __WXMSW__
283 bool InsertPage(int nPage,
284 /*wxNotebookPage*/ wxWindow *pPage,
285 const wxString& strText,
286 bool bSelect = FALSE,
287 int imageId = -1);
288 #endif
289 /*wxNotebookPage*/ wxWindow *GetPage(int nPage);
290
291 %addmethods {
292 void ResizeChildren() {
293 wxSizeEvent evt(self->GetClientSize());
294 self->GetEventHandler()->ProcessEvent(evt);
295 }
296 }
297
298
299 };
300
301 //---------------------------------------------------------------------------
302
303 class wxSplitterEvent : public wxCommandEvent {
304 public:
305 int GetSashPosition();
306 int GetX();
307 int GetY();
308 wxWindow* GetWindowBeingRemoved();
309 void SetSashPosition(int pos);
310 }
311
312
313
314
315 class wxSplitterWindow : public wxWindow {
316 public:
317 wxSplitterWindow(wxWindow* parent, wxWindowID id,
318 const wxPoint& point = wxPyDefaultPosition,
319 const wxSize& size = wxPyDefaultSize,
320 long style=wxSP_3D|wxCLIP_CHILDREN,
321 char* name = "splitterWindow");
322
323 %pragma(python) addtomethod = "__init__:wx._StdWindowCallbacks(self)"
324
325 int GetBorderSize();
326 int GetMinimumPaneSize();
327 int GetSashPosition();
328 int GetSashSize();
329 int GetSplitMode();
330 wxWindow* GetWindow1();
331 wxWindow* GetWindow2();
332 void Initialize(wxWindow* window);
333 bool IsSplit();
334
335
336 void SetBorderSize(int width);
337 void SetSashPosition(int position, int redraw = TRUE);
338 void SetSashSize(int width);
339 void SetMinimumPaneSize(int paneSize);
340 void SetSplitMode(int mode);
341 bool SplitHorizontally(wxWindow* window1, wxWindow* window2, int sashPosition = 0);
342 bool SplitVertically(wxWindow* window1, wxWindow* window2, int sashPosition = 0);
343 bool Unsplit(wxWindow* toRemove = NULL);
344 };
345
346 //---------------------------------------------------------------------------
347
348 #ifdef __WXMSW__
349
350 enum {
351 wxEVT_TASKBAR_MOVE,
352 wxEVT_TASKBAR_LEFT_DOWN,
353 wxEVT_TASKBAR_LEFT_UP,
354 wxEVT_TASKBAR_RIGHT_DOWN,
355 wxEVT_TASKBAR_RIGHT_UP,
356 wxEVT_TASKBAR_LEFT_DCLICK,
357 wxEVT_TASKBAR_RIGHT_DCLICK
358 };
359
360
361 class wxTaskBarIcon : public wxEvtHandler {
362 public:
363 wxTaskBarIcon();
364 ~wxTaskBarIcon();
365
366 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnMouseMove', wxEVT_TASKBAR_MOVE)"
367 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnLButtonDown', wxEVT_TASKBAR_LEFT_DOWN)"
368 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnLButtonUp', wxEVT_TASKBAR_LEFT_UP)"
369 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnRButtonDown', wxEVT_TASKBAR_RIGHT_DOWN)"
370 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnRButtonUp', wxEVT_TASKBAR_RIGHT_UP)"
371 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnLButtonDClick',wxEVT_TASKBAR_LEFT_DCLICK)"
372 %pragma(python) addtomethod = "__init__:wx._checkForCallback(self, 'OnRButtonDClick',wxEVT_TASKBAR_RIGHT_DCLICK)"
373
374 bool SetIcon(const wxIcon& icon, const char* tooltip = "");
375 bool RemoveIcon(void);
376 bool PopupMenu(wxMenu *menu);
377
378 };
379 #endif
380
381 //---------------------------------------------------------------------------