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