]>
Commit | Line | Data |
---|---|---|
7d9f12f3 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: toplevel.cpp | |
3 | // Purpose: | |
4 | // Author: Vaclav Slavik | |
5 | // Id: $Id$ | |
6 | // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | // ============================================================================ | |
11 | // declarations | |
12 | // ============================================================================ | |
13 | ||
14 | // ---------------------------------------------------------------------------- | |
15 | // headers | |
16 | // ---------------------------------------------------------------------------- | |
17 | ||
18 | #ifdef __GNUG__ | |
19 | #pragma implementation "toplevel.h" | |
20 | #endif | |
21 | ||
22 | // For compilers that support precompilation, includes "wx.h". | |
23 | #include "wx/wxprec.h" | |
24 | ||
25 | #ifdef __BORLANDC__ | |
26 | #pragma hdrstop | |
27 | #endif | |
28 | ||
29 | #include "wx/defs.h" | |
30 | #include "wx/toplevel.h" | |
2343d81b | 31 | #include "wx/app.h" |
7d9f12f3 VS |
32 | |
33 | // ---------------------------------------------------------------------------- | |
34 | // idle system | |
35 | // ---------------------------------------------------------------------------- | |
36 | ||
7d9f12f3 VS |
37 | extern int g_openDialogs; |
38 | ||
39 | // ---------------------------------------------------------------------------- | |
40 | // event tables | |
41 | // ---------------------------------------------------------------------------- | |
42 | ||
43 | #ifndef __WXUNIVERSAL__ | |
44 | IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow) | |
45 | #endif | |
46 | ||
7d9f12f3 VS |
47 | |
48 | // ============================================================================ | |
49 | // implementation | |
50 | // ============================================================================ | |
51 | ||
52 | void wxTopLevelWindowMGL::Init() | |
53 | { | |
2343d81b | 54 | m_isShown = FALSE; |
7d9f12f3 VS |
55 | m_isIconized = FALSE; |
56 | m_isMaximized = FALSE; | |
57 | m_fsIsShowing = FALSE; | |
58 | } | |
59 | ||
60 | bool wxTopLevelWindowMGL::Create(wxWindow *parent, | |
61 | wxWindowID id, | |
62 | const wxString& title, | |
63 | const wxPoint& pos, | |
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; | |
71 | if ( size.x == -1 || size.y == -1 ) | |
72 | { | |
73 | wxSize sizeDpy = wxGetDisplaySize(); | |
74 | if ( size.x == -1 ) | |
75 | size.x = sizeDpy.x / 3; | |
76 | if ( size.y == -1 ) | |
77 | size.y = sizeDpy.y / 5; | |
78 | } | |
2343d81b VS |
79 | |
80 | wxWindow::Create(parent, id, pos, sizeOrig, style, name); | |
7d9f12f3 VS |
81 | |
82 | wxTopLevelWindows.Append(this); | |
83 | ||
84 | m_title = title; | |
7d9f12f3 VS |
85 | |
86 | return TRUE; | |
87 | } | |
88 | ||
89 | wxTopLevelWindowMGL::~wxTopLevelWindowMGL() | |
90 | { | |
91 | m_isBeingDeleted = TRUE; | |
92 | ||
93 | wxTopLevelWindows.DeleteObject(this); | |
94 | ||
95 | if (wxTheApp->GetTopWindow() == this) | |
96 | wxTheApp->SetTopWindow(NULL); | |
97 | ||
98 | if ((wxTopLevelWindows.Number() == 0) && | |
99 | (wxTheApp->GetExitOnFrameDelete())) | |
100 | { | |
101 | wxTheApp->ExitMainLoop(); | |
102 | } | |
103 | } | |
104 | ||
105 | bool wxTopLevelWindowMGL::ShowFullScreen(bool show, long style) | |
106 | { | |
107 | if (show == m_fsIsShowing) return FALSE; // return what? | |
108 | ||
109 | m_fsIsShowing = show; | |
110 | ||
111 | if (show) | |
112 | { | |
113 | m_fsSaveStyle = m_windowStyle; | |
114 | m_fsSaveFlag = style; | |
115 | GetPosition(&m_fsSaveFrame.x, &m_fsSaveFrame.y); | |
116 | GetSize(&m_fsSaveFrame.width, &m_fsSaveFrame.height); | |
117 | ||
118 | if ( style & wxFULLSCREEN_NOCAPTION ) | |
038072e2 | 119 | m_windowStyle &= ~wxCAPTION; |
7d9f12f3 VS |
120 | if ( style & wxFULLSCREEN_NOBORDER ) |
121 | m_windowStyle = wxSIMPLE_BORDER; | |
122 | ||
123 | int x, y; | |
124 | wxDisplaySize(&x, &y); | |
125 | SetSize(0, 0, x, y); | |
126 | } | |
127 | else | |
128 | { | |
129 | m_windowStyle = m_fsSaveStyle; | |
130 | SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y, | |
131 | m_fsSaveFrame.width, m_fsSaveFrame.height); | |
132 | } | |
133 | ||
134 | return TRUE; | |
135 | } | |
136 | ||
917afc7b VS |
137 | bool wxTopLevelWindowMGL::Show(bool show) |
138 | { | |
139 | bool ret = wxTopLevelWindowBase::Show(show); | |
61bd618f | 140 | if ( ret && show && AcceptsFocus() ) |
917afc7b | 141 | SetFocus(); |
61bd618f | 142 | // FIXME_MGL -- don't do this for popup windows? |
917afc7b VS |
143 | return ret; |
144 | } | |
145 | ||
7d9f12f3 VS |
146 | void wxTopLevelWindowMGL::Maximize(bool maximize) |
147 | { | |
148 | if ( maximize && !m_isMaximized ) | |
149 | { | |
150 | int x, y, w, h; | |
151 | ||
15678bec VS |
152 | m_isMaximized = TRUE; |
153 | ||
7d9f12f3 VS |
154 | GetPosition(&m_savedFrame.x, &m_savedFrame.y); |
155 | GetSize(&m_savedFrame.width, &m_savedFrame.height); | |
156 | ||
157 | wxClientDisplayRect(&x, &y, &w, &h); | |
158 | SetSize(x, y, w, h); | |
7d9f12f3 VS |
159 | } |
160 | else if ( !maximize && m_isMaximized ) | |
161 | { | |
15678bec | 162 | m_isMaximized = FALSE; |
7d9f12f3 VS |
163 | SetSize(m_savedFrame.x, m_savedFrame.y, |
164 | m_savedFrame.width, m_savedFrame.height); | |
7d9f12f3 VS |
165 | } |
166 | } | |
167 | ||
168 | bool wxTopLevelWindowMGL::IsMaximized() const | |
169 | { | |
170 | return m_isMaximized; | |
171 | } | |
172 | ||
173 | void wxTopLevelWindowMGL::Restore() | |
174 | { | |
7cdbf02c | 175 | if ( IsIconized() ) |
7d9f12f3 VS |
176 | { |
177 | Iconize(FALSE); | |
178 | } | |
7cdbf02c | 179 | if ( IsMaximized() ) |
7d9f12f3 VS |
180 | { |
181 | Maximize(FALSE); | |
182 | } | |
183 | } | |
184 | ||
185 | void wxTopLevelWindowMGL::Iconize(bool iconize) | |
186 | { | |
2343d81b | 187 | // FIXME_MGL - use wxDesktop for this |
7d9f12f3 VS |
188 | } |
189 | ||
190 | bool wxTopLevelWindowMGL::IsIconized() const | |
191 | { | |
192 | return m_isIconized; | |
193 | } |