1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: mac/toplevel.cpp
3 // Purpose: implements wxTopLevelWindow for Mac
4 // Author: Stefan Csomor
8 // Copyright: (c) 2001-2004 Stefan Csomor
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "toplevel.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
33 #include "wx/toplevel.h"
35 #include "wx/string.h"
38 #include "wx/settings.h"
41 #include "wx/mac/uma.h"
42 #include "wx/mac/aga.h"
44 #include "wx/tooltip.h"
46 #if wxUSE_SYSTEM_OPTIONS
47 #include "wx/sysopt.h"
50 #include <ToolUtils.h>
52 // ----------------------------------------------------------------------------
54 // ----------------------------------------------------------------------------
56 // list of all frames and modeless dialogs
57 wxWindowList wxModelessWindows
;
59 static pascal long wxShapedMacWindowDef(short varCode
, WindowRef window
, SInt16 message
, SInt32 param
);
61 // ============================================================================
62 // wxTopLevelWindowMac implementation
63 // ============================================================================
65 BEGIN_EVENT_TABLE(wxTopLevelWindowMac
, wxTopLevelWindowBase
)
69 // ---------------------------------------------------------------------------
71 // ---------------------------------------------------------------------------
73 extern long wxMacTranslateKey(unsigned char key
, unsigned char code
) ;
75 static const EventTypeSpec eventList
[] =
77 // TODO remove control related event like key and mouse (except for WindowLeave events)
79 { kEventClassTextInput
, kEventTextInputUnicodeForKeyEvent
} ,
81 { kEventClassKeyboard
, kEventRawKeyDown
} ,
82 { kEventClassKeyboard
, kEventRawKeyRepeat
} ,
83 { kEventClassKeyboard
, kEventRawKeyUp
} ,
84 { kEventClassKeyboard
, kEventRawKeyModifiersChanged
} ,
87 { kEventClassWindow
, kEventWindowShown
} ,
88 { kEventClassWindow
, kEventWindowActivated
} ,
89 { kEventClassWindow
, kEventWindowDeactivated
} ,
90 { kEventClassWindow
, kEventWindowBoundsChanging
} ,
91 { kEventClassWindow
, kEventWindowBoundsChanged
} ,
92 { kEventClassWindow
, kEventWindowClose
} ,
94 // we have to catch these events on the toplevel window level, as controls don't get the
95 // raw mouse events anymore
97 { kEventClassMouse
, kEventMouseDown
} ,
98 { kEventClassMouse
, kEventMouseUp
} ,
99 { kEventClassMouse
, kEventMouseWheelMoved
} ,
100 { kEventClassMouse
, kEventMouseMoved
} ,
101 { kEventClassMouse
, kEventMouseDragged
} ,
104 static pascal OSStatus
TextInputEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
106 OSStatus result
= eventNotHandledErr
;
108 wxWindow
* focus
= wxWindow::FindFocus() ;
116 GetEventParameter( event
, kEventParamTextInputSendKeyboardEvent
,typeEventRef
,NULL
,sizeof(rawEvent
),NULL
,&rawEvent
) ;
118 GetEventParameter( rawEvent
, kEventParamKeyMacCharCodes
, typeChar
, NULL
,sizeof(char), NULL
,&charCode
);
119 GetEventParameter( rawEvent
, kEventParamKeyCode
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &keyCode
);
120 GetEventParameter( rawEvent
, kEventParamKeyModifiers
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &modifiers
);
121 GetEventParameter( rawEvent
, kEventParamMouseLocation
, typeQDPoint
, NULL
,
122 sizeof( Point
), NULL
, &point
);
124 switch ( GetEventKind( event
) )
126 case kEventTextInputUnicodeForKeyEvent
:
127 // this is only called when no default handler has jumped in, eg a wxControl on a floater window does not
128 // get its own kEventTextInputUnicodeForKeyEvent, so we route back the
129 wxControl
* control
= wxDynamicCast( focus
, wxControl
) ;
132 ControlRef macControl
= (ControlRef
) control
->GetHandle() ;
135 ::HandleControlKey( macControl
, keyCode
, charCode
, modifiers
) ;
140 // this may lead to double events sent to a window in case all handlers have skipped the key down event
141 UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;
142 UInt32 message = (keyCode << 8) + charCode;
144 if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
145 focus , message , modifiers , when , point.h , point.v ) )
156 static pascal OSStatus
KeyboardEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
158 OSStatus result
= eventNotHandledErr
;
160 wxWindow
* focus
= wxWindow::FindFocus() ;
168 UInt32 when
= EventTimeToTicks( GetEventTime( event
) ) ;
170 GetEventParameter( event
, kEventParamKeyMacCharCodes
, typeChar
, NULL
,sizeof(char), NULL
,&charCode
);
171 GetEventParameter( event
, kEventParamKeyCode
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &keyCode
);
172 GetEventParameter(event
, kEventParamKeyModifiers
, typeUInt32
, NULL
, sizeof(UInt32
), NULL
, &modifiers
);
173 GetEventParameter( event
, kEventParamMouseLocation
, typeQDPoint
, NULL
,
174 sizeof( Point
), NULL
, &point
);
176 UInt32 message
= (keyCode
<< 8) + charCode
;
177 switch( GetEventKind( event
) )
179 case kEventRawKeyRepeat
:
180 case kEventRawKeyDown
:
182 WXEVENTREF formerEvent
= wxTheApp
->MacGetCurrentEvent() ;
183 WXEVENTHANDLERCALLREF formerHandler
= wxTheApp
->MacGetCurrentEventHandlerCallRef() ;
184 wxTheApp
->MacSetCurrentEvent( event
, handler
) ;
185 if ( (focus
!= NULL
) && wxTheApp
->MacSendKeyDownEvent(
186 focus
, message
, modifiers
, when
, point
.h
, point
.v
) )
190 wxTheApp
->MacSetCurrentEvent( formerEvent
, formerHandler
) ;
193 case kEventRawKeyUp
:
194 if ( (focus
!= NULL
) && wxTheApp
->MacSendKeyUpEvent(
195 focus
, message
, modifiers
, when
, point
.h
, point
.v
) )
200 case kEventRawKeyModifiersChanged
:
202 wxKeyEvent
event(wxEVT_KEY_DOWN
);
204 event
.m_shiftDown
= modifiers
& shiftKey
;
205 event
.m_controlDown
= modifiers
& controlKey
;
206 event
.m_altDown
= modifiers
& optionKey
;
207 event
.m_metaDown
= modifiers
& cmdKey
;
211 event
.m_timeStamp
= when
;
212 wxWindow
* focus
= wxWindow::FindFocus() ;
213 event
.SetEventObject(focus
);
215 if ( focus
&& (modifiers
^ wxTheApp
->s_lastModifiers
) & controlKey
)
217 event
.m_keyCode
= WXK_CONTROL
;
218 event
.SetEventType( ( modifiers
& controlKey
) ? wxEVT_KEY_DOWN
: wxEVT_KEY_UP
) ;
219 focus
->GetEventHandler()->ProcessEvent( event
) ;
221 if ( focus
&& (modifiers
^ wxTheApp
->s_lastModifiers
) & shiftKey
)
223 event
.m_keyCode
= WXK_SHIFT
;
224 event
.SetEventType( ( modifiers
& shiftKey
) ? wxEVT_KEY_DOWN
: wxEVT_KEY_UP
) ;
225 focus
->GetEventHandler()->ProcessEvent( event
) ;
227 if ( focus
&& (modifiers
^ wxTheApp
->s_lastModifiers
) & optionKey
)
229 event
.m_keyCode
= WXK_ALT
;
230 event
.SetEventType( ( modifiers
& optionKey
) ? wxEVT_KEY_DOWN
: wxEVT_KEY_UP
) ;
231 focus
->GetEventHandler()->ProcessEvent( event
) ;
233 if ( focus
&& (modifiers
^ wxTheApp
->s_lastModifiers
) & cmdKey
)
235 event
.m_keyCode
= WXK_COMMAND
;
236 event
.SetEventType( ( modifiers
& cmdKey
) ? wxEVT_KEY_DOWN
: wxEVT_KEY_UP
) ;
237 focus
->GetEventHandler()->ProcessEvent( event
) ;
239 wxTheApp
->s_lastModifiers
= modifiers
;
247 // we don't interfere with foreign controls on our toplevel windows, therefore we always give back eventNotHandledErr
248 // for windows that we didn't create (like eg Scrollbars in a databrowser) , or for controls where we did not handle the
251 // This handler can also be called from app level where data (ie target window) may be null or a non wx window
253 wxWindow
* g_MacLastWindow
= NULL
;
255 static EventMouseButton lastButton
= 0 ;
257 static void SetupMouseEvent( wxMouseEvent
&wxevent
, wxMacCarbonEvent
&cEvent
)
259 UInt32 modifiers
= cEvent
.GetParameter
<UInt32
>(kEventParamKeyModifiers
, typeUInt32
) ;
260 Point screenMouseLocation
= cEvent
.GetParameter
<Point
>(kEventParamMouseLocation
) ;
262 // this parameter are not given for all events
263 EventMouseButton button
= 0 ;
264 UInt32 clickCount
= 0 ;
265 cEvent
.GetParameter
<EventMouseButton
>(kEventParamMouseButton
, typeMouseButton
, &button
) ;
266 cEvent
.GetParameter
<UInt32
>(kEventParamClickCount
, typeUInt32
, &clickCount
) ;
268 wxevent
.m_x
= screenMouseLocation
.h
;
269 wxevent
.m_y
= screenMouseLocation
.v
;
270 wxevent
.m_shiftDown
= modifiers
& shiftKey
;
271 wxevent
.m_controlDown
= modifiers
& controlKey
;
272 wxevent
.m_altDown
= modifiers
& optionKey
;
273 wxevent
.m_metaDown
= modifiers
& cmdKey
;
274 wxevent
.SetTimestamp( cEvent
.GetTicks() ) ;
275 // a control click is interpreted as a right click
276 if ( button
== kEventMouseButtonPrimary
&& (modifiers
& controlKey
) )
278 button
= kEventMouseButtonSecondary
;
281 // we must make sure that our synthetic 'right' button corresponds in
282 // mouse down, moved and mouse up, and does not deliver a right down and left up
284 if ( cEvent
.GetKind() == kEventMouseDown
)
285 lastButton
= button
;
289 else if ( lastButton
)
290 button
= lastButton
;
292 // determinate the correct down state, wx does not want a 'down' for a mouseUp event, while mac delivers
294 if ( button
!= 0 && cEvent
.GetKind() != kEventMouseUp
)
298 case kEventMouseButtonPrimary
:
299 wxevent
.m_leftDown
= true ;
301 case kEventMouseButtonSecondary
:
302 wxevent
.m_rightDown
= true ;
304 case kEventMouseButtonTertiary
:
305 wxevent
.m_middleDown
= true ;
309 // translate into wx types
310 switch ( cEvent
.GetKind() )
312 case kEventMouseDown
:
315 case kEventMouseButtonPrimary
:
316 wxevent
.SetEventType(clickCount
> 1 ? wxEVT_LEFT_DCLICK
: wxEVT_LEFT_DOWN
) ;
318 case kEventMouseButtonSecondary
:
319 wxevent
.SetEventType( clickCount
> 1 ? wxEVT_RIGHT_DCLICK
: wxEVT_RIGHT_DOWN
) ;
321 case kEventMouseButtonTertiary
:
322 wxevent
.SetEventType(clickCount
> 1 ? wxEVT_MIDDLE_DCLICK
: wxEVT_MIDDLE_DOWN
) ;
329 case kEventMouseButtonPrimary
:
330 wxevent
.SetEventType( wxEVT_LEFT_UP
) ;
332 case kEventMouseButtonSecondary
:
333 wxevent
.SetEventType( wxEVT_RIGHT_UP
) ;
335 case kEventMouseButtonTertiary
:
336 wxevent
.SetEventType( wxEVT_MIDDLE_UP
) ;
340 case kEventMouseWheelMoved
:
341 wxevent
.SetEventType(wxEVT_MOUSEWHEEL
) ;
343 // EventMouseWheelAxis axis = cEvent.GetParameter<EventMouseWheelAxis>(kEventParamMouseWheelAxis, typeMouseWheelAxis) ;
344 SInt32 delta
= cEvent
.GetParameter
<SInt32
>(kEventParamMouseWheelDelta
, typeLongInteger
) ;
346 wxevent
.m_wheelRotation
= delta
;
347 wxevent
.m_wheelDelta
= 1;
348 wxevent
.m_linesPerAction
= 1;
351 wxevent
.SetEventType(wxEVT_MOTION
) ;
356 ControlRef
wxMacFindSubControl( Point location
, ControlRef superControl
, ControlPartCode
*outPart
)
360 UInt16 childrenCount
= 0 ;
361 OSStatus err
= CountSubControls( superControl
, &childrenCount
) ;
362 if ( err
== errControlIsNotEmbedder
)
364 wxASSERT_MSG( err
== noErr
, wxT("Unexpected error when accessing subcontrols") ) ;
366 for ( UInt16 i
= childrenCount
; i
>=1 ; --i
)
368 ControlHandle sibling
;
369 err
= GetIndexedSubControl( superControl
, i
, & sibling
) ;
370 if ( err
== errControlIsNotEmbedder
)
373 wxASSERT_MSG( err
== noErr
, wxT("Unexpected error when accessing subcontrols") ) ;
374 if ( IsControlVisible( sibling
) )
377 UMAGetControlBoundsInWindowCoords( sibling
, &r
) ;
378 if ( MacPtInRect( location
, &r
) )
380 ControlHandle child
= wxMacFindSubControl( location
, sibling
, outPart
) ;
385 Point testLocation
= location
;
386 #if TARGET_API_MAC_OSX
387 testLocation
.h
-= r
.left
;
388 testLocation
.v
-= r
.top
;
390 *outPart
= TestControl( sibling
, testLocation
) ;
400 ControlRef
wxMacFindControlUnderMouse( Point location
, WindowRef window
, ControlPartCode
*outPart
)
402 #if TARGET_API_MAC_OSX
403 if ( UMAGetSystemVersion() >= 0x1030 )
404 return FindControlUnderMouse( location
, window
, outPart
) ;
406 ControlRef rootControl
= NULL
;
407 verify_noerr( GetRootControl( window
, &rootControl
) ) ;
408 return wxMacFindSubControl( location
, rootControl
, outPart
) ;
411 pascal OSStatus
wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
414 OSStatus result
= eventNotHandledErr
;
416 wxMacCarbonEvent
cEvent( event
) ;
418 Point screenMouseLocation
= cEvent
.GetParameter
<Point
>(kEventParamMouseLocation
) ;
419 Point windowMouseLocation
= screenMouseLocation
;
422 short windowPart
= ::FindWindow(screenMouseLocation
, &window
);
424 wxWindow
* currentMouseWindow
= NULL
;
428 QDGlobalToLocalPoint( UMAGetWindowPort(window
) , &windowMouseLocation
) ;
430 if ( wxTheApp
->s_captureWindow
&& wxTheApp
->s_captureWindow
->MacGetTopLevelWindowRef() == (WXWindow
) window
&& windowPart
== inContent
)
432 currentMouseWindow
= wxTheApp
->s_captureWindow
;
434 else if ( (IsWindowActive(window
) && windowPart
== inContent
) )
436 ControlPartCode part
;
437 ControlRef control
= wxMacFindControlUnderMouse( windowMouseLocation
, window
, &part
) ;
439 currentMouseWindow
= (wxWindow
*) data
;
441 currentMouseWindow
= wxFindControlFromMacControl( control
) ;
445 wxMouseEvent
wxevent(wxEVT_LEFT_DOWN
);
446 SetupMouseEvent( wxevent
, cEvent
) ;
448 // handle all enter / leave events
450 if ( currentMouseWindow
!= g_MacLastWindow
)
452 if ( g_MacLastWindow
)
454 wxMouseEvent
eventleave(wxevent
);
455 eventleave
.SetEventType( wxEVT_LEAVE_WINDOW
);
456 g_MacLastWindow
->ScreenToClient( &eventleave
.m_x
, &eventleave
.m_y
);
457 eventleave
.SetEventObject( g_MacLastWindow
) ;
460 wxToolTip::RelayEvent( g_MacLastWindow
, eventleave
);
461 #endif // wxUSE_TOOLTIPS
462 g_MacLastWindow
->GetEventHandler()->ProcessEvent(eventleave
);
464 if ( currentMouseWindow
)
466 wxMouseEvent
evententer(wxevent
);
467 evententer
.SetEventType( wxEVT_ENTER_WINDOW
);
468 currentMouseWindow
->ScreenToClient( &evententer
.m_x
, &evententer
.m_y
);
469 evententer
.SetEventObject( currentMouseWindow
) ;
471 wxToolTip::RelayEvent( currentMouseWindow
, evententer
);
472 #endif // wxUSE_TOOLTIPS
473 currentMouseWindow
->GetEventHandler()->ProcessEvent(evententer
);
475 g_MacLastWindow
= currentMouseWindow
;
478 if ( windowPart
== inMenuBar
)
480 // special case menu bar, as we are having a low-level runloop we must do it ourselves
481 if ( cEvent
.GetKind() == kEventMouseDown
)
483 ::MenuSelect( screenMouseLocation
) ;
486 } // if ( windowPart == inMenuBar )
487 else if ( currentMouseWindow
)
489 currentMouseWindow
->ScreenToClient( &wxevent
.m_x
, &wxevent
.m_y
) ;
491 wxevent
.SetEventObject( currentMouseWindow
) ;
495 wxWindow
* cursorTarget
= currentMouseWindow
;
496 wxPoint
cursorPoint( wxevent
.m_x
, wxevent
.m_y
) ;
498 while( cursorTarget
&& !cursorTarget
->MacSetupCursor( cursorPoint
) )
500 cursorTarget
= cursorTarget
->GetParent() ;
502 cursorPoint
+= cursorTarget
->GetPosition() ;
507 if ( wxevent
.GetEventType() == wxEVT_LEFT_DOWN
)
509 // set focus to this window
510 if (currentMouseWindow
->AcceptsFocus() && wxWindow::FindFocus()!=currentMouseWindow
)
511 currentMouseWindow
->SetFocus();
514 // make tooltips current
517 if ( wxevent
.GetEventType() == wxEVT_MOTION
518 || wxevent
.GetEventType() == wxEVT_ENTER_WINDOW
519 || wxevent
.GetEventType() == wxEVT_LEAVE_WINDOW
)
520 wxToolTip::RelayEvent( currentMouseWindow
, wxevent
);
521 #endif // wxUSE_TOOLTIPS
522 if ( currentMouseWindow
->GetEventHandler()->ProcessEvent(wxevent
) )
526 ControlPartCode dummyPart
;
527 // if built-in find control is finding the wrong control (ie static box instead of overlaid
528 // button, we cannot let the standard handler do its job, but must handle manually
530 if ( ( cEvent
.GetKind() == kEventMouseDown
) &&
531 (FindControlUnderMouse(windowMouseLocation
, window
, &dummyPart
) !=
532 wxMacFindControlUnderMouse( windowMouseLocation
, window
, &dummyPart
) ) )
534 EventModifiers modifiers
= cEvent
.GetParameter
<EventModifiers
>(kEventParamKeyModifiers
, typeUInt32
) ;
535 Point clickLocation
= windowMouseLocation
;
536 #if TARGET_API_MAC_OSX
537 currentMouseWindow
->MacRootWindowToWindow( &clickLocation
.h
, &clickLocation
.v
) ;
539 HandleControlClick( (ControlRef
) currentMouseWindow
->GetHandle() , clickLocation
,
540 modifiers
, (ControlActionUPP
) -1 ) ;
544 if ( cEvent
.GetKind() == kEventMouseUp
&& wxTheApp
->s_captureWindow
)
546 wxTheApp
->s_captureWindow
= NULL
;
549 } // else if ( currentMouseWindow )
553 static pascal OSStatus
wxMacTopLevelWindowEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
555 OSStatus result
= eventNotHandledErr
;
557 wxMacCarbonEvent
cEvent( event
) ;
559 // WindowRef windowRef = cEvent.GetParameter<WindowRef>(kEventParamDirectObject) ;
560 wxTopLevelWindowMac
* toplevelWindow
= (wxTopLevelWindowMac
*) data
;
562 switch( GetEventKind( event
) )
564 case kEventWindowActivated
:
566 toplevelWindow
->MacActivate( cEvent
.GetTicks() , true) ;
567 wxActivateEvent
wxevent(wxEVT_ACTIVATE
, true , toplevelWindow
->GetId());
568 wxevent
.SetTimestamp( cEvent
.GetTicks() ) ;
569 wxevent
.SetEventObject(toplevelWindow
);
570 toplevelWindow
->GetEventHandler()->ProcessEvent(wxevent
);
571 // we still sending an eventNotHandledErr in order to allow for default processing
574 case kEventWindowDeactivated
:
576 toplevelWindow
->MacActivate(cEvent
.GetTicks() , false) ;
577 wxActivateEvent
wxevent(wxEVT_ACTIVATE
, false , toplevelWindow
->GetId());
578 wxevent
.SetTimestamp( cEvent
.GetTicks() ) ;
579 wxevent
.SetEventObject(toplevelWindow
);
580 toplevelWindow
->GetEventHandler()->ProcessEvent(wxevent
);
581 // we still sending an eventNotHandledErr in order to allow for default processing
584 case kEventWindowShown
:
585 toplevelWindow
->Refresh() ;
588 case kEventWindowClose
:
589 toplevelWindow
->Close() ;
592 case kEventWindowBoundsChanged
:
594 UInt32 attributes
= cEvent
.GetParameter
<UInt32
>(kEventParamAttributes
,typeUInt32
) ;
595 Rect newRect
= cEvent
.GetParameter
<Rect
>(kEventParamCurrentBounds
) ;
596 wxRect
r( newRect
.left
, newRect
.top
, newRect
.right
- newRect
.left
, newRect
.bottom
- newRect
.top
) ;
597 if ( attributes
& kWindowBoundsChangeSizeChanged
)
599 // according to the other ports we handle this within the OS level
600 // resize event, not within a wxSizeEvent
601 wxFrame
*frame
= wxDynamicCast( toplevelWindow
, wxFrame
) ;
605 frame
->PositionStatusBar();
608 frame
->PositionToolBar();
612 wxSizeEvent
event( r
.GetSize() , toplevelWindow
->GetId() ) ;
613 event
.SetEventObject( toplevelWindow
) ;
615 toplevelWindow
->GetEventHandler()->ProcessEvent(event
) ;
617 if ( attributes
& kWindowBoundsChangeOriginChanged
)
619 wxMoveEvent
event( r
.GetLeftTop() , toplevelWindow
->GetId() ) ;
620 event
.SetEventObject( toplevelWindow
) ;
621 toplevelWindow
->GetEventHandler()->ProcessEvent(event
) ;
626 case kEventWindowBoundsChanging
:
628 UInt32 attributes
= cEvent
.GetParameter
<UInt32
>(kEventParamAttributes
,typeUInt32
) ;
629 Rect newRect
= cEvent
.GetParameter
<Rect
>(kEventParamCurrentBounds
) ;
631 if ( (attributes
& kWindowBoundsChangeSizeChanged
) || (attributes
& kWindowBoundsChangeOriginChanged
) )
633 // all (Mac) rects are in content area coordinates, all wxRects in structure coordinates
634 int left
, top
, right
, bottom
;
635 toplevelWindow
->MacGetContentAreaInset( left
, top
, right
, bottom
) ;
636 wxRect
r( newRect
.left
- left
, newRect
.top
- top
,
637 newRect
.right
- newRect
.left
+ left
+ right
, newRect
.bottom
- newRect
.top
+ top
+ bottom
) ;
638 // this is a EVT_SIZING not a EVT_SIZE type !
639 wxSizeEvent
wxevent( r
, toplevelWindow
->GetId() ) ;
640 wxevent
.SetEventObject( toplevelWindow
) ;
642 if ( toplevelWindow
->GetEventHandler()->ProcessEvent(wxevent
) )
643 adjustR
= wxevent
.GetRect() ;
645 if ( toplevelWindow
->GetMaxWidth() != -1 && adjustR
.GetWidth() > toplevelWindow
->GetMaxWidth() )
646 adjustR
.SetWidth( toplevelWindow
->GetMaxWidth() ) ;
647 if ( toplevelWindow
->GetMaxHeight() != -1 && adjustR
.GetHeight() > toplevelWindow
->GetMaxHeight() )
648 adjustR
.SetHeight( toplevelWindow
->GetMaxHeight() ) ;
649 if ( toplevelWindow
->GetMinWidth() != -1 && adjustR
.GetWidth() < toplevelWindow
->GetMinWidth() )
650 adjustR
.SetWidth( toplevelWindow
->GetMinWidth() ) ;
651 if ( toplevelWindow
->GetMinHeight() != -1 && adjustR
.GetHeight() < toplevelWindow
->GetMinHeight() )
652 adjustR
.SetHeight( toplevelWindow
->GetMinHeight() ) ;
653 const Rect adjustedRect
= { adjustR
.y
+ top
, adjustR
.x
+ left
, adjustR
.y
+ adjustR
.height
- bottom
, adjustR
.x
+ adjustR
.width
- right
} ;
654 if ( !EqualRect( &newRect
, &adjustedRect
) )
655 cEvent
.SetParameter
<Rect
>( kEventParamCurrentBounds
, &adjustedRect
) ;
667 pascal OSStatus
wxMacTopLevelEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
669 OSStatus result
= eventNotHandledErr
;
671 switch ( GetEventClass( event
) )
673 case kEventClassKeyboard
:
674 result
= KeyboardEventHandler( handler
, event
, data
) ;
676 case kEventClassTextInput
:
677 result
= TextInputEventHandler( handler
, event
, data
) ;
679 case kEventClassWindow
:
680 result
= wxMacTopLevelWindowEventHandler( handler
, event
, data
) ;
682 case kEventClassMouse
:
683 result
= wxMacTopLevelMouseEventHandler( handler
, event
, data
) ;
691 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacTopLevelEventHandler
)
693 // ---------------------------------------------------------------------------
694 // wxWindowMac utility functions
695 // ---------------------------------------------------------------------------
697 // Find an item given the Macintosh Window Reference
699 wxList
wxWinMacWindowList(wxKEY_INTEGER
);
700 wxTopLevelWindowMac
*wxFindWinFromMacWindow(WindowRef inWindowRef
)
702 wxNode
*node
= wxWinMacWindowList
.Find((long)inWindowRef
);
705 return (wxTopLevelWindowMac
*)node
->GetData();
708 void wxAssociateWinWithMacWindow(WindowRef inWindowRef
, wxTopLevelWindowMac
*win
) ;
709 void wxAssociateWinWithMacWindow(WindowRef inWindowRef
, wxTopLevelWindowMac
*win
)
711 // adding NULL WindowRef is (first) surely a result of an error and
712 // (secondly) breaks menu command processing
713 wxCHECK_RET( inWindowRef
!= (WindowRef
) NULL
, wxT("attempt to add a NULL WindowRef to window list") );
715 if ( !wxWinMacWindowList
.Find((long)inWindowRef
) )
716 wxWinMacWindowList
.Append((long)inWindowRef
, win
);
719 void wxRemoveMacWindowAssociation(wxTopLevelWindowMac
*win
) ;
720 void wxRemoveMacWindowAssociation(wxTopLevelWindowMac
*win
)
722 wxWinMacWindowList
.DeleteObject(win
);
726 // ----------------------------------------------------------------------------
727 // wxTopLevelWindowMac creation
728 // ----------------------------------------------------------------------------
730 wxTopLevelWindowMac
*wxTopLevelWindowMac::s_macDeactivateWindow
= NULL
;
732 void wxTopLevelWindowMac::Init()
735 m_maximizeOnShow
= FALSE
;
737 #if TARGET_API_MAC_OSX
738 m_macUsesCompositing
= TRUE
;
740 m_macUsesCompositing
= FALSE
;
742 m_macEventHandler
= NULL
;
745 class wxMacDeferredWindowDeleter
: public wxObject
748 wxMacDeferredWindowDeleter( WindowRef windowRef
)
750 m_macWindow
= windowRef
;
752 virtual ~wxMacDeferredWindowDeleter()
754 UMADisposeWindow( (WindowRef
) m_macWindow
) ;
757 WindowRef m_macWindow
;
760 bool wxTopLevelWindowMac::Create(wxWindow
*parent
,
762 const wxString
& title
,
766 const wxString
& name
)
771 m_windowStyle
= style
;
775 m_windowId
= id
== -1 ? NewControlId() : id
;
777 MacCreateRealWindow( title
, pos
, size
, MacRemoveBordersFromStyle(style
) , name
) ;
779 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
));
781 wxTopLevelWindows
.Append(this);
784 parent
->AddChild(this);
789 wxTopLevelWindowMac::~wxTopLevelWindowMac()
793 wxToolTip::NotifyWindowDelete(m_macWindow
) ;
794 wxPendingDelete
.Append( new wxMacDeferredWindowDeleter( (WindowRef
) m_macWindow
) ) ;
797 if ( m_macEventHandler
)
799 ::RemoveEventHandler((EventHandlerRef
) m_macEventHandler
);
800 m_macEventHandler
= NULL
;
803 wxRemoveMacWindowAssociation( this ) ;
805 if ( wxModelessWindows
.Find(this) )
806 wxModelessWindows
.DeleteObject(this);
810 // ----------------------------------------------------------------------------
811 // wxTopLevelWindowMac maximize/minimize
812 // ----------------------------------------------------------------------------
814 void wxTopLevelWindowMac::Maximize(bool maximize
)
816 wxMacPortStateHelper
help( (GrafPtr
) GetWindowPort( (WindowRef
) m_macWindow
) ) ;
817 wxMacWindowClipper
clip (this);
818 ZoomWindow( (WindowRef
)m_macWindow
, maximize
? inZoomOut
: inZoomIn
, false ) ;
821 bool wxTopLevelWindowMac::IsMaximized() const
823 return IsWindowInStandardState( (WindowRef
)m_macWindow
, NULL
, NULL
) ;
826 void wxTopLevelWindowMac::Iconize(bool iconize
)
828 if ( IsWindowCollapsable((WindowRef
)m_macWindow
) )
829 CollapseWindow((WindowRef
)m_macWindow
, iconize
) ;
832 bool wxTopLevelWindowMac::IsIconized() const
834 return IsWindowCollapsed((WindowRef
)m_macWindow
) ;
837 void wxTopLevelWindowMac::Restore()
839 // not available on mac
842 // ----------------------------------------------------------------------------
843 // wxTopLevelWindowMac misc
844 // ----------------------------------------------------------------------------
846 wxPoint
wxTopLevelWindowMac::GetClientAreaOrigin() const
848 return wxPoint(0,0) ;
851 void wxTopLevelWindowMac::SetIcon(const wxIcon
& icon
)
854 wxTopLevelWindowBase::SetIcon(icon
);
857 void wxTopLevelWindowMac::MacSetBackgroundBrush( const wxBrush
&brush
)
859 wxTopLevelWindowBase::MacSetBackgroundBrush( brush
) ;
861 if ( m_macBackgroundBrush
.Ok() && m_macBackgroundBrush
.GetStyle() != wxTRANSPARENT
&& m_macBackgroundBrush
.MacGetBrushKind() == kwxMacBrushTheme
)
863 SetThemeWindowBackground( (WindowRef
) m_macWindow
, m_macBackgroundBrush
.MacGetTheme() , false ) ;
867 void wxTopLevelWindowMac::MacInstallTopLevelWindowEventHandler()
869 if ( m_macEventHandler
!= NULL
)
871 verify_noerr( ::RemoveEventHandler( (EventHandlerRef
) m_macEventHandler
) ) ;
873 InstallWindowEventHandler(MAC_WXHWND(m_macWindow
), GetwxMacTopLevelEventHandlerUPP(),
874 GetEventTypeCount(eventList
), eventList
, this, (EventHandlerRef
*)&m_macEventHandler
);
877 void wxTopLevelWindowMac::MacCreateRealWindow( const wxString
& title
,
881 const wxString
& name
)
883 OSStatus err
= noErr
;
885 m_windowStyle
= style
;
899 int w
= WidthDefault(size
.x
);
900 int h
= HeightDefault(size
.y
);
902 ::SetRect(&theBoundsRect
, x
, y
, x
+ w
, y
+ h
);
904 // translate the window attributes in the appropriate window class and attributes
906 WindowClass wclass
= 0;
907 WindowAttributes attr
= kWindowNoAttributes
;
909 if ( HasFlag( wxFRAME_TOOL_WINDOW
) )
912 HasFlag( wxMINIMIZE_BOX
) || HasFlag( wxMAXIMIZE_BOX
) ||
913 HasFlag( wxSYSTEM_MENU
) || HasFlag( wxCAPTION
) ||
914 HasFlag(wxTINY_CAPTION_HORIZ
) || HasFlag(wxTINY_CAPTION_VERT
)
917 wclass
= kFloatingWindowClass
;
918 if ( HasFlag(wxTINY_CAPTION_VERT
) )
920 attr
|= kWindowSideTitlebarAttribute
;
925 wclass
= kPlainWindowClass
;
928 else if ( HasFlag( wxCAPTION
) )
930 wclass
= kDocumentWindowClass
;
934 if ( HasFlag( wxMINIMIZE_BOX
) || HasFlag( wxMAXIMIZE_BOX
) ||
935 HasFlag( wxCLOSE_BOX
) || HasFlag( wxSYSTEM_MENU
) )
937 wclass
= kDocumentWindowClass
;
941 wclass
= kPlainWindowClass
;
945 if ( HasFlag( wxMINIMIZE_BOX
) )
947 attr
|= kWindowCollapseBoxAttribute
;
949 if ( HasFlag( wxMAXIMIZE_BOX
) )
951 attr
|= kWindowFullZoomAttribute
;
953 if ( HasFlag( wxRESIZE_BORDER
) )
955 attr
|= kWindowResizableAttribute
;
957 if ( HasFlag( wxCLOSE_BOX
) )
959 attr
|= kWindowCloseBoxAttribute
;
962 if (UMAGetSystemVersion() >= 0x1000)
964 // turn on live resizing (OS X only)
965 attr
|= kWindowLiveResizeAttribute
;
968 if (HasFlag(wxSTAY_ON_TOP
))
969 wclass
= kUtilityWindowClass
;
971 #if TARGET_API_MAC_OSX
972 attr
|= kWindowCompositingAttribute
;
975 if ( HasFlag(wxFRAME_SHAPED
) )
977 WindowDefSpec customWindowDefSpec
;
978 customWindowDefSpec
.defType
= kWindowDefProcPtr
;
979 customWindowDefSpec
.u
.defProc
= NewWindowDefUPP(wxShapedMacWindowDef
);
981 err
= ::CreateCustomWindow( &customWindowDefSpec
, wclass
,
982 attr
, &theBoundsRect
,
983 (WindowRef
*) &m_macWindow
);
987 err
= ::CreateNewWindow( wclass
, attr
, &theBoundsRect
, (WindowRef
*)&m_macWindow
) ;
990 wxCHECK_RET( err
== noErr
, wxT("Mac OS error when trying to create new window") );
992 // the create commands are only for content rect, so we have to set the size again as
994 SetWindowBounds( (WindowRef
) m_macWindow
, kWindowStructureRgn
, &theBoundsRect
) ;
996 wxAssociateWinWithMacWindow( (WindowRef
) m_macWindow
, this ) ;
997 UMASetWTitle( (WindowRef
) m_macWindow
, title
, m_font
.GetEncoding() ) ;
998 m_peer
= new wxMacControl() ;
999 #if TARGET_API_MAC_OSX
1000 // There is a bug in 10.2.X for ::GetRootControl returning the window view instead of
1001 // the content view, so we have to retrieve it explicitely
1002 HIViewFindByID( HIViewGetRoot( (WindowRef
) m_macWindow
) , kHIViewWindowContentID
,
1004 if ( !m_peer
->Ok() )
1006 // compatibility mode fallback
1007 GetRootControl( (WindowRef
) m_macWindow
, *m_peer
) ;
1010 ::CreateRootControl( (WindowRef
)m_macWindow
, *m_peer
) ;
1012 // the root control level handleer
1013 MacInstallEventHandler() ;
1015 // the frame window event handler
1016 InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow
)) ) ;
1017 MacInstallTopLevelWindowEventHandler() ;
1021 if ( HasFlag(wxFRAME_SHAPED
) )
1023 // default shape matches the window size
1024 wxRegion
rgn(0, 0, w
, h
);
1028 wxWindowCreateEvent
event(this);
1029 GetEventHandler()->ProcessEvent(event
);
1032 void wxTopLevelWindowMac::ClearBackground()
1034 wxWindow::ClearBackground() ;
1037 // Raise the window to the top of the Z order
1038 void wxTopLevelWindowMac::Raise()
1040 ::SelectWindow( (WindowRef
)m_macWindow
) ;
1043 // Lower the window to the bottom of the Z order
1044 void wxTopLevelWindowMac::Lower()
1046 ::SendBehind( (WindowRef
)m_macWindow
, NULL
) ;
1050 void wxTopLevelWindowMac::MacDelayedDeactivation(long timestamp
)
1052 if(s_macDeactivateWindow
)
1054 wxLogDebug(wxT("Doing delayed deactivation of %p"),s_macDeactivateWindow
);
1055 s_macDeactivateWindow
->MacActivate(timestamp
, false);
1059 void wxTopLevelWindowMac::MacActivate( long timestamp
, bool inIsActivating
)
1061 // wxLogDebug(wxT("TopLevel=%p::MacActivate"),this);
1063 if(s_macDeactivateWindow
==this)
1064 s_macDeactivateWindow
=NULL
;
1065 MacDelayedDeactivation(timestamp
);
1066 MacPropagateHiliteChanged() ;
1069 void wxTopLevelWindowMac::SetTitle(const wxString
& title
)
1071 wxWindow::SetTitle( title
) ;
1072 UMASetWTitle( (WindowRef
)m_macWindow
, title
, m_font
.GetEncoding() ) ;
1075 bool wxTopLevelWindowMac::Show(bool show
)
1077 if ( !wxTopLevelWindowBase::Show(show
) )
1082 #if wxUSE_SYSTEM_OPTIONS //code contributed by Ryan Wilcox December 18, 2003
1083 if ( (wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION
) ) && ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION
) == 1) )
1085 ::ShowWindow( (WindowRef
)m_macWindow
);
1090 ::TransitionWindow((WindowRef
)m_macWindow
,kWindowZoomTransitionEffect
,kWindowShowTransitionAction
,nil
);
1092 ::SelectWindow( (WindowRef
)m_macWindow
) ;
1093 // as apps expect a size event to occur at this moment
1094 wxSizeEvent
event( GetSize() , m_windowId
);
1095 event
.SetEventObject(this);
1096 GetEventHandler()->ProcessEvent(event
);
1100 #if wxUSE_SYSTEM_OPTIONS
1101 if ( (wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION
) ) && ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION
) == 1) )
1103 ::HideWindow((WindowRef
) m_macWindow
);
1108 ::TransitionWindow((WindowRef
)m_macWindow
,kWindowZoomTransitionEffect
,kWindowHideTransitionAction
,nil
);
1112 MacPropagateVisibilityChanged() ;
1117 // we are still using coordinates of the content view, todo switch to structure bounds
1119 void wxTopLevelWindowMac::MacGetContentAreaInset( int &left
, int &top
, int &right
, int &bottom
)
1123 GetWindowBounds( (WindowRef
) m_macWindow
, kWindowStructureRgn
, &structure
) ;
1124 GetWindowBounds( (WindowRef
) m_macWindow
, kWindowContentRgn
, &content
) ;
1126 left
= content
.left
- structure
.left
;
1127 top
= content
.top
- structure
.top
;
1128 right
= structure
.right
- content
.right
;
1129 bottom
= structure
.bottom
- content
.bottom
;
1132 void wxTopLevelWindowMac::DoMoveWindow(int x
, int y
, int width
, int height
)
1134 Rect bounds
= { y
, x
, y
+ height
, x
+ width
} ;
1135 verify_noerr(SetWindowBounds( (WindowRef
) m_macWindow
, kWindowStructureRgn
, &bounds
)) ;
1138 void wxTopLevelWindowMac::DoGetPosition( int *x
, int *y
) const
1141 verify_noerr(GetWindowBounds((WindowRef
) m_macWindow
, kWindowStructureRgn
, &bounds
)) ;
1142 if(x
) *x
= bounds
.left
;
1143 if(y
) *y
= bounds
.top
;
1145 void wxTopLevelWindowMac::DoGetSize( int *width
, int *height
) const
1148 verify_noerr(GetWindowBounds((WindowRef
) m_macWindow
, kWindowStructureRgn
, &bounds
)) ;
1149 if(width
) *width
= bounds
.right
- bounds
.left
;
1150 if(height
) *height
= bounds
.bottom
- bounds
.top
;
1153 void wxTopLevelWindowMac::DoGetClientSize( int *width
, int *height
) const
1156 verify_noerr(GetWindowBounds((WindowRef
) m_macWindow
, kWindowContentRgn
, &bounds
)) ;
1157 if(width
) *width
= bounds
.right
- bounds
.left
;
1158 if(height
) *height
= bounds
.bottom
- bounds
.top
;
1161 void wxTopLevelWindowMac::MacSetMetalAppearance( bool set
)
1163 #if TARGET_API_MAC_OSX
1165 GetWindowAttributes((WindowRef
) m_macWindow
, &attr
) ;
1166 wxASSERT_MSG( attr
& kWindowCompositingAttribute
,
1167 wxT("Cannot set metal appearance on a non-compositing window") ) ;
1169 MacChangeWindowAttributes( set
? kWindowMetalAttribute
: kWindowNoAttributes
,
1170 set
? kWindowNoAttributes
: kWindowMetalAttribute
) ;
1174 bool wxTopLevelWindowMac::MacGetMetalAppearance() const
1176 #if TARGET_API_MAC_OSX
1177 return MacGetWindowAttributes() & kWindowMetalAttribute
;
1183 void wxTopLevelWindowMac::MacChangeWindowAttributes( wxUint32 attributesToSet
, wxUint32 attributesToClear
)
1185 ChangeWindowAttributes ( (WindowRef
) m_macWindow
, attributesToSet
, attributesToClear
) ;
1188 wxUint32
wxTopLevelWindowMac::MacGetWindowAttributes() const
1191 GetWindowAttributes((WindowRef
) m_macWindow
, &attr
) ;
1195 // ---------------------------------------------------------------------------
1196 // Shape implementation
1197 // ---------------------------------------------------------------------------
1200 bool wxTopLevelWindowMac::SetShape(const wxRegion
& region
)
1202 wxCHECK_MSG( HasFlag(wxFRAME_SHAPED
), FALSE
,
1203 _T("Shaped windows must be created with the wxFRAME_SHAPED style."));
1205 // The empty region signifies that the shape should be removed from the
1207 if ( region
.IsEmpty() )
1209 wxSize sz
= GetClientSize();
1210 wxRegion
rgn(0, 0, sz
.x
, sz
.y
);
1211 return SetShape(rgn
);
1214 // Make a copy of the region
1215 RgnHandle shapeRegion
= NewRgn();
1216 CopyRgn( (RgnHandle
)region
.GetWXHRGN(), shapeRegion
);
1218 // Dispose of any shape region we may already have
1219 RgnHandle oldRgn
= (RgnHandle
)GetWRefCon( (WindowRef
)MacGetWindowRef() );
1223 // Save the region so we can use it later
1224 SetWRefCon((WindowRef
)MacGetWindowRef(), (SInt32
)shapeRegion
);
1226 // Tell the window manager that the window has changed shape
1227 ReshapeCustomWindow((WindowRef
)MacGetWindowRef());
1231 // ---------------------------------------------------------------------------
1232 // Support functions for shaped windows, based on Apple's CustomWindow sample at
1233 // http://developer.apple.com/samplecode/Sample_Code/Human_Interface_Toolbox/Mac_OS_High_Level_Toolbox/CustomWindow.htm
1234 // ---------------------------------------------------------------------------
1236 static void wxShapedMacWindowGetPos(WindowRef window
, Rect
* inRect
)
1238 GetWindowPortBounds(window
, inRect
);
1239 Point pt
= {inRect
->left
, inRect
->top
};
1240 QDLocalToGlobalPoint( GetWindowPort(window
) , &pt
) ;
1242 inRect
->left
= pt
.h
;
1243 inRect
->bottom
+= pt
.v
;
1244 inRect
->right
+= pt
.h
;
1248 static SInt32
wxShapedMacWindowGetFeatures(WindowRef window
, SInt32 param
)
1250 /*------------------------------------------------------
1251 Define which options your custom window supports.
1252 --------------------------------------------------------*/
1253 //just enable everything for our demo
1254 *(OptionBits
*)param
=//kWindowCanGrow|
1256 //kWindowCanCollapse|
1257 //kWindowCanGetWindowRegion|
1258 //kWindowHasTitleBar|
1259 //kWindowSupportsDragHilite|
1260 kWindowCanDrawInCurrentPort
|
1261 //kWindowCanMeasureTitle|
1262 kWindowWantsDisposeAtProcessDeath
|
1263 kWindowSupportsSetGrowImageRegion
|
1264 kWindowDefSupportsColorGrafPort
;
1268 // The content region is left as a rectangle matching the window size, this is
1269 // so the origin in the paint event, and etc. still matches what the
1270 // programmer expects.
1271 static void wxShapedMacWindowContentRegion(WindowRef window
, RgnHandle rgn
)
1274 wxTopLevelWindowMac
* win
= wxFindWinFromMacWindow(window
);
1278 wxShapedMacWindowGetPos(window
, &r
) ;
1279 RectRgn( rgn
, &r
) ;
1283 // The structure region is set to the shape given to the SetShape method.
1284 static void wxShapedMacWindowStructureRegion(WindowRef window
, RgnHandle rgn
)
1286 RgnHandle cachedRegion
= (RgnHandle
) GetWRefCon(window
);
1292 wxShapedMacWindowGetPos(window
, &windowRect
); //how big is the window
1293 CopyRgn(cachedRegion
, rgn
); //make a copy of our cached region
1294 OffsetRgn(rgn
, windowRect
.left
, windowRect
.top
); // position it over window
1295 //MapRgn(rgn, &mMaskSize, &windowRect); //scale it to our actual window size
1301 static SInt32
wxShapedMacWindowGetRegion(WindowRef window
, SInt32 param
)
1303 GetWindowRegionPtr rgnRec
=(GetWindowRegionPtr
)param
;
1305 switch(rgnRec
->regionCode
)
1307 case kWindowStructureRgn
:
1308 wxShapedMacWindowStructureRegion(window
, rgnRec
->winRgn
);
1310 case kWindowContentRgn
:
1311 wxShapedMacWindowContentRegion(window
, rgnRec
->winRgn
);
1314 SetEmptyRgn(rgnRec
->winRgn
);
1321 static SInt32
wxShapedMacWindowHitTest(WindowRef window
,SInt32 param
)
1323 /*------------------------------------------------------
1324 Determine the region of the window which was hit
1325 --------------------------------------------------------*/
1327 static RgnHandle tempRgn
=nil
;
1332 SetPt(&hitPoint
,LoWord(param
),HiWord(param
));//get the point clicked
1334 //Mac OS 8.5 or later
1335 wxShapedMacWindowStructureRegion(window
, tempRgn
);
1336 if (PtInRgn(hitPoint
, tempRgn
)) //in window content region?
1339 return wNoHit
;//no significant area was hit.
1343 static pascal long wxShapedMacWindowDef(short varCode
, WindowRef window
, SInt16 message
, SInt32 param
)
1347 case kWindowMsgHitTest
:
1348 return wxShapedMacWindowHitTest(window
,param
);
1350 case kWindowMsgGetFeatures
:
1351 return wxShapedMacWindowGetFeatures(window
,param
);
1353 // kWindowMsgGetRegion is sent during CreateCustomWindow and ReshapeCustomWindow
1354 case kWindowMsgGetRegion
:
1355 return wxShapedMacWindowGetRegion(window
,param
);
1361 // ---------------------------------------------------------------------------