]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_toplvl.i
Added wxCB_FILENAME
[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
57 // Obsolete
58 wxDIALOG_MODAL,
59 wxDIALOG_MODELESS,
60 wxUSER_COLOURS,
61 wxNO_3D,
62 };
63
64 enum
65 {
66 wxFULLSCREEN_NOMENUBAR,
67 wxFULLSCREEN_NOTOOLBAR,
68 wxFULLSCREEN_NOSTATUSBAR,
69 wxFULLSCREEN_NOBORDER,
70 wxFULLSCREEN_NOCAPTION,
71 wxFULLSCREEN_ALL,
72
73 wxTOPLEVEL_EX_DIALOG,
74 };
75
76 // Styles for RequestUserAttention
77 enum
78 {
79 wxUSER_ATTENTION_INFO = 1,
80 wxUSER_ATTENTION_ERROR = 2
81 };
82
83 //---------------------------------------------------------------------------
84
85 class wxTopLevelWindow : public wxWindow
86 {
87 public:
88
89 // No constructor as it can not be used directly from Python
90
91 // maximize = True => maximize, otherwise - restore
92 virtual void Maximize(bool maximize = true);
93
94 // undo Maximize() or Iconize()
95 virtual void Restore();
96
97 // iconize = True => iconize, otherwise - restore
98 virtual void Iconize(bool iconize = true);
99
100 // return True if the frame is maximized
101 virtual bool IsMaximized() const;
102
103 // return true if the frame is always maximized
104 // due to native guidelines or current policy
105 virtual bool IsAlwaysMaximized() const;
106
107 // return True if the frame is iconized
108 virtual bool IsIconized() const;
109
110 // get the frame icon
111 wxIcon GetIcon() const;
112
113 // set the frame icon
114 virtual void SetIcon(const wxIcon& icon);
115
116 // set the frame icons
117 virtual void SetIcons(const wxIconBundle& icons);
118
119 // maximize the window to cover entire screen
120 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
121
122 // return True if the frame is in fullscreen mode
123 virtual bool IsFullScreen() const;
124
125 virtual void SetTitle(const wxString& title);
126 virtual wxString GetTitle() const;
127
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);
132
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);
136
137 // Is this the active frame (highlighted in the taskbar)?
138 virtual bool IsActive();
139
140 #ifdef __WXMAC__
141 %extend {
142 void MacSetMetalAppearance( bool on ) {
143 int style = self->GetExtraStyle();
144 if ( on )
145 style |= wxFRAME_EX_METAL;
146 else
147 style &= ~wxFRAME_EX_METAL;
148 self->SetExtraStyle(style);
149 }
150 }
151 bool MacGetMetalAppearance() const;
152 #else
153 %extend
154 {
155 // TODO: Should they raise not implemented or just NOP???
156 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
157 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
158 }
159 #endif
160
161 DocDeclStr(
162 void , CenterOnScreen(int dir = wxBOTH),
163 "Center the window on screen", "");
164 %pythoncode { CentreOnScreen = CenterOnScreen }
165
166 #ifdef __WXMSW__
167 bool EnableCloseButton(bool enable = true);
168 #else
169 %extend {
170 bool EnableCloseButton(bool enable = true) { return false; }
171 }
172 #endif
173
174 virtual bool SetTransparent(byte alpha);
175 virtual bool CanSetTransparent();
176
177
178
179 DocDeclStr(
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.", "");
183
184 DocDeclStr(
185 virtual wxWindow *, SetDefaultItem(wxWindow * child),
186 "Set this child as default, return the old default.", "");
187
188 DocDeclStr(
189 virtual void , SetTmpDefaultItem(wxWindow * win),
190 "Set this child as temporary default", "");
191
192 DocDeclStr(
193 virtual wxWindow *, GetTmpDefaultItem() const,
194 "Return the temporary default item, which can be None.", "");
195
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
321 //---------------------------------------------------------------------------
322 %newgroup
323
324 MustHaveApp(wxDialog);
325
326 class wxDialog : public wxTopLevelWindow
327 {
328 public:
329 enum
330 {
331 // all flags allowed in wxDialogBase::CreateButtonSizer()
332 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
333 };
334
335 %pythonAppend wxDialog "self._setOORInfo(self)"
336 %pythonAppend wxDialog() ""
337 %typemap(out) wxDialog*; // turn off this typemap
338
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());
347
348 // Turn it back on again
349 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
350
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);
358
359 // the modal dialogs have a return code - usually the ID of the last
360 // pressed button
361 void SetReturnCode(int returnCode);
362 int GetReturnCode() const;
363
364 // The identifier for the affirmative button
365 void SetAffirmativeId(int affirmativeId);
366 int GetAffirmativeId() const;
367
368 // Identifier for Esc key translation
369 void SetEscapeId(int escapeId);
370 int GetEscapeId() const;
371
372 // splits text up at newlines and places the
373 // lines into a vertical wxBoxSizer
374 wxSizer* CreateTextSizer( const wxString &message );
375
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 );
381
382 //void SetModal( bool flag );
383
384 // is the dialog in modal state right now?
385 virtual bool IsModal() const;
386
387 // Shows the dialog and starts a nested event loop that returns when
388 // EndModal is called.
389 virtual int ShowModal();
390
391 // may be called to terminate the dialog with the given return code
392 virtual void EndModal(int retCode);
393
394 static wxVisualAttributes
395 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
396 };
397
398 //---------------------------------------------------------------------------
399 %newgroup
400
401
402 MustHaveApp(wxMiniFrame);
403
404 class wxMiniFrame : public wxFrame
405 {
406 public:
407 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
408 %pythonAppend wxMiniFrame() ""
409
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());
418
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);
426 };
427
428
429 //---------------------------------------------------------------------------
430 %newgroup
431
432
433 enum
434 {
435 wxSPLASH_CENTRE_ON_PARENT,
436 wxSPLASH_CENTRE_ON_SCREEN,
437 wxSPLASH_NO_CENTRE,
438 wxSPLASH_TIMEOUT,
439 wxSPLASH_NO_TIMEOUT,
440 };
441
442
443 MustHaveApp(wxSplashScreenWindow);
444
445 class wxSplashScreenWindow: public wxWindow
446 {
447 public:
448 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
449
450 wxSplashScreenWindow(const wxBitmap& bitmap,
451 wxWindow* parent,
452 wxWindowID id,
453 const wxPoint& pos = wxDefaultPosition,
454 const wxSize& size = wxDefaultSize,
455 long style = wxNO_BORDER);
456
457 void SetBitmap(const wxBitmap& bitmap);
458 wxBitmap& GetBitmap();
459 };
460
461
462 MustHaveApp(wxSplashScreen);
463
464 class wxSplashScreen : public wxFrame
465 {
466 public:
467 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
468
469 wxSplashScreen(const wxBitmap& bitmap,
470 long splashStyle, int milliseconds,
471 wxWindow* parent,
472 wxWindowID id = -1,
473 const wxPoint& pos = wxDefaultPosition,
474 const wxSize& size = wxDefaultSize,
475 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
476
477 long GetSplashStyle() const;
478 wxSplashScreenWindow* GetSplashWindow() const;
479 int GetTimeout() const;
480 };
481
482
483 //---------------------------------------------------------------------------