]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mgl/toplevel.cpp
better windows painting in wxMGL
[wxWidgets.git] / src / mgl / toplevel.cpp
... / ...
CommitLineData
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"
31#include "wx/app.h"
32
33// ----------------------------------------------------------------------------
34// idle system
35// ----------------------------------------------------------------------------
36
37extern int g_openDialogs;
38
39// ----------------------------------------------------------------------------
40// event tables
41// ----------------------------------------------------------------------------
42
43#ifndef __WXUNIVERSAL__
44 IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow)
45#endif
46
47
48// ============================================================================
49// implementation
50// ============================================================================
51
52void wxTopLevelWindowMGL::Init()
53{
54 m_isShown = FALSE;
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 }
79
80 wxWindow::Create(NULL, id, pos, sizeOrig, style, name);
81 SetParent(parent);
82 if ( parent )
83 parent->AddChild(this);
84
85 wxTopLevelWindows.Append(this);
86
87 m_title = title;
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 )
122 m_windowStyle &= ~wxCAPTION;
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
140bool wxTopLevelWindowMGL::Show(bool show)
141{
142 bool ret = wxTopLevelWindowBase::Show(show);
143 if ( ret && show && AcceptsFocus() )
144 SetFocus();
145 // FIXME_MGL -- don't do this for popup windows?
146 return ret;
147}
148
149void wxTopLevelWindowMGL::Maximize(bool maximize)
150{
151 if ( maximize && !m_isMaximized )
152 {
153 int x, y, w, h;
154
155 m_isMaximized = TRUE;
156
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);
162 }
163 else if ( !maximize && m_isMaximized )
164 {
165 m_isMaximized = FALSE;
166 SetSize(m_savedFrame.x, m_savedFrame.y,
167 m_savedFrame.width, m_savedFrame.height);
168 }
169}
170
171bool wxTopLevelWindowMGL::IsMaximized() const
172{
173 return m_isMaximized;
174}
175
176void wxTopLevelWindowMGL::Restore()
177{
178 if ( IsIconized() )
179 {
180 Iconize(FALSE);
181 }
182 if ( IsMaximized() )
183 {
184 Maximize(FALSE);
185 }
186}
187
188void wxTopLevelWindowMGL::Iconize(bool iconize)
189{
190 // FIXME_MGL - use wxDesktop for this
191}
192
193bool wxTopLevelWindowMGL::IsIconized() const
194{
195 return m_isIconized;
196}