]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/src/_toplvl.i
Added wx.lib.dragscroller from Riaan Booysen.
[wxWidgets.git] / wxPython / src / _toplvl.i
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: _toplvl.i
3// Purpose: SWIG definitions for wxTopLevelWindow, wxFrame, wxDialog and etc.
4//
5// Author: Robin Dunn
6//
7// Created: 27-Aug-1998
8// RCS-ID: $Id$
9// Copyright: (c) 2003 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13// Not a %module
14
15
16//---------------------------------------------------------------------------
17
18MAKE_CONST_WXSTRING(FrameNameStr);
19MAKE_CONST_WXSTRING(DialogNameStr);
20MAKE_CONST_WXSTRING(StatusLineNameStr);
21MAKE_CONST_WXSTRING(ToolBarNameStr);
22
23//---------------------------------------------------------------------------
24%newgroup
25
26enum
27{
28 wxSTAY_ON_TOP,
29 wxICONIZE,
30 wxMINIMIZE,
31 wxMAXIMIZE,
32 wxCLOSE_BOX,
33 wxTHICK_FRAME,
34 wxSYSTEM_MENU,
35 wxMINIMIZE_BOX,
36 wxMAXIMIZE_BOX,
37 wxTINY_CAPTION_HORIZ,
38 wxTINY_CAPTION_VERT,
39 wxRESIZE_BOX,
40 wxRESIZE_BORDER,
41
42 wxDIALOG_NO_PARENT,
43
44 wxDEFAULT_FRAME_STYLE,
45 wxDEFAULT_DIALOG_STYLE,
46
47 wxFRAME_TOOL_WINDOW,
48 wxFRAME_FLOAT_ON_PARENT,
49 wxFRAME_NO_WINDOW_MENU,
50 wxFRAME_NO_TASKBAR,
51 wxFRAME_SHAPED,
52 wxFRAME_DRAWER,
53
54 wxFRAME_EX_METAL,
55 wxDIALOG_EX_METAL,
56 wxWS_EX_CONTEXTHELP,
57
58 // Obsolete
59 wxDIALOG_MODAL,
60 wxDIALOG_MODELESS,
61 wxUSER_COLOURS,
62 wxNO_3D,
63
64 wxFRAME_EX_CONTEXTHELP,
65 wxDIALOG_EX_CONTEXTHELP,
66};
67
68
69enum
70{
71 wxFULLSCREEN_NOMENUBAR,
72 wxFULLSCREEN_NOTOOLBAR,
73 wxFULLSCREEN_NOSTATUSBAR,
74 wxFULLSCREEN_NOBORDER,
75 wxFULLSCREEN_NOCAPTION,
76 wxFULLSCREEN_ALL,
77
78 wxTOPLEVEL_EX_DIALOG,
79};
80
81// Styles for RequestUserAttention
82enum
83{
84 wxUSER_ATTENTION_INFO = 1,
85 wxUSER_ATTENTION_ERROR = 2
86};
87
88//---------------------------------------------------------------------------
89
90class wxTopLevelWindow : public wxWindow
91{
92public:
93
94 // No constructor as it can not be used directly from Python
95
96 // maximize = True => maximize, otherwise - restore
97 virtual void Maximize(bool maximize = true);
98
99 // undo Maximize() or Iconize()
100 virtual void Restore();
101
102 // iconize = True => iconize, otherwise - restore
103 virtual void Iconize(bool iconize = true);
104
105 // return True if the frame is maximized
106 virtual bool IsMaximized() const;
107
108 // return true if the frame is always maximized
109 // due to native guidelines or current policy
110 virtual bool IsAlwaysMaximized() const;
111
112 // return True if the frame is iconized
113 virtual bool IsIconized() const;
114
115 // get the frame icon
116 wxIcon GetIcon() const;
117
118 // set the frame icon
119 virtual void SetIcon(const wxIcon& icon);
120
121 // set the frame icons
122 virtual void SetIcons(const wxIconBundle& icons);
123
124 // maximize the window to cover entire screen
125 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
126
127 // return True if the frame is in fullscreen mode
128 virtual bool IsFullScreen() const;
129
130 virtual void SetTitle(const wxString& title);
131 virtual wxString GetTitle() const;
132
133 // Set the shape of the window to the given region.
134 // Returns True if the platform supports this feature
135 // (and the operation is successful.)
136 virtual bool SetShape(const wxRegion& region);
137
138 // Attracts the users attention to this window if the application is inactive
139 // (should be called when a background event occurs)
140 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
141
142 // Is this the active frame (highlighted in the taskbar)?
143 virtual bool IsActive();
144
145#ifdef __WXMAC__
146 %extend {
147 void MacSetMetalAppearance( bool on ) {
148 int style = self->GetExtraStyle();
149 if ( on )
150 style |= wxFRAME_EX_METAL;
151 else
152 style &= ~wxFRAME_EX_METAL;
153 self->SetExtraStyle(style);
154 }
155 }
156 bool MacGetMetalAppearance() const;
157#else
158 %extend
159 {
160 // TODO: Should they raise not implemented or just NOP???
161 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
162 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
163 }
164#endif
165
166 DocDeclStr(
167 void , CenterOnScreen(int dir = wxBOTH),
168 "Center the window on screen", "");
169 %pythoncode { CentreOnScreen = CenterOnScreen }
170
171#ifdef __WXMSW__
172 bool EnableCloseButton(bool enable = true);
173#else
174 %extend {
175 bool EnableCloseButton(bool enable = true) { return false; }
176 }
177#endif
178
179
180
181 DocDeclStr(
182 virtual wxWindow *, GetDefaultItem() const,
183 "Get the default child of this parent, i.e. the one which is activated
184by pressing <Enter> such as the OK button on a wx.Dialog.", "");
185
186 DocDeclStr(
187 virtual wxWindow *, SetDefaultItem(wxWindow * child),
188 "Set this child as default, return the old default.", "");
189
190 DocDeclStr(
191 virtual void , SetTmpDefaultItem(wxWindow * win),
192 "Set this child as temporary default", "");
193
194 DocDeclStr(
195 virtual wxWindow *, GetTmpDefaultItem() const,
196 "Return the temporary default item, which can be None.", "");
197
198};
199
200
201//---------------------------------------------------------------------------
202%newgroup
203
204// wxFrame is a top-level window with optional menubar, statusbar and toolbar
205//
206// For each of *bars, a frame may have several of them, but only one is
207// managed by the frame, i.e. resized/moved when the frame is and whose size
208// is accounted for in client size calculations - all others should be taken
209// care of manually.
210
211MustHaveApp(wxFrame);
212
213class wxFrame : public wxTopLevelWindow
214{
215public:
216 %pythonAppend wxFrame "self._setOORInfo(self)"
217 %pythonAppend wxFrame() ""
218 %typemap(out) wxFrame*; // turn off this typemap
219
220 wxFrame(wxWindow* parent,
221 const wxWindowID id = -1,
222 const wxString& title = wxPyEmptyString,
223 const wxPoint& pos = wxDefaultPosition,
224 const wxSize& size = wxDefaultSize,
225 long style = wxDEFAULT_FRAME_STYLE,
226 const wxString& name = wxPyFrameNameStr);
227 %RenameCtor(PreFrame, wxFrame());
228
229 // Turn it back on again
230 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
231
232 bool Create(wxWindow* parent,
233 const wxWindowID id = -1,
234 const wxString& title = wxPyEmptyString,
235 const wxPoint& pos = wxDefaultPosition,
236 const wxSize& size = wxDefaultSize,
237 long style = wxDEFAULT_FRAME_STYLE,
238 const wxString& name = wxPyFrameNameStr);
239
240 // frame state
241 // -----------
242
243 // get the origin of the client area (which may be different from (0, 0)
244 // if the frame has a toolbar) in client coordinates
245 virtual wxPoint GetClientAreaOrigin() const;
246
247 // sends a size event to the window using its current size:
248 // this has a side effect of refreshing the window layout
249 virtual void SendSizeEvent();
250
251 // menu bar functions
252 // ------------------
253
254 virtual void SetMenuBar(wxMenuBar *menubar);
255 virtual wxMenuBar *GetMenuBar() const;
256
257 // process menu command: returns True if processed
258 bool ProcessCommand(int winid);
259 %pythoncode { Command = ProcessCommand }
260
261 // status bar functions
262 // --------------------
263
264 // create the main status bar by calling OnCreateStatusBar()
265 virtual wxStatusBar* CreateStatusBar(int number = 1,
266 long style = wxDEFAULT_STATUSBAR_STYLE,
267 wxWindowID winid = 0,
268 const wxString& name = wxPyStatusLineNameStr);
269
270// TODO: with directors?
271// // return a new status bar
272// virtual wxStatusBar *OnCreateStatusBar(int number,
273// long style,
274// wxWindowID winid,
275// const wxString& name);
276
277 // get the main status bar
278 virtual wxStatusBar *GetStatusBar() const;
279
280 // sets the main status bar
281 void SetStatusBar(wxStatusBar *statBar);
282
283 // forward these to status bar
284 virtual void SetStatusText(const wxString &text, int number = 0);
285 virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
286 void PushStatusText(const wxString &text, int number = 0);
287 void PopStatusText(int number = 0);
288
289 // set the status bar pane the help will be shown in
290 void SetStatusBarPane(int n);
291 int GetStatusBarPane() const;
292
293 // toolbar functions
294 // -----------------
295
296 // create main toolbar bycalling OnCreateToolBar()
297 virtual wxToolBar* CreateToolBar(long style = -1,
298 wxWindowID winid = -1,
299 const wxString& name = wxPyToolBarNameStr);
300
301// TODO: with directors?
302// // return a new toolbar
303// virtual wxToolBar *OnCreateToolBar(long style,
304// wxWindowID winid,
305// const wxString& name );
306
307 // get/set the main toolbar
308 virtual wxToolBar *GetToolBar() const;
309 virtual void SetToolBar(wxToolBar *toolbar);
310
311 // show help text (typically in the statusbar); show is False
312 // if you are hiding the help, True otherwise
313 virtual void DoGiveHelp(const wxString& text, bool show);
314
315 // send wxUpdateUIEvents for all menu items in the menubar,
316 // or just for menu if non-NULL
317 void DoMenuUpdates(wxMenu* menu = NULL);
318
319 static wxVisualAttributes
320 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
321};
322
323//---------------------------------------------------------------------------
324%newgroup
325
326MustHaveApp(wxDialog);
327
328class wxDialog : public wxTopLevelWindow
329{
330public:
331 enum
332 {
333 // all flags allowed in wxDialogBase::CreateButtonSizer()
334 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
335 };
336
337 %pythonAppend wxDialog "self._setOORInfo(self)"
338 %pythonAppend wxDialog() ""
339 %typemap(out) wxDialog*; // turn off this typemap
340
341 wxDialog(wxWindow* parent,
342 const wxWindowID id = -1,
343 const wxString& title = wxPyEmptyString,
344 const wxPoint& pos = wxDefaultPosition,
345 const wxSize& size = wxDefaultSize,
346 long style = wxDEFAULT_DIALOG_STYLE,
347 const wxString& name = wxPyDialogNameStr);
348 %RenameCtor(PreDialog, wxDialog());
349
350 // Turn it back on again
351 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
352
353 bool Create(wxWindow* parent,
354 const wxWindowID id = -1,
355 const wxString& title = wxPyEmptyString,
356 const wxPoint& pos = wxDefaultPosition,
357 const wxSize& size = wxDefaultSize,
358 long style = wxDEFAULT_DIALOG_STYLE,
359 const wxString& name = wxPyDialogNameStr);
360
361 // the modal dialogs have a return code - usually the ID of the last
362 // pressed button
363 void SetReturnCode(int returnCode);
364 int GetReturnCode() const;
365
366 // Set the identifier for the affirmative button: this button will close
367 // the dialog after validating data and calling TransferDataFromWindow()
368 void SetAffirmativeId(int affirmativeId);
369 int GetAffirmativeId() const;
370
371 // Set identifier for Esc key translation: the button with this id will
372 // close the dialog without doing anything else; special value wxID_NONE
373 // means to not handle Esc at all while wxID_ANY means to map Esc to
374 // wxID_CANCEL if present and GetAffirmativeId() otherwise
375 void SetEscapeId(int escapeId);
376 int GetEscapeId() const;
377
378 // splits text up at newlines and places the
379 // lines into a vertical wxBoxSizer
380 wxSizer* CreateTextSizer( const wxString &message );
381
382 // places buttons into a horizontal wxBoxSizer
383 wxSizer* CreateButtonSizer( long flags,
384 bool separated = false,
385 wxCoord distance = 0 );
386 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
387
388 //void SetModal( bool flag );
389
390 // is the dialog in modal state right now?
391 virtual bool IsModal() const;
392
393 // Shows the dialog and starts a nested event loop that returns when
394 // EndModal is called.
395 virtual int ShowModal();
396
397 // may be called to terminate the dialog with the given return code
398 virtual void EndModal(int retCode);
399
400 static wxVisualAttributes
401 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
402
403 %property(AffirmativeId, GetAffirmativeId, SetAffirmativeId, doc="See `GetAffirmativeId` and `SetAffirmativeId`");
404 %property(EscapeId, GetEscapeId, SetEscapeId, doc="See `GetEscapeId` and `SetEscapeId`");
405 %property(ReturnCode, GetReturnCode, SetReturnCode, doc="See `GetReturnCode` and `SetReturnCode`");
406};
407
408//---------------------------------------------------------------------------
409%newgroup
410
411
412MustHaveApp(wxMiniFrame);
413
414class wxMiniFrame : public wxFrame
415{
416public:
417 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
418 %pythonAppend wxMiniFrame() ""
419
420 wxMiniFrame(wxWindow* parent,
421 const wxWindowID id = -1,
422 const wxString& title = wxPyEmptyString,
423 const wxPoint& pos = wxDefaultPosition,
424 const wxSize& size = wxDefaultSize,
425 long style = wxDEFAULT_FRAME_STYLE,
426 const wxString& name = wxPyFrameNameStr);
427 %RenameCtor(PreMiniFrame, wxMiniFrame());
428
429 bool Create(wxWindow* parent,
430 const wxWindowID id = -1,
431 const wxString& title = wxPyEmptyString,
432 const wxPoint& pos = wxDefaultPosition,
433 const wxSize& size = wxDefaultSize,
434 long style = wxDEFAULT_FRAME_STYLE,
435 const wxString& name = wxPyFrameNameStr);
436};
437
438
439//---------------------------------------------------------------------------
440%newgroup
441
442
443enum
444{
445 wxSPLASH_CENTRE_ON_PARENT,
446 wxSPLASH_CENTRE_ON_SCREEN,
447 wxSPLASH_NO_CENTRE,
448 wxSPLASH_TIMEOUT,
449 wxSPLASH_NO_TIMEOUT,
450};
451
452
453MustHaveApp(wxSplashScreenWindow);
454
455class wxSplashScreenWindow: public wxWindow
456{
457public:
458 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
459
460 wxSplashScreenWindow(const wxBitmap& bitmap,
461 wxWindow* parent,
462 wxWindowID id,
463 const wxPoint& pos = wxDefaultPosition,
464 const wxSize& size = wxDefaultSize,
465 long style = wxNO_BORDER);
466
467 void SetBitmap(const wxBitmap& bitmap);
468 wxBitmap& GetBitmap();
469};
470
471
472MustHaveApp(wxSplashScreen);
473
474class wxSplashScreen : public wxFrame
475{
476public:
477 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
478
479 wxSplashScreen(const wxBitmap& bitmap,
480 long splashStyle, int milliseconds,
481 wxWindow* parent,
482 wxWindowID id = -1,
483 const wxPoint& pos = wxDefaultPosition,
484 const wxSize& size = wxDefaultSize,
485 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
486
487 long GetSplashStyle() const;
488 wxSplashScreenWindow* GetSplashWindow() const;
489 int GetTimeout() const;
490};
491
492
493//---------------------------------------------------------------------------