]>
git.saurik.com Git - wxWidgets.git/blob - src/mgl/toplevel.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mgl/toplevel.cpp
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 // ============================================================================
19 // ============================================================================
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
25 #include "wx/toplevel.h"
31 #include "wx/mgl/private.h"
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 extern int g_openDialogs
;
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 #ifndef __WXUNIVERSAL__
44 IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow
, wxWindow
)
48 // ============================================================================
50 // ============================================================================
52 void wxTopLevelWindowMGL::Init()
56 m_isMaximized
= false;
57 m_fsIsShowing
= false;
61 bool wxTopLevelWindowMGL::Create(wxWindow
*parent
,
63 const wxString
& title
,
64 const wxPoint
& posOrig
,
65 const wxSize
& sizeOrig
,
69 // always create a frame of some reasonable, even if arbitrary, size (at
70 // least for MSW compatibility)
71 wxSize size
= sizeOrig
;
72 if ( size
.x
== wxDefaultCoord
|| size
.y
== wxDefaultCoord
)
74 wxSize sizeDefault
= GetDefaultSize();
75 if ( size
.x
== wxDefaultCoord
)
76 size
.x
= sizeDefault
.x
;
77 if ( size
.y
== wxDefaultCoord
)
78 size
.y
= sizeDefault
.y
;
81 // for default positioning, centre the first top level window and
82 // cascade any addtional ones from there.
83 wxPoint pos
= posOrig
;
84 if ( pos
.x
== wxDefaultCoord
|| pos
.y
== wxDefaultCoord
)
86 wxSize sizeDisplay
= wxGetDisplaySize();
87 static wxPoint
nextPos((sizeDisplay
.x
- size
.x
) / 2,
88 (sizeDisplay
.y
- size
.y
) / 2);
90 if ( pos
.x
== wxDefaultCoord
)
92 if ( pos
.y
== wxDefaultCoord
)
94 if ( pos
.x
+ size
.x
> sizeDisplay
.x
|| pos
.y
+ size
.y
> sizeDisplay
.y
)
97 const wxSize
cascadeOffset(16, 20);
98 nextPos
= pos
+ cascadeOffset
;
101 wxWindow::Create(NULL
, id
, pos
, size
, style
, name
);
104 parent
->AddChild(this);
106 wxTopLevelWindows
.Append(this);
112 wxTopLevelWindowMGL::~wxTopLevelWindowMGL()
114 m_isBeingDeleted
= true;
116 wxTopLevelWindows
.DeleteObject(this);
118 if (wxTheApp
->GetTopWindow() == this)
119 wxTheApp
->SetTopWindow(NULL
);
121 if (wxTopLevelWindows
.IsEmpty() &&
122 wxTheApp
->GetExitOnFrameDelete())
124 wxTheApp
->ExitMainLoop();
128 bool wxTopLevelWindowMGL::ShowFullScreen(bool show
, long style
)
130 if (show
== m_fsIsShowing
) return false; // return what?
132 m_fsIsShowing
= show
;
136 m_fsSaveStyle
= m_windowStyle
;
137 m_fsSaveFlag
= style
;
138 GetPosition(&m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
139 GetSize(&m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
141 if ( style
& wxFULLSCREEN_NOCAPTION
)
142 m_windowStyle
&= ~wxCAPTION
;
143 if ( style
& wxFULLSCREEN_NOBORDER
)
144 m_windowStyle
= wxSIMPLE_BORDER
;
147 wxDisplaySize(&x
, &y
);
152 m_windowStyle
= m_fsSaveStyle
;
153 SetSize(m_fsSaveFrame
.x
, m_fsSaveFrame
.y
,
154 m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
160 bool wxTopLevelWindowMGL::Show(bool show
)
162 bool ret
= wxTopLevelWindowBase::Show(show
);
164 // If this is the first time Show was called, send size event,
165 // so that the frame can adjust itself (think auto layout or single child)
169 wxSizeEvent
event(GetSize(), GetId());
170 event
.SetEventObject(this);
171 GetEventHandler()->ProcessEvent(event
);
174 if ( ret
&& show
&& AcceptsFocus() )
176 // FIXME_MGL -- don't do this for popup windows?
180 void wxTopLevelWindowMGL::Maximize(bool maximize
)
183 wxClientDisplayRect(&x
, &y
, &w
, &h
);
185 rect_t screenRect
= MGL_defRect(x
, y
, w
, h
);
186 MGL_wmInvalidateRect(g_winMng
, &screenRect
);
188 if ( maximize
&& !m_isMaximized
)
190 m_isMaximized
= true;
192 GetPosition(&m_savedFrame
.x
, &m_savedFrame
.y
);
193 GetSize(&m_savedFrame
.width
, &m_savedFrame
.height
);
197 else if ( !maximize
&& m_isMaximized
)
199 m_isMaximized
= false;
200 SetSize(m_savedFrame
.x
, m_savedFrame
.y
,
201 m_savedFrame
.width
, m_savedFrame
.height
);
205 bool wxTopLevelWindowMGL::IsMaximized() const
207 return m_isMaximized
;
210 void wxTopLevelWindowMGL::Restore()
222 void wxTopLevelWindowMGL::Iconize(bool WXUNUSED(iconize
))
224 wxFAIL_MSG(wxT("Iconize not supported under wxMGL"));
225 // FIXME_MGL - Iconize is not supported in fullscreen mode.
226 // It will be supported in windowed mode (if ever implemented in MGL...)
229 bool wxTopLevelWindowMGL::IsIconized() const