1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions for wxTopLevelWindow, wxFrame, wxDialog and etc.
7 // Created: 27-Aug-1998
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
18 MAKE_CONST_WXSTRING(FrameNameStr);
19 MAKE_CONST_WXSTRING(DialogNameStr);
20 MAKE_CONST_WXSTRING(StatusLineNameStr);
21 MAKE_CONST_WXSTRING(ToolBarNameStr);
23 //---------------------------------------------------------------------------
44 wxDEFAULT_FRAME_STYLE,
45 wxDEFAULT_DIALOG_STYLE,
48 wxFRAME_FLOAT_ON_PARENT,
49 wxFRAME_NO_WINDOW_MENU,
64 wxFRAME_EX_CONTEXTHELP,
65 wxDIALOG_EX_CONTEXTHELP,
71 wxFULLSCREEN_NOMENUBAR,
72 wxFULLSCREEN_NOTOOLBAR,
73 wxFULLSCREEN_NOSTATUSBAR,
74 wxFULLSCREEN_NOBORDER,
75 wxFULLSCREEN_NOCAPTION,
81 // Styles for RequestUserAttention
84 wxUSER_ATTENTION_INFO = 1,
85 wxUSER_ATTENTION_ERROR = 2
88 //---------------------------------------------------------------------------
90 class wxTopLevelWindow : public wxWindow
94 // No constructor as it can not be used directly from Python
96 // maximize = True => maximize, otherwise - restore
97 virtual void Maximize(bool maximize = true);
99 // undo Maximize() or Iconize()
100 virtual void Restore();
102 // iconize = True => iconize, otherwise - restore
103 virtual void Iconize(bool iconize = true);
105 // return True if the frame is maximized
106 virtual bool IsMaximized() const;
108 // return true if the frame is always maximized
109 // due to native guidelines or current policy
110 virtual bool IsAlwaysMaximized() const;
112 // return True if the frame is iconized
113 virtual bool IsIconized() const;
115 // get the frame icon
116 wxIcon GetIcon() const;
118 // set the frame icon
119 virtual void SetIcon(const wxIcon& icon);
121 // set the frame icons
122 virtual void SetIcons(const wxIconBundle& icons);
124 // maximize the window to cover entire screen
125 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
127 // return True if the frame is in fullscreen mode
128 virtual bool IsFullScreen() const;
130 virtual void SetTitle(const wxString& title);
131 virtual wxString GetTitle() const;
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);
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);
142 // Is this the active frame (highlighted in the taskbar)?
143 virtual bool IsActive();
147 void MacSetMetalAppearance( bool on ) {
148 int style = self->GetExtraStyle();
150 style |= wxFRAME_EX_METAL;
152 style &= ~wxFRAME_EX_METAL;
153 self->SetExtraStyle(style);
156 bool MacGetMetalAppearance() const;
160 // TODO: Should they raise not implemented or just NOP???
161 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
162 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
167 void , CenterOnScreen(int dir = wxBOTH),
168 "Center the window on screen", "");
169 %pythoncode { CentreOnScreen = CenterOnScreen }
172 bool EnableCloseButton(bool enable = true);
175 bool EnableCloseButton(bool enable = true) { return false; }
179 virtual bool SetTransparent(byte alpha);
180 virtual bool CanSetTransparent();
185 virtual wxWindow *, GetDefaultItem() const,
186 "Get the default child of this parent, i.e. the one which is activated
187 by pressing <Enter> such as the OK button on a wx.Dialog.", "");
190 virtual wxWindow *, SetDefaultItem(wxWindow * child),
191 "Set this child as default, return the old default.", "");
194 virtual void , SetTmpDefaultItem(wxWindow * win),
195 "Set this child as temporary default", "");
198 virtual wxWindow *, GetTmpDefaultItem() const,
199 "Return the temporary default item, which can be None.", "");
204 //---------------------------------------------------------------------------
207 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
209 // For each of *bars, a frame may have several of them, but only one is
210 // managed by the frame, i.e. resized/moved when the frame is and whose size
211 // is accounted for in client size calculations - all others should be taken
214 MustHaveApp(wxFrame);
216 class wxFrame : public wxTopLevelWindow
219 %pythonAppend wxFrame "self._setOORInfo(self)"
220 %pythonAppend wxFrame() ""
221 %typemap(out) wxFrame*; // turn off this typemap
223 wxFrame(wxWindow* parent,
224 const wxWindowID id = -1,
225 const wxString& title = wxPyEmptyString,
226 const wxPoint& pos = wxDefaultPosition,
227 const wxSize& size = wxDefaultSize,
228 long style = wxDEFAULT_FRAME_STYLE,
229 const wxString& name = wxPyFrameNameStr);
230 %RenameCtor(PreFrame, wxFrame());
232 // Turn it back on again
233 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
235 bool Create(wxWindow* parent,
236 const wxWindowID id = -1,
237 const wxString& title = wxPyEmptyString,
238 const wxPoint& pos = wxDefaultPosition,
239 const wxSize& size = wxDefaultSize,
240 long style = wxDEFAULT_FRAME_STYLE,
241 const wxString& name = wxPyFrameNameStr);
246 // get the origin of the client area (which may be different from (0, 0)
247 // if the frame has a toolbar) in client coordinates
248 virtual wxPoint GetClientAreaOrigin() const;
250 // sends a size event to the window using its current size:
251 // this has a side effect of refreshing the window layout
252 virtual void SendSizeEvent();
254 // menu bar functions
255 // ------------------
257 virtual void SetMenuBar(wxMenuBar *menubar);
258 virtual wxMenuBar *GetMenuBar() const;
260 // process menu command: returns True if processed
261 bool ProcessCommand(int winid);
262 %pythoncode { Command = ProcessCommand }
264 // status bar functions
265 // --------------------
267 // create the main status bar by calling OnCreateStatusBar()
268 virtual wxStatusBar* CreateStatusBar(int number = 1,
269 long style = wxDEFAULT_STATUSBAR_STYLE,
270 wxWindowID winid = 0,
271 const wxString& name = wxPyStatusLineNameStr);
273 // TODO: with directors?
274 // // return a new status bar
275 // virtual wxStatusBar *OnCreateStatusBar(int number,
278 // const wxString& name);
280 // get the main status bar
281 virtual wxStatusBar *GetStatusBar() const;
283 // sets the main status bar
284 void SetStatusBar(wxStatusBar *statBar);
286 // forward these to status bar
287 virtual void SetStatusText(const wxString &text, int number = 0);
288 virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
289 void PushStatusText(const wxString &text, int number = 0);
290 void PopStatusText(int number = 0);
292 // set the status bar pane the help will be shown in
293 void SetStatusBarPane(int n);
294 int GetStatusBarPane() const;
299 // create main toolbar bycalling OnCreateToolBar()
300 virtual wxToolBar* CreateToolBar(long style = -1,
301 wxWindowID winid = -1,
302 const wxString& name = wxPyToolBarNameStr);
304 // TODO: with directors?
305 // // return a new toolbar
306 // virtual wxToolBar *OnCreateToolBar(long style,
308 // const wxString& name );
310 // get/set the main toolbar
311 virtual wxToolBar *GetToolBar() const;
312 virtual void SetToolBar(wxToolBar *toolbar);
314 // show help text (typically in the statusbar); show is False
315 // if you are hiding the help, True otherwise
316 virtual void DoGiveHelp(const wxString& text, bool show);
318 // send wxUpdateUIEvents for all menu items in the menubar,
319 // or just for menu if non-NULL
320 void DoMenuUpdates(wxMenu* menu = NULL);
322 static wxVisualAttributes
323 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
326 //---------------------------------------------------------------------------
329 MustHaveApp(wxDialog);
331 class wxDialog : public wxTopLevelWindow
336 // all flags allowed in wxDialogBase::CreateButtonSizer()
337 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
340 %pythonAppend wxDialog "self._setOORInfo(self)"
341 %pythonAppend wxDialog() ""
342 %typemap(out) wxDialog*; // turn off this typemap
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());
353 // Turn it back on again
354 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
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);
364 // the modal dialogs have a return code - usually the ID of the last
366 void SetReturnCode(int returnCode);
367 int GetReturnCode() const;
369 // The identifier for the affirmative button
370 void SetAffirmativeId(int affirmativeId);
371 int GetAffirmativeId() const;
373 // Identifier for Esc key translation
374 void SetEscapeId(int escapeId);
375 int GetEscapeId() const;
377 // splits text up at newlines and places the
378 // lines into a vertical wxBoxSizer
379 wxSizer* CreateTextSizer( const wxString &message );
381 // places buttons into a horizontal wxBoxSizer
382 wxSizer* CreateButtonSizer( long flags,
383 bool separated = false,
384 wxCoord distance = 0 );
385 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
387 //void SetModal( bool flag );
389 // is the dialog in modal state right now?
390 virtual bool IsModal() const;
392 // Shows the dialog and starts a nested event loop that returns when
393 // EndModal is called.
394 virtual int ShowModal();
396 // may be called to terminate the dialog with the given return code
397 virtual void EndModal(int retCode);
399 static wxVisualAttributes
400 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
403 //---------------------------------------------------------------------------
407 MustHaveApp(wxMiniFrame);
409 class wxMiniFrame : public wxFrame
412 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
413 %pythonAppend wxMiniFrame() ""
415 wxMiniFrame(wxWindow* parent,
416 const wxWindowID id = -1,
417 const wxString& title = wxPyEmptyString,
418 const wxPoint& pos = wxDefaultPosition,
419 const wxSize& size = wxDefaultSize,
420 long style = wxDEFAULT_FRAME_STYLE,
421 const wxString& name = wxPyFrameNameStr);
422 %RenameCtor(PreMiniFrame, wxMiniFrame());
424 bool Create(wxWindow* parent,
425 const wxWindowID id = -1,
426 const wxString& title = wxPyEmptyString,
427 const wxPoint& pos = wxDefaultPosition,
428 const wxSize& size = wxDefaultSize,
429 long style = wxDEFAULT_FRAME_STYLE,
430 const wxString& name = wxPyFrameNameStr);
434 //---------------------------------------------------------------------------
440 wxSPLASH_CENTRE_ON_PARENT,
441 wxSPLASH_CENTRE_ON_SCREEN,
448 MustHaveApp(wxSplashScreenWindow);
450 class wxSplashScreenWindow: public wxWindow
453 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
455 wxSplashScreenWindow(const wxBitmap& bitmap,
458 const wxPoint& pos = wxDefaultPosition,
459 const wxSize& size = wxDefaultSize,
460 long style = wxNO_BORDER);
462 void SetBitmap(const wxBitmap& bitmap);
463 wxBitmap& GetBitmap();
467 MustHaveApp(wxSplashScreen);
469 class wxSplashScreen : public wxFrame
472 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
474 wxSplashScreen(const wxBitmap& bitmap,
475 long splashStyle, int milliseconds,
478 const wxPoint& pos = wxDefaultPosition,
479 const wxSize& size = wxDefaultSize,
480 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
482 long GetSplashStyle() const;
483 wxSplashScreenWindow* GetSplashWindow() const;
484 int GetTimeout() const;
488 //---------------------------------------------------------------------------