]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/toplevel.cpp
Updated to new PyCrust
[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;
58}
59
60bool wxTopLevelWindowMGL::Create(wxWindow *parent,
61 wxWindowID id,
62 const wxString& title,
63 const wxPoint& pos,
64 const wxSize& sizeOrig,
65 long style,
66 const wxString &name)
67{
68 // always create a frame of some reasonable, even if arbitrary, size (at
69 // least for MSW compatibility)
70 wxSize size = sizeOrig;
71 if ( size.x == -1 || size.y == -1 )
72 {
73 wxSize sizeDpy = wxGetDisplaySize();
74 if ( size.x == -1 )
75 size.x = sizeDpy.x / 3;
76 if ( size.y == -1 )
77 size.y = sizeDpy.y / 5;
78 }
2343d81b 79
b8c0528d
VS
80 wxWindow::Create(NULL, id, pos, sizeOrig, style, name);
81 SetParent(parent);
82 if ( parent )
83 parent->AddChild(this);
7d9f12f3
VS
84
85 wxTopLevelWindows.Append(this);
86
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);
61bd618f 143 if ( ret && show && AcceptsFocus() )
917afc7b 144 SetFocus();
61bd618f 145 // FIXME_MGL -- don't do this for popup windows?
917afc7b
VS
146 return ret;
147}
148
7d9f12f3
VS
149void wxTopLevelWindowMGL::Maximize(bool maximize)
150{
151 if ( maximize && !m_isMaximized )
152 {
153 int x, y, w, h;
154
15678bec
VS
155 m_isMaximized = TRUE;
156
7d9f12f3
VS
157 GetPosition(&m_savedFrame.x, &m_savedFrame.y);
158 GetSize(&m_savedFrame.width, &m_savedFrame.height);
159
160 wxClientDisplayRect(&x, &y, &w, &h);
161 SetSize(x, y, w, h);
7d9f12f3
VS
162 }
163 else if ( !maximize && m_isMaximized )
164 {
15678bec 165 m_isMaximized = FALSE;
7d9f12f3
VS
166 SetSize(m_savedFrame.x, m_savedFrame.y,
167 m_savedFrame.width, m_savedFrame.height);
7d9f12f3
VS
168 }
169}
170
171bool wxTopLevelWindowMGL::IsMaximized() const
172{
173 return m_isMaximized;
174}
175
176void wxTopLevelWindowMGL::Restore()
177{
7cdbf02c 178 if ( IsIconized() )
7d9f12f3
VS
179 {
180 Iconize(FALSE);
181 }
7cdbf02c 182 if ( IsMaximized() )
7d9f12f3
VS
183 {
184 Maximize(FALSE);
185 }
186}
187
188void wxTopLevelWindowMGL::Iconize(bool iconize)
189{
2343d81b 190 // FIXME_MGL - use wxDesktop for this
7d9f12f3
VS
191}
192
193bool wxTopLevelWindowMGL::IsIconized() const
194{
195 return m_isIconized;
196}