]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/toplevel.cpp
don't strip &s from tooltips (patch 1488318)
[wxWidgets.git] / src / mgl / toplevel.cpp
CommitLineData
7d9f12f3 1/////////////////////////////////////////////////////////////////////////////
46ae103b 2// Name: src/mgl/toplevel.cpp
7d9f12f3
VS
3// Purpose:
4// Author: Vaclav Slavik
5// Id: $Id$
c41c20a5 6// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
65571936 7// Licence: wxWindows licence
7d9f12f3
VS
8/////////////////////////////////////////////////////////////////////////////
9
7520f3da
WS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
7d9f12f3
VS
17// ============================================================================
18// declarations
19// ============================================================================
20
21// ----------------------------------------------------------------------------
22// headers
23// ----------------------------------------------------------------------------
24
78f93365 25#ifndef WX_PRECOMP
78f93365
WS
26 #include "wx/toplevel.h"
27 #include "wx/app.h"
28#endif // WX_PRECOMP
29
5465a788 30#include "wx/mgl/private.h"
7d9f12f3
VS
31
32// ----------------------------------------------------------------------------
33// idle system
34// ----------------------------------------------------------------------------
35
7d9f12f3
VS
36extern int g_openDialogs;
37
38// ----------------------------------------------------------------------------
39// event tables
40// ----------------------------------------------------------------------------
41
42#ifndef __WXUNIVERSAL__
43 IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow)
44#endif
45
7d9f12f3
VS
46
47// ============================================================================
48// implementation
49// ============================================================================
50
51void wxTopLevelWindowMGL::Init()
52{
46ae103b
WS
53 m_isShown = false;
54 m_isIconized = false;
55 m_isMaximized = false;
56 m_fsIsShowing = false;
57 m_sizeSet = false;
7d9f12f3
VS
58}
59
60bool wxTopLevelWindowMGL::Create(wxWindow *parent,
61 wxWindowID id,
62 const wxString& title,
6807396f 63 const wxPoint& posOrig,
7d9f12f3
VS
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;
46ae103b 71 if ( size.x == wxDefaultCoord || size.y == wxDefaultCoord )
7d9f12f3 72 {
6807396f 73 wxSize sizeDefault = GetDefaultSize();
46ae103b 74 if ( size.x == wxDefaultCoord )
6807396f 75 size.x = sizeDefault.x;
46ae103b 76 if ( size.y == wxDefaultCoord )
6807396f 77 size.y = sizeDefault.y;
7d9f12f3 78 }
46ae103b 79
6807396f
MW
80 // for default positioning, centre the first top level window and
81 // cascade any addtional ones from there.
82 wxPoint pos = posOrig;
46ae103b 83 if ( pos.x == wxDefaultCoord || pos.y == wxDefaultCoord )
6807396f
MW
84 {
85 wxSize sizeDisplay = wxGetDisplaySize();
86 static wxPoint nextPos((sizeDisplay.x - size.x) / 2,
87 (sizeDisplay.y - size.y) / 2);
88
46ae103b 89 if ( pos.x == wxDefaultCoord )
6807396f 90 pos.x = nextPos.x;
46ae103b 91 if ( pos.y == wxDefaultCoord )
6807396f
MW
92 pos.y = nextPos.y;
93 if ( pos.x + size.x > sizeDisplay.x || pos.y + size.y > sizeDisplay.y )
94 pos = wxPoint();
95
96 const wxSize cascadeOffset(16, 20);
97 nextPos = pos + cascadeOffset;
98 }
99
100 wxWindow::Create(NULL, id, pos, size, style, name);
b8c0528d
VS
101 SetParent(parent);
102 if ( parent )
103 parent->AddChild(this);
7d9f12f3
VS
104
105 wxTopLevelWindows.Append(this);
7d9f12f3 106 m_title = title;
7d9f12f3 107
46ae103b 108 return true;
7d9f12f3
VS
109}
110
111wxTopLevelWindowMGL::~wxTopLevelWindowMGL()
112{
46ae103b 113 m_isBeingDeleted = true;
7d9f12f3
VS
114
115 wxTopLevelWindows.DeleteObject(this);
116
117 if (wxTheApp->GetTopWindow() == this)
118 wxTheApp->SetTopWindow(NULL);
119
78f93365
WS
120 if (wxTopLevelWindows.IsEmpty() &&
121 wxTheApp->GetExitOnFrameDelete())
7d9f12f3
VS
122 {
123 wxTheApp->ExitMainLoop();
124 }
125}
126
127bool wxTopLevelWindowMGL::ShowFullScreen(bool show, long style)
128{
46ae103b 129 if (show == m_fsIsShowing) return false; // return what?
7d9f12f3
VS
130
131 m_fsIsShowing = show;
132
133 if (show)
134 {
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);
139
140 if ( style & wxFULLSCREEN_NOCAPTION )
038072e2 141 m_windowStyle &= ~wxCAPTION;
7d9f12f3
VS
142 if ( style & wxFULLSCREEN_NOBORDER )
143 m_windowStyle = wxSIMPLE_BORDER;
144
145 int x, y;
146 wxDisplaySize(&x, &y);
147 SetSize(0, 0, x, y);
148 }
149 else
150 {
151 m_windowStyle = m_fsSaveStyle;
46ae103b 152 SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
7d9f12f3
VS
153 m_fsSaveFrame.width, m_fsSaveFrame.height);
154 }
155
46ae103b 156 return true;
7d9f12f3
VS
157}
158
917afc7b
VS
159bool wxTopLevelWindowMGL::Show(bool show)
160{
161 bool ret = wxTopLevelWindowBase::Show(show);
f41ed3c4
VS
162
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)
165 if ( !m_sizeSet )
166 {
46ae103b 167 m_sizeSet = true;
f41ed3c4
VS
168 wxSizeEvent event(GetSize(), GetId());
169 event.SetEventObject(this);
170 GetEventHandler()->ProcessEvent(event);
171 }
172
61bd618f 173 if ( ret && show && AcceptsFocus() )
917afc7b 174 SetFocus();
61bd618f 175 // FIXME_MGL -- don't do this for popup windows?
917afc7b
VS
176 return ret;
177}
178
7d9f12f3
VS
179void wxTopLevelWindowMGL::Maximize(bool maximize)
180{
5465a788
VS
181 int x, y, w, h;
182 wxClientDisplayRect(&x, &y, &w, &h);
183
184 rect_t screenRect = MGL_defRect(x, y, w, h);
185 MGL_wmInvalidateRect(g_winMng, &screenRect);
186
7d9f12f3
VS
187 if ( maximize && !m_isMaximized )
188 {
46ae103b 189 m_isMaximized = true;
15678bec 190
7d9f12f3
VS
191 GetPosition(&m_savedFrame.x, &m_savedFrame.y);
192 GetSize(&m_savedFrame.width, &m_savedFrame.height);
193
7d9f12f3 194 SetSize(x, y, w, h);
7d9f12f3
VS
195 }
196 else if ( !maximize && m_isMaximized )
197 {
46ae103b
WS
198 m_isMaximized = false;
199 SetSize(m_savedFrame.x, m_savedFrame.y,
7d9f12f3 200 m_savedFrame.width, m_savedFrame.height);
7d9f12f3
VS
201 }
202}
203
204bool wxTopLevelWindowMGL::IsMaximized() const
205{
206 return m_isMaximized;
207}
208
209void wxTopLevelWindowMGL::Restore()
210{
7cdbf02c 211 if ( IsIconized() )
7d9f12f3 212 {
46ae103b 213 Iconize(false);
7d9f12f3 214 }
7cdbf02c 215 if ( IsMaximized() )
7d9f12f3 216 {
46ae103b 217 Maximize(false);
7d9f12f3
VS
218 }
219}
220
58061670 221void wxTopLevelWindowMGL::Iconize(bool WXUNUSED(iconize))
7d9f12f3 222{
58061670
VS
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...)
7d9f12f3
VS
226}
227
228bool wxTopLevelWindowMGL::IsIconized() const
229{
230 return m_isIconized;
231}