]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_toplvl.i
added filename comparison test
[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 iconized
104 virtual bool IsIconized() const;
105
106 // get the frame icon
107 wxIcon GetIcon() const;
108
109 // set the frame icon
110 virtual void SetIcon(const wxIcon& icon);
111
112 // set the frame icons
113 virtual void SetIcons(const wxIconBundle& icons);
114
115 // maximize the window to cover entire screen
116 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
117
118 // return True if the frame is in fullscreen mode
119 virtual bool IsFullScreen() const;
120
121 virtual void SetTitle(const wxString& title);
122 virtual wxString GetTitle() const;
123
124 // Set the shape of the window to the given region.
125 // Returns True if the platform supports this feature
126 // (and the operation is successful.)
127 virtual bool SetShape(const wxRegion& region);
128
129 // Attracts the users attention to this window if the application is inactive
130 // (should be called when a background event occurs)
131 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
132
133 // Is this the active frame (highlighted in the taskbar)?
134 virtual bool IsActive();
135
136 #ifdef __WXMAC__
137 %extend {
138 void MacSetMetalAppearance( bool on ) {
139 int style = self->GetExtraStyle();
140 if ( on )
141 style |= wxFRAME_EX_METAL;
142 else
143 style &= ~wxFRAME_EX_METAL;
144 self->SetExtraStyle(style);
145 }
146 }
147 bool MacGetMetalAppearance() const;
148 #else
149 %extend
150 {
151 // TODO: Should they raise not implemented or just NOP???
152 void MacSetMetalAppearance( bool on ) { /*wxPyRaiseNotImplemented();*/ }
153 bool MacGetMetalAppearance() const { /*wxPyRaiseNotImplemented();*/ return false; }
154 }
155 #endif
156
157 DocDeclStr(
158 void , CenterOnScreen(int dir = wxBOTH),
159 "Center the window on screen", "");
160 %pythoncode { CentreOnScreen = CenterOnScreen }
161 };
162
163
164 //---------------------------------------------------------------------------
165 %newgroup
166
167 // wxFrame is a top-level window with optional menubar, statusbar and toolbar
168 //
169 // For each of *bars, a frame may have several of them, but only one is
170 // managed by the frame, i.e. resized/moved when the frame is and whose size
171 // is accounted for in client size calculations - all others should be taken
172 // care of manually.
173
174 MustHaveApp(wxFrame);
175
176 class wxFrame : public wxTopLevelWindow
177 {
178 public:
179 %pythonAppend wxFrame "self._setOORInfo(self)"
180 %pythonAppend wxFrame() ""
181 %typemap(out) wxFrame*; // turn off this typemap
182
183 wxFrame(wxWindow* parent,
184 const wxWindowID id = -1,
185 const wxString& title = wxPyEmptyString,
186 const wxPoint& pos = wxDefaultPosition,
187 const wxSize& size = wxDefaultSize,
188 long style = wxDEFAULT_FRAME_STYLE,
189 const wxString& name = wxPyFrameNameStr);
190 %RenameCtor(PreFrame, wxFrame());
191
192 // Turn it back on again
193 %typemap(out) wxFrame* { $result = wxPyMake_wxObject($1, $owner); }
194
195 bool Create(wxWindow* parent,
196 const wxWindowID id = -1,
197 const wxString& title = wxPyEmptyString,
198 const wxPoint& pos = wxDefaultPosition,
199 const wxSize& size = wxDefaultSize,
200 long style = wxDEFAULT_FRAME_STYLE,
201 const wxString& name = wxPyFrameNameStr);
202
203 // frame state
204 // -----------
205
206 // get the origin of the client area (which may be different from (0, 0)
207 // if the frame has a toolbar) in client coordinates
208 virtual wxPoint GetClientAreaOrigin() const;
209
210 // sends a size event to the window using its current size:
211 // this has a side effect of refreshing the window layout
212 virtual void SendSizeEvent();
213
214 // menu bar functions
215 // ------------------
216
217 virtual void SetMenuBar(wxMenuBar *menubar);
218 virtual wxMenuBar *GetMenuBar() const;
219
220 // process menu command: returns True if processed
221 bool ProcessCommand(int winid);
222 %pythoncode { Command = ProcessCommand }
223
224 // status bar functions
225 // --------------------
226
227 // create the main status bar by calling OnCreateStatusBar()
228 virtual wxStatusBar* CreateStatusBar(int number = 1,
229 long style = wxDEFAULT_STATUSBAR_STYLE,
230 wxWindowID winid = 0,
231 const wxString& name = wxPyStatusLineNameStr);
232
233 // TODO: with directors?
234 // // return a new status bar
235 // virtual wxStatusBar *OnCreateStatusBar(int number,
236 // long style,
237 // wxWindowID winid,
238 // const wxString& name);
239
240 // get the main status bar
241 virtual wxStatusBar *GetStatusBar() const;
242
243 // sets the main status bar
244 void SetStatusBar(wxStatusBar *statBar);
245
246 // forward these to status bar
247 virtual void SetStatusText(const wxString &text, int number = 0);
248 virtual void SetStatusWidths(int widths, const int* widths_field); // uses typemap above
249 void PushStatusText(const wxString &text, int number = 0);
250 void PopStatusText(int number = 0);
251
252 // set the status bar pane the help will be shown in
253 void SetStatusBarPane(int n);
254 int GetStatusBarPane() const;
255
256 // toolbar functions
257 // -----------------
258
259 // create main toolbar bycalling OnCreateToolBar()
260 virtual wxToolBar* CreateToolBar(long style = -1,
261 wxWindowID winid = -1,
262 const wxString& name = wxPyToolBarNameStr);
263
264 // TODO: with directors?
265 // // return a new toolbar
266 // virtual wxToolBar *OnCreateToolBar(long style,
267 // wxWindowID winid,
268 // const wxString& name );
269
270 // get/set the main toolbar
271 virtual wxToolBar *GetToolBar() const;
272 virtual void SetToolBar(wxToolBar *toolbar);
273
274 // show help text (typically in the statusbar); show is False
275 // if you are hiding the help, True otherwise
276 virtual void DoGiveHelp(const wxString& text, bool show);
277
278 // send wxUpdateUIEvents for all menu items in the menubar,
279 // or just for menu if non-NULL
280 void DoMenuUpdates(wxMenu* menu = NULL);
281
282 static wxVisualAttributes
283 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
284 };
285
286 //---------------------------------------------------------------------------
287 %newgroup
288
289 MustHaveApp(wxDialog);
290
291 class wxDialog : public wxTopLevelWindow
292 {
293 public:
294 enum
295 {
296 // all flags allowed in wxDialogBase::CreateButtonSizer()
297 ButtonSizerFlags = wxOK | wxCANCEL | wxYES | wxNO | wxHELP | wxNO_DEFAULT
298 };
299
300 %pythonAppend wxDialog "self._setOORInfo(self)"
301 %pythonAppend wxDialog() ""
302 %typemap(out) wxDialog*; // turn off this typemap
303
304 wxDialog(wxWindow* parent,
305 const wxWindowID id = -1,
306 const wxString& title = wxPyEmptyString,
307 const wxPoint& pos = wxDefaultPosition,
308 const wxSize& size = wxDefaultSize,
309 long style = wxDEFAULT_DIALOG_STYLE,
310 const wxString& name = wxPyDialogNameStr);
311 %RenameCtor(PreDialog, wxDialog());
312
313 // Turn it back on again
314 %typemap(out) wxDialog* { $result = wxPyMake_wxObject($1, $owner); }
315
316 bool Create(wxWindow* parent,
317 const wxWindowID id = -1,
318 const wxString& title = wxPyEmptyString,
319 const wxPoint& pos = wxDefaultPosition,
320 const wxSize& size = wxDefaultSize,
321 long style = wxDEFAULT_DIALOG_STYLE,
322 const wxString& name = wxPyDialogNameStr);
323
324 // the modal dialogs have a return code - usually the ID of the last
325 // pressed button
326 void SetReturnCode(int returnCode);
327 int GetReturnCode() const;
328
329 // The identifier for the affirmative button
330 void SetAffirmativeId(int affirmativeId);
331 int GetAffirmativeId() const;
332
333 // Identifier for Esc key translation
334 void SetEscapeId(int escapeId);
335 int GetEscapeId() const;
336
337 // splits text up at newlines and places the
338 // lines into a vertical wxBoxSizer
339 wxSizer* CreateTextSizer( const wxString &message );
340
341 // places buttons into a horizontal wxBoxSizer
342 wxSizer* CreateButtonSizer( long flags,
343 bool separated = false,
344 wxCoord distance = 0 );
345 wxStdDialogButtonSizer* CreateStdDialogButtonSizer( long flags );
346
347 //void SetModal( bool flag );
348
349 // is the dialog in modal state right now?
350 virtual bool IsModal() const;
351
352 // Shows the dialog and starts a nested event loop that returns when
353 // EndModal is called.
354 virtual int ShowModal();
355
356 // may be called to terminate the dialog with the given return code
357 virtual void EndModal(int retCode);
358
359 static wxVisualAttributes
360 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
361 };
362
363 //---------------------------------------------------------------------------
364 %newgroup
365
366
367 MustHaveApp(wxMiniFrame);
368
369 class wxMiniFrame : public wxFrame
370 {
371 public:
372 %pythonAppend wxMiniFrame "self._setOORInfo(self)"
373 %pythonAppend wxMiniFrame() ""
374
375 wxMiniFrame(wxWindow* parent,
376 const wxWindowID id = -1,
377 const wxString& title = wxPyEmptyString,
378 const wxPoint& pos = wxDefaultPosition,
379 const wxSize& size = wxDefaultSize,
380 long style = wxDEFAULT_FRAME_STYLE,
381 const wxString& name = wxPyFrameNameStr);
382 %RenameCtor(PreMiniFrame, wxMiniFrame());
383
384 bool Create(wxWindow* parent,
385 const wxWindowID id = -1,
386 const wxString& title = wxPyEmptyString,
387 const wxPoint& pos = wxDefaultPosition,
388 const wxSize& size = wxDefaultSize,
389 long style = wxDEFAULT_FRAME_STYLE,
390 const wxString& name = wxPyFrameNameStr);
391 };
392
393
394 //---------------------------------------------------------------------------
395 %newgroup
396
397
398 enum
399 {
400 wxSPLASH_CENTRE_ON_PARENT,
401 wxSPLASH_CENTRE_ON_SCREEN,
402 wxSPLASH_NO_CENTRE,
403 wxSPLASH_TIMEOUT,
404 wxSPLASH_NO_TIMEOUT,
405 };
406
407
408 MustHaveApp(wxSplashScreenWindow);
409
410 class wxSplashScreenWindow: public wxWindow
411 {
412 public:
413 %pythonAppend wxSplashScreenWindow "self._setOORInfo(self)"
414
415 wxSplashScreenWindow(const wxBitmap& bitmap,
416 wxWindow* parent,
417 wxWindowID id,
418 const wxPoint& pos = wxDefaultPosition,
419 const wxSize& size = wxDefaultSize,
420 long style = wxNO_BORDER);
421
422 void SetBitmap(const wxBitmap& bitmap);
423 wxBitmap& GetBitmap();
424 };
425
426
427 MustHaveApp(wxSplashScreen);
428
429 class wxSplashScreen : public wxFrame
430 {
431 public:
432 %pythonAppend wxSplashScreen "self._setOORInfo(self)"
433
434 wxSplashScreen(const wxBitmap& bitmap,
435 long splashStyle, int milliseconds,
436 wxWindow* parent,
437 wxWindowID id = -1,
438 const wxPoint& pos = wxDefaultPosition,
439 const wxSize& size = wxDefaultSize,
440 long style = wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP);
441
442 long GetSplashStyle() const;
443 wxSplashScreenWindow* GetSplashWindow() const;
444 int GetTimeout() const;
445 };
446
447
448 //---------------------------------------------------------------------------