]>
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" | |
31 | ||
32 | // ---------------------------------------------------------------------------- | |
33 | // idle system | |
34 | // ---------------------------------------------------------------------------- | |
35 | ||
36 | extern void wxapp_install_idle_handler(); | |
37 | extern bool g_isIdle; | |
38 | extern int g_openDialogs; | |
39 | ||
40 | // ---------------------------------------------------------------------------- | |
41 | // event tables | |
42 | // ---------------------------------------------------------------------------- | |
43 | ||
44 | #ifndef __WXUNIVERSAL__ | |
45 | IMPLEMENT_DYNAMIC_CLASS(wxTopLevelWindow, wxWindow) | |
46 | #endif | |
47 | ||
48 | // ---------------------------------------------------------------------------- | |
49 | // data | |
50 | // ---------------------------------------------------------------------------- | |
51 | ||
52 | extern wxList wxPendingDelete; | |
53 | ||
54 | ||
55 | // ============================================================================ | |
56 | // implementation | |
57 | // ============================================================================ | |
58 | ||
59 | void wxTopLevelWindowMGL::Init() | |
60 | { | |
61 | m_isIconized = FALSE; | |
62 | m_isMaximized = FALSE; | |
63 | m_fsIsShowing = FALSE; | |
64 | } | |
65 | ||
66 | bool wxTopLevelWindowMGL::Create(wxWindow *parent, | |
67 | wxWindowID id, | |
68 | const wxString& title, | |
69 | const wxPoint& pos, | |
70 | const wxSize& sizeOrig, | |
71 | long style, | |
72 | const wxString &name) | |
73 | { | |
74 | // always create a frame of some reasonable, even if arbitrary, size (at | |
75 | // least for MSW compatibility) | |
76 | wxSize size = sizeOrig; | |
77 | if ( size.x == -1 || size.y == -1 ) | |
78 | { | |
79 | wxSize sizeDpy = wxGetDisplaySize(); | |
80 | if ( size.x == -1 ) | |
81 | size.x = sizeDpy.x / 3; | |
82 | if ( size.y == -1 ) | |
83 | size.y = sizeDpy.y / 5; | |
84 | } | |
85 | ||
86 | wxTopLevelWindows.Append(this); | |
87 | ||
88 | m_title = title; | |
89 | ||
90 | ||
91 | if (m_parent) | |
92 | m_parent->AddChild(this); | |
93 | ||
94 | return TRUE; | |
95 | } | |
96 | ||
97 | wxTopLevelWindowMGL::~wxTopLevelWindowMGL() | |
98 | { | |
99 | m_isBeingDeleted = TRUE; | |
100 | ||
101 | wxTopLevelWindows.DeleteObject(this); | |
102 | ||
103 | if (wxTheApp->GetTopWindow() == this) | |
104 | wxTheApp->SetTopWindow(NULL); | |
105 | ||
106 | if ((wxTopLevelWindows.Number() == 0) && | |
107 | (wxTheApp->GetExitOnFrameDelete())) | |
108 | { | |
109 | wxTheApp->ExitMainLoop(); | |
110 | } | |
111 | } | |
112 | ||
113 | bool wxTopLevelWindowMGL::ShowFullScreen(bool show, long style) | |
114 | { | |
115 | if (show == m_fsIsShowing) return FALSE; // return what? | |
116 | ||
117 | m_fsIsShowing = show; | |
118 | ||
119 | if (show) | |
120 | { | |
121 | m_fsSaveStyle = m_windowStyle; | |
122 | m_fsSaveFlag = style; | |
123 | GetPosition(&m_fsSaveFrame.x, &m_fsSaveFrame.y); | |
124 | GetSize(&m_fsSaveFrame.width, &m_fsSaveFrame.height); | |
125 | ||
126 | if ( style & wxFULLSCREEN_NOCAPTION ) | |
127 | m_windowStyle &= !wxCAPTION; | |
128 | if ( style & wxFULLSCREEN_NOBORDER ) | |
129 | m_windowStyle = wxSIMPLE_BORDER; | |
130 | ||
131 | int x, y; | |
132 | wxDisplaySize(&x, &y); | |
133 | SetSize(0, 0, x, y); | |
134 | } | |
135 | else | |
136 | { | |
137 | m_windowStyle = m_fsSaveStyle; | |
138 | SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y, | |
139 | m_fsSaveFrame.width, m_fsSaveFrame.height); | |
140 | } | |
141 | ||
142 | return TRUE; | |
143 | } | |
144 | ||
145 | void wxTopLevelWindowMGL::Maximize(bool maximize) | |
146 | { | |
147 | if ( maximize && !m_isMaximized ) | |
148 | { | |
149 | int x, y, w, h; | |
150 | ||
151 | GetPosition(&m_savedFrame.x, &m_savedFrame.y); | |
152 | GetSize(&m_savedFrame.width, &m_savedFrame.height); | |
153 | ||
154 | wxClientDisplayRect(&x, &y, &w, &h); | |
155 | SetSize(x, y, w, h); | |
156 | m_isMaximized = TRUE; | |
157 | } | |
158 | else if ( !maximize && m_isMaximized ) | |
159 | { | |
160 | SetSize(m_savedFrame.x, m_savedFrame.y, | |
161 | m_savedFrame.width, m_savedFrame.height); | |
162 | m_isMaximized = FALSE; | |
163 | } | |
164 | } | |
165 | ||
166 | bool wxTopLevelWindowMGL::IsMaximized() const | |
167 | { | |
168 | return m_isMaximized; | |
169 | } | |
170 | ||
171 | void wxTopLevelWindowMGL::Restore() | |
172 | { | |
173 | if ( m_isIconized ) | |
174 | { | |
175 | Iconize(FALSE); | |
176 | } | |
177 | if ( m_isMaximized ) | |
178 | { | |
179 | Maximize(FALSE); | |
180 | } | |
181 | } | |
182 | ||
183 | void wxTopLevelWindowMGL::Iconize(bool iconize) | |
184 | { | |
185 | // FIXME_MGL | |
186 | } | |
187 | ||
188 | bool wxTopLevelWindowMGL::IsIconized() const | |
189 | { | |
190 | return m_isIconized; | |
191 | } |