]>
Commit | Line | Data |
---|---|---|
489468fe | 1 | /////////////////////////////////////////////////////////////////////////////// |
524c47aa | 2 | // Name: src/osx/toplevel.cpp |
489468fe SC |
3 | // Purpose: implements wxTopLevelWindow for Mac |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 24.09.01 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2001-2004 Stefan Csomor | |
9 | // License: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | // For compilers that support precompilation, includes "wx.h". | |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
27 | #include "wx/toplevel.h" | |
28 | ||
29 | #ifndef WX_PRECOMP | |
30 | #include "wx/app.h" | |
31 | #include "wx/frame.h" | |
32 | #include "wx/string.h" | |
33 | #include "wx/log.h" | |
34 | #include "wx/intl.h" | |
35 | #include "wx/settings.h" | |
36 | #include "wx/strconv.h" | |
37 | #include "wx/control.h" | |
38 | #endif //WX_PRECOMP | |
39 | ||
489468fe SC |
40 | #include "wx/tooltip.h" |
41 | #include "wx/dnd.h" | |
42 | ||
43 | #if wxUSE_SYSTEM_OPTIONS | |
44 | #include "wx/sysopt.h" | |
45 | #endif | |
46 | ||
489468fe | 47 | // for targeting OSX |
1f0c8f31 | 48 | #include "wx/osx/private.h" |
489468fe SC |
49 | |
50 | // ============================================================================ | |
51 | // wxTopLevelWindowMac implementation | |
52 | // ============================================================================ | |
53 | ||
54 | BEGIN_EVENT_TABLE(wxTopLevelWindowMac, wxTopLevelWindowBase) | |
55 | END_EVENT_TABLE() | |
56 | ||
57 | // ---------------------------------------------------------------------------- | |
58 | // wxTopLevelWindowMac creation | |
59 | // ---------------------------------------------------------------------------- | |
60 | ||
489468fe SC |
61 | |
62 | void wxTopLevelWindowMac::Init() | |
63 | { | |
64 | m_iconized = | |
65 | m_maximizeOnShow = false; | |
489468fe SC |
66 | } |
67 | ||
68 | bool wxTopLevelWindowMac::Create(wxWindow *parent, | |
69 | wxWindowID id, | |
70 | const wxString& title, | |
71 | const wxPoint& pos, | |
72 | const wxSize& size, | |
73 | long style, | |
74 | const wxString& name) | |
75 | { | |
b99c746c SC |
76 | int w = WidthDefault(size.x); |
77 | int h = HeightDefault(size.y); | |
78 | ||
79 | if ( !wxNonOwnedWindow::Create(parent, id, pos, wxSize(w,h), style, name) ) | |
489468fe SC |
80 | return false; |
81 | ||
82 | wxWindow::SetLabel( title ) ; | |
b2680ced | 83 | m_nowpeer->SetTitle(title, GetFont().GetEncoding() ); |
489468fe SC |
84 | wxTopLevelWindows.Append(this); |
85 | ||
86 | return true; | |
87 | } | |
88 | ||
638b3cd7 SC |
89 | bool wxTopLevelWindowMac::Create(wxWindow *parent, |
90 | WXWindow nativeWindow) | |
91 | { | |
92 | if ( !wxNonOwnedWindow::Create(parent, nativeWindow ) ) | |
93 | return false; | |
94 | ||
95 | wxTopLevelWindows.Append(this); | |
96 | ||
97 | return true; | |
98 | } | |
99 | ||
489468fe SC |
100 | wxTopLevelWindowMac::~wxTopLevelWindowMac() |
101 | { | |
489468fe SC |
102 | } |
103 | ||
c9f9deab KO |
104 | bool wxTopLevelWindowMac::Destroy() |
105 | { | |
106 | // NB: this will get called during destruction if we don't do it now, | |
107 | // and may fire a kill focus event on a control being destroyed | |
108 | #if wxOSX_USE_CARBON | |
d4d799e9 | 109 | if (m_nowpeer && m_nowpeer->GetWXWindow()) |
c9f9deab KO |
110 | ClearKeyboardFocus( (WindowRef)m_nowpeer->GetWXWindow() ); |
111 | #endif | |
112 | return wxTopLevelWindowBase::Destroy(); | |
113 | } | |
114 | ||
489468fe SC |
115 | |
116 | // ---------------------------------------------------------------------------- | |
117 | // wxTopLevelWindowMac maximize/minimize | |
118 | // ---------------------------------------------------------------------------- | |
119 | ||
120 | void wxTopLevelWindowMac::Maximize(bool maximize) | |
121 | { | |
b2680ced SC |
122 | if ( IsMaximized() != maximize ) |
123 | m_nowpeer->Maximize(maximize); | |
489468fe SC |
124 | } |
125 | ||
126 | bool wxTopLevelWindowMac::IsMaximized() const | |
127 | { | |
aa47eebb SC |
128 | if ( m_nowpeer == NULL ) |
129 | return false; | |
130 | ||
b2680ced | 131 | return m_nowpeer->IsMaximized(); |
489468fe SC |
132 | } |
133 | ||
134 | void wxTopLevelWindowMac::Iconize(bool iconize) | |
135 | { | |
b2680ced SC |
136 | if ( IsIconized() != iconize ) |
137 | m_nowpeer->Iconize(iconize); | |
489468fe SC |
138 | } |
139 | ||
140 | bool wxTopLevelWindowMac::IsIconized() const | |
141 | { | |
aa47eebb SC |
142 | if ( m_nowpeer == NULL ) |
143 | return false; | |
144 | ||
b2680ced | 145 | return m_nowpeer->IsIconized(); |
489468fe SC |
146 | } |
147 | ||
148 | void wxTopLevelWindowMac::Restore() | |
149 | { | |
150 | if ( IsMaximized() ) | |
151 | Maximize(false); | |
152 | else if ( IsIconized() ) | |
153 | Iconize(false); | |
154 | } | |
155 | ||
156 | // ---------------------------------------------------------------------------- | |
157 | // wxTopLevelWindowMac misc | |
158 | // ---------------------------------------------------------------------------- | |
159 | ||
160 | wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const | |
161 | { | |
162 | return wxPoint(0, 0) ; | |
163 | } | |
164 | ||
165 | void wxTopLevelWindowMac::SetTitle(const wxString& title) | |
166 | { | |
8ec413ce SC |
167 | m_label = title ; |
168 | ||
cd0d451b SC |
169 | if ( m_nowpeer ) |
170 | m_nowpeer->SetTitle(title, GetFont().GetEncoding() ); | |
489468fe SC |
171 | } |
172 | ||
173 | wxString wxTopLevelWindowMac::GetTitle() const | |
174 | { | |
175 | return wxWindow::GetLabel(); | |
176 | } | |
177 | ||
dbc7ceb9 KO |
178 | void wxTopLevelWindowMac::ShowWithoutActivating() |
179 | { | |
598ad2b9 KO |
180 | // wxTopLevelWindowBase is derived from wxNonOwnedWindow, so don't |
181 | // call it here. | |
182 | if ( !wxWindow::Show(true) ) | |
b487746a KO |
183 | return; |
184 | ||
185 | m_nowpeer->ShowWithoutActivating(); | |
186 | ||
187 | // TODO: Should we call EVT_SIZE here? | |
dbc7ceb9 KO |
188 | } |
189 | ||
489468fe SC |
190 | bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style) |
191 | { | |
b2680ced | 192 | return m_nowpeer->ShowFullScreen(show, style); |
489468fe SC |
193 | } |
194 | ||
195 | bool wxTopLevelWindowMac::IsFullScreen() const | |
196 | { | |
b2680ced | 197 | return m_nowpeer->IsFullScreen(); |
489468fe SC |
198 | } |
199 | ||
b2680ced | 200 | void wxTopLevelWindowMac::RequestUserAttention(int flags) |
489468fe | 201 | { |
b2680ced | 202 | return m_nowpeer->RequestUserAttention(flags); |
489468fe | 203 | } |
dbc7ceb9 KO |
204 | |
205 | bool wxTopLevelWindowMac::IsActive() | |
206 | { | |
207 | return m_nowpeer->IsActive(); | |
208 | } | |
efb2fa41 | 209 | |
ebf7d5c4 | 210 | void wxTopLevelWindowMac::OSXSetModified(bool modified) |
efb2fa41 KO |
211 | { |
212 | m_nowpeer->SetModified(modified); | |
213 | } | |
214 | ||
ebf7d5c4 | 215 | bool wxTopLevelWindowMac::OSXIsModified() const |
efb2fa41 | 216 | { |
ebf7d5c4 KO |
217 | return m_nowpeer->IsModified(); |
218 | } |