]>
Commit | Line | Data |
---|---|---|
a15eb0a5 | 1 | /////////////////////////////////////////////////////////////////////////////// |
fb5246be | 2 | // Name: src/mac/carbon/toplevel.cpp |
d66c3960 SC |
3 | // Purpose: implements wxTopLevelWindow for Mac |
4 | // Author: Stefan Csomor | |
a15eb0a5 SC |
5 | // Modified by: |
6 | // Created: 24.09.01 | |
7 | // RCS-ID: $Id$ | |
d66c3960 | 8 | // Copyright: (c) 2001-2004 Stefan Csomor |
65571936 | 9 | // License: wxWindows licence |
a15eb0a5 SC |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
a15eb0a5 SC |
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 | #ifndef WX_PRECOMP | |
28 | #include "wx/app.h" | |
29 | #include "wx/toplevel.h" | |
422644a3 | 30 | #include "wx/frame.h" |
a15eb0a5 SC |
31 | #include "wx/string.h" |
32 | #include "wx/log.h" | |
33 | #include "wx/intl.h" | |
37ec2bd3 | 34 | #include "wx/settings.h" |
2d17efa9 | 35 | #include "wx/strconv.h" |
179e085f | 36 | #include "wx/control.h" |
a15eb0a5 SC |
37 | #endif //WX_PRECOMP |
38 | ||
5f0b2f22 | 39 | #include "wx/mac/uma.h" |
422644a3 | 40 | #include "wx/mac/aga.h" |
7c091673 | 41 | #include "wx/app.h" |
5f0b2f22 | 42 | #include "wx/tooltip.h" |
a07c1212 | 43 | #include "wx/dnd.h" |
a979e444 | 44 | |
1f90939c SC |
45 | #if wxUSE_SYSTEM_OPTIONS |
46 | #include "wx/sysopt.h" | |
47 | #endif | |
5f0b2f22 | 48 | |
3c393c0a | 49 | #ifndef __DARWIN__ |
7f0c3a63 | 50 | #include <ToolUtils.h> |
3c393c0a | 51 | #endif |
dd49c691 | 52 | |
a979e444 | 53 | // for targeting OSX |
eab19a7c RN |
54 | #include "wx/mac/private.h" |
55 | ||
f02a4ffa VZ |
56 | // ---------------------------------------------------------------------------- |
57 | // constants | |
58 | // ---------------------------------------------------------------------------- | |
59 | ||
60 | // trace mask for activation tracing messages | |
61 | static const wxChar *TRACE_ACTIVATE = _T("activation"); | |
62 | ||
a15eb0a5 SC |
63 | // ---------------------------------------------------------------------------- |
64 | // globals | |
65 | // ---------------------------------------------------------------------------- | |
66 | ||
67 | // list of all frames and modeless dialogs | |
32b5be3d RR |
68 | wxWindowList wxModelessWindows; |
69 | ||
6a7e6411 RD |
70 | static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param); |
71 | ||
a15eb0a5 SC |
72 | // ============================================================================ |
73 | // wxTopLevelWindowMac implementation | |
74 | // ============================================================================ | |
75 | ||
facd6764 SC |
76 | BEGIN_EVENT_TABLE(wxTopLevelWindowMac, wxTopLevelWindowBase) |
77 | END_EVENT_TABLE() | |
78 | ||
79 | ||
851b3a88 SC |
80 | // --------------------------------------------------------------------------- |
81 | // Carbon Events | |
82 | // --------------------------------------------------------------------------- | |
83 | ||
851b3a88 SC |
84 | extern long wxMacTranslateKey(unsigned char key, unsigned char code) ; |
85 | ||
1542ea39 | 86 | static const EventTypeSpec eventList[] = |
851b3a88 | 87 | { |
a979e444 | 88 | // TODO: remove control related event like key and mouse (except for WindowLeave events) |
ffc75ee4 | 89 | |
e40298d5 | 90 | { kEventClassKeyboard, kEventRawKeyDown } , |
c5c9378c SC |
91 | { kEventClassKeyboard, kEventRawKeyRepeat } , |
92 | { kEventClassKeyboard, kEventRawKeyUp } , | |
93 | { kEventClassKeyboard, kEventRawKeyModifiersChanged } , | |
94 | ||
ffc75ee4 SC |
95 | { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } , |
96 | { kEventClassTextInput, kEventTextInputUpdateActiveInputArea } , | |
97 | ||
16a76184 | 98 | { kEventClassWindow , kEventWindowShown } , |
851b3a88 SC |
99 | { kEventClassWindow , kEventWindowActivated } , |
100 | { kEventClassWindow , kEventWindowDeactivated } , | |
101 | { kEventClassWindow , kEventWindowBoundsChanging } , | |
102 | { kEventClassWindow , kEventWindowBoundsChanged } , | |
103 | { kEventClassWindow , kEventWindowClose } , | |
104 | ||
a979e444 DS |
105 | // we have to catch these events on the toplevel window level, |
106 | // as controls don't get the raw mouse events anymore | |
902725ee | 107 | |
851b3a88 SC |
108 | { kEventClassMouse , kEventMouseDown } , |
109 | { kEventClassMouse , kEventMouseUp } , | |
de127c69 | 110 | { kEventClassMouse , kEventMouseWheelMoved } , |
851b3a88 SC |
111 | { kEventClassMouse , kEventMouseMoved } , |
112 | { kEventClassMouse , kEventMouseDragged } , | |
851b3a88 SC |
113 | } ; |
114 | ||
c5c9378c SC |
115 | static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) |
116 | { | |
117 | OSStatus result = eventNotHandledErr ; | |
b3bd613a | 118 | // call DoFindFocus instead of FindFocus, because for Composite Windows(like WxGenericListCtrl) |
a979e444 | 119 | // FindFocus does not return the actual focus window, but the enclosing window |
b3bd613a | 120 | wxWindow* focus = wxWindow::DoFindFocus(); |
92a7272f | 121 | if ( focus == NULL ) |
ccf1ef0f | 122 | focus = (wxTopLevelWindowMac*) data ; |
52c3df99 | 123 | |
19fc48c6 | 124 | unsigned char charCode ; |
902725ee | 125 | wxChar uniChar = 0 ; |
1542ea39 | 126 | UInt32 keyCode ; |
c5c9378c | 127 | UInt32 modifiers ; |
e40298d5 JS |
128 | Point point ; |
129 | UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; | |
130 | ||
2d17efa9 SC |
131 | #if wxUSE_UNICODE |
132 | UInt32 dataSize = 0 ; | |
a979e444 | 133 | if ( GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0 , &dataSize, NULL ) == noErr ) |
2d17efa9 SC |
134 | { |
135 | UniChar buf[2] ; | |
902725ee | 136 | |
2d17efa9 | 137 | UniChar* charBuf = buf ; |
902725ee | 138 | |
2d17efa9 SC |
139 | if ( dataSize > 4 ) |
140 | charBuf = new UniChar[ dataSize / sizeof( UniChar) ] ; | |
141 | GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ; | |
a979e444 | 142 | |
2d17efa9 SC |
143 | #if SIZEOF_WCHAR_T == 2 |
144 | uniChar = charBuf[0] ; | |
145 | #else | |
d9d488cf | 146 | wxMBConvUTF16 converter ; |
2d17efa9 | 147 | converter.MB2WC( &uniChar , (const char*)charBuf , 1 ) ; |
902725ee | 148 | #endif |
a979e444 | 149 | |
2d17efa9 SC |
150 | if ( dataSize > 4 ) |
151 | delete[] charBuf ; | |
152 | } | |
153 | #endif | |
154 | ||
a979e444 | 155 | GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode ); |
52c3df99 DS |
156 | GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); |
157 | GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers ); | |
158 | GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &point ); | |
902725ee | 159 | |
e40298d5 | 160 | UInt32 message = (keyCode << 8) + charCode; |
a979e444 | 161 | switch ( GetEventKind( event ) ) |
e40298d5 JS |
162 | { |
163 | case kEventRawKeyRepeat : | |
164 | case kEventRawKeyDown : | |
e40298d5 | 165 | { |
404f1d80 SC |
166 | WXEVENTREF formerEvent = wxTheApp->MacGetCurrentEvent() ; |
167 | WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ; | |
168 | wxTheApp->MacSetCurrentEvent( event , handler ) ; | |
902725ee | 169 | if ( /* focus && */ wxTheApp->MacSendKeyDownEvent( |
2d17efa9 | 170 | focus , message , modifiers , when , point.h , point.v , uniChar ) ) |
404f1d80 SC |
171 | { |
172 | result = noErr ; | |
173 | } | |
174 | wxTheApp->MacSetCurrentEvent( formerEvent , formerHandler ) ; | |
e40298d5 JS |
175 | } |
176 | break ; | |
52c3df99 | 177 | |
e40298d5 | 178 | case kEventRawKeyUp : |
902725ee | 179 | if ( /* focus && */ wxTheApp->MacSendKeyUpEvent( |
2d17efa9 | 180 | focus , message , modifiers , when , point.h , point.v , uniChar ) ) |
e40298d5 JS |
181 | { |
182 | result = noErr ; | |
183 | } | |
184 | break ; | |
52c3df99 | 185 | |
e40298d5 JS |
186 | case kEventRawKeyModifiersChanged : |
187 | { | |
188 | wxKeyEvent event(wxEVT_KEY_DOWN); | |
189 | ||
190 | event.m_shiftDown = modifiers & shiftKey; | |
191 | event.m_controlDown = modifiers & controlKey; | |
192 | event.m_altDown = modifiers & optionKey; | |
193 | event.m_metaDown = modifiers & cmdKey; | |
a979e444 DS |
194 | event.m_x = point.h; |
195 | event.m_y = point.v; | |
196 | ||
2d17efa9 SC |
197 | #if wxUSE_UNICODE |
198 | event.m_uniChar = uniChar ; | |
199 | #endif | |
a979e444 | 200 | |
687706f5 | 201 | event.SetTimestamp(when); |
e40298d5 JS |
202 | event.SetEventObject(focus); |
203 | ||
902725ee | 204 | if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & controlKey ) |
e40298d5 JS |
205 | { |
206 | event.m_keyCode = WXK_CONTROL ; | |
207 | event.SetEventType( ( modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; | |
208 | focus->GetEventHandler()->ProcessEvent( event ) ; | |
209 | } | |
902725ee | 210 | if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & shiftKey ) |
e40298d5 JS |
211 | { |
212 | event.m_keyCode = WXK_SHIFT ; | |
213 | event.SetEventType( ( modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; | |
214 | focus->GetEventHandler()->ProcessEvent( event ) ; | |
215 | } | |
902725ee | 216 | if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & optionKey ) |
e40298d5 JS |
217 | { |
218 | event.m_keyCode = WXK_ALT ; | |
219 | event.SetEventType( ( modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; | |
220 | focus->GetEventHandler()->ProcessEvent( event ) ; | |
221 | } | |
902725ee | 222 | if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & cmdKey ) |
b7aec135 SC |
223 | { |
224 | event.m_keyCode = WXK_COMMAND ; | |
225 | event.SetEventType( ( modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ; | |
226 | focus->GetEventHandler()->ProcessEvent( event ) ; | |
227 | } | |
a979e444 | 228 | |
2a1f999f | 229 | wxApp::s_lastModifiers = modifiers ; |
e40298d5 | 230 | } |
902725ee | 231 | break ; |
52c3df99 DS |
232 | |
233 | default: | |
234 | break; | |
e40298d5 | 235 | } |
851b3a88 SC |
236 | |
237 | return result ; | |
238 | } | |
239 | ||
facd6764 | 240 | // we don't interfere with foreign controls on our toplevel windows, therefore we always give back eventNotHandledErr |
52c3df99 | 241 | // for windows that we didn't create (like eg Scrollbars in a databrowser), or for controls where we did not handle the |
facd6764 | 242 | // mouse down at all |
52c3df99 | 243 | // |
facd6764 | 244 | // This handler can also be called from app level where data (ie target window) may be null or a non wx window |
1542ea39 | 245 | |
facd6764 | 246 | wxWindow* g_MacLastWindow = NULL ; |
a3195b73 | 247 | |
86a9144f SC |
248 | static EventMouseButton lastButton = 0 ; |
249 | ||
facd6764 SC |
250 | static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ) |
251 | { | |
252 | UInt32 modifiers = cEvent.GetParameter<UInt32>(kEventParamKeyModifiers, typeUInt32) ; | |
253 | Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ; | |
67245665 | 254 | |
902725ee | 255 | // this parameter are not given for all events |
facd6764 | 256 | EventMouseButton button = 0 ; |
902725ee | 257 | UInt32 clickCount = 0 ; |
a979e444 DS |
258 | cEvent.GetParameter<EventMouseButton>( kEventParamMouseButton, typeMouseButton , &button ) ; |
259 | cEvent.GetParameter<UInt32>( kEventParamClickCount, typeUInt32 , &clickCount ) ; | |
facd6764 SC |
260 | |
261 | wxevent.m_x = screenMouseLocation.h; | |
262 | wxevent.m_y = screenMouseLocation.v; | |
263 | wxevent.m_shiftDown = modifiers & shiftKey; | |
264 | wxevent.m_controlDown = modifiers & controlKey; | |
265 | wxevent.m_altDown = modifiers & optionKey; | |
266 | wxevent.m_metaDown = modifiers & cmdKey; | |
267 | wxevent.SetTimestamp( cEvent.GetTicks() ) ; | |
52c3df99 | 268 | |
902725ee | 269 | // a control click is interpreted as a right click |
facd6764 | 270 | if ( button == kEventMouseButtonPrimary && (modifiers & controlKey) ) |
facd6764 | 271 | button = kEventMouseButtonSecondary ; |
902725ee | 272 | |
b343fb9f SC |
273 | // otherwise we report double clicks by connecting a left click with a ctrl-left click |
274 | if ( clickCount > 1 && button != lastButton ) | |
275 | clickCount = 1 ; | |
902725ee | 276 | |
86a9144f SC |
277 | // we must make sure that our synthetic 'right' button corresponds in |
278 | // mouse down, moved and mouse up, and does not deliver a right down and left up | |
902725ee | 279 | |
86a9144f SC |
280 | if ( cEvent.GetKind() == kEventMouseDown ) |
281 | lastButton = button ; | |
902725ee | 282 | |
4e4e6dce | 283 | if ( button == 0 ) |
902725ee | 284 | lastButton = 0 ; |
86a9144f SC |
285 | else if ( lastButton ) |
286 | button = lastButton ; | |
facd6764 | 287 | |
a979e444 DS |
288 | // determine the correct down state, wx does not want a 'down' for a mouseUp event, |
289 | // while mac delivers this button | |
facd6764 SC |
290 | if ( button != 0 && cEvent.GetKind() != kEventMouseUp ) |
291 | { | |
a979e444 | 292 | switch ( button ) |
e40298d5 | 293 | { |
facd6764 SC |
294 | case kEventMouseButtonPrimary : |
295 | wxevent.m_leftDown = true ; | |
e40298d5 | 296 | break ; |
52c3df99 | 297 | |
facd6764 SC |
298 | case kEventMouseButtonSecondary : |
299 | wxevent.m_rightDown = true ; | |
e40298d5 | 300 | break ; |
52c3df99 | 301 | |
facd6764 SC |
302 | case kEventMouseButtonTertiary : |
303 | wxevent.m_middleDown = true ; | |
e40298d5 | 304 | break ; |
52c3df99 DS |
305 | |
306 | default: | |
307 | break ; | |
facd6764 SC |
308 | } |
309 | } | |
52c3df99 | 310 | |
90ff87d7 SC |
311 | // translate into wx types |
312 | switch ( cEvent.GetKind() ) | |
facd6764 | 313 | { |
90ff87d7 | 314 | case kEventMouseDown : |
52c3df99 | 315 | switch ( button ) |
90ff87d7 SC |
316 | { |
317 | case kEventMouseButtonPrimary : | |
a979e444 | 318 | wxevent.SetEventType( clickCount > 1 ? wxEVT_LEFT_DCLICK : wxEVT_LEFT_DOWN ) ; |
90ff87d7 | 319 | break ; |
52c3df99 | 320 | |
90ff87d7 SC |
321 | case kEventMouseButtonSecondary : |
322 | wxevent.SetEventType( clickCount > 1 ? wxEVT_RIGHT_DCLICK : wxEVT_RIGHT_DOWN ) ; | |
323 | break ; | |
52c3df99 | 324 | |
90ff87d7 | 325 | case kEventMouseButtonTertiary : |
a979e444 | 326 | wxevent.SetEventType( clickCount > 1 ? wxEVT_MIDDLE_DCLICK : wxEVT_MIDDLE_DOWN ) ; |
90ff87d7 | 327 | break ; |
52c3df99 DS |
328 | |
329 | default: | |
330 | break ; | |
90ff87d7 SC |
331 | } |
332 | break ; | |
52c3df99 | 333 | |
90ff87d7 | 334 | case kEventMouseUp : |
52c3df99 | 335 | switch ( button ) |
90ff87d7 SC |
336 | { |
337 | case kEventMouseButtonPrimary : | |
338 | wxevent.SetEventType( wxEVT_LEFT_UP ) ; | |
339 | break ; | |
52c3df99 | 340 | |
90ff87d7 SC |
341 | case kEventMouseButtonSecondary : |
342 | wxevent.SetEventType( wxEVT_RIGHT_UP ) ; | |
343 | break ; | |
52c3df99 | 344 | |
90ff87d7 SC |
345 | case kEventMouseButtonTertiary : |
346 | wxevent.SetEventType( wxEVT_MIDDLE_UP ) ; | |
347 | break ; | |
52c3df99 DS |
348 | |
349 | default: | |
350 | break ; | |
90ff87d7 SC |
351 | } |
352 | break ; | |
52c3df99 | 353 | |
2cce9b11 | 354 | case kEventMouseWheelMoved : |
52c3df99 | 355 | { |
a979e444 | 356 | wxevent.SetEventType( wxEVT_MOUSEWHEEL ) ; |
facd6764 SC |
357 | |
358 | // EventMouseWheelAxis axis = cEvent.GetParameter<EventMouseWheelAxis>(kEventParamMouseWheelAxis, typeMouseWheelAxis) ; | |
359 | SInt32 delta = cEvent.GetParameter<SInt32>(kEventParamMouseWheelDelta, typeLongInteger) ; | |
360 | ||
361 | wxevent.m_wheelRotation = delta; | |
362 | wxevent.m_wheelDelta = 1; | |
363 | wxevent.m_linesPerAction = 1; | |
52c3df99 DS |
364 | } |
365 | break ; | |
366 | ||
90ff87d7 | 367 | default : |
a979e444 | 368 | wxevent.SetEventType( wxEVT_MOTION ) ; |
90ff87d7 | 369 | break ; |
902725ee | 370 | } |
facd6764 SC |
371 | } |
372 | ||
fbfb8bcc | 373 | ControlRef wxMacFindSubControl( wxTopLevelWindowMac* toplevelWindow, const Point& location , ControlRef superControl , ControlPartCode *outPart ) |
facd6764 SC |
374 | { |
375 | if ( superControl ) | |
376 | { | |
377 | UInt16 childrenCount = 0 ; | |
a979e444 DS |
378 | ControlHandle sibling ; |
379 | Rect r ; | |
902725ee | 380 | OSStatus err = CountSubControls( superControl , &childrenCount ) ; |
facd6764 SC |
381 | if ( err == errControlIsNotEmbedder ) |
382 | return NULL ; | |
a979e444 | 383 | |
facd6764 | 384 | wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") ) ; |
902725ee | 385 | |
facd6764 SC |
386 | for ( UInt16 i = childrenCount ; i >=1 ; --i ) |
387 | { | |
facd6764 SC |
388 | err = GetIndexedSubControl( superControl , i , & sibling ) ; |
389 | if ( err == errControlIsNotEmbedder ) | |
390 | return NULL ; | |
902725ee | 391 | |
facd6764 SC |
392 | wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") ) ; |
393 | if ( IsControlVisible( sibling ) ) | |
394 | { | |
d6fd667b | 395 | UMAGetControlBoundsInWindowCoords( sibling , &r ) ; |
facd6764 | 396 | if ( MacPtInRect( location , &r ) ) |
de127c69 | 397 | { |
789ae0cf | 398 | ControlHandle child = wxMacFindSubControl( toplevelWindow , location , sibling , outPart ) ; |
facd6764 | 399 | if ( child ) |
a979e444 | 400 | { |
facd6764 | 401 | return child ; |
a979e444 | 402 | } |
facd6764 | 403 | else |
de127c69 | 404 | { |
d6fd667b | 405 | Point testLocation = location ; |
789ae0cf SC |
406 | |
407 | if ( toplevelWindow && toplevelWindow->MacUsesCompositing() ) | |
408 | { | |
409 | testLocation.h -= r.left ; | |
410 | testLocation.v -= r.top ; | |
411 | } | |
902725ee | 412 | |
d6fd667b | 413 | *outPart = TestControl( sibling , testLocation ) ; |
a979e444 | 414 | |
facd6764 | 415 | return sibling ; |
de127c69 GD |
416 | } |
417 | } | |
facd6764 | 418 | } |
e40298d5 JS |
419 | } |
420 | } | |
52c3df99 | 421 | |
facd6764 SC |
422 | return NULL ; |
423 | } | |
1542ea39 | 424 | |
fbfb8bcc | 425 | ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow , const Point& location , WindowRef window , ControlPartCode *outPart ) |
facd6764 SC |
426 | { |
427 | #if TARGET_API_MAC_OSX | |
789ae0cf | 428 | if ( UMAGetSystemVersion() >= 0x1030 && ( toplevelWindow == 0 || toplevelWindow->MacUsesCompositing() ) ) |
30e0b1c9 SC |
429 | return FindControlUnderMouse( location , window , outPart ) ; |
430 | #endif | |
a979e444 | 431 | |
facd6764 SC |
432 | ControlRef rootControl = NULL ; |
433 | verify_noerr( GetRootControl( window , &rootControl ) ) ; | |
30e0b1c9 | 434 | |
a979e444 | 435 | return wxMacFindSubControl( toplevelWindow , location , rootControl , outPart ) ; |
facd6764 | 436 | } |
3c393c0a SC |
437 | |
438 | #define NEW_CAPTURE_HANDLING 1 | |
439 | ||
facd6764 SC |
440 | pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) |
441 | { | |
789ae0cf | 442 | wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ; |
902725ee | 443 | |
facd6764 SC |
444 | OSStatus result = eventNotHandledErr ; |
445 | ||
446 | wxMacCarbonEvent cEvent( event ) ; | |
902725ee | 447 | |
facd6764 SC |
448 | Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ; |
449 | Point windowMouseLocation = screenMouseLocation ; | |
450 | ||
451 | WindowRef window ; | |
452 | short windowPart = ::FindWindow(screenMouseLocation, &window); | |
453 | ||
454 | wxWindow* currentMouseWindow = NULL ; | |
d88ffaaa | 455 | ControlRef control = NULL ; |
902725ee | 456 | |
3c393c0a SC |
457 | #if NEW_CAPTURE_HANDLING |
458 | if ( wxApp::s_captureWindow ) | |
459 | { | |
460 | window = (WindowRef) wxApp::s_captureWindow->MacGetTopLevelWindowRef() ; | |
8fc754bf | 461 | windowPart = inContent ; |
3c393c0a SC |
462 | } |
463 | #endif | |
fb5246be | 464 | |
facd6764 SC |
465 | if ( window ) |
466 | { | |
d6fd667b | 467 | QDGlobalToLocalPoint( UMAGetWindowPort(window ) , &windowMouseLocation ) ; |
facd6764 | 468 | |
3c393c0a SC |
469 | if ( wxApp::s_captureWindow |
470 | #if !NEW_CAPTURE_HANDLING | |
471 | && wxApp::s_captureWindow->MacGetTopLevelWindowRef() == (WXWindow) window && windowPart == inContent | |
472 | #endif | |
473 | ) | |
facd6764 | 474 | { |
2a1f999f | 475 | currentMouseWindow = wxApp::s_captureWindow ; |
facd6764 SC |
476 | } |
477 | else if ( (IsWindowActive(window) && windowPart == inContent) ) | |
478 | { | |
479 | ControlPartCode part ; | |
789ae0cf | 480 | control = wxMacFindControlUnderMouse( toplevelWindow , windowMouseLocation , window , &part ) ; |
d88ffaaa | 481 | // if there is no control below the mouse position, send the event to the toplevel window itself |
b19bf058 | 482 | if ( control == 0 ) |
a979e444 | 483 | { |
b19bf058 | 484 | currentMouseWindow = (wxWindow*) data ; |
a979e444 | 485 | } |
b19bf058 | 486 | else |
b16f4bfa | 487 | { |
b19bf058 | 488 | currentMouseWindow = wxFindControlFromMacControl( control ) ; |
8198ae50 | 489 | if ( currentMouseWindow == NULL && cEvent.GetKind() == kEventMouseMoved ) |
b16f4bfa | 490 | { |
179e085f | 491 | #if wxUSE_TOOLBAR |
902725ee WS |
492 | // for wxToolBar to function we have to send certaint events to it |
493 | // instead of its children (wxToolBarTools) | |
b16f4bfa SC |
494 | ControlRef parent ; |
495 | GetSuperControl(control, &parent ); | |
496 | wxWindow *wxParent = wxFindControlFromMacControl( parent ) ; | |
497 | if ( wxParent && wxParent->IsKindOf( CLASSINFO( wxToolBar ) ) ) | |
498 | currentMouseWindow = wxParent ; | |
179e085f | 499 | #endif |
b16f4bfa SC |
500 | } |
501 | } | |
f0756835 VZ |
502 | |
503 | // disabled windows must not get any input messages | |
504 | if ( currentMouseWindow && !currentMouseWindow->MacIsReallyEnabled() ) | |
505 | currentMouseWindow = NULL; | |
902725ee | 506 | } |
facd6764 | 507 | } |
902725ee | 508 | |
facd6764 SC |
509 | wxMouseEvent wxevent(wxEVT_LEFT_DOWN); |
510 | SetupMouseEvent( wxevent , cEvent ) ; | |
511 | ||
512 | // handle all enter / leave events | |
902725ee | 513 | |
facd6764 SC |
514 | if ( currentMouseWindow != g_MacLastWindow ) |
515 | { | |
516 | if ( g_MacLastWindow ) | |
517 | { | |
518 | wxMouseEvent eventleave(wxevent); | |
519 | eventleave.SetEventType( wxEVT_LEAVE_WINDOW ); | |
520 | g_MacLastWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y ); | |
521 | eventleave.SetEventObject( g_MacLastWindow ) ; | |
d4bd6c97 | 522 | wxevent.SetId( g_MacLastWindow->GetId() ) ; |
a979e444 | 523 | |
facd6764 SC |
524 | #if wxUSE_TOOLTIPS |
525 | wxToolTip::RelayEvent( g_MacLastWindow , eventleave); | |
a979e444 DS |
526 | #endif |
527 | ||
facd6764 SC |
528 | g_MacLastWindow->GetEventHandler()->ProcessEvent(eventleave); |
529 | } | |
52c3df99 | 530 | |
facd6764 SC |
531 | if ( currentMouseWindow ) |
532 | { | |
533 | wxMouseEvent evententer(wxevent); | |
534 | evententer.SetEventType( wxEVT_ENTER_WINDOW ); | |
535 | currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y ); | |
536 | evententer.SetEventObject( currentMouseWindow ) ; | |
d4bd6c97 | 537 | wxevent.SetId( currentMouseWindow->GetId() ) ; |
a979e444 | 538 | |
facd6764 | 539 | #if wxUSE_TOOLTIPS |
a979e444 DS |
540 | wxToolTip::RelayEvent( currentMouseWindow , evententer ); |
541 | #endif | |
542 | ||
facd6764 SC |
543 | currentMouseWindow->GetEventHandler()->ProcessEvent(evententer); |
544 | } | |
52c3df99 | 545 | |
facd6764 SC |
546 | g_MacLastWindow = currentMouseWindow ; |
547 | } | |
902725ee | 548 | |
facd6764 SC |
549 | if ( windowPart == inMenuBar ) |
550 | { | |
551 | // special case menu bar, as we are having a low-level runloop we must do it ourselves | |
552 | if ( cEvent.GetKind() == kEventMouseDown ) | |
553 | { | |
554 | ::MenuSelect( screenMouseLocation ) ; | |
555 | result = noErr ; | |
556 | } | |
52c3df99 | 557 | } |
facd6764 SC |
558 | else if ( currentMouseWindow ) |
559 | { | |
e10e9469 | 560 | wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent(); |
62ade180 RR |
561 | |
562 | currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ; | |
902725ee | 563 | |
facd6764 | 564 | wxevent.SetEventObject( currentMouseWindow ) ; |
d4bd6c97 | 565 | wxevent.SetId( currentMouseWindow->GetId() ) ; |
facd6764 | 566 | |
facd6764 | 567 | // make tooltips current |
902725ee | 568 | |
a979e444 | 569 | #if wxUSE_TOOLTIPS |
f124c908 | 570 | if ( wxevent.GetEventType() == wxEVT_MOTION ) |
a979e444 DS |
571 | wxToolTip::RelayEvent( currentMouseWindow , wxevent ); |
572 | #endif | |
573 | ||
facd6764 | 574 | if ( currentMouseWindow->GetEventHandler()->ProcessEvent(wxevent) ) |
62ade180 | 575 | { |
902725ee | 576 | if ((currentMouseWindowParent != NULL) && |
62ade180 RR |
577 | (currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL)) |
578 | currentMouseWindow = NULL; | |
902725ee | 579 | |
facd6764 | 580 | result = noErr; |
62ade180 | 581 | } |
30e0b1c9 SC |
582 | else |
583 | { | |
f90387b4 VZ |
584 | // if the user code did _not_ handle the event, then perform the |
585 | // default processing | |
586 | if ( wxevent.GetEventType() == wxEVT_LEFT_DOWN ) | |
587 | { | |
588 | // ... that is set focus to this window | |
589 | if (currentMouseWindow->AcceptsFocus() && wxWindow::FindFocus()!=currentMouseWindow) | |
590 | currentMouseWindow->SetFocus(); | |
591 | } | |
592 | ||
30e0b1c9 SC |
593 | ControlPartCode dummyPart ; |
594 | // if built-in find control is finding the wrong control (ie static box instead of overlaid | |
595 | // button, we cannot let the standard handler do its job, but must handle manually | |
596 | ||
902725ee | 597 | if ( ( cEvent.GetKind() == kEventMouseDown ) |
23ad132c | 598 | #ifdef __WXMAC_OSX__ |
902725ee WS |
599 | && |
600 | (FindControlUnderMouse(windowMouseLocation , window , &dummyPart) != | |
601 | wxMacFindControlUnderMouse( toplevelWindow , windowMouseLocation , window , &dummyPart ) ) | |
23ad132c SC |
602 | #endif |
603 | ) | |
30e0b1c9 | 604 | { |
902725ee | 605 | if ( currentMouseWindow->MacIsReallyEnabled() ) |
7ce1a4e1 SC |
606 | { |
607 | EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ; | |
608 | Point clickLocation = windowMouseLocation ; | |
789ae0cf SC |
609 | |
610 | if ( toplevelWindow->MacUsesCompositing() ) | |
611 | currentMouseWindow->MacRootWindowToWindow( &clickLocation.h , &clickLocation.v ) ; | |
612 | ||
7ce1a4e1 SC |
613 | HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation , |
614 | modifiers , (ControlActionUPP ) -1 ) ; | |
902725ee WS |
615 | |
616 | if ((currentMouseWindowParent != NULL) && | |
62ade180 | 617 | (currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL)) |
a979e444 | 618 | { |
e10e9469 | 619 | currentMouseWindow = NULL; |
a979e444 | 620 | } |
7ce1a4e1 | 621 | } |
a979e444 | 622 | |
30e0b1c9 SC |
623 | result = noErr ; |
624 | } | |
625 | } | |
52c3df99 | 626 | |
2a1f999f | 627 | if ( cEvent.GetKind() == kEventMouseUp && wxApp::s_captureWindow ) |
facd6764 | 628 | { |
2a1f999f | 629 | wxApp::s_captureWindow = NULL ; |
facd6764 SC |
630 | // update cursor ? |
631 | } | |
6d63e2fc SC |
632 | |
633 | // update cursor | |
902725ee | 634 | |
6d63e2fc SC |
635 | wxWindow* cursorTarget = currentMouseWindow ; |
636 | wxPoint cursorPoint( wxevent.m_x , wxevent.m_y ) ; | |
637 | ||
52c3df99 | 638 | while ( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) ) |
6d63e2fc SC |
639 | { |
640 | cursorTarget = cursorTarget->GetParent() ; | |
641 | if ( cursorTarget ) | |
e10e9469 | 642 | cursorPoint += cursorTarget->GetPosition(); |
6d63e2fc SC |
643 | } |
644 | ||
f124c908 VZ |
645 | } |
646 | else // currentMouseWindow == NULL | |
d88ffaaa SC |
647 | { |
648 | // don't mess with controls we don't know about | |
649 | // for some reason returning eventNotHandledErr does not lead to the correct behaviour | |
650 | // so we try sending them the correct control directly | |
e4b7e0b4 | 651 | if ( cEvent.GetKind() == kEventMouseDown && toplevelWindow && control ) |
d88ffaaa SC |
652 | { |
653 | EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ; | |
654 | Point clickLocation = windowMouseLocation ; | |
f124c908 | 655 | #if TARGET_API_MAC_OSX |
789ae0cf SC |
656 | if ( toplevelWindow->MacUsesCompositing() ) |
657 | { | |
789ae0cf SC |
658 | HIPoint hiPoint ; |
659 | hiPoint.x = clickLocation.h ; | |
660 | hiPoint.y = clickLocation.v ; | |
661 | HIViewConvertPoint( &hiPoint , (ControlRef) toplevelWindow->GetHandle() , control ) ; | |
662 | clickLocation.h = (int)hiPoint.x ; | |
663 | clickLocation.v = (int)hiPoint.y ; | |
789ae0cf | 664 | } |
f124c908 | 665 | #endif // TARGET_API_MAC_OSX |
52c3df99 DS |
666 | |
667 | HandleControlClick( control , clickLocation , modifiers , (ControlActionUPP ) -1 ) ; | |
d88ffaaa SC |
668 | result = noErr ; |
669 | } | |
670 | } | |
a979e444 | 671 | |
facd6764 | 672 | return result ; |
851b3a88 | 673 | } |
facd6764 SC |
674 | |
675 | static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) | |
851b3a88 SC |
676 | { |
677 | OSStatus result = eventNotHandledErr ; | |
851b3a88 | 678 | |
facd6764 | 679 | wxMacCarbonEvent cEvent( event ) ; |
902725ee | 680 | |
facd6764 | 681 | // WindowRef windowRef = cEvent.GetParameter<WindowRef>(kEventParamDirectObject) ; |
e40298d5 | 682 | wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ; |
1542ea39 | 683 | |
52c3df99 | 684 | switch ( GetEventKind( event ) ) |
e40298d5 | 685 | { |
e40298d5 | 686 | case kEventWindowActivated : |
facd6764 SC |
687 | { |
688 | toplevelWindow->MacActivate( cEvent.GetTicks() , true) ; | |
facd6764 SC |
689 | wxActivateEvent wxevent(wxEVT_ACTIVATE, true , toplevelWindow->GetId()); |
690 | wxevent.SetTimestamp( cEvent.GetTicks() ) ; | |
691 | wxevent.SetEventObject(toplevelWindow); | |
692 | toplevelWindow->GetEventHandler()->ProcessEvent(wxevent); | |
73fe67bd | 693 | // we still sending an eventNotHandledErr in order to allow for default processing |
facd6764 | 694 | } |
52c3df99 DS |
695 | break ; |
696 | ||
e40298d5 | 697 | case kEventWindowDeactivated : |
facd6764 SC |
698 | { |
699 | toplevelWindow->MacActivate(cEvent.GetTicks() , false) ; | |
700 | wxActivateEvent wxevent(wxEVT_ACTIVATE, false , toplevelWindow->GetId()); | |
701 | wxevent.SetTimestamp( cEvent.GetTicks() ) ; | |
702 | wxevent.SetEventObject(toplevelWindow); | |
703 | toplevelWindow->GetEventHandler()->ProcessEvent(wxevent); | |
73fe67bd | 704 | // we still sending an eventNotHandledErr in order to allow for default processing |
facd6764 | 705 | } |
52c3df99 DS |
706 | break ; |
707 | ||
902725ee | 708 | case kEventWindowShown : |
902725ee WS |
709 | toplevelWindow->Refresh() ; |
710 | result = noErr ; | |
711 | break ; | |
52c3df99 | 712 | |
e40298d5 | 713 | case kEventWindowClose : |
52c3df99 | 714 | toplevelWindow->Close() ; |
e40298d5 JS |
715 | result = noErr ; |
716 | break ; | |
52c3df99 | 717 | |
e40298d5 | 718 | case kEventWindowBoundsChanged : |
facd6764 | 719 | { |
52c3df99 | 720 | UInt32 attributes = cEvent.GetParameter<UInt32>(kEventParamAttributes, typeUInt32) ; |
facd6764 SC |
721 | Rect newRect = cEvent.GetParameter<Rect>(kEventParamCurrentBounds) ; |
722 | wxRect r( newRect.left , newRect.top , newRect.right - newRect.left , newRect.bottom - newRect.top ) ; | |
723 | if ( attributes & kWindowBoundsChangeSizeChanged ) | |
e40298d5 | 724 | { |
facd6764 SC |
725 | // according to the other ports we handle this within the OS level |
726 | // resize event, not within a wxSizeEvent | |
727 | wxFrame *frame = wxDynamicCast( toplevelWindow , wxFrame ) ; | |
728 | if ( frame ) | |
729 | { | |
6f02a879 | 730 | frame->PositionBars(); |
facd6764 | 731 | } |
1542ea39 | 732 | |
facd6764 SC |
733 | wxSizeEvent event( r.GetSize() , toplevelWindow->GetId() ) ; |
734 | event.SetEventObject( toplevelWindow ) ; | |
851b3a88 | 735 | |
facd6764 | 736 | toplevelWindow->GetEventHandler()->ProcessEvent(event) ; |
5e533062 | 737 | toplevelWindow->wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified |
e40298d5 | 738 | } |
52c3df99 | 739 | |
facd6764 SC |
740 | if ( attributes & kWindowBoundsChangeOriginChanged ) |
741 | { | |
742 | wxMoveEvent event( r.GetLeftTop() , toplevelWindow->GetId() ) ; | |
743 | event.SetEventObject( toplevelWindow ) ; | |
744 | toplevelWindow->GetEventHandler()->ProcessEvent(event) ; | |
745 | } | |
52c3df99 | 746 | |
facd6764 | 747 | result = noErr ; |
facd6764 | 748 | } |
52c3df99 DS |
749 | break ; |
750 | ||
f81bfef9 | 751 | case kEventWindowBoundsChanging : |
facd6764 SC |
752 | { |
753 | UInt32 attributes = cEvent.GetParameter<UInt32>(kEventParamAttributes,typeUInt32) ; | |
754 | Rect newRect = cEvent.GetParameter<Rect>(kEventParamCurrentBounds) ; | |
83901ec2 | 755 | |
facd6764 SC |
756 | if ( (attributes & kWindowBoundsChangeSizeChanged) || (attributes & kWindowBoundsChangeOriginChanged) ) |
757 | { | |
29281095 SC |
758 | // all (Mac) rects are in content area coordinates, all wxRects in structure coordinates |
759 | int left , top , right , bottom ; | |
760 | toplevelWindow->MacGetContentAreaInset( left , top , right , bottom ) ; | |
52c3df99 DS |
761 | |
762 | wxRect r( | |
763 | newRect.left - left, | |
764 | newRect.top - top, | |
765 | newRect.right - newRect.left + left + right, | |
766 | newRect.bottom - newRect.top + top + bottom ) ; | |
767 | ||
facd6764 SC |
768 | // this is a EVT_SIZING not a EVT_SIZE type ! |
769 | wxSizeEvent wxevent( r , toplevelWindow->GetId() ) ; | |
770 | wxevent.SetEventObject( toplevelWindow ) ; | |
771 | wxRect adjustR = r ; | |
772 | if ( toplevelWindow->GetEventHandler()->ProcessEvent(wxevent) ) | |
facd6764 | 773 | adjustR = wxevent.GetRect() ; |
29281095 | 774 | |
facd6764 SC |
775 | if ( toplevelWindow->GetMaxWidth() != -1 && adjustR.GetWidth() > toplevelWindow->GetMaxWidth() ) |
776 | adjustR.SetWidth( toplevelWindow->GetMaxWidth() ) ; | |
2c25bd55 | 777 | if ( toplevelWindow->GetMaxHeight() != -1 && adjustR.GetHeight() > toplevelWindow->GetMaxHeight() ) |
facd6764 SC |
778 | adjustR.SetHeight( toplevelWindow->GetMaxHeight() ) ; |
779 | if ( toplevelWindow->GetMinWidth() != -1 && adjustR.GetWidth() < toplevelWindow->GetMinWidth() ) | |
780 | adjustR.SetWidth( toplevelWindow->GetMinWidth() ) ; | |
2c25bd55 | 781 | if ( toplevelWindow->GetMinHeight() != -1 && adjustR.GetHeight() < toplevelWindow->GetMinHeight() ) |
facd6764 | 782 | adjustR.SetHeight( toplevelWindow->GetMinHeight() ) ; |
4a5f2351 | 783 | const Rect adjustedRect = { adjustR.y + top , adjustR.x + left , adjustR.y + adjustR.height - bottom , adjustR.x + adjustR.width - right } ; |
facd6764 | 784 | if ( !EqualRect( &newRect , &adjustedRect ) ) |
1f919f38 | 785 | cEvent.SetParameter<Rect>( kEventParamCurrentBounds , &adjustedRect ) ; |
4817190d | 786 | toplevelWindow->wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified |
f81bfef9 | 787 | } |
facd6764 | 788 | |
902725ee | 789 | result = noErr ; |
facd6764 | 790 | } |
52c3df99 DS |
791 | break ; |
792 | ||
e40298d5 JS |
793 | default : |
794 | break ; | |
795 | } | |
52c3df99 | 796 | |
e40298d5 | 797 | return result ; |
851b3a88 SC |
798 | } |
799 | ||
ffc75ee4 SC |
800 | // mix this in from window.cpp |
801 | pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ; | |
802 | ||
facd6764 | 803 | pascal OSStatus wxMacTopLevelEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) |
851b3a88 SC |
804 | { |
805 | OSStatus result = eventNotHandledErr ; | |
806 | ||
807 | switch ( GetEventClass( event ) ) | |
808 | { | |
ffc75ee4 SC |
809 | case kEventClassTextInput : |
810 | result = wxMacUnicodeTextEventHandler( handler, event , data ) ; | |
811 | break ; | |
812 | ||
c5c9378c | 813 | case kEventClassKeyboard : |
e40298d5 | 814 | result = KeyboardEventHandler( handler, event , data ) ; |
c5c9378c | 815 | break ; |
52c3df99 | 816 | |
851b3a88 | 817 | case kEventClassWindow : |
facd6764 | 818 | result = wxMacTopLevelWindowEventHandler( handler, event , data ) ; |
e40298d5 | 819 | break ; |
52c3df99 | 820 | |
851b3a88 | 821 | case kEventClassMouse : |
facd6764 | 822 | result = wxMacTopLevelMouseEventHandler( handler, event , data ) ; |
e40298d5 | 823 | break ; |
52c3df99 | 824 | |
851b3a88 SC |
825 | default : |
826 | break ; | |
827 | } | |
52c3df99 | 828 | |
851b3a88 SC |
829 | return result ; |
830 | } | |
831 | ||
facd6764 | 832 | DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacTopLevelEventHandler ) |
851b3a88 | 833 | |
5f0b2f22 SC |
834 | // --------------------------------------------------------------------------- |
835 | // wxWindowMac utility functions | |
836 | // --------------------------------------------------------------------------- | |
837 | ||
838 | // Find an item given the Macintosh Window Reference | |
839 | ||
71f2fb52 RN |
840 | WX_DECLARE_HASH_MAP(WindowRef, wxTopLevelWindowMac*, wxPointerHash, wxPointerEqual, MacWindowMap); |
841 | ||
842 | static MacWindowMap wxWinMacWindowList; | |
843 | ||
844 | wxTopLevelWindowMac *wxFindWinFromMacWindow(WindowRef inWindowRef) | |
845 | { | |
846 | MacWindowMap::iterator node = wxWinMacWindowList.find(inWindowRef); | |
847 | ||
848 | return (node == wxWinMacWindowList.end()) ? NULL : node->second; | |
849 | } | |
850 | ||
851 | void wxAssociateWinWithMacWindow(WindowRef inWindowRef, wxTopLevelWindowMac *win) ; | |
852 | void wxAssociateWinWithMacWindow(WindowRef inWindowRef, wxTopLevelWindowMac *win) | |
853 | { | |
854 | // adding NULL WindowRef is (first) surely a result of an error and | |
855 | // nothing else :-) | |
856 | wxCHECK_RET( inWindowRef != (WindowRef) NULL, wxT("attempt to add a NULL WindowRef to window list") ); | |
857 | ||
858 | wxWinMacWindowList[inWindowRef] = win; | |
859 | } | |
860 | ||
861 | void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win) ; | |
862 | void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win) | |
863 | { | |
864 | MacWindowMap::iterator it; | |
865 | for ( it = wxWinMacWindowList.begin(); it != wxWinMacWindowList.end(); ++it ) | |
866 | { | |
867 | if ( it->second == win ) | |
868 | { | |
869 | wxWinMacWindowList.erase(it); | |
870 | break; | |
871 | } | |
872 | } | |
873 | } | |
5f0b2f22 | 874 | |
a15eb0a5 SC |
875 | // ---------------------------------------------------------------------------- |
876 | // wxTopLevelWindowMac creation | |
877 | // ---------------------------------------------------------------------------- | |
878 | ||
245f3581 | 879 | wxTopLevelWindowMac *wxTopLevelWindowMac::s_macDeactivateWindow = NULL; |
5f0b2f22 | 880 | |
902725ee | 881 | typedef struct |
c5985061 SC |
882 | { |
883 | wxPoint m_position ; | |
902725ee | 884 | wxSize m_size ; |
f3b2e2d7 | 885 | bool m_wasResizable ; |
52c3df99 DS |
886 | } |
887 | FullScreenData ; | |
c5985061 | 888 | |
a15eb0a5 SC |
889 | void wxTopLevelWindowMac::Init() |
890 | { | |
891 | m_iconized = | |
902725ee | 892 | m_maximizeOnShow = false; |
6a17ca35 | 893 | m_macWindow = NULL ; |
52c3df99 | 894 | |
902725ee | 895 | #if TARGET_API_MAC_OSX |
52c3df99 DS |
896 | m_macUsesCompositing = ( UMAGetSystemVersion() >= 0x1030 ); |
897 | #else | |
898 | m_macUsesCompositing = false; | |
facd6764 | 899 | #endif |
52c3df99 | 900 | |
7c091673 | 901 | m_macEventHandler = NULL ; |
c5985061 | 902 | m_macFullScreenData = NULL ; |
a15eb0a5 SC |
903 | } |
904 | ||
118f012e SC |
905 | class wxMacDeferredWindowDeleter : public wxObject |
906 | { | |
907 | public : | |
1542ea39 RD |
908 | wxMacDeferredWindowDeleter( WindowRef windowRef ) |
909 | { | |
910 | m_macWindow = windowRef ; | |
118f012e | 911 | } |
52c3df99 | 912 | |
1542ea39 RD |
913 | virtual ~wxMacDeferredWindowDeleter() |
914 | { | |
915 | UMADisposeWindow( (WindowRef) m_macWindow ) ; | |
118f012e | 916 | } |
52c3df99 DS |
917 | |
918 | protected : | |
118f012e SC |
919 | WindowRef m_macWindow ; |
920 | } ; | |
921 | ||
a15eb0a5 SC |
922 | bool wxTopLevelWindowMac::Create(wxWindow *parent, |
923 | wxWindowID id, | |
924 | const wxString& title, | |
925 | const wxPoint& pos, | |
926 | const wxSize& size, | |
927 | long style, | |
928 | const wxString& name) | |
929 | { | |
930 | // init our fields | |
931 | Init(); | |
932 | ||
933 | m_windowStyle = style; | |
934 | ||
52c3df99 | 935 | SetName( name ); |
a15eb0a5 SC |
936 | |
937 | m_windowId = id == -1 ? NewControlId() : id; | |
fb5246be | 938 | wxWindow::SetLabel( title ) ; |
a15eb0a5 | 939 | |
facd6764 SC |
940 | MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ; |
941 | ||
94d1d0f4 | 942 | SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); |
902725ee | 943 | |
5bd78bbc JS |
944 | if (GetExtraStyle() & wxFRAME_EX_METAL) |
945 | MacSetMetalAppearance(true); | |
94d1d0f4 | 946 | |
a15eb0a5 SC |
947 | wxTopLevelWindows.Append(this); |
948 | ||
949 | if ( parent ) | |
950 | parent->AddChild(this); | |
951 | ||
902725ee | 952 | return true; |
a15eb0a5 SC |
953 | } |
954 | ||
955 | wxTopLevelWindowMac::~wxTopLevelWindowMac() | |
956 | { | |
6a17ca35 SC |
957 | if ( m_macWindow ) |
958 | { | |
c81c6d54 | 959 | #if wxUSE_TOOLTIPS |
6a17ca35 | 960 | wxToolTip::NotifyWindowDelete(m_macWindow) ; |
c81c6d54 | 961 | #endif |
118f012e | 962 | wxPendingDelete.Append( new wxMacDeferredWindowDeleter( (WindowRef) m_macWindow ) ) ; |
6a17ca35 | 963 | } |
1542ea39 | 964 | |
7c091673 SC |
965 | if ( m_macEventHandler ) |
966 | { | |
967 | ::RemoveEventHandler((EventHandlerRef) m_macEventHandler); | |
968 | m_macEventHandler = NULL ; | |
969 | } | |
851b3a88 | 970 | |
5f0b2f22 SC |
971 | wxRemoveMacWindowAssociation( this ) ; |
972 | ||
a15eb0a5 SC |
973 | if ( wxModelessWindows.Find(this) ) |
974 | wxModelessWindows.DeleteObject(this); | |
902725ee | 975 | |
c5985061 SC |
976 | FullScreenData *data = (FullScreenData *) m_macFullScreenData ; |
977 | delete data ; | |
978 | m_macFullScreenData = NULL ; | |
a15eb0a5 SC |
979 | } |
980 | ||
981 | ||
982 | // ---------------------------------------------------------------------------- | |
983 | // wxTopLevelWindowMac maximize/minimize | |
984 | // ---------------------------------------------------------------------------- | |
985 | ||
986 | void wxTopLevelWindowMac::Maximize(bool maximize) | |
987 | { | |
a979e444 | 988 | // TODO: check if this is still necessary |
699b6af4 | 989 | #if 0 |
a979e444 DS |
990 | wxMacPortStateHelper help( (GrafPtr)GetWindowPort( (WindowRef)m_macWindow) ) ; |
991 | wxMacWindowClipper clip( this ); | |
699b6af4 | 992 | #endif |
52c3df99 DS |
993 | |
994 | if ( !IsWindowInStandardState( (WindowRef)m_macWindow, NULL, NULL ) ) | |
699b6af4 SC |
995 | { |
996 | Rect rect; | |
a979e444 | 997 | |
699b6af4 SC |
998 | GetWindowBounds((WindowRef)m_macWindow, kWindowGlobalPortRgn, &rect); |
999 | SetWindowIdealUserState((WindowRef)m_macWindow, &rect); | |
1000 | SetWindowUserState((WindowRef)m_macWindow, &rect); | |
1001 | } | |
52c3df99 | 1002 | |
b7aec135 | 1003 | ZoomWindow( (WindowRef)m_macWindow , maximize ? inZoomOut : inZoomIn , false ) ; |
a15eb0a5 SC |
1004 | } |
1005 | ||
1006 | bool wxTopLevelWindowMac::IsMaximized() const | |
1007 | { | |
a979e444 | 1008 | return IsWindowInStandardState( (WindowRef)m_macWindow , NULL , NULL ) ; |
a15eb0a5 SC |
1009 | } |
1010 | ||
1011 | void wxTopLevelWindowMac::Iconize(bool iconize) | |
1012 | { | |
52c3df99 DS |
1013 | if ( IsWindowCollapsable( (WindowRef)m_macWindow) ) |
1014 | CollapseWindow( (WindowRef)m_macWindow , iconize ) ; | |
a15eb0a5 SC |
1015 | } |
1016 | ||
1017 | bool wxTopLevelWindowMac::IsIconized() const | |
1018 | { | |
b7aec135 | 1019 | return IsWindowCollapsed((WindowRef)m_macWindow ) ; |
a15eb0a5 SC |
1020 | } |
1021 | ||
1022 | void wxTopLevelWindowMac::Restore() | |
1023 | { | |
902725ee | 1024 | if ( IsMaximized() ) |
699b6af4 | 1025 | Maximize(false); |
902725ee | 1026 | else if ( IsIconized() ) |
699b6af4 | 1027 | Iconize(false); |
a15eb0a5 SC |
1028 | } |
1029 | ||
1030 | // ---------------------------------------------------------------------------- | |
1031 | // wxTopLevelWindowMac misc | |
1032 | // ---------------------------------------------------------------------------- | |
1033 | ||
facd6764 SC |
1034 | wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const |
1035 | { | |
52c3df99 | 1036 | return wxPoint(0, 0) ; |
facd6764 SC |
1037 | } |
1038 | ||
a15eb0a5 SC |
1039 | void wxTopLevelWindowMac::SetIcon(const wxIcon& icon) |
1040 | { | |
1041 | // this sets m_icon | |
1042 | wxTopLevelWindowBase::SetIcon(icon); | |
1043 | } | |
5f0b2f22 | 1044 | |
facd6764 | 1045 | void wxTopLevelWindowMac::MacSetBackgroundBrush( const wxBrush &brush ) |
902725ee | 1046 | { |
facd6764 SC |
1047 | wxTopLevelWindowBase::MacSetBackgroundBrush( brush ) ; |
1048 | ||
1049 | if ( m_macBackgroundBrush.Ok() && m_macBackgroundBrush.GetStyle() != wxTRANSPARENT && m_macBackgroundBrush.MacGetBrushKind() == kwxMacBrushTheme ) | |
1050 | { | |
1051 | SetThemeWindowBackground( (WindowRef) m_macWindow , m_macBackgroundBrush.MacGetTheme() , false ) ; | |
1052 | } | |
1053 | } | |
1054 | ||
902725ee | 1055 | void wxTopLevelWindowMac::MacInstallTopLevelWindowEventHandler() |
949cb163 SC |
1056 | { |
1057 | if ( m_macEventHandler != NULL ) | |
1058 | { | |
1059 | verify_noerr( ::RemoveEventHandler( (EventHandlerRef) m_macEventHandler ) ) ; | |
1060 | } | |
52c3df99 DS |
1061 | |
1062 | InstallWindowEventHandler( | |
1063 | MAC_WXHWND(m_macWindow), GetwxMacTopLevelEventHandlerUPP(), | |
1064 | GetEventTypeCount(eventList), eventList, this, (EventHandlerRef *)&m_macEventHandler ); | |
949cb163 SC |
1065 | } |
1066 | ||
a979e444 DS |
1067 | void wxTopLevelWindowMac::MacCreateRealWindow( |
1068 | const wxString& title, | |
1069 | const wxPoint& pos, | |
1070 | const wxSize& size, | |
1071 | long style, | |
1072 | const wxString& name ) | |
5f0b2f22 | 1073 | { |
47ac4f9b | 1074 | OSStatus err = noErr ; |
e40298d5 JS |
1075 | SetName(name); |
1076 | m_windowStyle = style; | |
902725ee | 1077 | m_isShown = false; |
1542ea39 | 1078 | |
e40298d5 | 1079 | // create frame. |
facd6764 SC |
1080 | int x = (int)pos.x; |
1081 | int y = (int)pos.y; | |
902725ee | 1082 | |
52c3df99 | 1083 | Rect theBoundsRect; |
5a486641 SC |
1084 | wxRect display = wxGetClientDisplayRect() ; |
1085 | ||
1086 | if ( x == wxDefaultPosition.x ) | |
1087 | x = display.x ; | |
902725ee | 1088 | |
5a486641 SC |
1089 | if ( y == wxDefaultPosition.y ) |
1090 | y = display.y ; | |
1542ea39 | 1091 | |
facd6764 SC |
1092 | int w = WidthDefault(size.x); |
1093 | int h = HeightDefault(size.y); | |
1542ea39 | 1094 | |
facd6764 | 1095 | ::SetRect(&theBoundsRect, x, y , x + w, y + h); |
1542ea39 | 1096 | |
5f0b2f22 | 1097 | // translate the window attributes in the appropriate window class and attributes |
5f0b2f22 SC |
1098 | WindowClass wclass = 0; |
1099 | WindowAttributes attr = kWindowNoAttributes ; | |
e353795e | 1100 | WindowGroupRef group = NULL ; |
1542ea39 | 1101 | |
f5744893 | 1102 | if ( HasFlag( wxFRAME_TOOL_WINDOW) ) |
5f0b2f22 | 1103 | { |
1542ea39 | 1104 | if ( |
f5744893 SC |
1105 | HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) || |
1106 | HasFlag( wxSYSTEM_MENU ) || HasFlag( wxCAPTION ) || | |
1107 | HasFlag(wxTINY_CAPTION_HORIZ) || HasFlag(wxTINY_CAPTION_VERT) | |
e40298d5 | 1108 | ) |
5f0b2f22 | 1109 | { |
f5744893 | 1110 | wclass = kFloatingWindowClass ; |
52c3df99 | 1111 | |
f5744893 | 1112 | if ( HasFlag(wxTINY_CAPTION_VERT) ) |
f5744893 | 1113 | attr |= kWindowSideTitlebarAttribute ; |
f5744893 SC |
1114 | } |
1115 | else | |
1116 | { | |
1117 | wclass = kPlainWindowClass ; | |
5f0b2f22 SC |
1118 | } |
1119 | } | |
1120 | else if ( HasFlag( wxCAPTION ) ) | |
1121 | { | |
1542ea39 | 1122 | wclass = kDocumentWindowClass ; |
22e3c5bd | 1123 | attr |= kWindowInWindowMenuAttribute ; |
5f0b2f22 | 1124 | } |
eab19a7c | 1125 | #if defined( __WXMAC__ ) && TARGET_API_MAC_OSX && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2 ) |
3e17bc3f RN |
1126 | else if ( HasFlag( wxFRAME_DRAWER ) ) |
1127 | { | |
1128 | wclass = kDrawerWindowClass; | |
789ae0cf | 1129 | // we must force compositing on a drawer |
902725ee | 1130 | m_macUsesCompositing = true ; |
3e17bc3f RN |
1131 | } |
1132 | #endif //10.2 and up | |
5f0b2f22 SC |
1133 | else |
1134 | { | |
f5744893 | 1135 | if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) || |
47ac4f9b | 1136 | HasFlag( wxCLOSE_BOX ) || HasFlag( wxSYSTEM_MENU ) ) |
f5744893 SC |
1137 | { |
1138 | wclass = kDocumentWindowClass ; | |
1139 | } | |
1140 | else | |
1141 | { | |
1142 | wclass = kPlainWindowClass ; | |
1143 | } | |
5f0b2f22 | 1144 | } |
1542ea39 | 1145 | |
52c3df99 | 1146 | if ( wclass != kPlainWindowClass ) |
5f0b2f22 | 1147 | { |
52c3df99 DS |
1148 | if ( HasFlag( wxMINIMIZE_BOX ) ) |
1149 | attr |= kWindowCollapseBoxAttribute ; | |
1150 | ||
1151 | if ( HasFlag( wxMAXIMIZE_BOX ) ) | |
1152 | attr |= kWindowFullZoomAttribute ; | |
1153 | ||
1154 | if ( HasFlag( wxRESIZE_BORDER ) ) | |
1155 | attr |= kWindowResizableAttribute ; | |
1156 | ||
1157 | if ( HasFlag( wxCLOSE_BOX) ) | |
1158 | attr |= kWindowCloseBoxAttribute ; | |
5f0b2f22 | 1159 | } |
1542ea39 | 1160 | |
52c3df99 | 1161 | // turn on live resizing (OS X only) |
eb630bf1 | 1162 | if (UMAGetSystemVersion() >= 0x1000) |
eb630bf1 | 1163 | attr |= kWindowLiveResizeAttribute; |
eb630bf1 | 1164 | |
e353795e | 1165 | if ( HasFlag(wxSTAY_ON_TOP) ) |
e353795e | 1166 | group = GetWindowGroupOfClass(kUtilityWindowClass) ; |
6a7e6411 | 1167 | |
902725ee | 1168 | #if TARGET_API_MAC_OSX |
789ae0cf SC |
1169 | if ( m_macUsesCompositing ) |
1170 | attr |= kWindowCompositingAttribute; | |
d66c3960 | 1171 | #endif |
902725ee | 1172 | |
6a7e6411 RD |
1173 | if ( HasFlag(wxFRAME_SHAPED) ) |
1174 | { | |
1175 | WindowDefSpec customWindowDefSpec; | |
1176 | customWindowDefSpec.defType = kWindowDefProcPtr; | |
1177 | customWindowDefSpec.u.defProc = NewWindowDefUPP(wxShapedMacWindowDef); | |
1178 | ||
47ac4f9b | 1179 | err = ::CreateCustomWindow( &customWindowDefSpec, wclass, |
6a7e6411 RD |
1180 | attr, &theBoundsRect, |
1181 | (WindowRef*) &m_macWindow); | |
1182 | } | |
1183 | else | |
1184 | { | |
47ac4f9b | 1185 | err = ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ; |
6a7e6411 RD |
1186 | } |
1187 | ||
e353795e SC |
1188 | if ( err == noErr && m_macWindow != NULL && group != NULL ) |
1189 | SetWindowGroup( (WindowRef) m_macWindow , group ) ; | |
1190 | ||
47ac4f9b | 1191 | wxCHECK_RET( err == noErr, wxT("Mac OS error when trying to create new window") ); |
f83b6761 | 1192 | |
a979e444 DS |
1193 | // the create commands are only for content rect, |
1194 | // so we have to set the size again as structure bounds | |
f83b6761 SC |
1195 | SetWindowBounds( (WindowRef) m_macWindow , kWindowStructureRgn , &theBoundsRect ) ; |
1196 | ||
facd6764 SC |
1197 | wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ; |
1198 | UMASetWTitle( (WindowRef) m_macWindow , title , m_font.GetEncoding() ) ; | |
1f1c8bd4 | 1199 | m_peer = new wxMacControl(this , true /*isRootControl*/) ; |
902725ee | 1200 | |
a979e444 | 1201 | #if TARGET_API_MAC_OSX |
789ae0cf | 1202 | if ( m_macUsesCompositing ) |
f57d9215 | 1203 | { |
902725ee | 1204 | // There is a bug in 10.2.X for ::GetRootControl returning the window view instead of |
3103e8a9 | 1205 | // the content view, so we have to retrieve it explicitly |
902725ee | 1206 | HIViewFindByID( HIViewGetRoot( (WindowRef) m_macWindow ) , kHIViewWindowContentID , |
789ae0cf SC |
1207 | m_peer->GetControlRefAddr() ) ; |
1208 | if ( !m_peer->Ok() ) | |
1209 | { | |
1210 | // compatibility mode fallback | |
1211 | GetRootControl( (WindowRef) m_macWindow , m_peer->GetControlRefAddr() ) ; | |
1212 | } | |
f57d9215 | 1213 | } |
3a9dc061 | 1214 | #endif |
789ae0cf SC |
1215 | { |
1216 | ::CreateRootControl( (WindowRef)m_macWindow , m_peer->GetControlRefAddr() ) ; | |
1217 | } | |
52c3df99 DS |
1218 | |
1219 | // the root control level handler | |
5ca0d812 | 1220 | MacInstallEventHandler( (WXWidget) m_peer->GetControlRef() ) ; |
facd6764 | 1221 | |
8ec0a8fa SC |
1222 | #if TARGET_API_MAC_OSX |
1223 | if ( m_macUsesCompositing && m_macWindow != NULL ) | |
1224 | { | |
1225 | if ( GetExtraStyle() & wxFRAME_EX_METAL ) | |
1226 | MacSetMetalAppearance( true ) ; | |
1227 | } | |
1228 | #endif | |
52c3df99 | 1229 | |
73fe67bd | 1230 | // the frame window event handler |
e40298d5 | 1231 | InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ; |
949cb163 | 1232 | MacInstallTopLevelWindowEventHandler() ; |
b19bf058 | 1233 | |
14c96cf2 SC |
1234 | DoSetWindowVariant( m_windowVariant ) ; |
1235 | ||
facd6764 | 1236 | m_macFocus = NULL ; |
6a7e6411 RD |
1237 | |
1238 | if ( HasFlag(wxFRAME_SHAPED) ) | |
1239 | { | |
1240 | // default shape matches the window size | |
52c3df99 DS |
1241 | wxRegion rgn( 0, 0, w, h ); |
1242 | SetShape( rgn ); | |
6a7e6411 | 1243 | } |
3dfafdb9 RD |
1244 | |
1245 | wxWindowCreateEvent event(this); | |
1246 | GetEventHandler()->ProcessEvent(event); | |
5f0b2f22 SC |
1247 | } |
1248 | ||
5d2e69e8 | 1249 | void wxTopLevelWindowMac::ClearBackground() |
5f0b2f22 | 1250 | { |
5d2e69e8 | 1251 | wxWindow::ClearBackground() ; |
5f0b2f22 SC |
1252 | } |
1253 | ||
5f0b2f22 SC |
1254 | // Raise the window to the top of the Z order |
1255 | void wxTopLevelWindowMac::Raise() | |
1256 | { | |
7f3c339c | 1257 | ::SelectWindow( (WindowRef)m_macWindow ) ; |
5f0b2f22 SC |
1258 | } |
1259 | ||
1260 | // Lower the window to the bottom of the Z order | |
1261 | void wxTopLevelWindowMac::Lower() | |
1262 | { | |
76a5e5d2 | 1263 | ::SendBehind( (WindowRef)m_macWindow , NULL ) ; |
5f0b2f22 SC |
1264 | } |
1265 | ||
245f3581 DE |
1266 | void wxTopLevelWindowMac::MacDelayedDeactivation(long timestamp) |
1267 | { | |
52c3df99 | 1268 | if (s_macDeactivateWindow) |
245f3581 | 1269 | { |
f02a4ffa VZ |
1270 | wxLogTrace(TRACE_ACTIVATE, |
1271 | wxT("Doing delayed deactivation of %p"), | |
1272 | s_macDeactivateWindow); | |
52c3df99 | 1273 | |
245f3581 DE |
1274 | s_macDeactivateWindow->MacActivate(timestamp, false); |
1275 | } | |
1276 | } | |
1277 | ||
851b3a88 | 1278 | void wxTopLevelWindowMac::MacActivate( long timestamp , bool inIsActivating ) |
5f0b2f22 | 1279 | { |
f02a4ffa | 1280 | wxLogTrace(TRACE_ACTIVATE, wxT("TopLevel=%p::MacActivate"), this); |
17f8d2a7 | 1281 | |
52c3df99 DS |
1282 | if (s_macDeactivateWindow == this) |
1283 | s_macDeactivateWindow = NULL; | |
1284 | ||
245f3581 | 1285 | MacDelayedDeactivation(timestamp); |
8ab50549 | 1286 | MacPropagateHiliteChanged() ; |
5f0b2f22 SC |
1287 | } |
1288 | ||
1289 | void wxTopLevelWindowMac::SetTitle(const wxString& title) | |
1290 | { | |
fb5246be | 1291 | wxWindow::SetLabel( title ) ; |
16a76184 | 1292 | UMASetWTitle( (WindowRef)m_macWindow , title , m_font.GetEncoding() ) ; |
5f0b2f22 SC |
1293 | } |
1294 | ||
d4bd6c97 | 1295 | wxString wxTopLevelWindowMac::GetTitle() const |
fb5246be WS |
1296 | { |
1297 | return wxWindow::GetLabel(); | |
1298 | } | |
1299 | ||
5f0b2f22 SC |
1300 | bool wxTopLevelWindowMac::Show(bool show) |
1301 | { | |
facd6764 | 1302 | if ( !wxTopLevelWindowBase::Show(show) ) |
902725ee | 1303 | return false; |
5f0b2f22 | 1304 | |
21e77aa1 DS |
1305 | bool plainTransition = false; |
1306 | ||
a979e444 | 1307 | #if wxUSE_SYSTEM_OPTIONS |
21e77aa1 DS |
1308 | // code contributed by Ryan Wilcox December 18, 2003 |
1309 | plainTransition = UMAGetSystemVersion() >= 0x1000 ; | |
1310 | if ( wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) ) | |
1311 | plainTransition = ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1 ) ; | |
1312 | #endif | |
52c3df99 | 1313 | |
21e77aa1 DS |
1314 | if (show) |
1315 | { | |
8c8f6a4b | 1316 | if ( plainTransition ) |
1f90939c | 1317 | ::ShowWindow( (WindowRef)m_macWindow ); |
1f90939c | 1318 | else |
52c3df99 | 1319 | ::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowShowTransitionAction, NULL ); |
52c3df99 | 1320 | |
1f90939c | 1321 | ::SelectWindow( (WindowRef)m_macWindow ) ; |
52c3df99 DS |
1322 | |
1323 | // because apps expect a size event to occur at this moment | |
a979e444 | 1324 | wxSizeEvent event(GetSize() , m_windowId); |
1f90939c SC |
1325 | event.SetEventObject(this); |
1326 | GetEventHandler()->ProcessEvent(event); | |
5f0b2f22 SC |
1327 | } |
1328 | else | |
1329 | { | |
8c8f6a4b | 1330 | if ( plainTransition ) |
21e77aa1 | 1331 | ::HideWindow( (WindowRef)m_macWindow ); |
1f90939c | 1332 | else |
21e77aa1 | 1333 | ::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowHideTransitionAction, NULL ); |
5f0b2f22 SC |
1334 | } |
1335 | ||
facd6764 | 1336 | MacPropagateVisibilityChanged() ; |
5f0b2f22 | 1337 | |
902725ee | 1338 | return true ; |
5f0b2f22 SC |
1339 | } |
1340 | ||
c5985061 | 1341 | bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style) |
902725ee | 1342 | { |
c5985061 SC |
1343 | if ( show ) |
1344 | { | |
1345 | FullScreenData *data = (FullScreenData *)m_macFullScreenData ; | |
1346 | delete data ; | |
1347 | data = new FullScreenData() ; | |
902725ee | 1348 | |
c5985061 SC |
1349 | m_macFullScreenData = data ; |
1350 | data->m_position = GetPosition() ; | |
1351 | data->m_size = GetSize() ; | |
f3b2e2d7 | 1352 | data->m_wasResizable = MacGetWindowAttributes() & kWindowResizableAttribute ; |
902725ee | 1353 | |
c5985061 | 1354 | if ( style & wxFULLSCREEN_NOMENUBAR ) |
52c3df99 DS |
1355 | HideMenuBar() ; |
1356 | ||
c5985061 SC |
1357 | wxRect client = wxGetClientDisplayRect() ; |
1358 | ||
52c3df99 | 1359 | int left , top , right , bottom ; |
c5985061 | 1360 | int x, y, w, h ; |
902725ee | 1361 | |
c5985061 SC |
1362 | x = client.x ; |
1363 | y = client.y ; | |
1364 | w = client.width ; | |
1365 | h = client.height ; | |
902725ee | 1366 | |
c5985061 SC |
1367 | MacGetContentAreaInset( left , top , right , bottom ) ; |
1368 | ||
1369 | if ( style & wxFULLSCREEN_NOCAPTION ) | |
1370 | { | |
1371 | y -= top ; | |
1372 | h += top ; | |
1373 | } | |
52c3df99 | 1374 | |
c5985061 SC |
1375 | if ( style & wxFULLSCREEN_NOBORDER ) |
1376 | { | |
1377 | x -= left ; | |
1378 | w += left + right ; | |
1379 | h += bottom ; | |
1380 | } | |
52c3df99 | 1381 | |
c5985061 SC |
1382 | if ( style & wxFULLSCREEN_NOTOOLBAR ) |
1383 | { | |
3c86150d SC |
1384 | // TODO |
1385 | } | |
52c3df99 | 1386 | |
3c86150d SC |
1387 | if ( style & wxFULLSCREEN_NOSTATUSBAR ) |
1388 | { | |
1389 | // TODO | |
c5985061 | 1390 | } |
52c3df99 | 1391 | |
c5985061 | 1392 | SetSize( x , y , w, h ) ; |
172da31f | 1393 | if ( data->m_wasResizable ) |
f3b2e2d7 | 1394 | MacChangeWindowAttributes( kWindowNoAttributes , kWindowResizableAttribute ) ; |
c5985061 SC |
1395 | } |
1396 | else | |
1397 | { | |
1398 | ShowMenuBar() ; | |
1399 | FullScreenData *data = (FullScreenData *) m_macFullScreenData ; | |
172da31f | 1400 | if ( data->m_wasResizable ) |
f3b2e2d7 | 1401 | MacChangeWindowAttributes( kWindowResizableAttribute , kWindowNoAttributes ) ; |
c5985061 SC |
1402 | SetPosition( data->m_position ) ; |
1403 | SetSize( data->m_size ) ; | |
52c3df99 | 1404 | |
c5985061 SC |
1405 | delete data ; |
1406 | m_macFullScreenData = NULL ; | |
1407 | } | |
52c3df99 | 1408 | |
902725ee | 1409 | return false; |
c5985061 SC |
1410 | } |
1411 | ||
902725ee WS |
1412 | bool wxTopLevelWindowMac::IsFullScreen() const |
1413 | { | |
1414 | return m_macFullScreenData != NULL ; | |
c5985061 SC |
1415 | } |
1416 | ||
8ec0a8fa SC |
1417 | void wxTopLevelWindowMac::SetExtraStyle(long exStyle) |
1418 | { | |
1419 | if ( GetExtraStyle() == exStyle ) | |
1420 | return ; | |
1421 | ||
1422 | wxTopLevelWindowBase::SetExtraStyle( exStyle ) ; | |
52c3df99 | 1423 | |
8ec0a8fa SC |
1424 | #if TARGET_API_MAC_OSX |
1425 | if ( m_macUsesCompositing && m_macWindow != NULL ) | |
1426 | { | |
1427 | bool metal = GetExtraStyle() & wxFRAME_EX_METAL ; | |
1428 | if ( MacGetMetalAppearance() != metal ) | |
1429 | MacSetMetalAppearance( metal ) ; | |
1430 | } | |
1431 | #endif | |
1432 | } | |
1433 | ||
21e77aa1 DS |
1434 | // we are still using coordinates of the content view |
1435 | // TODO: switch to structure bounds | |
1436 | // | |
29281095 SC |
1437 | void wxTopLevelWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , int &bottom ) |
1438 | { | |
21e77aa1 DS |
1439 | Rect content, structure ; |
1440 | ||
29281095 SC |
1441 | GetWindowBounds( (WindowRef) m_macWindow, kWindowStructureRgn , &structure ) ; |
1442 | GetWindowBounds( (WindowRef) m_macWindow, kWindowContentRgn , &content ) ; | |
1443 | ||
1444 | left = content.left - structure.left ; | |
1445 | top = content.top - structure.top ; | |
1446 | right = structure.right - content.right ; | |
1447 | bottom = structure.bottom - content.bottom ; | |
1448 | } | |
1449 | ||
5f0b2f22 SC |
1450 | void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height) |
1451 | { | |
c9698388 | 1452 | m_cachedClippedRectValid = false ; |
facd6764 SC |
1453 | Rect bounds = { y , x , y + height , x + width } ; |
1454 | verify_noerr(SetWindowBounds( (WindowRef) m_macWindow, kWindowStructureRgn , &bounds )) ; | |
4817190d | 1455 | wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified |
5f0b2f22 SC |
1456 | } |
1457 | ||
facd6764 | 1458 | void wxTopLevelWindowMac::DoGetPosition( int *x, int *y ) const |
5f0b2f22 | 1459 | { |
facd6764 | 1460 | Rect bounds ; |
52c3df99 | 1461 | |
facd6764 | 1462 | verify_noerr(GetWindowBounds((WindowRef) m_macWindow, kWindowStructureRgn , &bounds )) ; |
52c3df99 DS |
1463 | |
1464 | if (x) | |
1465 | *x = bounds.left ; | |
1466 | if (y) | |
1467 | *y = bounds.top ; | |
facd6764 | 1468 | } |
52c3df99 | 1469 | |
facd6764 SC |
1470 | void wxTopLevelWindowMac::DoGetSize( int *width, int *height ) const |
1471 | { | |
1472 | Rect bounds ; | |
52c3df99 | 1473 | |
facd6764 | 1474 | verify_noerr(GetWindowBounds((WindowRef) m_macWindow, kWindowStructureRgn , &bounds )) ; |
52c3df99 DS |
1475 | |
1476 | if (width) | |
1477 | *width = bounds.right - bounds.left ; | |
1478 | if (height) | |
1479 | *height = bounds.bottom - bounds.top ; | |
facd6764 | 1480 | } |
1542ea39 | 1481 | |
facd6764 SC |
1482 | void wxTopLevelWindowMac::DoGetClientSize( int *width, int *height ) const |
1483 | { | |
1484 | Rect bounds ; | |
52c3df99 | 1485 | |
facd6764 | 1486 | verify_noerr(GetWindowBounds((WindowRef) m_macWindow, kWindowContentRgn , &bounds )) ; |
52c3df99 DS |
1487 | |
1488 | if (width) | |
1489 | *width = bounds.right - bounds.left ; | |
1490 | if (height) | |
1491 | *height = bounds.bottom - bounds.top ; | |
facd6764 | 1492 | } |
1542ea39 | 1493 | |
902725ee | 1494 | void wxTopLevelWindowMac::MacSetMetalAppearance( bool set ) |
facd6764 SC |
1495 | { |
1496 | #if TARGET_API_MAC_OSX | |
789ae0cf | 1497 | wxASSERT_MSG( m_macUsesCompositing , |
facd6764 | 1498 | wxT("Cannot set metal appearance on a non-compositing window") ) ; |
902725ee WS |
1499 | |
1500 | MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes , | |
facd6764 SC |
1501 | set ? kWindowNoAttributes : kWindowMetalAttribute ) ; |
1502 | #endif | |
1503 | } | |
1542ea39 | 1504 | |
902725ee | 1505 | bool wxTopLevelWindowMac::MacGetMetalAppearance() const |
6aab345b SC |
1506 | { |
1507 | #if TARGET_API_MAC_OSX | |
1508 | return MacGetWindowAttributes() & kWindowMetalAttribute ; | |
1509 | #else | |
1510 | return false ; | |
1511 | #endif | |
1512 | } | |
1513 | ||
902725ee | 1514 | void wxTopLevelWindowMac::MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear ) |
facd6764 | 1515 | { |
52c3df99 | 1516 | ChangeWindowAttributes( (WindowRef)m_macWindow, attributesToSet, attributesToClear ) ; |
facd6764 | 1517 | } |
1542ea39 | 1518 | |
902725ee | 1519 | wxUint32 wxTopLevelWindowMac::MacGetWindowAttributes() const |
facd6764 SC |
1520 | { |
1521 | UInt32 attr = 0 ; | |
52c3df99 DS |
1522 | GetWindowAttributes( (WindowRef) m_macWindow, &attr ) ; |
1523 | ||
facd6764 | 1524 | return attr ; |
5f0b2f22 | 1525 | } |
a07c1212 | 1526 | |
902725ee | 1527 | void wxTopLevelWindowMac::MacPerformUpdates() |
92346151 SC |
1528 | { |
1529 | #if TARGET_API_MAC_OSX | |
902725ee WS |
1530 | if ( m_macUsesCompositing ) |
1531 | { | |
92346151 | 1532 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 |
902725ee WS |
1533 | // for composited windows this also triggers a redraw of all |
1534 | // invalid views in the window | |
52c3df99 | 1535 | if ( UMAGetSystemVersion() >= 0x1030 ) |
902725ee WS |
1536 | HIWindowFlush((WindowRef) m_macWindow) ; |
1537 | else | |
92346151 | 1538 | #endif |
902725ee WS |
1539 | { |
1540 | // the only way to trigger the redrawing on earlier systems is to call | |
1541 | // ReceiveNextEvent | |
1542 | ||
1543 | EventRef currentEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ; | |
1544 | UInt32 currentEventClass = 0 ; | |
1545 | UInt32 currentEventKind = 0 ; | |
1546 | if ( currentEvent != NULL ) | |
1547 | { | |
1548 | currentEventClass = ::GetEventClass( currentEvent ) ; | |
1549 | currentEventKind = ::GetEventKind( currentEvent ) ; | |
1550 | } | |
52c3df99 | 1551 | |
902725ee WS |
1552 | if ( currentEventClass != kEventClassMenu ) |
1553 | { | |
1554 | // when tracking a menu, strange redraw errors occur if we flush now, so leave.. | |
1555 | EventRef theEvent; | |
1556 | OSStatus status = noErr ; | |
1557 | status = ReceiveNextEvent( 0 , NULL , kEventDurationNoWait , false , &theEvent ) ; | |
1558 | } | |
1559 | } | |
92346151 SC |
1560 | } |
1561 | else | |
1562 | #endif | |
1563 | { | |
902725ee WS |
1564 | BeginUpdate( (WindowRef) m_macWindow ) ; |
1565 | ||
1566 | RgnHandle updateRgn = NewRgn(); | |
1567 | if ( updateRgn ) | |
1568 | { | |
1569 | GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn ); | |
1570 | UpdateControls( (WindowRef)m_macWindow , updateRgn ) ; | |
52c3df99 | 1571 | |
902725ee WS |
1572 | // if ( !EmptyRgn( updateRgn ) ) |
1573 | // MacDoRedraw( updateRgn , 0 , true) ; | |
52c3df99 | 1574 | |
902725ee WS |
1575 | DisposeRgn( updateRgn ); |
1576 | } | |
52c3df99 | 1577 | |
902725ee WS |
1578 | EndUpdate( (WindowRef)m_macWindow ) ; |
1579 | QDFlushPortBuffer( GetWindowPort( (WindowRef)m_macWindow ) , NULL ) ; | |
92346151 SC |
1580 | } |
1581 | } | |
1582 | ||
3feeb1e1 SC |
1583 | // Attracts the users attention to this window if the application is |
1584 | // inactive (should be called when a background event occurs) | |
1585 | ||
1586 | static pascal void wxMacNMResponse( NMRecPtr ptr ) | |
1587 | { | |
1588 | NMRemove( ptr ) ; | |
a979e444 | 1589 | DisposePtr( (Ptr)ptr ) ; |
3feeb1e1 SC |
1590 | } |
1591 | ||
3feeb1e1 SC |
1592 | void wxTopLevelWindowMac::RequestUserAttention(int flags ) |
1593 | { | |
1594 | NMRecPtr notificationRequest = (NMRecPtr) NewPtr( sizeof( NMRec) ) ; | |
52c3df99 DS |
1595 | static wxMacNMUPP nmupp( wxMacNMResponse ); |
1596 | ||
3feeb1e1 SC |
1597 | memset( notificationRequest , 0 , sizeof(*notificationRequest) ) ; |
1598 | notificationRequest->qType = nmType ; | |
1599 | notificationRequest->nmMark = 1 ; | |
1600 | notificationRequest->nmIcon = 0 ; | |
1601 | notificationRequest->nmSound = 0 ; | |
1602 | notificationRequest->nmStr = NULL ; | |
1603 | notificationRequest->nmResp = nmupp ; | |
52c3df99 | 1604 | |
3feeb1e1 SC |
1605 | verify_noerr( NMInstall( notificationRequest ) ) ; |
1606 | } | |
1607 | ||
facd6764 SC |
1608 | // --------------------------------------------------------------------------- |
1609 | // Shape implementation | |
1610 | // --------------------------------------------------------------------------- | |
1611 | ||
6a7e6411 | 1612 | |
1542ea39 RD |
1613 | bool wxTopLevelWindowMac::SetShape(const wxRegion& region) |
1614 | { | |
902725ee | 1615 | wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false, |
6a7e6411 RD |
1616 | _T("Shaped windows must be created with the wxFRAME_SHAPED style.")); |
1617 | ||
a979e444 DS |
1618 | // The empty region signifies that the shape |
1619 | // should be removed from the window. | |
6a7e6411 RD |
1620 | if ( region.IsEmpty() ) |
1621 | { | |
1622 | wxSize sz = GetClientSize(); | |
1623 | wxRegion rgn(0, 0, sz.x, sz.y); | |
3c393c0a SC |
1624 | if ( rgn.IsEmpty() ) |
1625 | return false ; | |
1626 | else | |
1627 | return SetShape(rgn); | |
6a7e6411 RD |
1628 | } |
1629 | ||
1630 | // Make a copy of the region | |
1631 | RgnHandle shapeRegion = NewRgn(); | |
1632 | CopyRgn( (RgnHandle)region.GetWXHRGN(), shapeRegion ); | |
1633 | ||
1634 | // Dispose of any shape region we may already have | |
1635 | RgnHandle oldRgn = (RgnHandle)GetWRefCon( (WindowRef)MacGetWindowRef() ); | |
1636 | if ( oldRgn ) | |
1637 | DisposeRgn(oldRgn); | |
1638 | ||
1639 | // Save the region so we can use it later | |
1640 | SetWRefCon((WindowRef)MacGetWindowRef(), (SInt32)shapeRegion); | |
1641 | ||
52c3df99 | 1642 | // inform the window manager that the window has changed shape |
6a7e6411 | 1643 | ReshapeCustomWindow((WindowRef)MacGetWindowRef()); |
52c3df99 | 1644 | |
902725ee | 1645 | return true; |
6a7e6411 RD |
1646 | } |
1647 | ||
6a7e6411 RD |
1648 | // --------------------------------------------------------------------------- |
1649 | // Support functions for shaped windows, based on Apple's CustomWindow sample at | |
1650 | // http://developer.apple.com/samplecode/Sample_Code/Human_Interface_Toolbox/Mac_OS_High_Level_Toolbox/CustomWindow.htm | |
1651 | // --------------------------------------------------------------------------- | |
1652 | ||
6a7e6411 RD |
1653 | static void wxShapedMacWindowGetPos(WindowRef window, Rect* inRect) |
1654 | { | |
1655 | GetWindowPortBounds(window, inRect); | |
a979e444 DS |
1656 | Point pt = { inRect->left, inRect->top }; |
1657 | ||
1658 | QDLocalToGlobalPoint( GetWindowPort(window), &pt ) ; | |
6a7e6411 RD |
1659 | inRect->top = pt.v; |
1660 | inRect->left = pt.h; | |
1661 | inRect->bottom += pt.v; | |
1662 | inRect->right += pt.h; | |
1663 | } | |
1664 | ||
6a7e6411 RD |
1665 | static SInt32 wxShapedMacWindowGetFeatures(WindowRef window, SInt32 param) |
1666 | { | |
1667 | /*------------------------------------------------------ | |
1668 | Define which options your custom window supports. | |
1669 | --------------------------------------------------------*/ | |
1670 | //just enable everything for our demo | |
52c3df99 DS |
1671 | *(OptionBits*)param = |
1672 | //kWindowCanGrow | | |
1673 | //kWindowCanZoom | | |
1674 | //kWindowCanCollapse | | |
1675 | //kWindowCanGetWindowRegion | | |
1676 | //kWindowHasTitleBar | | |
1677 | //kWindowSupportsDragHilite | | |
1678 | kWindowCanDrawInCurrentPort | | |
1679 | //kWindowCanMeasureTitle | | |
1680 | kWindowWantsDisposeAtProcessDeath | | |
1681 | kWindowSupportsGetGrowImageRegion | | |
1682 | kWindowDefSupportsColorGrafPort; | |
1683 | ||
6a7e6411 | 1684 | return 1; |
1542ea39 | 1685 | } |
6a7e6411 RD |
1686 | |
1687 | // The content region is left as a rectangle matching the window size, this is | |
1688 | // so the origin in the paint event, and etc. still matches what the | |
1689 | // programmer expects. | |
1690 | static void wxShapedMacWindowContentRegion(WindowRef window, RgnHandle rgn) | |
1691 | { | |
1692 | SetEmptyRgn(rgn); | |
1693 | wxTopLevelWindowMac* win = wxFindWinFromMacWindow(window); | |
1694 | if (win) | |
1695 | { | |
b19bf058 | 1696 | Rect r ; |
52c3df99 | 1697 | wxShapedMacWindowGetPos( window, &r ) ; |
b19bf058 | 1698 | RectRgn( rgn , &r ) ; |
6a7e6411 RD |
1699 | } |
1700 | } | |
1701 | ||
1702 | // The structure region is set to the shape given to the SetShape method. | |
1703 | static void wxShapedMacWindowStructureRegion(WindowRef window, RgnHandle rgn) | |
1704 | { | |
1705 | RgnHandle cachedRegion = (RgnHandle) GetWRefCon(window); | |
1706 | ||
1707 | SetEmptyRgn(rgn); | |
1708 | if (cachedRegion) | |
1709 | { | |
1710 | Rect windowRect; | |
902725ee WS |
1711 | wxShapedMacWindowGetPos(window, &windowRect); // how big is the window |
1712 | CopyRgn(cachedRegion, rgn); // make a copy of our cached region | |
6a7e6411 | 1713 | OffsetRgn(rgn, windowRect.left, windowRect.top); // position it over window |
902725ee | 1714 | //MapRgn(rgn, &mMaskSize, &windowRect); //scale it to our actual window size |
6a7e6411 RD |
1715 | } |
1716 | } | |
1717 | ||
6a7e6411 RD |
1718 | static SInt32 wxShapedMacWindowGetRegion(WindowRef window, SInt32 param) |
1719 | { | |
52c3df99 DS |
1720 | GetWindowRegionPtr rgnRec = (GetWindowRegionPtr)param; |
1721 | ||
1722 | if (rgnRec == NULL) | |
1723 | return paramErr; | |
6a7e6411 | 1724 | |
52c3df99 | 1725 | switch (rgnRec->regionCode) |
6a7e6411 RD |
1726 | { |
1727 | case kWindowStructureRgn: | |
1728 | wxShapedMacWindowStructureRegion(window, rgnRec->winRgn); | |
1729 | break; | |
52c3df99 | 1730 | |
6a7e6411 RD |
1731 | case kWindowContentRgn: |
1732 | wxShapedMacWindowContentRegion(window, rgnRec->winRgn); | |
1733 | break; | |
52c3df99 | 1734 | |
6a7e6411 RD |
1735 | default: |
1736 | SetEmptyRgn(rgnRec->winRgn); | |
52c3df99 DS |
1737 | break; |
1738 | } | |
6a7e6411 RD |
1739 | |
1740 | return noErr; | |
1741 | } | |
1742 | ||
52c3df99 DS |
1743 | // Determine the region of the window which was hit |
1744 | // | |
1745 | static SInt32 wxShapedMacWindowHitTest(WindowRef window, SInt32 param) | |
6a7e6411 | 1746 | { |
6a7e6411 | 1747 | Point hitPoint; |
52c3df99 | 1748 | static RgnHandle tempRgn = NULL; |
6a7e6411 | 1749 | |
52c3df99 DS |
1750 | if (tempRgn == NULL) |
1751 | tempRgn = NewRgn(); | |
6a7e6411 | 1752 | |
52c3df99 DS |
1753 | // get the point clicked |
1754 | SetPt( &hitPoint, LoWord(param), HiWord(param) ); | |
6a7e6411 | 1755 | |
52c3df99 | 1756 | // Mac OS 8.5 or later |
6a7e6411 | 1757 | wxShapedMacWindowStructureRegion(window, tempRgn); |
52c3df99 | 1758 | if (PtInRgn( hitPoint, tempRgn )) //in window content region? |
6a7e6411 RD |
1759 | return wInContent; |
1760 | ||
52c3df99 DS |
1761 | // no significant area was hit |
1762 | return wNoHit; | |
6a7e6411 RD |
1763 | } |
1764 | ||
6a7e6411 RD |
1765 | static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param) |
1766 | { | |
52c3df99 | 1767 | switch (message) |
6a7e6411 RD |
1768 | { |
1769 | case kWindowMsgHitTest: | |
52c3df99 | 1770 | return wxShapedMacWindowHitTest(window, param); |
6a7e6411 RD |
1771 | |
1772 | case kWindowMsgGetFeatures: | |
52c3df99 | 1773 | return wxShapedMacWindowGetFeatures(window, param); |
6a7e6411 RD |
1774 | |
1775 | // kWindowMsgGetRegion is sent during CreateCustomWindow and ReshapeCustomWindow | |
1776 | case kWindowMsgGetRegion: | |
52c3df99 DS |
1777 | return wxShapedMacWindowGetRegion(window, param); |
1778 | ||
1779 | default: | |
1780 | break; | |
6a7e6411 RD |
1781 | } |
1782 | ||
1783 | return 0; | |
1784 | } | |
1925be65 | 1785 |