]>
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
19 #pragma implementation "toplevel.h"
22 // For compilers that support precompilation, includes "wx.h".
23 #include "wx/wxprec.h"
30 #include "wx/toplevel.h"
32 #include "wx/mgl/private.h"
34 // ----------------------------------------------------------------------------
36 // ----------------------------------------------------------------------------
38 extern int g_openDialogs
;
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 #ifndef __WXUNIVERSAL__
45 IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow
, wxWindow
)
49 // ============================================================================
51 // ============================================================================
53 void wxTopLevelWindowMGL::Init()
57 m_isMaximized
= FALSE
;
58 m_fsIsShowing
= FALSE
;
62 bool wxTopLevelWindowMGL::Create(wxWindow
*parent
,
64 const wxString
& title
,
65 const wxPoint
& posOrig
,
66 const wxSize
& sizeOrig
,
70 // always create a frame of some reasonable, even if arbitrary, size (at
71 // least for MSW compatibility)
72 wxSize size
= sizeOrig
;
73 if ( size
.x
== -1 || size
.y
== -1 )
75 wxSize sizeDefault
= GetDefaultSize();
77 size
.x
= sizeDefault
.x
;
79 size
.y
= sizeDefault
.y
;
82 // for default positioning, centre the first top level window and
83 // cascade any addtional ones from there.
84 wxPoint pos
= posOrig
;
85 if ( pos
.x
== -1 || pos
.y
== -1 )
87 wxSize sizeDisplay
= wxGetDisplaySize();
88 static wxPoint
nextPos((sizeDisplay
.x
- size
.x
) / 2,
89 (sizeDisplay
.y
- size
.y
) / 2);
95 if ( pos
.x
+ size
.x
> sizeDisplay
.x
|| pos
.y
+ size
.y
> sizeDisplay
.y
)
98 const wxSize
cascadeOffset(16, 20);
99 nextPos
= pos
+ cascadeOffset
;
102 wxWindow::Create(NULL
, id
, pos
, size
, style
, name
);
105 parent
->AddChild(this);
107 wxTopLevelWindows
.Append(this);
113 wxTopLevelWindowMGL::~wxTopLevelWindowMGL()
115 m_isBeingDeleted
= TRUE
;
117 wxTopLevelWindows
.DeleteObject(this);
119 if (wxTheApp
->GetTopWindow() == this)
120 wxTheApp
->SetTopWindow(NULL
);
122 if ((wxTopLevelWindows
.Number() == 0) &&
123 (wxTheApp
->GetExitOnFrameDelete()))
125 wxTheApp
->ExitMainLoop();
129 bool wxTopLevelWindowMGL::ShowFullScreen(bool show
, long style
)
131 if (show
== m_fsIsShowing
) return FALSE
; // return what?
133 m_fsIsShowing
= show
;
137 m_fsSaveStyle
= m_windowStyle
;
138 m_fsSaveFlag
= style
;
139 GetPosition(&m_fsSaveFrame
.x
, &m_fsSaveFrame
.y
);
140 GetSize(&m_fsSaveFrame
.width
, &m_fsSaveFrame
.height
);
142 if ( style
& wxFULLSCREEN_NOCAPTION
)
143 m_windowStyle
&= ~wxCAPTION
;
144 if ( style
& wxFULLSCREEN_NOBORDER
)
145 m_windowStyle
= wxSIMPLE_BORDER
;
148 wxDisplaySize(&x
, &y
);
153 m_windowStyle
= m_fsSaveStyle
;
154 SetSize(m_fsSaveFrame
.x
, m_fsSaveFrame
.y
,
155 m_fsSaveFrame
.width
, m_fsSaveFrame
.height
);
161 bool wxTopLevelWindowMGL::Show(bool show
)
163 bool ret
= wxTopLevelWindowBase::Show(show
);
165 // If this is the first time Show was called, send size event,
166 // so that the frame can adjust itself (think auto layout or single child)
170 wxSizeEvent
event(GetSize(), GetId());
171 event
.SetEventObject(this);
172 GetEventHandler()->ProcessEvent(event
);
175 if ( ret
&& show
&& AcceptsFocus() )
177 // FIXME_MGL -- don't do this for popup windows?
181 void wxTopLevelWindowMGL::Maximize(bool maximize
)
184 wxClientDisplayRect(&x
, &y
, &w
, &h
);
186 rect_t screenRect
= MGL_defRect(x
, y
, w
, h
);
187 MGL_wmInvalidateRect(g_winMng
, &screenRect
);
189 if ( maximize
&& !m_isMaximized
)
191 m_isMaximized
= TRUE
;
193 GetPosition(&m_savedFrame
.x
, &m_savedFrame
.y
);
194 GetSize(&m_savedFrame
.width
, &m_savedFrame
.height
);
198 else if ( !maximize
&& m_isMaximized
)
200 m_isMaximized
= FALSE
;
201 SetSize(m_savedFrame
.x
, m_savedFrame
.y
,
202 m_savedFrame
.width
, m_savedFrame
.height
);
206 bool wxTopLevelWindowMGL::IsMaximized() const
208 return m_isMaximized
;
211 void wxTopLevelWindowMGL::Restore()
223 void wxTopLevelWindowMGL::Iconize(bool WXUNUSED(iconize
))
225 wxFAIL_MSG(wxT("Iconize not supported under wxMGL"));
226 // FIXME_MGL - Iconize is not supported in fullscreen mode.
227 // It will be supported in windowed mode (if ever implemented in MGL...)
230 bool wxTopLevelWindowMGL::IsIconized() const