]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_toplvl.i
bitwise vs. logical operator
[wxWidgets.git] / wxPython / src / _toplvl.i
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
18 MAKE_CONST_WXSTRING(FrameNameStr);
19 MAKE_CONST_WXSTRING(DialogNameStr);
20 MAKE_CONST_WXSTRING(StatusLineNameStr);
21 MAKE_CONST_WXSTRING(ToolBarNameStr);
22
23 //---------------------------------------------------------------------------
24 %newgroup
25
26 enum
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
69 enum
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
82 enum
83 {
84 wxUSER_ATTENTION_INFO = 1,
85 wxUSER_ATTENTION_ERROR = 2
86 };
87
88 //---------------------------------------------------------------------------
89
90 class wxTopLevelWindow : public wxWindow
91 {
92 public:
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 // enable/disable close button [x]
134 virtual bool EnableCloseButton(bool enable );
135
136 // Set the shape of the window to the given region.
137 // Returns True if the platform supports this feature
138 // (and the operation is successful.)
139 virtual bool SetShape(const wxRegion& region);
140
141 // Attracts the users attention to this window if the application is inactive
142 // (should be called when a background event occurs)
143 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
144
145 // Is this the active frame (highlighted in the taskbar)?
146 virtual bool IsActive();
147
148 #ifdef __WXMAC__
149 %extend {
150 void MacSetMetalAppearance( bool on ) {
151 int style = self->GetExtraStyle();
152 if ( on )
153 style |= wxFRAME_EX_METAL;
154 else
155 style &= ~wxFRAME_EX_METAL;
156 self->SetExtraStyle(style);
157 }
158 }
159 bool MacGetMetalAppearance() const;
160 #else
161 %extend
162 {
163 // TODO: Should they raise not implemented or just NOP???
164 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
165 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
166 }
167 #endif
168
169 DocDeclStr(
170 void , CenterOnScreen(int dir = wxBOTH),
171 "Center the window on screen", "");
172 %pythoncode { CentreOnScreen = CenterOnScreen }
173
174
175 DocDeclStr(
176 virtual wxWindow *, GetDefaultItem() const,
177 "Get the default child of this parent, i.e. the one which is activated
178 by pressing <Enter> such as the OK button on a wx.Dialog.", "");
179
180 DocDeclStr(
181 virtual wxWindow *, SetDefaultItem(wxWindow * child),
182 "Set this child as default, return the old default.", "");
183
184 DocDeclStr(
185 virtual void , SetTmpDefaultItem(wxWindow * win),
186 "Set this child as temporary default", "");
187
188 DocDeclStr(
189 virtual wxWindow *, GetTmpDefaultItem() const,
190 "Return the temporary default item, which can be None.", "");
191
192 %property(DefaultItem, GetDefaultItem, SetDefaultItem, doc="See `GetDefaultItem` and `SetDefaultItem`");
193 %property(Icon, GetIcon, SetIcon, doc="See `GetIcon` and `SetIcon`");
194 %property(Title, GetTitle, SetTitle, doc="See `GetTitle` and `SetTitle`");
195 %property(TmpDefaultItem, GetTmpDefaultItem, SetTmpDefaultItem, doc="See `GetTmpDefaultItem` and `SetTmpDefaultItem`");
196 };
197
198
199 //---------------------------------------------------------------------------
200 %newgroup
201
202 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
203 //
204 // For each of *bars, a frame may have several of them, but only one is
205 // managed by the frame, i.e. resized/moved when the frame is and whose size
206 // is accounted for in client size calculations - all others should be taken
207 // care of manually.
208
209 MustHaveApp(wxFrame);
210
211 class wxFrame : public wxTopLevelWindow
212 {
213 public:
214 %pythonAppend wxFrame "self._setOORInfo(self)"
215 %pythonAppend wxFrame() ""
216 %typemap(out) wxFrame*; // turn off this typemap
217
218 wxFrame(wxWindow* parent,
219 const wxWindowID id = -1,
220 const wxString& title = wxPyEmptyString,
221 const wxPoint& pos = wxDefaultPosition,
222 const wxSize& size = wxDefaultSize,
223 long style = wxDEFAULT_FRAME_STYLE,
224 const wxString& name = wxPyFrameNameStr);
225 %RenameCtor(PreFrame, wxFrame());
226
227 // Turn it back on again
228 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
229
230 bool Create(wxWindow* parent,
231 const wxWindowID id = -1,
232 const wxString& title = wxPyEmptyString,
233 const wxPoint& pos = wxDefaultPosition,
234 const wxSize& size = wxDefaultSize,
235 long style = wxDEFAULT_FRAME_STYLE,
236 const wxString& name = wxPyFrameNameStr);
237
238 // frame state
239 // -----------
240
241 // get the origin of the client area (which may be different from (0, 0)
242 // if the frame has a toolbar) in client coordinates
243 virtual wxPoint GetClientAreaOrigin() const;
244
245 // sends a size event to the window using its current size:
246 // this has a side effect of refreshing the window layout
247 virtual void SendSizeEvent();
248
249 // menu bar functions
250 // ------------------
251
252 virtual void SetMenuBar(wxMenuBar *menubar);
253 virtual wxMenuBar *GetMenuBar() const;
254
255 // process menu command: returns True if processed
256 bool ProcessCommand(int winid);
257 %pythoncode { Command = ProcessCommand }
258
259 // status bar functions
260 // --------------------
261
262 // create the main status bar by calling OnCreateStatusBar()
263 virtual wxStatusBar* CreateStatusBar(int number = 1,
264 long style = wxDEFAULT_STATUSBAR_STYLE,
265 wxWindowID winid = 0,
266 const wxString& name = wxPyStatusLineNameStr);
267
268 // TODO: with directors?
269 // // return a new status bar
270 // virtual wxStatusBar *OnCreateStatusBar(int number,
271 // long style,
272 // wxWindowID winid,
273 // const wxString& name);
274
275 // get the main status bar
276 virtual wxStatusBar *GetStatusBar() const;
277
278 // sets the main status bar
279 void SetStatusBar(wxStatusBar *statBar);
280
281 // forward these to status bar
282 virtual void SetStatusText(const wxString &text, int number = 0);
283 virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
284 void PushStatusText(const wxString &text, int number = 0);
285 void PopStatusText(int number = 0);
286
287 // set the status bar pane the help will be shown in
288 void SetStatusBarPane(int n);
289 int GetStatusBarPane() const;
290
291 // toolbar functions
292 // -----------------
293
294 // create main toolbar bycalling OnCreateToolBar()
295 virtual wxToolBar* CreateToolBar(long style = -1,
296 wxWindowID winid = -1,
297 const wxString& name = wxPyToolBarNameStr);
298
299 // TODO: with directors?
300 // // return a new toolbar
301 // virtual wxToolBar *OnCreateToolBar(long style,
302 // wxWindowID winid,
303 // const wxString& name );
304
305 // get/set the main toolbar
306 virtual wxToolBar *GetToolBar() const;
307 virtual void SetToolBar(wxToolBar *toolbar);
308
309 // show help text (typically in the statusbar); show is False
310 // if you are hiding the help, True otherwise
311 virtual void DoGiveHelp(const wxString& text, bool show);
312
313 // send wxUpdateUIEvents for all menu items in the menubar,
314 // or just for menu if non-NULL
315 void DoMenuUpdates(wxMenu* menu = NULL);
316
317 static wxVisualAttributes
318 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
319
320 %property(MenuBar, GetMenuBar, SetMenuBar, doc="See `GetMenuBar` and `SetMenuBar`");
321 %property(StatusBar, GetStatusBar, SetStatusBar, doc="See `GetStatusBar` and `SetStatusBar`");
322 %property(StatusBarPane, GetStatusBarPane, SetStatusBarPane, doc="See `GetStatusBarPane` and `SetStatusBarPane`");
323 %property(ToolBar, GetToolBar, SetToolBar, doc="See `GetToolBar` and `SetToolBar`");
324 };
325
326 //---------------------------------------------------------------------------
327 %newgroup
328
329 MustHaveApp(wxDialog);
330
331 class wxDialog : public wxTopLevelWindow
332 {
333 public:
334 enum
335 {
336 // all flags allowed in wxDialogBase::CreateButtonSizer()
337 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
338 };
339
340 %pythonAppend wxDialog "self._setOORInfo(self)"
341 %pythonAppend wxDialog() ""
342 %typemap(out) wxDialog*; // turn off this typemap
343
344 wxDialog(wxWindow* parent,
345 const wxWindowID id = -1,
346 const wxString& title = wxPyEmptyString,
347 const wxPoint& pos = wxDefaultPosition,
348 const wxSize& size = wxDefaultSize,
349 long style = wxDEFAULT_DIALOG_STYLE,
350 const wxString& name = wxPyDialogNameStr);
351 %RenameCtor(PreDialog, wxDialog());
352
353 // Turn it back on again
354 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
355
356 bool Create(wxWindow* parent,
357 const wxWindowID id = -1,
358 const wxString& title = wxPyEmptyString,
359 const wxPoint& pos = wxDefaultPosition,
360 const wxSize& size = wxDefaultSize,
361 long style = wxDEFAULT_DIALOG_STYLE,
362 const wxString& name = wxPyDialogNameStr);
363
364 // the modal dialogs have a return code - usually the ID of the last
365 // pressed button
366 void SetReturnCode(int returnCode);
367 int GetReturnCode() const;
368
369 // Set the identifier for the affirmative button: this button will close
370 // the dialog after validating data and calling TransferDataFromWindow()
371 void SetAffirmativeId(int affirmativeId);
372 int GetAffirmativeId() const;
373
374 // Set identifier for Esc key translation: the button with this id will
375 // close the dialog without doing anything else; special value wxID_NONE
376 // means to not handle Esc at all while wxID_ANY means to map Esc to
377 // wxID_CANCEL if present and GetAffirmativeId() otherwise
378 void SetEscapeId(int escapeId);
379 int GetEscapeId() const;
380
381 // splits text up at newlines and places the
382 // lines into a vertical wxBoxSizer
383 wxSizer* CreateTextSizer( const wxString &message );
384
385
386 // returns a horizontal wxBoxSizer containing the given buttons
387 //
388 // notice that the returned sizer can be NULL if no buttons are put in the
389 // sizer (this mostly happens under smart phones and other atypical
390 // platforms which have hardware buttons replacing OK/Cancel and such)
391 %Rename(_CreateButtonSizer,
392 wxSizer* , CreateButtonSizer( long flags ));
393 %pythoncode {
394 def CreateButtonSizer(self, flags, *ignored):
395 return self._CreateButtonSizer(flags)
396 }
397
398 // returns the sizer containing CreateButtonSizer() below a separating
399 // static line for the platforms which use static lines for items
400 // separation (i.e. not Mac)
401 wxSizer *CreateSeparatedButtonSizer(long flags);
402
403 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
404
405 //void SetModal( bool flag );
406
407 // is the dialog in modal state right now?
408 virtual bool IsModal() const;
409
410 // Shows the dialog and starts a nested event loop that returns when
411 // EndModal is called.
412 virtual int ShowModal();
413
414 // may be called to terminate the dialog with the given return code
415 virtual void EndModal(int retCode);
416
417 static wxVisualAttributes
418 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
419
420 %property(AffirmativeId, GetAffirmativeId, SetAffirmativeId, doc="See `GetAffirmativeId` and `SetAffirmativeId`");
421 %property(EscapeId, GetEscapeId, SetEscapeId, doc="See `GetEscapeId` and `SetEscapeId`");
422 %property(ReturnCode, GetReturnCode, SetReturnCode, doc="See `GetReturnCode` and `SetReturnCode`");
423 };
424
425 //---------------------------------------------------------------------------
426 %newgroup
427
428 %{
429 #define wxDEFAULT_MINIFRAME_STYLE wxCAPTION | wxRESIZE_BORDER | wxTINY_CAPTION_HORIZ
430 %}
431
432 enum {
433 wxDEFAULT_MINIFRAME_STYLE
434 };
435
436
437 MustHaveApp(wxMiniFrame);
438
439 class wxMiniFrame : public wxFrame
440 {
441 public:
442 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
443 %pythonAppend wxMiniFrame() ""
444
445 wxMiniFrame(wxWindow* parent,
446 const wxWindowID id = -1,
447 const wxString& title = wxPyEmptyString,
448 const wxPoint& pos = wxDefaultPosition,
449 const wxSize& size = wxDefaultSize,
450 long style = wxDEFAULT_MINIFRAME_STYLE,
451 const wxString& name = wxPyFrameNameStr);
452 %RenameCtor(PreMiniFrame, wxMiniFrame());
453
454 bool Create(wxWindow* parent,
455 const wxWindowID id = -1,
456 const wxString& title = wxPyEmptyString,
457 const wxPoint& pos = wxDefaultPosition,
458 const wxSize& size = wxDefaultSize,
459 long style = wxDEFAULT_MINIFRAME_STYLE,
460 const wxString& name = wxPyFrameNameStr);
461 };
462
463
464 //---------------------------------------------------------------------------
465 %newgroup
466
467
468 enum
469 {
470 wxSPLASH_CENTRE_ON_PARENT,
471 wxSPLASH_CENTRE_ON_SCREEN,
472 wxSPLASH_NO_CENTRE,
473 wxSPLASH_TIMEOUT,
474 wxSPLASH_NO_TIMEOUT,
475 };
476
477
478 MustHaveApp(wxSplashScreenWindow);
479
480 class wxSplashScreenWindow: public wxWindow
481 {
482 public:
483 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
484
485 wxSplashScreenWindow(const wxBitmap& bitmap,
486 wxWindow* parent,
487 wxWindowID id,
488 const wxPoint& pos = wxDefaultPosition,
489 const wxSize& size = wxDefaultSize,
490 long style = wxNO_BORDER);
491
492 void SetBitmap(const wxBitmap& bitmap);
493 wxBitmap& GetBitmap();
494
495 %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
496 };
497
498
499 MustHaveApp(wxSplashScreen);
500
501 class wxSplashScreen : public wxFrame
502 {
503 public:
504 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
505
506 wxSplashScreen(const wxBitmap& bitmap,
507 long splashStyle, int milliseconds,
508 wxWindow* parent,
509 wxWindowID id = -1,
510 const wxPoint& pos = wxDefaultPosition,
511 const wxSize& size = wxDefaultSize,
512 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
513
514 long GetSplashStyle() const;
515 wxSplashScreenWindow* GetSplashWindow() const;
516 int GetTimeout() const;
517
518 %property(SplashStyle, GetSplashStyle, doc="See `GetSplashStyle`");
519 %property(SplashWindow, GetSplashWindow, doc="See `GetSplashWindow`");
520 %property(Timeout, GetTimeout, doc="See `GetTimeout`");
521 };
522
523
524 //---------------------------------------------------------------------------