]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/toplevel.cpp
DLL compilation fix
[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
32 // ----------------------------------------------------------------------------
33 // idle system
34 // ----------------------------------------------------------------------------
35
36 extern int g_openDialogs;
37
38 // ----------------------------------------------------------------------------
39 // event tables
40 // ----------------------------------------------------------------------------
41
42 #ifndef __WXUNIVERSAL__
43 IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow)
44 #endif
45
46
47 // ============================================================================
48 // implementation
49 // ============================================================================
50
51 void wxTopLevelWindowMGL::Init()
52 {
53 m_isIconized = FALSE;
54 m_isMaximized = FALSE;
55 m_fsIsShowing = FALSE;
56 }
57
58 bool wxTopLevelWindowMGL::Create(wxWindow *parent,
59 wxWindowID id,
60 const wxString& title,
61 const wxPoint& pos,
62 const wxSize& sizeOrig,
63 long style,
64 const wxString &name)
65 {
66 // always create a frame of some reasonable, even if arbitrary, size (at
67 // least for MSW compatibility)
68 wxSize size = sizeOrig;
69 if ( size.x == -1 || size.y == -1 )
70 {
71 wxSize sizeDpy = wxGetDisplaySize();
72 if ( size.x == -1 )
73 size.x = sizeDpy.x / 3;
74 if ( size.y == -1 )
75 size.y = sizeDpy.y / 5;
76 }
77
78 wxTopLevelWindows.Append(this);
79
80 m_title = title;
81
82
83 if (m_parent)
84 m_parent->AddChild(this);
85
86 return TRUE;
87 }
88
89 wxTopLevelWindowMGL::~wxTopLevelWindowMGL()
90 {
91 m_isBeingDeleted = TRUE;
92
93 wxTopLevelWindows.DeleteObject(this);
94
95 if (wxTheApp->GetTopWindow() == this)
96 wxTheApp->SetTopWindow(NULL);
97
98 if ((wxTopLevelWindows.Number() == 0) &&
99 (wxTheApp->GetExitOnFrameDelete()))
100 {
101 wxTheApp->ExitMainLoop();
102 }
103 }
104
105 bool wxTopLevelWindowMGL::ShowFullScreen(bool show, long style)
106 {
107 if (show == m_fsIsShowing) return FALSE; // return what?
108
109 m_fsIsShowing = show;
110
111 if (show)
112 {
113 m_fsSaveStyle = m_windowStyle;
114 m_fsSaveFlag = style;
115 GetPosition(&m_fsSaveFrame.x, &m_fsSaveFrame.y);
116 GetSize(&m_fsSaveFrame.width, &m_fsSaveFrame.height);
117
118 if ( style & wxFULLSCREEN_NOCAPTION )
119 m_windowStyle &= ~wxCAPTION;
120 if ( style & wxFULLSCREEN_NOBORDER )
121 m_windowStyle = wxSIMPLE_BORDER;
122
123 int x, y;
124 wxDisplaySize(&x, &y);
125 SetSize(0, 0, x, y);
126 }
127 else
128 {
129 m_windowStyle = m_fsSaveStyle;
130 SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
131 m_fsSaveFrame.width, m_fsSaveFrame.height);
132 }
133
134 return TRUE;
135 }
136
137 void wxTopLevelWindowMGL::Maximize(bool maximize)
138 {
139 if ( maximize && !m_isMaximized )
140 {
141 int x, y, w, h;
142
143 GetPosition(&m_savedFrame.x, &m_savedFrame.y);
144 GetSize(&m_savedFrame.width, &m_savedFrame.height);
145
146 wxClientDisplayRect(&x, &y, &w, &h);
147 SetSize(x, y, w, h);
148 m_isMaximized = TRUE;
149 }
150 else if ( !maximize && m_isMaximized )
151 {
152 SetSize(m_savedFrame.x, m_savedFrame.y,
153 m_savedFrame.width, m_savedFrame.height);
154 m_isMaximized = FALSE;
155 }
156 }
157
158 bool wxTopLevelWindowMGL::IsMaximized() const
159 {
160 return m_isMaximized;
161 }
162
163 void wxTopLevelWindowMGL::Restore()
164 {
165 if ( m_isIconized )
166 {
167 Iconize(FALSE);
168 }
169 if ( m_isMaximized )
170 {
171 Maximize(FALSE);
172 }
173 }
174
175 void wxTopLevelWindowMGL::Iconize(bool iconize)
176 {
177 // FIXME_MGL
178 }
179
180 bool wxTopLevelWindowMGL::IsIconized() const
181 {
182 return m_isIconized;
183 }