]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/toplevel.cpp
wxMGL update
[wxWidgets.git] / src / mgl / toplevel.cpp
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
37 extern 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
52 void wxTopLevelWindowMGL::Init()
53 {
54 m_isShown = FALSE;
55 m_isIconized = FALSE;
56 m_isMaximized = FALSE;
57 m_fsIsShowing = FALSE;
58 }
59
60 bool 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(parent, id, pos, sizeOrig, style, name);
81
82 wxTopLevelWindows.Append(this);
83
84 m_title = title;
85
86 // FIXME_MGL -- should activate itself when shown!
87
88 return TRUE;
89 }
90
91 wxTopLevelWindowMGL::~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
107 bool 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 )
121 m_windowStyle &= ~wxCAPTION;
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
139 void wxTopLevelWindowMGL::Maximize(bool maximize)
140 {
141 if ( maximize && !m_isMaximized )
142 {
143 int x, y, w, h;
144
145 GetPosition(&m_savedFrame.x, &m_savedFrame.y);
146 GetSize(&m_savedFrame.width, &m_savedFrame.height);
147
148 wxClientDisplayRect(&x, &y, &w, &h);
149 SetSize(x, y, w, h);
150 m_isMaximized = TRUE;
151 }
152 else if ( !maximize && m_isMaximized )
153 {
154 SetSize(m_savedFrame.x, m_savedFrame.y,
155 m_savedFrame.width, m_savedFrame.height);
156 m_isMaximized = FALSE;
157 }
158 }
159
160 bool wxTopLevelWindowMGL::IsMaximized() const
161 {
162 return m_isMaximized;
163 }
164
165 void wxTopLevelWindowMGL::Restore()
166 {
167 if ( m_isIconized )
168 {
169 Iconize(FALSE);
170 }
171 if ( m_isMaximized )
172 {
173 Maximize(FALSE);
174 }
175 }
176
177 void wxTopLevelWindowMGL::Iconize(bool iconize)
178 {
179 // FIXME_MGL - use wxDesktop for this
180 }
181
182 bool wxTopLevelWindowMGL::IsIconized() const
183 {
184 return m_isIconized;
185 }