]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/toplevel.cpp
fixed wxUniv/GTK linking by getting rid of GENERICOBJS and putting them into GUIOBJS...
[wxWidgets.git] / src / mgl / toplevel.cpp
CommitLineData
7d9f12f3
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: toplevel.cpp
3// Purpose:
4// Author: Vaclav Slavik
5// Id: $Id$
6// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10// ============================================================================
11// declarations
12// ============================================================================
13
14// ----------------------------------------------------------------------------
15// headers
16// ----------------------------------------------------------------------------
17
18#ifdef __GNUG__
19 #pragma implementation "toplevel.h"
20#endif
21
22// For compilers that support precompilation, includes "wx.h".
23#include "wx/wxprec.h"
24
25#ifdef __BORLANDC__
26#pragma hdrstop
27#endif
28
29#include "wx/defs.h"
30#include "wx/toplevel.h"
2343d81b 31#include "wx/app.h"
7d9f12f3
VS
32
33// ----------------------------------------------------------------------------
34// idle system
35// ----------------------------------------------------------------------------
36
7d9f12f3
VS
37extern int g_openDialogs;
38
39// ----------------------------------------------------------------------------
40// event tables
41// ----------------------------------------------------------------------------
42
43#ifndef __WXUNIVERSAL__
44 IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow)
45#endif
46
7d9f12f3
VS
47
48// ============================================================================
49// implementation
50// ============================================================================
51
52void wxTopLevelWindowMGL::Init()
53{
2343d81b 54 m_isShown = FALSE;
7d9f12f3
VS
55 m_isIconized = FALSE;
56 m_isMaximized = FALSE;
57 m_fsIsShowing = FALSE;
f41ed3c4 58 m_sizeSet = FALSE;
7d9f12f3
VS
59}
60
61bool wxTopLevelWindowMGL::Create(wxWindow *parent,
62 wxWindowID id,
63 const wxString& title,
64 const wxPoint& pos,
65 const wxSize& sizeOrig,
66 long style,
67 const wxString &name)
68{
69 // always create a frame of some reasonable, even if arbitrary, size (at
70 // least for MSW compatibility)
71 wxSize size = sizeOrig;
72 if ( size.x == -1 || size.y == -1 )
73 {
74 wxSize sizeDpy = wxGetDisplaySize();
75 if ( size.x == -1 )
76 size.x = sizeDpy.x / 3;
77 if ( size.y == -1 )
78 size.y = sizeDpy.y / 5;
79 }
2343d81b 80
b8c0528d
VS
81 wxWindow::Create(NULL, id, pos, sizeOrig, style, name);
82 SetParent(parent);
83 if ( parent )
84 parent->AddChild(this);
7d9f12f3
VS
85
86 wxTopLevelWindows.Append(this);
7d9f12f3 87 m_title = title;
7d9f12f3
VS
88
89 return TRUE;
90}
91
92wxTopLevelWindowMGL::~wxTopLevelWindowMGL()
93{
94 m_isBeingDeleted = TRUE;
95
96 wxTopLevelWindows.DeleteObject(this);
97
98 if (wxTheApp->GetTopWindow() == this)
99 wxTheApp->SetTopWindow(NULL);
100
101 if ((wxTopLevelWindows.Number() == 0) &&
102 (wxTheApp->GetExitOnFrameDelete()))
103 {
104 wxTheApp->ExitMainLoop();
105 }
106}
107
108bool wxTopLevelWindowMGL::ShowFullScreen(bool show, long style)
109{
110 if (show == m_fsIsShowing) return FALSE; // return what?
111
112 m_fsIsShowing = show;
113
114 if (show)
115 {
116 m_fsSaveStyle = m_windowStyle;
117 m_fsSaveFlag = style;
118 GetPosition(&m_fsSaveFrame.x, &m_fsSaveFrame.y);
119 GetSize(&m_fsSaveFrame.width, &m_fsSaveFrame.height);
120
121 if ( style & wxFULLSCREEN_NOCAPTION )
038072e2 122 m_windowStyle &= ~wxCAPTION;
7d9f12f3
VS
123 if ( style & wxFULLSCREEN_NOBORDER )
124 m_windowStyle = wxSIMPLE_BORDER;
125
126 int x, y;
127 wxDisplaySize(&x, &y);
128 SetSize(0, 0, x, y);
129 }
130 else
131 {
132 m_windowStyle = m_fsSaveStyle;
133 SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
134 m_fsSaveFrame.width, m_fsSaveFrame.height);
135 }
136
137 return TRUE;
138}
139
917afc7b
VS
140bool wxTopLevelWindowMGL::Show(bool show)
141{
142 bool ret = wxTopLevelWindowBase::Show(show);
f41ed3c4
VS
143
144 // If this is the first time Show was called, send size event,
145 // so that the frame can adjust itself (think auto layout or single child)
146 if ( !m_sizeSet )
147 {
148 m_sizeSet = TRUE;
149 wxSizeEvent event(GetSize(), GetId());
150 event.SetEventObject(this);
151 GetEventHandler()->ProcessEvent(event);
152 }
153
61bd618f 154 if ( ret && show && AcceptsFocus() )
917afc7b 155 SetFocus();
61bd618f 156 // FIXME_MGL -- don't do this for popup windows?
917afc7b
VS
157 return ret;
158}
159
7d9f12f3
VS
160void wxTopLevelWindowMGL::Maximize(bool maximize)
161{
162 if ( maximize && !m_isMaximized )
163 {
164 int x, y, w, h;
165
15678bec
VS
166 m_isMaximized = TRUE;
167
7d9f12f3
VS
168 GetPosition(&m_savedFrame.x, &m_savedFrame.y);
169 GetSize(&m_savedFrame.width, &m_savedFrame.height);
170
171 wxClientDisplayRect(&x, &y, &w, &h);
172 SetSize(x, y, w, h);
7d9f12f3
VS
173 }
174 else if ( !maximize && m_isMaximized )
175 {
15678bec 176 m_isMaximized = FALSE;
7d9f12f3
VS
177 SetSize(m_savedFrame.x, m_savedFrame.y,
178 m_savedFrame.width, m_savedFrame.height);
7d9f12f3
VS
179 }
180}
181
182bool wxTopLevelWindowMGL::IsMaximized() const
183{
184 return m_isMaximized;
185}
186
187void wxTopLevelWindowMGL::Restore()
188{
7cdbf02c 189 if ( IsIconized() )
7d9f12f3
VS
190 {
191 Iconize(FALSE);
192 }
7cdbf02c 193 if ( IsMaximized() )
7d9f12f3
VS
194 {
195 Maximize(FALSE);
196 }
197}
198
58061670 199void wxTopLevelWindowMGL::Iconize(bool WXUNUSED(iconize))
7d9f12f3 200{
58061670
VS
201 wxFAIL_MSG(wxT("Iconize not supported under wxMGL"));
202 // FIXME_MGL - Iconize is not supported in fullscreen mode.
203 // It will be supported in windowed mode (if ever implemented in MGL...)
7d9f12f3
VS
204}
205
206bool wxTopLevelWindowMGL::IsIconized() const
207{
208 return m_isIconized;
209}