]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/osx/toplevel.cpp | |
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 | ||
40 | #include "wx/tooltip.h" | |
41 | #include "wx/dnd.h" | |
42 | ||
43 | #if wxUSE_SYSTEM_OPTIONS | |
44 | #include "wx/sysopt.h" | |
45 | #endif | |
46 | ||
47 | // for targeting OSX | |
48 | #include "wx/osx/private.h" | |
49 | ||
50 | // ============================================================================ | |
51 | // wxTopLevelWindowMac implementation | |
52 | // ============================================================================ | |
53 | ||
54 | BEGIN_EVENT_TABLE(wxTopLevelWindowMac, wxTopLevelWindowBase) | |
55 | END_EVENT_TABLE() | |
56 | ||
57 | // ---------------------------------------------------------------------------- | |
58 | // wxTopLevelWindowMac creation | |
59 | // ---------------------------------------------------------------------------- | |
60 | ||
61 | ||
62 | void wxTopLevelWindowMac::Init() | |
63 | { | |
64 | m_iconized = | |
65 | m_maximizeOnShow = false; | |
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 | { | |
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) ) | |
80 | return false; | |
81 | ||
82 | wxWindow::SetLabel( title ) ; | |
83 | m_nowpeer->SetTitle(title, GetFont().GetEncoding() ); | |
84 | wxTopLevelWindows.Append(this); | |
85 | ||
86 | return true; | |
87 | } | |
88 | ||
89 | wxTopLevelWindowMac::~wxTopLevelWindowMac() | |
90 | { | |
91 | } | |
92 | ||
93 | bool wxTopLevelWindowMac::Destroy() | |
94 | { | |
95 | // NB: this will get called during destruction if we don't do it now, | |
96 | // and may fire a kill focus event on a control being destroyed | |
97 | #if wxOSX_USE_CARBON | |
98 | if (m_nowpeer && m_nowpeer->GetWXWindow()) | |
99 | ClearKeyboardFocus( (WindowRef)m_nowpeer->GetWXWindow() ); | |
100 | #endif | |
101 | return wxTopLevelWindowBase::Destroy(); | |
102 | } | |
103 | ||
104 | ||
105 | // ---------------------------------------------------------------------------- | |
106 | // wxTopLevelWindowMac maximize/minimize | |
107 | // ---------------------------------------------------------------------------- | |
108 | ||
109 | void wxTopLevelWindowMac::Maximize(bool maximize) | |
110 | { | |
111 | if ( IsMaximized() != maximize ) | |
112 | m_nowpeer->Maximize(maximize); | |
113 | } | |
114 | ||
115 | bool wxTopLevelWindowMac::IsMaximized() const | |
116 | { | |
117 | if ( m_nowpeer == NULL ) | |
118 | return false; | |
119 | ||
120 | return m_nowpeer->IsMaximized(); | |
121 | } | |
122 | ||
123 | void wxTopLevelWindowMac::Iconize(bool iconize) | |
124 | { | |
125 | if ( IsIconized() != iconize ) | |
126 | m_nowpeer->Iconize(iconize); | |
127 | } | |
128 | ||
129 | bool wxTopLevelWindowMac::IsIconized() const | |
130 | { | |
131 | if ( m_nowpeer == NULL ) | |
132 | return false; | |
133 | ||
134 | return m_nowpeer->IsIconized(); | |
135 | } | |
136 | ||
137 | void wxTopLevelWindowMac::Restore() | |
138 | { | |
139 | if ( IsMaximized() ) | |
140 | Maximize(false); | |
141 | else if ( IsIconized() ) | |
142 | Iconize(false); | |
143 | } | |
144 | ||
145 | // ---------------------------------------------------------------------------- | |
146 | // wxTopLevelWindowMac misc | |
147 | // ---------------------------------------------------------------------------- | |
148 | ||
149 | wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const | |
150 | { | |
151 | return wxPoint(0, 0) ; | |
152 | } | |
153 | ||
154 | void wxTopLevelWindowMac::SetTitle(const wxString& title) | |
155 | { | |
156 | wxWindow::SetLabel( title ) ; | |
157 | if ( m_nowpeer ) | |
158 | m_nowpeer->SetTitle(title, GetFont().GetEncoding() ); | |
159 | } | |
160 | ||
161 | wxString wxTopLevelWindowMac::GetTitle() const | |
162 | { | |
163 | return wxWindow::GetLabel(); | |
164 | } | |
165 | ||
166 | void wxTopLevelWindowMac::ShowWithoutActivating() | |
167 | { | |
168 | // wxTopLevelWindowBase is derived from wxNonOwnedWindow, so don't | |
169 | // call it here. | |
170 | if ( !wxWindow::Show(true) ) | |
171 | return; | |
172 | ||
173 | m_nowpeer->ShowWithoutActivating(); | |
174 | ||
175 | // TODO: Should we call EVT_SIZE here? | |
176 | } | |
177 | ||
178 | bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style) | |
179 | { | |
180 | return m_nowpeer->ShowFullScreen(show, style); | |
181 | } | |
182 | ||
183 | bool wxTopLevelWindowMac::IsFullScreen() const | |
184 | { | |
185 | return m_nowpeer->IsFullScreen(); | |
186 | } | |
187 | ||
188 | void wxTopLevelWindowMac::RequestUserAttention(int flags) | |
189 | { | |
190 | return m_nowpeer->RequestUserAttention(flags); | |
191 | } | |
192 | ||
193 | bool wxTopLevelWindowMac::IsActive() | |
194 | { | |
195 | return m_nowpeer->IsActive(); | |
196 | } | |
197 | ||
198 | void wxTopLevelWindowMac::OSXSetModified(bool modified) | |
199 | { | |
200 | m_nowpeer->SetModified(modified); | |
201 | } | |
202 | ||
203 | bool wxTopLevelWindowMac::OSXIsModified() const | |
204 | { | |
205 | return m_nowpeer->IsModified(); | |
206 | } |