]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/toplevel.cpp
Added new cmdline parsing classes to wxOS2
[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 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 bool wxTopLevelWindowMGL::Show(bool show)
138 {
139 bool ret = wxTopLevelWindowBase::Show(show);
140 if ( ret && show && AcceptsFocus() )
141 SetFocus();
142 // FIXME_MGL -- don't do this for popup windows?
143 return ret;
144 }
145
146 void wxTopLevelWindowMGL::Maximize(bool maximize)
147 {
148 if ( maximize && !m_isMaximized )
149 {
150 int x, y, w, h;
151
152 m_isMaximized = TRUE;
153
154 GetPosition(&m_savedFrame.x, &m_savedFrame.y);
155 GetSize(&m_savedFrame.width, &m_savedFrame.height);
156
157 wxClientDisplayRect(&x, &y, &w, &h);
158 SetSize(x, y, w, h);
159 }
160 else if ( !maximize && m_isMaximized )
161 {
162 m_isMaximized = FALSE;
163 SetSize(m_savedFrame.x, m_savedFrame.y,
164 m_savedFrame.width, m_savedFrame.height);
165 }
166 }
167
168 bool wxTopLevelWindowMGL::IsMaximized() const
169 {
170 return m_isMaximized;
171 }
172
173 void wxTopLevelWindowMGL::Restore()
174 {
175 if ( IsIconized() )
176 {
177 Iconize(FALSE);
178 }
179 if ( IsMaximized() )
180 {
181 Maximize(FALSE);
182 }
183 }
184
185 void wxTopLevelWindowMGL::Iconize(bool iconize)
186 {
187 // FIXME_MGL - use wxDesktop for this
188 }
189
190 bool wxTopLevelWindowMGL::IsIconized() const
191 {
192 return m_isIconized;
193 }