]> git.saurik.com Git - wxWidgets.git/blame - include/wx/toplevel.h
Added reparenting helper classes to help apps to grab the windows
[wxWidgets.git] / include / wx / toplevel.h
CommitLineData
ec4f95c4
VZ
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)
7d9f12f3 5// Author: Vadim Zeitlin, Vaclav Slavik
ec4f95c4
VZ
6// Modified by:
7// Created: 06.08.01
8// RCS-ID: $Id$
9// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
7d9f12f3 10// Vaclav Slavik <vaclav@wxwindows.org>
ec4f95c4
VZ
11// Licence: wxWindows licence
12///////////////////////////////////////////////////////////////////////////////
13
7d9f12f3
VS
14#ifndef _WX_TOPLEVEL_BASE_H_
15#define _WX_TOPLEVEL_BASE_H_
16
17// ----------------------------------------------------------------------------
18// headers
19// ----------------------------------------------------------------------------
20
21#ifdef __GNUG__
22 #pragma interface "toplevelbase.h"
23#endif
ec4f95c4
VZ
24
25#include "wx/window.h"
7d9f12f3
VS
26#include "wx/icon.h"
27
28// the default names for various classs
29WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
30
31class WXDLLEXPORT wxTopLevelWindowBase;
32
b22d16ad
VS
33// ----------------------------------------------------------------------------
34// constants
35// ----------------------------------------------------------------------------
36
7d9f12f3 37// Dialogs are created in a special way
21f4383a 38#define wxTOPLEVEL_EX_DIALOG 0x00000008
7d9f12f3
VS
39
40// Styles for ShowFullScreen
41// (note that wxTopLevelWindow only handles wxFULLSCREEN_NOBORDER and
42// wxFULLSCREEN_NOCAPTION; the rest is handled by wxTopLevelWindow)
b22d16ad
VS
43enum
44{
45 wxFULLSCREEN_NOMENUBAR = 0x0001,
46 wxFULLSCREEN_NOTOOLBAR = 0x0002,
47 wxFULLSCREEN_NOSTATUSBAR = 0x0004,
48 wxFULLSCREEN_NOBORDER = 0x0008,
49 wxFULLSCREEN_NOCAPTION = 0x0010,
d4597e13
VZ
50
51 wxFULLSCREEN_ALL = wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR |
52 wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER |
b22d16ad
VS
53 wxFULLSCREEN_NOCAPTION
54};
55
ec4f95c4
VZ
56// ----------------------------------------------------------------------------
57// wxTopLevelWindow: a top level (as opposed to child) window
58// ----------------------------------------------------------------------------
59
7d9f12f3 60class WXDLLEXPORT wxTopLevelWindowBase : public wxWindow
ec4f95c4
VZ
61{
62public:
7d9f12f3
VS
63 // construction
64 wxTopLevelWindowBase();
799ea011 65 virtual ~wxTopLevelWindowBase();
b22d16ad 66
7d9f12f3
VS
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_icon; }
87
88 // set the frame icon
89 virtual void SetIcon(const wxIcon& icon) { m_icon = icon; }
90
c8e8ae85
VS
91 // maximize the window to cover entire screen
92 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0;
d4597e13 93
c8e8ae85
VS
94 // return TRUE if the frame is in fullscreen mode
95 virtual bool IsFullScreen() const = 0;
96
ec4f95c4
VZ
97 /*
98 for now we already have them in wxWindow, but this is wrong: these
99 methods really only make sense for wxTopLevelWindow!
100
7d9f12f3 101 virtual void SetTitle(const wxString& title) = 0;
ec4f95c4
VZ
102 virtual wxString GetTitle() const = 0;
103 */
7d9f12f3
VS
104
105 // old functions, use the new ones instead!
106#if WXWIN_COMPATIBILITY_2
107 bool Iconized() const { return IsIconized(); }
108#endif // WXWIN_COMPATIBILITY_2
109
110 // implementation only from now on
111 // -------------------------------
112
113 // override some base class virtuals
114 virtual bool Destroy();
115 virtual bool IsTopLevel() const { return TRUE; }
34c3ffca 116 virtual wxSize GetMaxSize() const;
7d9f12f3
VS
117
118 // event handlers
119 void OnCloseWindow(wxCloseEvent& event);
120 void OnSize(wxSizeEvent& event);
121
122 // this should go away, but for now it's called from docview.cpp,
123 // so should be there for all platforms
124 void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
125
126protected:
127 // the frame client to screen translation should take account of the
128 // toolbar which may shift the origin of the client area
129 virtual void DoClientToScreen(int *x, int *y) const;
130 virtual void DoScreenToClient(int *x, int *y) const;
131
132 // send the iconize event, return TRUE if processed
133 bool SendIconizeEvent(bool iconized = TRUE);
134
135 // the frame icon
136 wxIcon m_icon;
137
138 // test whether this window makes part of the frame
139 // (menubar, toolbar and statusbar are excluded from automatic layout)
140 virtual bool IsOneOfBars(const wxWindow *WXUNUSED(win)) const { return FALSE; }
141
142 DECLARE_EVENT_TABLE()
ec4f95c4
VZ
143};
144
7d9f12f3
VS
145
146// include the real class declaration
82c9f85c
VZ
147#if defined(__WXMSW__)
148 #include "wx/msw/toplevel.h"
149 #define wxTopLevelWindowNative wxTopLevelWindowMSW
150#elif defined(__WXGTK__)
7d9f12f3
VS
151 #include "wx/gtk/toplevel.h"
152 #define wxTopLevelWindowNative wxTopLevelWindowGTK
83df96d6
JS
153#elif defined(__WXX11__)
154 #include "wx/x11/toplevel.h"
155 #define wxTopLevelWindowNative wxTopLevelWindowX11
7d9f12f3
VS
156#elif defined(__WXMGL__)
157 #include "wx/mgl/toplevel.h"
158 #define wxTopLevelWindowNative wxTopLevelWindowMGL
93b4dc4b
SC
159#elif defined(__WXMAC__)
160 #include "wx/mac/toplevel.h"
161 #define wxTopLevelWindowNative wxTopLevelWindowMac
c9782ca3
DW
162#elif defined(__WXPM__)
163 #include "wx/os2/toplevel.h"
164 #define wxTopLevelWindowNative wxTopLevelWindowOS2
7d9f12f3
VS
165#endif
166
167#ifdef __WXUNIVERSAL__
168 #include "wx/univ/toplevel.h"
169#else // !__WXUNIVERSAL__
170 #ifdef wxTopLevelWindowNative
171 class WXDLLEXPORT wxTopLevelWindow : public wxTopLevelWindowNative
172 {
173 public:
174 // construction
175 wxTopLevelWindow() { Init(); }
176 wxTopLevelWindow(wxWindow *parent,
177 wxWindowID id,
178 const wxString& title,
179 const wxPoint& pos = wxDefaultPosition,
180 const wxSize& size = wxDefaultSize,
181 long style = wxDEFAULT_FRAME_STYLE,
182 const wxString& name = wxFrameNameStr)
183 {
184 Init();
185 Create(parent, id, title, pos, size, style, name);
186 }
187
188 DECLARE_DYNAMIC_CLASS(wxTopLevelWindow)
189 };
190 #endif // wxTopLevelWindowNative
191#endif // __WXUNIVERSAL__/!__WXUNIVERSAL__
192
193
194#endif // _WX_TOPLEVEL_BASE_H_
34c3ffca
RL
195
196// vi:sts=4:sw=4:et