1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declares wxTopLevelWindow class, the base class for all
4 // top level windows (such as frames and dialogs)
5 // Author: Vadim Zeitlin, Vaclav Slavik
9 // Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
10 // Vaclav Slavik <vaclav@wxwindows.org>
11 // Licence: wxWindows licence
12 ///////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_TOPLEVEL_BASE_H_
15 #define _WX_TOPLEVEL_BASE_H_
17 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
18 #pragma interface "toplevelbase.h"
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
25 #include "wx/window.h"
26 #include "wx/iconbndl.h"
28 // the default names for various classs
29 WXDLLEXPORT_DATA(extern const wxChar
*) wxFrameNameStr
;
31 class WXDLLEXPORT wxTopLevelWindowBase
;
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 // Dialogs are created in a special way
38 #define wxTOPLEVEL_EX_DIALOG 0x00000008
40 // Styles for ShowFullScreen
41 // (note that wxTopLevelWindow only handles wxFULLSCREEN_NOBORDER and
42 // wxFULLSCREEN_NOCAPTION; the rest is handled by wxTopLevelWindow)
45 wxFULLSCREEN_NOMENUBAR
= 0x0001,
46 wxFULLSCREEN_NOTOOLBAR
= 0x0002,
47 wxFULLSCREEN_NOSTATUSBAR
= 0x0004,
48 wxFULLSCREEN_NOBORDER
= 0x0008,
49 wxFULLSCREEN_NOCAPTION
= 0x0010,
51 wxFULLSCREEN_ALL
= wxFULLSCREEN_NOMENUBAR
| wxFULLSCREEN_NOTOOLBAR
|
52 wxFULLSCREEN_NOSTATUSBAR
| wxFULLSCREEN_NOBORDER
|
53 wxFULLSCREEN_NOCAPTION
56 // ----------------------------------------------------------------------------
57 // wxTopLevelWindow: a top level (as opposed to child) window
58 // ----------------------------------------------------------------------------
60 class WXDLLEXPORT wxTopLevelWindowBase
: public wxWindow
64 wxTopLevelWindowBase();
65 virtual ~wxTopLevelWindowBase();
67 // top level wnd state
68 // --------------------
70 // maximize = TRUE => maximize, otherwise - restore
71 virtual void Maximize(bool maximize
= TRUE
) = 0;
73 // undo Maximize() or Iconize()
74 virtual void Restore() = 0;
76 // iconize = TRUE => iconize, otherwise - restore
77 virtual void Iconize(bool iconize
= TRUE
) = 0;
79 // return TRUE if the frame is maximized
80 virtual bool IsMaximized() const = 0;
82 // return TRUE if the frame is iconized
83 virtual bool IsIconized() const = 0;
86 const wxIcon
& GetIcon() const { return m_icons
.GetIcon( -1 ); }
88 // get the frame icons
89 const wxIconBundle
& GetIcons() const { return m_icons
; }
92 virtual void SetIcon(const wxIcon
& icon
) { m_icons
= wxIconBundle( icon
); }
94 // set the frame icons
95 virtual void SetIcons(const wxIconBundle
& icons
) { m_icons
= icons
; }
97 // maximize the window to cover entire screen
98 virtual bool ShowFullScreen(bool show
, long style
= wxFULLSCREEN_ALL
) = 0;
100 // return TRUE if the frame is in fullscreen mode
101 virtual bool IsFullScreen() const = 0;
104 for now we already have them in wxWindow, but this is wrong: these
105 methods really only make sense for wxTopLevelWindow!
107 virtual void SetTitle(const wxString& title) = 0;
108 virtual wxString GetTitle() const = 0;
111 // Set the shape of the window to the given region.
112 // Returns TRUE if the platform supports this feature (and the
113 // operation is successful.)
114 virtual bool SetShape(const wxRegion
& WXUNUSED(region
)) { return FALSE
; }
116 // implementation only from now on
117 // -------------------------------
119 // override some base class virtuals
120 virtual bool Destroy();
121 virtual bool IsTopLevel() const { return TRUE
; }
122 virtual wxSize
GetMaxSize() const;
125 void OnCloseWindow(wxCloseEvent
& event
);
126 void OnSize(wxSizeEvent
& event
);
128 // this should go away, but for now it's called from docview.cpp,
129 // so should be there for all platforms
130 void OnActivate(wxActivateEvent
&WXUNUSED(event
)) { }
132 // do the window-specific processing after processing the update event
133 virtual void DoUpdateWindowUI(wxUpdateUIEvent
& event
) ;
136 // the frame client to screen translation should take account of the
137 // toolbar which may shift the origin of the client area
138 virtual void DoClientToScreen(int *x
, int *y
) const;
139 virtual void DoScreenToClient(int *x
, int *y
) const;
141 // test whether this window makes part of the frame
142 // (menubar, toolbar and statusbar are excluded from automatic layout)
143 virtual bool IsOneOfBars(const wxWindow
*WXUNUSED(win
)) const
146 // check if we should exit the program after deleting this top level
147 // window (this is used in common dtor and wxMSW code)
148 bool IsLastBeforeExit() const;
150 // send the iconize event, return TRUE if processed
151 bool SendIconizeEvent(bool iconized
= TRUE
);
153 // Get the default size for the new window if no explicit size given. If
154 // there are better default sizes then these can be changed, just as long
155 // as they are not too small for TLWs (and not larger than screen).
156 static wxSize
GetDefaultSize();
157 static int WidthDefault(int w
) { return w
== -1 ? GetDefaultSize().x
: w
; }
158 static int HeightDefault(int h
) { return h
== -1 ? GetDefaultSize().y
: h
; }
161 wxIconBundle m_icons
;
163 DECLARE_NO_COPY_CLASS(wxTopLevelWindowBase
)
164 DECLARE_EVENT_TABLE()
168 // include the real class declaration
169 #if defined(__WXMSW__)
170 #include "wx/msw/toplevel.h"
171 #define wxTopLevelWindowNative wxTopLevelWindowMSW
172 #elif defined(__WXGTK__)
173 #include "wx/gtk/toplevel.h"
174 #define wxTopLevelWindowNative wxTopLevelWindowGTK
175 #elif defined(__WXX11__)
176 #include "wx/x11/toplevel.h"
177 #define wxTopLevelWindowNative wxTopLevelWindowX11
178 #elif defined(__WXMGL__)
179 #include "wx/mgl/toplevel.h"
180 #define wxTopLevelWindowNative wxTopLevelWindowMGL
181 #elif defined(__WXMAC__)
182 #include "wx/mac/toplevel.h"
183 #define wxTopLevelWindowNative wxTopLevelWindowMac
184 #elif defined(__WXCOCOA__)
185 #include "wx/cocoa/toplevel.h"
186 #define wxTopLevelWindowNative wxTopLevelWindowCocoa
187 #elif defined(__WXPM__)
188 #include "wx/os2/toplevel.h"
189 #define wxTopLevelWindowNative wxTopLevelWindowOS2
190 #elif defined(__WXMOTIF__)
191 #include "wx/motif/toplevel.h"
192 #define wxTopLevelWindowNative wxTopLevelWindowMotif
195 #ifdef __WXUNIVERSAL__
196 #include "wx/univ/toplevel.h"
197 #else // !__WXUNIVERSAL__
198 #ifdef wxTopLevelWindowNative
199 class WXDLLEXPORT wxTopLevelWindow
: public wxTopLevelWindowNative
203 wxTopLevelWindow() { Init(); }
204 wxTopLevelWindow(wxWindow
*parent
,
206 const wxString
& title
,
207 const wxPoint
& pos
= wxDefaultPosition
,
208 const wxSize
& size
= wxDefaultSize
,
209 long style
= wxDEFAULT_FRAME_STYLE
,
210 const wxString
& name
= wxFrameNameStr
)
213 Create(parent
, winid
, title
, pos
, size
, style
, name
);
216 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTopLevelWindow
)
218 #endif // wxTopLevelWindowNative
219 #endif // __WXUNIVERSAL__/!__WXUNIVERSAL__
222 #endif // _WX_TOPLEVEL_BASE_H_