]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/toplevel.cpp
more active frame stuff
[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
VS
79
80 wxWindow::Create(parent, id, pos, sizeOrig, style, name);
7d9f12f3
VS
81
82 wxTopLevelWindows.Append(this);
83
84 m_title = title;
2343d81b
VS
85
86 // FIXME_MGL -- should activate itself when shown!
7d9f12f3
VS
87
88 return TRUE;
89}
90
91wxTopLevelWindowMGL::~wxTopLevelWindowMGL()
92{
93 m_isBeingDeleted = TRUE;
94
95 wxTopLevelWindows.DeleteObject(this);
96
97 if (wxTheApp->GetTopWindow() == this)
98 wxTheApp->SetTopWindow(NULL);
99
100 if ((wxTopLevelWindows.Number() == 0) &&
101 (wxTheApp->GetExitOnFrameDelete()))
102 {
103 wxTheApp->ExitMainLoop();
104 }
105}
106
107bool wxTopLevelWindowMGL::ShowFullScreen(bool show, long style)
108{
109 if (show == m_fsIsShowing) return FALSE; // return what?
110
111 m_fsIsShowing = show;
112
113 if (show)
114 {
115 m_fsSaveStyle = m_windowStyle;
116 m_fsSaveFlag = style;
117 GetPosition(&m_fsSaveFrame.x, &m_fsSaveFrame.y);
118 GetSize(&m_fsSaveFrame.width, &m_fsSaveFrame.height);
119
120 if ( style & wxFULLSCREEN_NOCAPTION )
038072e2 121 m_windowStyle &= ~wxCAPTION;
7d9f12f3
VS
122 if ( style & wxFULLSCREEN_NOBORDER )
123 m_windowStyle = wxSIMPLE_BORDER;
124
125 int x, y;
126 wxDisplaySize(&x, &y);
127 SetSize(0, 0, x, y);
128 }
129 else
130 {
131 m_windowStyle = m_fsSaveStyle;
132 SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
133 m_fsSaveFrame.width, m_fsSaveFrame.height);
134 }
135
136 return TRUE;
137}
138
917afc7b
VS
139bool wxTopLevelWindowMGL::Show(bool show)
140{
141 bool ret = wxTopLevelWindowBase::Show(show);
142 if ( ret && show )
143 SetFocus();
144 return ret;
145}
146
7d9f12f3
VS
147void wxTopLevelWindowMGL::Maximize(bool maximize)
148{
149 if ( maximize && !m_isMaximized )
150 {
151 int x, y, w, h;
152
15678bec
VS
153 m_isMaximized = TRUE;
154
7d9f12f3
VS
155 GetPosition(&m_savedFrame.x, &m_savedFrame.y);
156 GetSize(&m_savedFrame.width, &m_savedFrame.height);
157
158 wxClientDisplayRect(&x, &y, &w, &h);
159 SetSize(x, y, w, h);
7d9f12f3
VS
160 }
161 else if ( !maximize && m_isMaximized )
162 {
15678bec 163 m_isMaximized = FALSE;
7d9f12f3
VS
164 SetSize(m_savedFrame.x, m_savedFrame.y,
165 m_savedFrame.width, m_savedFrame.height);
7d9f12f3
VS
166 }
167}
168
169bool wxTopLevelWindowMGL::IsMaximized() const
170{
171 return m_isMaximized;
172}
173
174void wxTopLevelWindowMGL::Restore()
175{
7cdbf02c 176 if ( IsIconized() )
7d9f12f3
VS
177 {
178 Iconize(FALSE);
179 }
7cdbf02c 180 if ( IsMaximized() )
7d9f12f3
VS
181 {
182 Maximize(FALSE);
183 }
184}
185
186void wxTopLevelWindowMGL::Iconize(bool iconize)
187{
2343d81b 188 // FIXME_MGL - use wxDesktop for this
7d9f12f3
VS
189}
190
191bool wxTopLevelWindowMGL::IsIconized() const
192{
193 return m_isIconized;
194}