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,
66 wxFULLSCREEN_NOMENUBAR,
67 wxFULLSCREEN_NOTOOLBAR,
68 wxFULLSCREEN_NOSTATUSBAR,
69 wxFULLSCREEN_NOBORDER,
70 wxFULLSCREEN_NOCAPTION,
76 // Styles for RequestUserAttention
79 wxUSER_ATTENTION_INFO = 1,
80 wxUSER_ATTENTION_ERROR = 2
83 //---------------------------------------------------------------------------
85 class wxTopLevelWindow : public wxWindow
89 // No constructor as it can not be used directly from Python
91 // maximize = True => maximize, otherwise - restore
92 virtual void Maximize(bool maximize = true);
94 // undo Maximize() or Iconize()
95 virtual void Restore();
97 // iconize = True => iconize, otherwise - restore
98 virtual void Iconize(bool iconize = true);
100 // return True if the frame is maximized
101 virtual bool IsMaximized() const;
103 // return true if the frame is always maximized
104 // due to native guidelines or current policy
105 virtual bool IsAlwaysMaximized() const;
107 // return True if the frame is iconized
108 virtual bool IsIconized() const;
110 // get the frame icon
111 wxIcon GetIcon() const;
113 // set the frame icon
114 virtual void SetIcon(const wxIcon& icon);
116 // set the frame icons
117 virtual void SetIcons(const wxIconBundle& icons);
119 // maximize the window to cover entire screen
120 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
122 // return True if the frame is in fullscreen mode
123 virtual bool IsFullScreen() const;
125 virtual void SetTitle(const wxString& title);
126 virtual wxString GetTitle() const;
128 // Set the shape of the window to the given region.
129 // Returns True if the platform supports this feature
130 // (and the operation is successful.)
131 virtual bool SetShape(const wxRegion& region);
133 // Attracts the users attention to this window if the application is inactive
134 // (should be called when a background event occurs)
135 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
137 // Is this the active frame (highlighted in the taskbar)?
138 virtual bool IsActive();
142 void MacSetMetalAppearance( bool on ) {
143 int style = self->GetExtraStyle();
145 style |= wxFRAME_EX_METAL;
147 style &= ~wxFRAME_EX_METAL;
148 self->SetExtraStyle(style);
151 bool MacGetMetalAppearance() const;
155 // TODO: Should they raise not implemented or just NOP???
156 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
157 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
162 void , CenterOnScreen(int dir = wxBOTH),
163 "Center the window on screen", "");
164 %pythoncode { CentreOnScreen = CenterOnScreen }
167 bool EnableCloseButton(bool enable = true);
170 bool EnableCloseButton(bool enable = true) { return false; }
174 virtual bool SetTransparent(byte alpha);
175 virtual bool CanSetTransparent();
180 virtual wxWindow *, GetDefaultItem() const,
181 "Get the default child of this parent, i.e. the one which is activated
182 by pressing <Enter> such as the OK button on a wx.Dialog.", "");
185 virtual wxWindow *, SetDefaultItem(wxWindow * child),
186 "Set this child as default, return the old default.", "");
189 virtual void , SetTmpDefaultItem(wxWindow * win),
190 "Set this child as temporary default", "");
193 virtual wxWindow *, GetTmpDefaultItem() const,
194 "Return the temporary default item, which can be None.", "");
199 //---------------------------------------------------------------------------
202 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
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
209 MustHaveApp(wxFrame);
211 class wxFrame : public wxTopLevelWindow
214 %pythonAppend wxFrame "self._setOORInfo(self)"
215 %pythonAppend wxFrame() ""
216 %typemap(out) wxFrame*; // turn off this typemap
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());
227 // Turn it back on again
228 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
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);
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;
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();
249 // menu bar functions
250 // ------------------
252 virtual void SetMenuBar(wxMenuBar *menubar);
253 virtual wxMenuBar *GetMenuBar() const;
255 // process menu command: returns True if processed
256 bool ProcessCommand(int winid);
257 %pythoncode { Command = ProcessCommand }
259 // status bar functions
260 // --------------------
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);
268 // TODO: with directors?
269 // // return a new status bar
270 // virtual wxStatusBar *OnCreateStatusBar(int number,
273 // const wxString& name);
275 // get the main status bar
276 virtual wxStatusBar *GetStatusBar() const;
278 // sets the main status bar
279 void SetStatusBar(wxStatusBar *statBar);
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);
287 // set the status bar pane the help will be shown in
288 void SetStatusBarPane(int n);
289 int GetStatusBarPane() const;
294 // create main toolbar bycalling OnCreateToolBar()
295 virtual wxToolBar* CreateToolBar(long style = -1,
296 wxWindowID winid = -1,
297 const wxString& name = wxPyToolBarNameStr);
299 // TODO: with directors?
300 // // return a new toolbar
301 // virtual wxToolBar *OnCreateToolBar(long style,
303 // const wxString& name );
305 // get/set the main toolbar
306 virtual wxToolBar *GetToolBar() const;
307 virtual void SetToolBar(wxToolBar *toolbar);
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);
313 // send wxUpdateUIEvents for all menu items in the menubar,
314 // or just for menu if non-NULL
315 void DoMenuUpdates(wxMenu* menu = NULL);
317 static wxVisualAttributes
318 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
321 //---------------------------------------------------------------------------
324 MustHaveApp(wxDialog);
326 class wxDialog : public wxTopLevelWindow
331 // all flags allowed in wxDialogBase::CreateButtonSizer()
332 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
335 %pythonAppend wxDialog "self._setOORInfo(self)"
336 %pythonAppend wxDialog() ""
337 %typemap(out) wxDialog*; // turn off this typemap
339 wxDialog(wxWindow* parent,
340 const wxWindowID id = -1,
341 const wxString& title = wxPyEmptyString,
342 const wxPoint& pos = wxDefaultPosition,
343 const wxSize& size = wxDefaultSize,
344 long style = wxDEFAULT_DIALOG_STYLE,
345 const wxString& name = wxPyDialogNameStr);
346 %RenameCtor(PreDialog, wxDialog());
348 // Turn it back on again
349 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
351 bool Create(wxWindow* parent,
352 const wxWindowID id = -1,
353 const wxString& title = wxPyEmptyString,
354 const wxPoint& pos = wxDefaultPosition,
355 const wxSize& size = wxDefaultSize,
356 long style = wxDEFAULT_DIALOG_STYLE,
357 const wxString& name = wxPyDialogNameStr);
359 // the modal dialogs have a return code - usually the ID of the last
361 void SetReturnCode(int returnCode);
362 int GetReturnCode() const;
364 // The identifier for the affirmative button
365 void SetAffirmativeId(int affirmativeId);
366 int GetAffirmativeId() const;
368 // Identifier for Esc key translation
369 void SetEscapeId(int escapeId);
370 int GetEscapeId() const;
372 // splits text up at newlines and places the
373 // lines into a vertical wxBoxSizer
374 wxSizer* CreateTextSizer( const wxString &message );
376 // places buttons into a horizontal wxBoxSizer
377 wxSizer* CreateButtonSizer( long flags,
378 bool separated = false,
379 wxCoord distance = 0 );
380 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
382 //void SetModal( bool flag );
384 // is the dialog in modal state right now?
385 virtual bool IsModal() const;
387 // Shows the dialog and starts a nested event loop that returns when
388 // EndModal is called.
389 virtual int ShowModal();
391 // may be called to terminate the dialog with the given return code
392 virtual void EndModal(int retCode);
394 static wxVisualAttributes
395 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
398 //---------------------------------------------------------------------------
402 MustHaveApp(wxMiniFrame);
404 class wxMiniFrame : public wxFrame
407 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
408 %pythonAppend wxMiniFrame() ""
410 wxMiniFrame(wxWindow* parent,
411 const wxWindowID id = -1,
412 const wxString& title = wxPyEmptyString,
413 const wxPoint& pos = wxDefaultPosition,
414 const wxSize& size = wxDefaultSize,
415 long style = wxDEFAULT_FRAME_STYLE,
416 const wxString& name = wxPyFrameNameStr);
417 %RenameCtor(PreMiniFrame, wxMiniFrame());
419 bool Create(wxWindow* parent,
420 const wxWindowID id = -1,
421 const wxString& title = wxPyEmptyString,
422 const wxPoint& pos = wxDefaultPosition,
423 const wxSize& size = wxDefaultSize,
424 long style = wxDEFAULT_FRAME_STYLE,
425 const wxString& name = wxPyFrameNameStr);
429 //---------------------------------------------------------------------------
435 wxSPLASH_CENTRE_ON_PARENT,
436 wxSPLASH_CENTRE_ON_SCREEN,
443 MustHaveApp(wxSplashScreenWindow);
445 class wxSplashScreenWindow: public wxWindow
448 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
450 wxSplashScreenWindow(const wxBitmap& bitmap,
453 const wxPoint& pos = wxDefaultPosition,
454 const wxSize& size = wxDefaultSize,
455 long style = wxNO_BORDER);
457 void SetBitmap(const wxBitmap& bitmap);
458 wxBitmap& GetBitmap();
462 MustHaveApp(wxSplashScreen);
464 class wxSplashScreen : public wxFrame
467 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
469 wxSplashScreen(const wxBitmap& bitmap,
470 long splashStyle, int milliseconds,
473 const wxPoint& pos = wxDefaultPosition,
474 const wxSize& size = wxDefaultSize,
475 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
477 long GetSplashStyle() const;
478 wxSplashScreenWindow* GetSplashWindow() const;
479 int GetTimeout() const;
483 //---------------------------------------------------------------------------