]>
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 // ----------------------------------------------------------------------------
26 #include "wx/toplevel.h"
30 #include "wx/mgl/private.h"
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
36 extern int g_openDialogs
;
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 #ifndef __WXUNIVERSAL__
43 IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow
, wxWindow
)
47 // ============================================================================
49 // ============================================================================
51 void wxTopLevelWindowMGL::Init()
55 m_isMaximized
= false;
56 m_fsIsShowing
= false;
60 bool wxTopLevelWindowMGL::Create(wxWindow
*parent
,
62 const wxString
& title
,
63 const wxPoint
& posOrig
,
64 const wxSize
& sizeOrig
,
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
== wxDefaultCoord
|| size
.y
== wxDefaultCoord
)
73 wxSize sizeDefault
= GetDefaultSize();
74 if ( size
.x
== wxDefaultCoord
)
75 size
.x
= sizeDefault
.x
;
76 if ( size
.y
== wxDefaultCoord
)
77 size
.y
= sizeDefault
.y
;
80 // for default positioning, centre the first top level window and
81 // cascade any addtional ones from there.
82 wxPoint pos
= posOrig
;
83 if ( pos
.x
== wxDefaultCoord
|| pos
.y
== wxDefaultCoord
)
85 wxSize sizeDisplay
= wxGetDisplaySize();
86 static wxPoint
nextPos((sizeDisplay
.x
- size
.x
) / 2,
87 (sizeDisplay
.y
- size
.y
) / 2);
89 if ( pos
.x
== wxDefaultCoord
)
91 if ( pos
.y
== wxDefaultCoord
)
93 if ( pos
.x
+ size
.x
> sizeDisplay
.x
|| pos
.y
+ size
.y
> sizeDisplay
.y
)
96 const wxSize
cascadeOffset(16, 20);
97 nextPos
= pos
+ cascadeOffset
;
100 wxWindow::Create(NULL
, id
, pos
, size
, style
, name
);
103 parent
->AddChild(this);
105 wxTopLevelWindows
.Append(this);
111 wxTopLevelWindowMGL::~wxTopLevelWindowMGL()
113 m_isBeingDeleted
= true;
115 wxTopLevelWindows
.DeleteObject(this);
117 if (wxTheApp
->GetTopWindow() == this)
118 wxTheApp
->SetTopWindow(NULL
);
120 if (wxTopLevelWindows
.IsEmpty() &&
121 wxTheApp
->GetExitOnFrameDelete())
123 wxTheApp
->ExitMainLoop();
127 bool wxTopLevelWindowMGL::ShowFullScreen(bool show
, long style
)
129 if (show
== m_fsIsShowing
) return false; // return what?
131 m_fsIsShowing
= show
;
135 m_fsSaveStyle
= m_windowStyle
;
136 m_fsSaveFlag
= style
;
137 GetPosition(&m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
138 GetSize(&m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
140 if ( style
& wxFULLSCREEN_NOCAPTION
)
141 m_windowStyle
&= ~wxCAPTION
;
142 if ( style
& wxFULLSCREEN_NOBORDER
)
143 m_windowStyle
= wxSIMPLE_BORDER
;
146 wxDisplaySize(&x
, &y
);
151 m_windowStyle
= m_fsSaveStyle
;
152 SetSize(m_fsSaveFrame
.x
, m_fsSaveFrame
.y
,
153 m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
159 bool wxTopLevelWindowMGL::Show(bool show
)
161 bool ret
= wxTopLevelWindowBase::Show(show
);
163 // If this is the first time Show was called, send size event,
164 // so that the frame can adjust itself (think auto layout or single child)
168 wxSizeEvent
event(GetSize(), GetId());
169 event
.SetEventObject(this);
170 GetEventHandler()->ProcessEvent(event
);
173 if ( ret
&& show
&& AcceptsFocus() )
175 // FIXME_MGL -- don't do this for popup windows?
179 void wxTopLevelWindowMGL::Maximize(bool maximize
)
182 wxClientDisplayRect(&x
, &y
, &w
, &h
);
184 rect_t screenRect
= MGL_defRect(x
, y
, w
, h
);
185 MGL_wmInvalidateRect(g_winMng
, &screenRect
);
187 if ( maximize
&& !m_isMaximized
)
189 m_isMaximized
= true;
191 GetPosition(&m_savedFrame
.x
, &m_savedFrame
.y
);
192 GetSize(&m_savedFrame
.width
, &m_savedFrame
.height
);
196 else if ( !maximize
&& m_isMaximized
)
198 m_isMaximized
= false;
199 SetSize(m_savedFrame
.x
, m_savedFrame
.y
,
200 m_savedFrame
.width
, m_savedFrame
.height
);
204 bool wxTopLevelWindowMGL::IsMaximized() const
206 return m_isMaximized
;
209 void wxTopLevelWindowMGL::Restore()
221 void wxTopLevelWindowMGL::Iconize(bool WXUNUSED(iconize
))
223 wxFAIL_MSG(wxT("Iconize not supported under wxMGL"));
224 // FIXME_MGL - Iconize is not supported in fullscreen mode.
225 // It will be supported in windowed mode (if ever implemented in MGL...)
228 bool wxTopLevelWindowMGL::IsIconized() const