]> git.saurik.com Git - wxWidgets.git/blob - include/wx/toplevel.h
Removed overloaded DoMenuUpdates function since it duplicated
[wxWidgets.git] / include / wx / toplevel.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/toplevel.h
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
6 // Modified by:
7 // Created: 06.08.01
8 // RCS-ID: $Id$
9 // Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
10 // Vaclav Slavik <vaclav@wxwindows.org>
11 // Licence: wxWindows licence
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #ifndef _WX_TOPLEVEL_BASE_H_
15 #define _WX_TOPLEVEL_BASE_H_
16
17 #if defined(__GNUG__) && !defined(__APPLE__)
18 #pragma interface "toplevelbase.h"
19 #endif
20
21 // ----------------------------------------------------------------------------
22 // headers
23 // ----------------------------------------------------------------------------
24
25 #include "wx/window.h"
26 #include "wx/iconbndl.h"
27
28 // the default names for various classs
29 WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
30
31 class WXDLLEXPORT wxTopLevelWindowBase;
32
33 // ----------------------------------------------------------------------------
34 // constants
35 // ----------------------------------------------------------------------------
36
37 // Dialogs are created in a special way
38 #define wxTOPLEVEL_EX_DIALOG 0x00000008
39
40 // Styles for ShowFullScreen
41 // (note that wxTopLevelWindow only handles wxFULLSCREEN_NOBORDER and
42 // wxFULLSCREEN_NOCAPTION; the rest is handled by wxTopLevelWindow)
43 enum
44 {
45 wxFULLSCREEN_NOMENUBAR = 0x0001,
46 wxFULLSCREEN_NOTOOLBAR = 0x0002,
47 wxFULLSCREEN_NOSTATUSBAR = 0x0004,
48 wxFULLSCREEN_NOBORDER = 0x0008,
49 wxFULLSCREEN_NOCAPTION = 0x0010,
50
51 wxFULLSCREEN_ALL = wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR |
52 wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER |
53 wxFULLSCREEN_NOCAPTION
54 };
55
56 // ----------------------------------------------------------------------------
57 // wxTopLevelWindow: a top level (as opposed to child) window
58 // ----------------------------------------------------------------------------
59
60 class WXDLLEXPORT wxTopLevelWindowBase : public wxWindow
61 {
62 public:
63 // construction
64 wxTopLevelWindowBase();
65 virtual ~wxTopLevelWindowBase();
66
67 // top level wnd state
68 // --------------------
69
70 // maximize = TRUE => maximize, otherwise - restore
71 virtual void Maximize(bool maximize = TRUE) = 0;
72
73 // undo Maximize() or Iconize()
74 virtual void Restore() = 0;
75
76 // iconize = TRUE => iconize, otherwise - restore
77 virtual void Iconize(bool iconize = TRUE) = 0;
78
79 // return TRUE if the frame is maximized
80 virtual bool IsMaximized() const = 0;
81
82 // return TRUE if the frame is iconized
83 virtual bool IsIconized() const = 0;
84
85 // get the frame icon
86 const wxIcon& GetIcon() const { return m_icons.GetIcon( -1 ); }
87
88 // get the frame icons
89 const wxIconBundle& GetIcons() const { return m_icons; }
90
91 // set the frame icon
92 virtual void SetIcon(const wxIcon& icon) { m_icons = wxIconBundle( icon ); }
93
94 // set the frame icons
95 virtual void SetIcons(const wxIconBundle& icons ) { m_icons = icons; }
96
97 // maximize the window to cover entire screen
98 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0;
99
100 // return TRUE if the frame is in fullscreen mode
101 virtual bool IsFullScreen() const = 0;
102
103 /*
104 for now we already have them in wxWindow, but this is wrong: these
105 methods really only make sense for wxTopLevelWindow!
106
107 virtual void SetTitle(const wxString& title) = 0;
108 virtual wxString GetTitle() const = 0;
109 */
110
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& region) { return FALSE; }
115
116 // old functions, use the new ones instead!
117 #if WXWIN_COMPATIBILITY_2
118 bool Iconized() const { return IsIconized(); }
119 #endif // WXWIN_COMPATIBILITY_2
120
121 // implementation only from now on
122 // -------------------------------
123
124 // override some base class virtuals
125 virtual bool Destroy();
126 virtual bool IsTopLevel() const { return TRUE; }
127 virtual wxSize GetMaxSize() const;
128
129 // event handlers
130 void OnCloseWindow(wxCloseEvent& event);
131 void OnSize(wxSizeEvent& event);
132
133 // this should go away, but for now it's called from docview.cpp,
134 // so should be there for all platforms
135 void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
136
137 // do the window-specific processing after processing the update event
138 virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ;
139
140 protected:
141 // the frame client to screen translation should take account of the
142 // toolbar which may shift the origin of the client area
143 virtual void DoClientToScreen(int *x, int *y) const;
144 virtual void DoScreenToClient(int *x, int *y) const;
145
146 // test whether this window makes part of the frame
147 // (menubar, toolbar and statusbar are excluded from automatic layout)
148 virtual bool IsOneOfBars(const wxWindow *WXUNUSED(win)) const
149 { return FALSE; }
150
151 // check if we should exit the program after deleting this top level
152 // window (this is used in common dtor and wxMSW code)
153 bool IsLastBeforeExit() const;
154
155 // send the iconize event, return TRUE if processed
156 bool SendIconizeEvent(bool iconized = TRUE);
157
158 // the frame icon
159 wxIconBundle m_icons;
160
161 DECLARE_EVENT_TABLE()
162 };
163
164
165 // include the real class declaration
166 #if defined(__WXMSW__)
167 #include "wx/msw/toplevel.h"
168 #define wxTopLevelWindowNative wxTopLevelWindowMSW
169 #elif defined(__WXGTK__)
170 #include "wx/gtk/toplevel.h"
171 #define wxTopLevelWindowNative wxTopLevelWindowGTK
172 #elif defined(__WXX11__)
173 #include "wx/x11/toplevel.h"
174 #define wxTopLevelWindowNative wxTopLevelWindowX11
175 #elif defined(__WXMGL__)
176 #include "wx/mgl/toplevel.h"
177 #define wxTopLevelWindowNative wxTopLevelWindowMGL
178 #elif defined(__WXMAC__)
179 #include "wx/mac/toplevel.h"
180 #define wxTopLevelWindowNative wxTopLevelWindowMac
181 #elif defined(__WXCOCOA__)
182 #include "wx/cocoa/toplevel.h"
183 #define wxTopLevelWindowNative wxTopLevelWindowCocoa
184 #elif defined(__WXPM__)
185 #include "wx/os2/toplevel.h"
186 #define wxTopLevelWindowNative wxTopLevelWindowOS2
187 #elif defined(__WXMOTIF__)
188 #include "wx/motif/toplevel.h"
189 #define wxTopLevelWindowNative wxTopLevelWindowMotif
190 #endif
191
192 #ifdef __WXUNIVERSAL__
193 #include "wx/univ/toplevel.h"
194 #else // !__WXUNIVERSAL__
195 #ifdef wxTopLevelWindowNative
196 class WXDLLEXPORT wxTopLevelWindow : public wxTopLevelWindowNative
197 {
198 public:
199 // construction
200 wxTopLevelWindow() { Init(); }
201 wxTopLevelWindow(wxWindow *parent,
202 wxWindowID winid,
203 const wxString& title,
204 const wxPoint& pos = wxDefaultPosition,
205 const wxSize& size = wxDefaultSize,
206 long style = wxDEFAULT_FRAME_STYLE,
207 const wxString& name = wxFrameNameStr)
208 {
209 Init();
210 Create(parent, winid, title, pos, size, style, name);
211 }
212
213 DECLARE_DYNAMIC_CLASS(wxTopLevelWindow)
214 };
215 #endif // wxTopLevelWindowNative
216 #endif // __WXUNIVERSAL__/!__WXUNIVERSAL__
217
218
219 #endif // _WX_TOPLEVEL_BASE_H_
220
221 // vi:sts=4:sw=4:et