]>
git.saurik.com Git - wxWidgets.git/blob - src/mgl/toplevel.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 // For compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
26 #include "wx/toplevel.h"
28 #include "wx/mgl/private.h"
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 extern int g_openDialogs
;
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 #ifndef __WXUNIVERSAL__
41 IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow
, wxWindow
)
45 // ============================================================================
47 // ============================================================================
49 void wxTopLevelWindowMGL::Init()
53 m_isMaximized
= FALSE
;
54 m_fsIsShowing
= FALSE
;
58 bool wxTopLevelWindowMGL::Create(wxWindow
*parent
,
60 const wxString
& title
,
61 const wxPoint
& posOrig
,
62 const wxSize
& sizeOrig
,
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 )
71 wxSize sizeDefault
= GetDefaultSize();
73 size
.x
= sizeDefault
.x
;
75 size
.y
= sizeDefault
.y
;
78 // for default positioning, centre the first top level window and
79 // cascade any addtional ones from there.
80 wxPoint pos
= posOrig
;
81 if ( pos
.x
== -1 || pos
.y
== -1 )
83 wxSize sizeDisplay
= wxGetDisplaySize();
84 static wxPoint
nextPos((sizeDisplay
.x
- size
.x
) / 2,
85 (sizeDisplay
.y
- size
.y
) / 2);
91 if ( pos
.x
+ size
.x
> sizeDisplay
.x
|| pos
.y
+ size
.y
> sizeDisplay
.y
)
94 const wxSize
cascadeOffset(16, 20);
95 nextPos
= pos
+ cascadeOffset
;
98 wxWindow::Create(NULL
, id
, pos
, size
, style
, name
);
101 parent
->AddChild(this);
103 wxTopLevelWindows
.Append(this);
109 wxTopLevelWindowMGL::~wxTopLevelWindowMGL()
111 m_isBeingDeleted
= TRUE
;
113 wxTopLevelWindows
.DeleteObject(this);
115 if (wxTheApp
->GetTopWindow() == this)
116 wxTheApp
->SetTopWindow(NULL
);
118 if ((wxTopLevelWindows
.Number() == 0) &&
119 (wxTheApp
->GetExitOnFrameDelete()))
121 wxTheApp
->ExitMainLoop();
125 bool wxTopLevelWindowMGL::ShowFullScreen(bool show
, long style
)
127 if (show
== m_fsIsShowing
) return FALSE
; // return what?
129 m_fsIsShowing
= show
;
133 m_fsSaveStyle
= m_windowStyle
;
134 m_fsSaveFlag
= style
;
135 GetPosition(&m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
136 GetSize(&m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
138 if ( style
& wxFULLSCREEN_NOCAPTION
)
139 m_windowStyle
&= ~wxCAPTION
;
140 if ( style
& wxFULLSCREEN_NOBORDER
)
141 m_windowStyle
= wxSIMPLE_BORDER
;
144 wxDisplaySize(&x
, &y
);
149 m_windowStyle
= m_fsSaveStyle
;
150 SetSize(m_fsSaveFrame
.x
, m_fsSaveFrame
.y
,
151 m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
157 bool wxTopLevelWindowMGL::Show(bool show
)
159 bool ret
= wxTopLevelWindowBase::Show(show
);
161 // If this is the first time Show was called, send size event,
162 // so that the frame can adjust itself (think auto layout or single child)
166 wxSizeEvent
event(GetSize(), GetId());
167 event
.SetEventObject(this);
168 GetEventHandler()->ProcessEvent(event
);
171 if ( ret
&& show
&& AcceptsFocus() )
173 // FIXME_MGL -- don't do this for popup windows?
177 void wxTopLevelWindowMGL::Maximize(bool maximize
)
180 wxClientDisplayRect(&x
, &y
, &w
, &h
);
182 rect_t screenRect
= MGL_defRect(x
, y
, w
, h
);
183 MGL_wmInvalidateRect(g_winMng
, &screenRect
);
185 if ( maximize
&& !m_isMaximized
)
187 m_isMaximized
= TRUE
;
189 GetPosition(&m_savedFrame
.x
, &m_savedFrame
.y
);
190 GetSize(&m_savedFrame
.width
, &m_savedFrame
.height
);
194 else if ( !maximize
&& m_isMaximized
)
196 m_isMaximized
= FALSE
;
197 SetSize(m_savedFrame
.x
, m_savedFrame
.y
,
198 m_savedFrame
.width
, m_savedFrame
.height
);
202 bool wxTopLevelWindowMGL::IsMaximized() const
204 return m_isMaximized
;
207 void wxTopLevelWindowMGL::Restore()
219 void wxTopLevelWindowMGL::Iconize(bool WXUNUSED(iconize
))
221 wxFAIL_MSG(wxT("Iconize not supported under wxMGL"));
222 // FIXME_MGL - Iconize is not supported in fullscreen mode.
223 // It will be supported in windowed mode (if ever implemented in MGL...)
226 bool wxTopLevelWindowMGL::IsIconized() const