]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/carbon/toplevel.cpp
fixing string param
[wxWidgets.git] / src / mac / carbon / toplevel.cpp
... / ...
CommitLineData
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
64static const wxChar *TRACE_ACTIVATE = _T("activation");
65
66// ----------------------------------------------------------------------------
67// globals
68// ----------------------------------------------------------------------------
69
70// list of all frames and modeless dialogs
71wxWindowList wxModelessWindows;
72
73static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param);
74
75// ============================================================================
76// wxTopLevelWindowMac implementation
77// ============================================================================
78
79BEGIN_EVENT_TABLE(wxTopLevelWindowMac, wxTopLevelWindowBase)
80END_EVENT_TABLE()
81
82// ---------------------------------------------------------------------------
83// Carbon Events
84// ---------------------------------------------------------------------------
85
86static 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
116static 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->HandleWindowEvent( 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->HandleWindowEvent( 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->HandleWindowEvent( 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->HandleWindowEvent( 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
252wxWindow* g_MacLastWindow = NULL ;
253
254EventMouseButton g_lastButton = 0 ;
255bool g_lastButtonWasFakeRight = false ;
256
257void 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#define NEW_CAPTURE_HANDLING 1
394
395pascal OSStatus
396wxMacTopLevelMouseEventHandler(EventHandlerCallRef WXUNUSED(handler),
397 EventRef event,
398 void *data)
399{
400 wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
401
402 OSStatus result = eventNotHandledErr ;
403
404 wxMacCarbonEvent cEvent( event ) ;
405
406 Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ;
407 Point windowMouseLocation = screenMouseLocation ;
408
409 WindowRef window = NULL;
410 short windowPart = ::FindWindow(screenMouseLocation, &window);
411
412 wxWindow* currentMouseWindow = NULL ;
413 ControlRef control = NULL ;
414
415#if NEW_CAPTURE_HANDLING
416 if ( wxApp::s_captureWindow )
417 {
418 window = (WindowRef) wxApp::s_captureWindow->MacGetTopLevelWindowRef() ;
419 windowPart = inContent ;
420 }
421#endif
422
423 if ( window )
424 {
425 wxMacGlobalToLocal( window, &windowMouseLocation ) ;
426
427 if ( wxApp::s_captureWindow
428#if !NEW_CAPTURE_HANDLING
429 && wxApp::s_captureWindow->MacGetTopLevelWindowRef() == (WXWindow) window && windowPart == inContent
430#endif
431 )
432 {
433 currentMouseWindow = wxApp::s_captureWindow ;
434 }
435 else if ( (IsWindowActive(window) && windowPart == inContent) )
436 {
437 ControlPartCode part ;
438 control = FindControlUnderMouse( windowMouseLocation , window , &part ) ;
439 // if there is no control below the mouse position, send the event to the toplevel window itself
440 if ( control == 0 )
441 {
442 currentMouseWindow = (wxWindow*) data ;
443 }
444 else
445 {
446 currentMouseWindow = (wxWindow*) wxFindControlFromMacControl( control ) ;
447#ifndef __WXUNIVERSAL__
448 if ( currentMouseWindow == NULL && cEvent.GetKind() == kEventMouseMoved )
449 {
450#if wxUSE_TOOLBAR
451 // for wxToolBar to function we have to send certaint events to it
452 // instead of its children (wxToolBarTools)
453 ControlRef parent ;
454 GetSuperControl(control, &parent );
455 wxWindow *wxParent = (wxWindow*) wxFindControlFromMacControl( parent ) ;
456 if ( wxParent && wxParent->IsKindOf( CLASSINFO( wxToolBar ) ) )
457 currentMouseWindow = wxParent ;
458#endif
459 }
460#endif
461 }
462
463 // disabled windows must not get any input messages
464 if ( currentMouseWindow && !currentMouseWindow->MacIsReallyEnabled() )
465 currentMouseWindow = NULL;
466 }
467 }
468
469 wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
470 SetupMouseEvent( wxevent , cEvent ) ;
471
472 // handle all enter / leave events
473
474 if ( currentMouseWindow != g_MacLastWindow )
475 {
476 if ( g_MacLastWindow )
477 {
478 wxMouseEvent eventleave(wxevent);
479 eventleave.SetEventType( wxEVT_LEAVE_WINDOW );
480 g_MacLastWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
481 eventleave.SetEventObject( g_MacLastWindow ) ;
482 wxevent.SetId( g_MacLastWindow->GetId() ) ;
483
484#if wxUSE_TOOLTIPS
485 wxToolTip::RelayEvent( g_MacLastWindow , eventleave);
486#endif
487
488 g_MacLastWindow->HandleWindowEvent(eventleave);
489 }
490
491 if ( currentMouseWindow )
492 {
493 wxMouseEvent evententer(wxevent);
494 evententer.SetEventType( wxEVT_ENTER_WINDOW );
495 currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
496 evententer.SetEventObject( currentMouseWindow ) ;
497 wxevent.SetId( currentMouseWindow->GetId() ) ;
498
499#if wxUSE_TOOLTIPS
500 wxToolTip::RelayEvent( currentMouseWindow , evententer );
501#endif
502
503 currentMouseWindow->HandleWindowEvent(evententer);
504 }
505
506 g_MacLastWindow = currentMouseWindow ;
507 }
508
509 if ( windowPart == inMenuBar )
510 {
511 // special case menu bar, as we are having a low-level runloop we must do it ourselves
512 if ( cEvent.GetKind() == kEventMouseDown )
513 {
514 ::MenuSelect( screenMouseLocation ) ;
515 ::HiliteMenu(0);
516 result = noErr ;
517 }
518 }
519 else if ( currentMouseWindow )
520 {
521 wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent();
522
523 currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ;
524
525 wxevent.SetEventObject( currentMouseWindow ) ;
526 wxevent.SetId( currentMouseWindow->GetId() ) ;
527
528 // make tooltips current
529
530#if wxUSE_TOOLTIPS
531 if ( wxevent.GetEventType() == wxEVT_MOTION )
532 wxToolTip::RelayEvent( currentMouseWindow , wxevent );
533#endif
534
535 if ( currentMouseWindow->HandleWindowEvent(wxevent) )
536 {
537 if ((currentMouseWindowParent != NULL) &&
538 (currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL))
539 currentMouseWindow = NULL;
540
541 result = noErr;
542 }
543 else
544 {
545 // if the user code did _not_ handle the event, then perform the
546 // default processing
547 if ( wxevent.GetEventType() == wxEVT_LEFT_DOWN )
548 {
549 // ... that is set focus to this window
550 if (currentMouseWindow->CanAcceptFocus() && wxWindow::FindFocus()!=currentMouseWindow)
551 currentMouseWindow->SetFocus();
552 }
553 }
554
555 if ( cEvent.GetKind() == kEventMouseUp && wxApp::s_captureWindow )
556 {
557 wxApp::s_captureWindow = NULL ;
558 // update cursor ?
559 }
560
561 // update cursor
562
563 wxWindow* cursorTarget = currentMouseWindow ;
564 wxPoint cursorPoint( wxevent.m_x , wxevent.m_y ) ;
565
566 while ( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) )
567 {
568 cursorTarget = cursorTarget->GetParent() ;
569 if ( cursorTarget )
570 cursorPoint += cursorTarget->GetPosition();
571 }
572
573 }
574 else // currentMouseWindow == NULL
575 {
576 // don't mess with controls we don't know about
577 // for some reason returning eventNotHandledErr does not lead to the correct behaviour
578 // so we try sending them the correct control directly
579 if ( cEvent.GetKind() == kEventMouseDown && toplevelWindow && control )
580 {
581 EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
582 Point clickLocation = windowMouseLocation ;
583
584 HIPoint hiPoint ;
585 hiPoint.x = clickLocation.h ;
586 hiPoint.y = clickLocation.v ;
587 HIViewConvertPoint( &hiPoint , (ControlRef) toplevelWindow->GetHandle() , control ) ;
588 clickLocation.h = (int)hiPoint.x ;
589 clickLocation.v = (int)hiPoint.y ;
590
591 HandleControlClick( control , clickLocation , modifiers , (ControlActionUPP ) -1 ) ;
592 result = noErr ;
593 }
594 }
595
596 return result ;
597}
598
599static pascal OSStatus
600wxMacTopLevelWindowEventHandler(EventHandlerCallRef WXUNUSED(handler),
601 EventRef event,
602 void *data)
603{
604 OSStatus result = eventNotHandledErr ;
605
606 wxMacCarbonEvent cEvent( event ) ;
607
608 // WindowRef windowRef = cEvent.GetParameter<WindowRef>(kEventParamDirectObject) ;
609 wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
610
611 switch ( GetEventKind( event ) )
612 {
613 case kEventWindowActivated :
614 {
615 toplevelWindow->MacActivate( cEvent.GetTicks() , true) ;
616 wxActivateEvent wxevent(wxEVT_ACTIVATE, true , toplevelWindow->GetId());
617 wxevent.SetTimestamp( cEvent.GetTicks() ) ;
618 wxevent.SetEventObject(toplevelWindow);
619 toplevelWindow->HandleWindowEvent(wxevent);
620 // we still sending an eventNotHandledErr in order to allow for default processing
621 }
622 break ;
623
624 case kEventWindowDeactivated :
625 {
626 toplevelWindow->MacActivate(cEvent.GetTicks() , false) ;
627 wxActivateEvent wxevent(wxEVT_ACTIVATE, false , toplevelWindow->GetId());
628 wxevent.SetTimestamp( cEvent.GetTicks() ) ;
629 wxevent.SetEventObject(toplevelWindow);
630 toplevelWindow->HandleWindowEvent(wxevent);
631 // we still sending an eventNotHandledErr in order to allow for default processing
632 }
633 break ;
634
635 case kEventWindowShown :
636 toplevelWindow->Refresh() ;
637 result = noErr ;
638 break ;
639
640 case kEventWindowClose :
641 toplevelWindow->Close() ;
642 result = noErr ;
643 break ;
644
645 case kEventWindowBoundsChanged :
646 {
647 UInt32 attributes = cEvent.GetParameter<UInt32>(kEventParamAttributes, typeUInt32) ;
648 Rect newRect = cEvent.GetParameter<Rect>(kEventParamCurrentBounds) ;
649 wxRect r( newRect.left , newRect.top , newRect.right - newRect.left , newRect.bottom - newRect.top ) ;
650 if ( attributes & kWindowBoundsChangeSizeChanged )
651 {
652#ifndef __WXUNIVERSAL__
653 // according to the other ports we handle this within the OS level
654 // resize event, not within a wxSizeEvent
655 wxFrame *frame = wxDynamicCast( toplevelWindow , wxFrame ) ;
656 if ( frame )
657 {
658 frame->PositionBars();
659 }
660#endif
661 wxSizeEvent event( r.GetSize() , toplevelWindow->GetId() ) ;
662 event.SetEventObject( toplevelWindow ) ;
663
664 toplevelWindow->HandleWindowEvent(event) ;
665 toplevelWindow->wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
666 }
667
668 if ( attributes & kWindowBoundsChangeOriginChanged )
669 {
670 wxMoveEvent event( r.GetLeftTop() , toplevelWindow->GetId() ) ;
671 event.SetEventObject( toplevelWindow ) ;
672 toplevelWindow->HandleWindowEvent(event) ;
673 }
674
675 result = noErr ;
676 }
677 break ;
678
679 case kEventWindowBoundsChanging :
680 {
681 UInt32 attributes = cEvent.GetParameter<UInt32>(kEventParamAttributes,typeUInt32) ;
682 Rect newRect = cEvent.GetParameter<Rect>(kEventParamCurrentBounds) ;
683
684 if ( (attributes & kWindowBoundsChangeSizeChanged) || (attributes & kWindowBoundsChangeOriginChanged) )
685 {
686 // all (Mac) rects are in content area coordinates, all wxRects in structure coordinates
687 int left , top , right , bottom ;
688 toplevelWindow->MacGetContentAreaInset( left , top , right , bottom ) ;
689
690 wxRect r(
691 newRect.left - left,
692 newRect.top - top,
693 newRect.right - newRect.left + left + right,
694 newRect.bottom - newRect.top + top + bottom ) ;
695
696 // this is a EVT_SIZING not a EVT_SIZE type !
697 wxSizeEvent wxevent( r , toplevelWindow->GetId() ) ;
698 wxevent.SetEventObject( toplevelWindow ) ;
699 wxRect adjustR = r ;
700 if ( toplevelWindow->HandleWindowEvent(wxevent) )
701 adjustR = wxevent.GetRect() ;
702
703 if ( toplevelWindow->GetMaxWidth() != -1 && adjustR.GetWidth() > toplevelWindow->GetMaxWidth() )
704 adjustR.SetWidth( toplevelWindow->GetMaxWidth() ) ;
705 if ( toplevelWindow->GetMaxHeight() != -1 && adjustR.GetHeight() > toplevelWindow->GetMaxHeight() )
706 adjustR.SetHeight( toplevelWindow->GetMaxHeight() ) ;
707 if ( toplevelWindow->GetMinWidth() != -1 && adjustR.GetWidth() < toplevelWindow->GetMinWidth() )
708 adjustR.SetWidth( toplevelWindow->GetMinWidth() ) ;
709 if ( toplevelWindow->GetMinHeight() != -1 && adjustR.GetHeight() < toplevelWindow->GetMinHeight() )
710 adjustR.SetHeight( toplevelWindow->GetMinHeight() ) ;
711 const Rect adjustedRect = { adjustR.y + top , adjustR.x + left , adjustR.y + adjustR.height - bottom , adjustR.x + adjustR.width - right } ;
712 if ( !EqualRect( &newRect , &adjustedRect ) )
713 cEvent.SetParameter<Rect>( kEventParamCurrentBounds , &adjustedRect ) ;
714 toplevelWindow->wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
715 }
716
717 result = noErr ;
718 }
719 break ;
720
721 case kEventWindowGetRegion :
722 {
723 if ( toplevelWindow->GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
724 {
725 WindowRegionCode windowRegionCode ;
726
727 // Fetch the region code that is being queried
728 GetEventParameter( event,
729 kEventParamWindowRegionCode,
730 typeWindowRegionCode, NULL,
731 sizeof windowRegionCode, NULL,
732 &windowRegionCode ) ;
733
734 // If it is the opaque region code then set the
735 // region to empty and return noErr to stop event
736 // propagation
737 if ( windowRegionCode == kWindowOpaqueRgn ) {
738 RgnHandle region;
739 GetEventParameter( event,
740 kEventParamRgnHandle,
741 typeQDRgnHandle, NULL,
742 sizeof region, NULL,
743 &region) ;
744 SetEmptyRgn(region) ;
745 result = noErr ;
746 }
747 }
748 }
749 break ;
750
751 default :
752 break ;
753 }
754
755 return result ;
756}
757
758// mix this in from window.cpp
759pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ;
760
761pascal OSStatus wxMacTopLevelEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
762{
763 OSStatus result = eventNotHandledErr ;
764
765 switch ( GetEventClass( event ) )
766 {
767 case kEventClassTextInput :
768 result = wxMacUnicodeTextEventHandler( handler, event , data ) ;
769 break ;
770
771 case kEventClassKeyboard :
772 result = KeyboardEventHandler( handler, event , data ) ;
773 break ;
774
775 case kEventClassWindow :
776 result = wxMacTopLevelWindowEventHandler( handler, event , data ) ;
777 break ;
778
779 case kEventClassMouse :
780 result = wxMacTopLevelMouseEventHandler( handler, event , data ) ;
781 break ;
782
783 default :
784 break ;
785 }
786
787 return result ;
788}
789
790DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacTopLevelEventHandler )
791
792// ---------------------------------------------------------------------------
793// wxWindowMac utility functions
794// ---------------------------------------------------------------------------
795
796// Find an item given the Macintosh Window Reference
797
798WX_DECLARE_HASH_MAP(WindowRef, wxTopLevelWindowMac*, wxPointerHash, wxPointerEqual, MacWindowMap);
799
800static MacWindowMap wxWinMacWindowList;
801
802wxTopLevelWindowMac *wxFindWinFromMacWindow(WindowRef inWindowRef)
803{
804 MacWindowMap::iterator node = wxWinMacWindowList.find(inWindowRef);
805
806 return (node == wxWinMacWindowList.end()) ? NULL : node->second;
807}
808
809void wxAssociateWinWithMacWindow(WindowRef inWindowRef, wxTopLevelWindowMac *win) ;
810void wxAssociateWinWithMacWindow(WindowRef inWindowRef, wxTopLevelWindowMac *win)
811{
812 // adding NULL WindowRef is (first) surely a result of an error and
813 // nothing else :-)
814 wxCHECK_RET( inWindowRef != (WindowRef) NULL, wxT("attempt to add a NULL WindowRef to window list") );
815
816 wxWinMacWindowList[inWindowRef] = win;
817}
818
819void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win) ;
820void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win)
821{
822 MacWindowMap::iterator it;
823 for ( it = wxWinMacWindowList.begin(); it != wxWinMacWindowList.end(); ++it )
824 {
825 if ( it->second == win )
826 {
827 wxWinMacWindowList.erase(it);
828 break;
829 }
830 }
831}
832
833// ----------------------------------------------------------------------------
834// wxTopLevelWindowMac creation
835// ----------------------------------------------------------------------------
836
837wxTopLevelWindowMac *wxTopLevelWindowMac::s_macDeactivateWindow = NULL;
838
839typedef struct
840{
841 wxPoint m_position ;
842 wxSize m_size ;
843 bool m_wasResizable ;
844} FullScreenData ;
845
846void wxTopLevelWindowMac::Init()
847{
848 m_iconized =
849 m_maximizeOnShow = false;
850 m_macWindow = NULL ;
851
852 m_macEventHandler = NULL ;
853 m_macFullScreenData = NULL ;
854}
855
856wxMacDeferredWindowDeleter::wxMacDeferredWindowDeleter( WindowRef windowRef )
857{
858 m_macWindow = windowRef ;
859}
860
861wxMacDeferredWindowDeleter::~wxMacDeferredWindowDeleter()
862{
863 DisposeWindow( (WindowRef) m_macWindow ) ;
864}
865
866bool wxTopLevelWindowMac::Create(wxWindow *parent,
867 wxWindowID id,
868 const wxString& title,
869 const wxPoint& pos,
870 const wxSize& size,
871 long style,
872 const wxString& name)
873{
874 // init our fields
875 Init();
876
877 m_windowStyle = style;
878
879 SetName( name );
880
881 m_windowId = id == -1 ? NewControlId() : id;
882 wxWindow::SetLabel( title ) ;
883
884 DoMacCreateRealWindow( parent, title, pos , size , style , name ) ;
885
886 SetBackgroundColour(wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE ));
887
888 if (GetExtraStyle() & wxFRAME_EX_METAL)
889 MacSetMetalAppearance(true);
890
891 wxTopLevelWindows.Append(this);
892
893 if ( parent )
894 parent->AddChild(this);
895
896 return true;
897}
898
899wxTopLevelWindowMac::~wxTopLevelWindowMac()
900{
901 if ( m_macWindow )
902 {
903#if wxUSE_TOOLTIPS
904 wxToolTip::NotifyWindowDelete(m_macWindow) ;
905#endif
906 wxPendingDelete.Append( new wxMacDeferredWindowDeleter( (WindowRef) m_macWindow ) ) ;
907 }
908
909 if ( m_macEventHandler )
910 {
911 ::RemoveEventHandler((EventHandlerRef) m_macEventHandler);
912 m_macEventHandler = NULL ;
913 }
914
915 wxRemoveMacWindowAssociation( this ) ;
916
917 if ( wxModelessWindows.Find(this) )
918 wxModelessWindows.DeleteObject(this);
919
920 FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
921 delete data ;
922 m_macFullScreenData = NULL ;
923
924 // avoid dangling refs
925 if ( s_macDeactivateWindow == this )
926 s_macDeactivateWindow = NULL;
927}
928
929
930// ----------------------------------------------------------------------------
931// wxTopLevelWindowMac maximize/minimize
932// ----------------------------------------------------------------------------
933
934void wxTopLevelWindowMac::Maximize(bool maximize)
935{
936 Point idealSize = { 0 , 0 } ;
937 if ( maximize )
938 {
939#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
940 HIRect bounds ;
941 HIWindowGetAvailablePositioningBounds(kCGNullDirectDisplay,kHICoordSpace72DPIGlobal,
942 &bounds);
943 idealSize.h = bounds.size.width;
944 idealSize.v = bounds.size.height;
945#else
946 Rect rect ;
947 GetAvailableWindowPositioningBounds(GetMainDevice(),&rect) ;
948 idealSize.h = rect.right - rect.left ;
949 idealSize.v = rect.bottom - rect.top ;
950#endif
951 }
952 ZoomWindowIdeal( (WindowRef)m_macWindow , maximize ? inZoomOut : inZoomIn , &idealSize ) ;
953}
954
955bool wxTopLevelWindowMac::IsMaximized() const
956{
957 return IsWindowInStandardState( (WindowRef)m_macWindow , NULL , NULL ) ;
958}
959
960void wxTopLevelWindowMac::Iconize(bool iconize)
961{
962 if ( IsWindowCollapsable( (WindowRef)m_macWindow) )
963 CollapseWindow( (WindowRef)m_macWindow , iconize ) ;
964}
965
966bool wxTopLevelWindowMac::IsIconized() const
967{
968 return IsWindowCollapsed((WindowRef)m_macWindow ) ;
969}
970
971void wxTopLevelWindowMac::Restore()
972{
973 if ( IsMaximized() )
974 Maximize(false);
975 else if ( IsIconized() )
976 Iconize(false);
977}
978
979// ----------------------------------------------------------------------------
980// wxTopLevelWindowMac misc
981// ----------------------------------------------------------------------------
982
983wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const
984{
985 return wxPoint(0, 0) ;
986}
987
988bool wxTopLevelWindowMac::SetBackgroundColour(const wxColour& col )
989{
990 if ( !wxTopLevelWindowBase::SetBackgroundColour(col) && m_hasBgCol )
991 return false ;
992
993 if ( col == wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) || col == wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDocumentWindowBackground)) )
994 {
995 SetThemeWindowBackground( (WindowRef) m_macWindow, kThemeBrushDocumentWindowBackground, false ) ;
996 SetBackgroundStyle(wxBG_STYLE_CUSTOM);
997 }
998 else if ( col == wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE ) || col == wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDialogBackgroundActive)) )
999 {
1000 SetThemeWindowBackground( (WindowRef) m_macWindow, kThemeBrushDialogBackgroundActive, false ) ;
1001 SetBackgroundStyle(wxBG_STYLE_CUSTOM);
1002 }
1003 return true;
1004}
1005
1006void wxTopLevelWindowMacInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
1007{
1008 InstallWindowEventHandler(window, GetwxMacTopLevelEventHandlerUPP(),
1009 GetEventTypeCount(eventList), eventList, ref, handler );
1010}
1011
1012void wxTopLevelWindowMac::MacInstallTopLevelWindowEventHandler()
1013{
1014 if ( m_macEventHandler != NULL )
1015 {
1016 verify_noerr( ::RemoveEventHandler( (EventHandlerRef) m_macEventHandler ) ) ;
1017 }
1018 wxTopLevelWindowMacInstallTopLevelWindowEventHandler(MAC_WXHWND(m_macWindow),(EventHandlerRef *)&m_macEventHandler,this);
1019}
1020
1021void wxTopLevelWindowMac::MacCreateRealWindow(
1022 const wxString& title,
1023 const wxPoint& pos,
1024 const wxSize& size,
1025 long style,
1026 const wxString& name )
1027{
1028 DoMacCreateRealWindow( NULL, title, pos, size, style, name );
1029}
1030
1031void wxTopLevelWindowMac::DoMacCreateRealWindow(
1032 wxWindow* parent,
1033 const wxString& title,
1034 const wxPoint& pos,
1035 const wxSize& size,
1036 long style,
1037 const wxString& name )
1038{
1039 OSStatus err = noErr ;
1040 SetName(name);
1041 m_windowStyle = style;
1042 m_isShown = false;
1043
1044 // create frame.
1045 int x = (int)pos.x;
1046 int y = (int)pos.y;
1047
1048 Rect theBoundsRect;
1049 wxRect display = wxGetClientDisplayRect() ;
1050
1051 if ( x == wxDefaultPosition.x )
1052 x = display.x ;
1053
1054 if ( y == wxDefaultPosition.y )
1055 y = display.y ;
1056
1057 int w = WidthDefault(size.x);
1058 int h = HeightDefault(size.y);
1059
1060 ::SetRect(&theBoundsRect, x, y , x + w, y + h);
1061
1062 // translate the window attributes in the appropriate window class and attributes
1063 WindowClass wclass = 0;
1064 WindowAttributes attr = kWindowNoAttributes ;
1065 WindowGroupRef group = NULL ;
1066 bool activationScopeSet = false;
1067 WindowActivationScope activationScope = kWindowActivationScopeNone;
1068
1069 if ( HasFlag( wxFRAME_TOOL_WINDOW) )
1070 {
1071 if (
1072 HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) ||
1073 HasFlag( wxSYSTEM_MENU ) || HasFlag( wxCAPTION ) ||
1074 HasFlag(wxTINY_CAPTION_HORIZ) || HasFlag(wxTINY_CAPTION_VERT)
1075 )
1076 {
1077 if ( HasFlag( wxSTAY_ON_TOP ) )
1078 wclass = kUtilityWindowClass;
1079 else
1080 wclass = kFloatingWindowClass ;
1081
1082 if ( HasFlag(wxTINY_CAPTION_VERT) )
1083 attr |= kWindowSideTitlebarAttribute ;
1084 }
1085 else
1086 {
1087 wclass = kPlainWindowClass ;
1088 activationScopeSet = true;
1089 activationScope = kWindowActivationScopeNone;
1090 }
1091 }
1092 else if ( HasFlag( wxPOPUP_WINDOW ) )
1093 {
1094 // TEMPORARY HACK!
1095 // Until we've got a real wxPopupWindow class on wxMac make it a
1096 // little easier for wxFrame to be used to emulate it and workaround
1097 // the lack of wxPopupWindow.
1098 if ( HasFlag( wxBORDER_NONE ) )
1099 wclass = kHelpWindowClass ; // has no border
1100 else
1101 wclass = kPlainWindowClass ; // has a single line border, it will have to do for now
1102 //attr |= kWindowNoShadowAttribute; // turn off the shadow Should we??
1103 group = GetWindowGroupOfClass( // float above other windows
1104 kFloatingWindowClass) ;
1105 }
1106 else if ( HasFlag( wxCAPTION ) )
1107 {
1108 wclass = kDocumentWindowClass ;
1109 attr |= kWindowInWindowMenuAttribute ;
1110 }
1111 else if ( HasFlag( wxFRAME_DRAWER ) )
1112 {
1113 wclass = kDrawerWindowClass;
1114 }
1115 else
1116 {
1117 if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) ||
1118 HasFlag( wxCLOSE_BOX ) || HasFlag( wxSYSTEM_MENU ) )
1119 {
1120 wclass = kDocumentWindowClass ;
1121 }
1122 else if ( HasFlag( wxNO_BORDER ) )
1123 {
1124 wclass = kSimpleWindowClass ;
1125 }
1126 else
1127 {
1128 wclass = kPlainWindowClass ;
1129 }
1130 }
1131
1132 if ( wclass != kPlainWindowClass )
1133 {
1134 if ( HasFlag( wxMINIMIZE_BOX ) )
1135 attr |= kWindowCollapseBoxAttribute ;
1136
1137 if ( HasFlag( wxMAXIMIZE_BOX ) )
1138 attr |= kWindowFullZoomAttribute ;
1139
1140 if ( HasFlag( wxRESIZE_BORDER ) )
1141 attr |= kWindowResizableAttribute ;
1142
1143 if ( HasFlag( wxCLOSE_BOX) )
1144 attr |= kWindowCloseBoxAttribute ;
1145 }
1146 attr |= kWindowLiveResizeAttribute;
1147
1148 if ( HasFlag(wxSTAY_ON_TOP) )
1149 group = GetWindowGroupOfClass(kUtilityWindowClass) ;
1150
1151 if ( HasFlag( wxFRAME_FLOAT_ON_PARENT ) )
1152 group = GetWindowGroupOfClass(kFloatingWindowClass) ;
1153
1154 if ( group == NULL && parent != NULL )
1155 {
1156 WindowRef parenttlw = (WindowRef) parent->MacGetTopLevelWindowRef();
1157 if( parenttlw )
1158 group = GetWindowGroupParent( GetWindowGroup( parenttlw ) );
1159 }
1160
1161 attr |= kWindowCompositingAttribute;
1162#if 0 // wxMAC_USE_CORE_GRAPHICS ; TODO : decide on overall handling of high dpi screens (pixel vs userscale)
1163 attr |= kWindowFrameworkScaledAttribute;
1164#endif
1165
1166 if ( HasFlag(wxFRAME_SHAPED) )
1167 {
1168 WindowDefSpec customWindowDefSpec;
1169 customWindowDefSpec.defType = kWindowDefProcPtr;
1170 customWindowDefSpec.u.defProc =
1171#ifdef __LP64__
1172 (WindowDefUPP) wxShapedMacWindowDef;
1173#else
1174 NewWindowDefUPP(wxShapedMacWindowDef);
1175#endif
1176 err = ::CreateCustomWindow( &customWindowDefSpec, wclass,
1177 attr, &theBoundsRect,
1178 (WindowRef*) &m_macWindow);
1179 }
1180 else
1181 {
1182 err = ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ;
1183 }
1184
1185 if ( err == noErr && m_macWindow != NULL && group != NULL )
1186 SetWindowGroup( (WindowRef) m_macWindow , group ) ;
1187
1188 wxCHECK_RET( err == noErr, wxT("Mac OS error when trying to create new window") );
1189
1190 // setup a separate group for each window, so that overlays can be handled easily
1191
1192 WindowGroupRef overlaygroup = NULL;
1193 verify_noerr( CreateWindowGroup( kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrHideOnCollapse, &overlaygroup ));
1194 verify_noerr( SetWindowGroupParent( overlaygroup, GetWindowGroup( (WindowRef) m_macWindow )));
1195 verify_noerr( SetWindowGroup( (WindowRef) m_macWindow , overlaygroup ));
1196
1197 if ( activationScopeSet )
1198 {
1199 verify_noerr( SetWindowActivationScope( (WindowRef) m_macWindow , activationScope ));
1200 }
1201
1202 // the create commands are only for content rect,
1203 // so we have to set the size again as structure bounds
1204 SetWindowBounds( (WindowRef) m_macWindow , kWindowStructureRgn , &theBoundsRect ) ;
1205
1206 wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ;
1207 SetWindowTitleWithCFString( (WindowRef) m_macWindow , wxCFStringRef( title , m_font.GetEncoding() ) );
1208 m_peer = new wxMacControl(this , true /*isRootControl*/) ;
1209
1210 // There is a bug in 10.2.X for ::GetRootControl returning the window view instead of
1211 // the content view, so we have to retrieve it explicitly
1212 HIViewFindByID( HIViewGetRoot( (WindowRef) m_macWindow ) , kHIViewWindowContentID ,
1213 m_peer->GetControlRefAddr() ) ;
1214 if ( !m_peer->Ok() )
1215 {
1216 // compatibility mode fallback
1217 GetRootControl( (WindowRef) m_macWindow , m_peer->GetControlRefAddr() ) ;
1218 }
1219
1220 // the root control level handler
1221 MacInstallEventHandler( (WXWidget) m_peer->GetControlRef() ) ;
1222
1223 // Causes the inner part of the window not to be metal
1224 // if the style is used before window creation.
1225#if 0 // TARGET_API_MAC_OSX
1226 if ( m_macUsesCompositing && m_macWindow != NULL )
1227 {
1228 if ( GetExtraStyle() & wxFRAME_EX_METAL )
1229 MacSetMetalAppearance( true ) ;
1230 }
1231#endif
1232
1233 if ( m_macWindow != NULL )
1234 {
1235 MacSetUnifiedAppearance( true ) ;
1236 }
1237
1238 HIViewRef growBoxRef = 0 ;
1239 err = HIViewFindByID( HIViewGetRoot( (WindowRef)m_macWindow ), kHIViewWindowGrowBoxID, &growBoxRef );
1240 if ( err == noErr && growBoxRef != 0 )
1241 HIGrowBoxViewSetTransparent( growBoxRef, true ) ;
1242
1243 // the frame window event handler
1244 InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ;
1245 MacInstallTopLevelWindowEventHandler() ;
1246
1247 DoSetWindowVariant( m_windowVariant ) ;
1248
1249 m_macFocus = NULL ;
1250
1251 if ( HasFlag(wxFRAME_SHAPED) )
1252 {
1253 // default shape matches the window size
1254 wxRegion rgn( 0, 0, w, h );
1255 SetShape( rgn );
1256 }
1257
1258 wxWindowCreateEvent event(this);
1259 HandleWindowEvent(event);
1260}
1261
1262void wxTopLevelWindowMac::ClearBackground()
1263{
1264 wxWindow::ClearBackground() ;
1265}
1266
1267// Raise the window to the top of the Z order
1268void wxTopLevelWindowMac::Raise()
1269{
1270 ::SelectWindow( (WindowRef)m_macWindow ) ;
1271}
1272
1273// Lower the window to the bottom of the Z order
1274void wxTopLevelWindowMac::Lower()
1275{
1276 ::SendBehind( (WindowRef)m_macWindow , NULL ) ;
1277}
1278
1279void wxTopLevelWindowMac::MacDelayedDeactivation(long timestamp)
1280{
1281 if (s_macDeactivateWindow)
1282 {
1283 wxLogTrace(TRACE_ACTIVATE,
1284 wxT("Doing delayed deactivation of %p"),
1285 s_macDeactivateWindow);
1286
1287 s_macDeactivateWindow->MacActivate(timestamp, false);
1288 }
1289}
1290
1291void wxTopLevelWindowMac::MacActivate( long timestamp , bool WXUNUSED(inIsActivating) )
1292{
1293 wxLogTrace(TRACE_ACTIVATE, wxT("TopLevel=%p::MacActivate"), this);
1294
1295 if (s_macDeactivateWindow == this)
1296 s_macDeactivateWindow = NULL;
1297
1298 MacDelayedDeactivation(timestamp);
1299}
1300
1301void wxTopLevelWindowMac::SetTitle(const wxString& title)
1302{
1303 wxWindow::SetLabel( title ) ;
1304 SetWindowTitleWithCFString( (WindowRef) m_macWindow , wxCFStringRef( title , m_font.GetEncoding() ) ) ;
1305}
1306
1307wxString wxTopLevelWindowMac::GetTitle() const
1308{
1309 return wxWindow::GetLabel();
1310}
1311
1312bool wxTopLevelWindowMac::Show(bool show)
1313{
1314 if ( !wxTopLevelWindowBase::Show(show) )
1315 return false;
1316
1317 bool plainTransition = true;
1318
1319#if wxUSE_SYSTEM_OPTIONS
1320 if ( wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) )
1321 plainTransition = ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1 ) ;
1322#endif
1323
1324 if (show)
1325 {
1326 if ( plainTransition )
1327 ::ShowWindow( (WindowRef)m_macWindow );
1328 else
1329 ::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowShowTransitionAction, NULL );
1330
1331 ::SelectWindow( (WindowRef)m_macWindow ) ;
1332
1333 // because apps expect a size event to occur at this moment
1334 wxSizeEvent event(GetSize() , m_windowId);
1335 event.SetEventObject(this);
1336 HandleWindowEvent(event);
1337 }
1338 else
1339 {
1340 if ( plainTransition )
1341 ::HideWindow( (WindowRef)m_macWindow );
1342 else
1343 ::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowHideTransitionAction, NULL );
1344 }
1345
1346 return true ;
1347}
1348
1349bool wxTopLevelWindowMac::ShowWithEffect(wxShowEffect effect,
1350 unsigned timeout,
1351 wxDirection dir)
1352{
1353 // TODO factor common code
1354 if ( !wxTopLevelWindowBase::Show(true) )
1355 return false;
1356
1357 WindowTransitionEffect transition = 0 ;
1358 switch( effect )
1359 {
1360 case wxSHOW_EFFECT_ROLL :
1361 case wxSHOW_EFFECT_SLIDE :
1362 transition = kWindowGenieTransitionEffect;
1363 break;
1364 case wxSHOW_EFFECT_BLEND :
1365 transition = kWindowFadeTransitionEffect;
1366 break;
1367 case wxSHOW_EFFECT_EXPAND :
1368 default :
1369 // having sheets would be fine, but this might lead to a repositioning
1370#if 0
1371 if ( GetParent() )
1372 transition = kWindowSheetTransitionEffect;
1373 else
1374#endif
1375 transition = kWindowZoomTransitionEffect;
1376 break;
1377 }
1378
1379 TransitionWindowOptions options;
1380 options.version = 0;
1381 options.duration = timeout / 1000.0;
1382 options.window = transition == kWindowSheetTransitionEffect ? (WindowRef) GetParent()->MacGetTopLevelWindowRef() :0;
1383 options.userData = 0;
1384
1385 wxSize size = wxGetDisplaySize();
1386 Rect bounds;
1387 GetWindowBounds( (WindowRef)m_macWindow, kWindowStructureRgn, &bounds );
1388 CGRect hiBounds = CGRectMake( bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top );
1389
1390 if ( dir & wxRIGHT )
1391 {
1392 hiBounds.origin.x = size.x;
1393 hiBounds.size.width = 0;
1394 }
1395 if ( dir & wxUP )
1396 {
1397 hiBounds.origin.y = 0;
1398 hiBounds.size.height = 0;
1399 }
1400 if ( dir & wxDOWN )
1401 {
1402 hiBounds.origin.y = size.y;
1403 hiBounds.size.height = 0;
1404 }
1405 if ( dir & wxLEFT )
1406 {
1407 hiBounds.origin.x = 0;
1408 hiBounds.size.width = 0;
1409 }
1410
1411 ::TransitionWindowWithOptions( (WindowRef)m_macWindow, transition, kWindowShowTransitionAction, transition == kWindowGenieTransitionEffect ? &hiBounds : NULL ,
1412 false, &options );
1413
1414 ::SelectWindow( (WindowRef)m_macWindow ) ;
1415
1416 // because apps expect a size event to occur at this moment
1417 wxSizeEvent event(GetSize() , m_windowId);
1418 event.SetEventObject(this);
1419 HandleWindowEvent(event);
1420
1421 return true;
1422}
1423
1424bool wxTopLevelWindowMac::HideWithEffect(wxShowEffect effect,
1425 unsigned timeout ,
1426 wxDirection dir )
1427{
1428 if ( !wxTopLevelWindowBase::Show(false) )
1429 return false;
1430
1431 WindowTransitionEffect transition = 0 ;
1432 switch( effect )
1433 {
1434 case wxSHOW_EFFECT_ROLL :
1435 case wxSHOW_EFFECT_SLIDE :
1436 transition = kWindowGenieTransitionEffect;
1437 break;
1438 case wxSHOW_EFFECT_BLEND :
1439 transition = kWindowFadeTransitionEffect;
1440 break;
1441 case wxSHOW_EFFECT_EXPAND :
1442 default:
1443#if 0
1444 if ( GetParent() )
1445 transition = kWindowSheetTransitionEffect;
1446 else
1447#endif
1448 transition = kWindowZoomTransitionEffect;
1449 break;
1450 }
1451 TransitionWindowOptions options;
1452 options.version = 0;
1453 options.duration = timeout / 1000.0;
1454 options.window = transition == kWindowSheetTransitionEffect ? (WindowRef) GetParent()->MacGetTopLevelWindowRef() :0;
1455 options.userData = 0;
1456
1457 wxSize size = wxGetDisplaySize();
1458 Rect bounds;
1459 GetWindowBounds( (WindowRef)m_macWindow, kWindowStructureRgn, &bounds );
1460 CGRect hiBounds = CGRectMake( bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top );
1461
1462 if ( dir & wxRIGHT )
1463 {
1464 hiBounds.origin.x = size.x;
1465 hiBounds.size.width = 0;
1466 }
1467 if ( dir & wxUP )
1468 {
1469 hiBounds.origin.y = 0;
1470 hiBounds.size.height = 0;
1471 }
1472 if ( dir & wxDOWN )
1473 {
1474 hiBounds.origin.y = size.y;
1475 hiBounds.size.height = 0;
1476 }
1477 if ( dir & wxLEFT )
1478 {
1479 hiBounds.origin.x = 0;
1480 hiBounds.size.width = 0;
1481 }
1482 ::TransitionWindowWithOptions( (WindowRef)m_macWindow, transition, kWindowHideTransitionAction, transition == kWindowGenieTransitionEffect ? &hiBounds : NULL ,
1483 false, &options );
1484
1485 return true;
1486}
1487
1488bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
1489{
1490 if ( show )
1491 {
1492 FullScreenData *data = (FullScreenData *)m_macFullScreenData ;
1493 delete data ;
1494 data = new FullScreenData() ;
1495
1496 m_macFullScreenData = data ;
1497 data->m_position = GetPosition() ;
1498 data->m_size = GetSize() ;
1499 data->m_wasResizable = MacGetWindowAttributes() & kWindowResizableAttribute ;
1500
1501 if ( style & wxFULLSCREEN_NOMENUBAR )
1502 HideMenuBar() ;
1503
1504 wxRect client = wxGetClientDisplayRect() ;
1505
1506 int left , top , right , bottom ;
1507 int x, y, w, h ;
1508
1509 x = client.x ;
1510 y = client.y ;
1511 w = client.width ;
1512 h = client.height ;
1513
1514 MacGetContentAreaInset( left , top , right , bottom ) ;
1515
1516 if ( style & wxFULLSCREEN_NOCAPTION )
1517 {
1518 y -= top ;
1519 h += top ;
1520 }
1521
1522 if ( style & wxFULLSCREEN_NOBORDER )
1523 {
1524 x -= left ;
1525 w += left + right ;
1526 h += bottom ;
1527 }
1528
1529 if ( style & wxFULLSCREEN_NOTOOLBAR )
1530 {
1531 // TODO
1532 }
1533
1534 if ( style & wxFULLSCREEN_NOSTATUSBAR )
1535 {
1536 // TODO
1537 }
1538
1539 SetSize( x , y , w, h ) ;
1540 if ( data->m_wasResizable )
1541 MacChangeWindowAttributes( kWindowNoAttributes , kWindowResizableAttribute ) ;
1542 }
1543 else
1544 {
1545 ShowMenuBar() ;
1546 FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
1547 if ( data->m_wasResizable )
1548 MacChangeWindowAttributes( kWindowResizableAttribute , kWindowNoAttributes ) ;
1549 SetPosition( data->m_position ) ;
1550 SetSize( data->m_size ) ;
1551
1552 delete data ;
1553 m_macFullScreenData = NULL ;
1554 }
1555
1556 return false;
1557}
1558
1559bool wxTopLevelWindowMac::IsFullScreen() const
1560{
1561 return m_macFullScreenData != NULL ;
1562}
1563
1564
1565bool wxTopLevelWindowMac::SetTransparent(wxByte alpha)
1566{
1567 OSStatus result = SetWindowAlpha((WindowRef)m_macWindow, float(alpha)/255.0);
1568 return result == noErr;
1569}
1570
1571
1572bool wxTopLevelWindowMac::CanSetTransparent()
1573{
1574 return true;
1575}
1576
1577
1578void wxTopLevelWindowMac::SetExtraStyle(long exStyle)
1579{
1580 if ( GetExtraStyle() == exStyle )
1581 return ;
1582
1583 wxTopLevelWindowBase::SetExtraStyle( exStyle ) ;
1584
1585 if ( m_macWindow != NULL )
1586 {
1587 bool metal = GetExtraStyle() & wxFRAME_EX_METAL ;
1588
1589 if ( MacGetMetalAppearance() != metal )
1590 {
1591 if ( MacGetUnifiedAppearance() )
1592 MacSetUnifiedAppearance( !metal ) ;
1593
1594 MacSetMetalAppearance( metal ) ;
1595 }
1596 }
1597}
1598
1599bool wxTopLevelWindowMac::SetBackgroundStyle(wxBackgroundStyle style)
1600{
1601 if ( !wxTopLevelWindowBase::SetBackgroundStyle(style) )
1602 return false ;
1603
1604 WindowRef windowRef = HIViewGetWindow( (HIViewRef)GetHandle() );
1605
1606 if ( GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
1607 {
1608 OSStatus err = HIWindowChangeFeatures( windowRef, 0, kWindowIsOpaque );
1609 verify_noerr( err );
1610 err = ReshapeCustomWindow( windowRef );
1611 verify_noerr( err );
1612 }
1613
1614 return true ;
1615}
1616
1617// TODO: switch to structure bounds -
1618// we are still using coordinates of the content view
1619//
1620void wxTopLevelWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , int &bottom )
1621{
1622 Rect content, structure ;
1623
1624 GetWindowBounds( (WindowRef) m_macWindow, kWindowStructureRgn , &structure ) ;
1625 GetWindowBounds( (WindowRef) m_macWindow, kWindowContentRgn , &content ) ;
1626
1627 left = content.left - structure.left ;
1628 top = content.top - structure.top ;
1629 right = structure.right - content.right ;
1630 bottom = structure.bottom - content.bottom ;
1631}
1632
1633void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height)
1634{
1635 m_cachedClippedRectValid = false ;
1636 Rect bounds = { y , x , y + height , x + width } ;
1637 verify_noerr(SetWindowBounds( (WindowRef) m_macWindow, kWindowStructureRgn , &bounds )) ;
1638 wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
1639}
1640
1641void wxTopLevelWindowMac::DoGetPosition( int *x, int *y ) const
1642{
1643 Rect bounds ;
1644
1645 verify_noerr(GetWindowBounds((WindowRef) m_macWindow, kWindowStructureRgn , &bounds )) ;
1646
1647 if (x)
1648 *x = bounds.left ;
1649 if (y)
1650 *y = bounds.top ;
1651}
1652
1653void wxTopLevelWindowMac::DoGetSize( int *width, int *height ) const
1654{
1655 Rect bounds ;
1656
1657 verify_noerr(GetWindowBounds((WindowRef) m_macWindow, kWindowStructureRgn , &bounds )) ;
1658
1659 if (width)
1660 *width = bounds.right - bounds.left ;
1661 if (height)
1662 *height = bounds.bottom - bounds.top ;
1663}
1664
1665void wxTopLevelWindowMac::DoGetClientSize( int *width, int *height ) const
1666{
1667 Rect bounds ;
1668
1669 verify_noerr(GetWindowBounds((WindowRef) m_macWindow, kWindowContentRgn , &bounds )) ;
1670
1671 if (width)
1672 *width = bounds.right - bounds.left ;
1673 if (height)
1674 *height = bounds.bottom - bounds.top ;
1675}
1676
1677void wxTopLevelWindowMac::DoCentre(int dir)
1678{
1679 if ( m_macWindow != 0 )
1680 wxTopLevelWindowBase::DoCentre(dir);
1681}
1682
1683void wxTopLevelWindowMac::MacSetMetalAppearance( bool set )
1684{
1685 if ( MacGetUnifiedAppearance() )
1686 MacSetUnifiedAppearance( false ) ;
1687
1688 MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes ,
1689 set ? kWindowNoAttributes : kWindowMetalAttribute ) ;
1690}
1691
1692bool wxTopLevelWindowMac::MacGetMetalAppearance() const
1693{
1694 return MacGetWindowAttributes() & kWindowMetalAttribute ;
1695}
1696
1697void wxTopLevelWindowMac::MacSetUnifiedAppearance( bool set )
1698{
1699 if ( MacGetMetalAppearance() )
1700 MacSetMetalAppearance( false ) ;
1701
1702 MacChangeWindowAttributes( set ? kWindowUnifiedTitleAndToolbarAttribute : kWindowNoAttributes ,
1703 set ? kWindowNoAttributes : kWindowUnifiedTitleAndToolbarAttribute) ;
1704
1705 // For some reason, Tiger uses white as the background color for this appearance,
1706 // while most apps using it use the typical striped background. Restore that behavior
1707 // for wx.
1708 // TODO: Determine if we need this on Leopard as well. (should be harmless either way,
1709 // though)
1710 SetBackgroundColour( wxSYS_COLOUR_WINDOW ) ;
1711}
1712
1713bool wxTopLevelWindowMac::MacGetUnifiedAppearance() const
1714{
1715 return MacGetWindowAttributes() & kWindowUnifiedTitleAndToolbarAttribute ;
1716}
1717
1718void wxTopLevelWindowMac::MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear )
1719{
1720 ChangeWindowAttributes( (WindowRef)m_macWindow, attributesToSet, attributesToClear ) ;
1721}
1722
1723wxUint32 wxTopLevelWindowMac::MacGetWindowAttributes() const
1724{
1725 UInt32 attr = 0 ;
1726 GetWindowAttributes( (WindowRef) m_macWindow, &attr ) ;
1727
1728 return attr ;
1729}
1730
1731void wxTopLevelWindowMac::MacPerformUpdates()
1732{
1733 // for composited windows this also triggers a redraw of all
1734 // invalid views in the window
1735 HIWindowFlush((WindowRef) m_macWindow) ;
1736}
1737
1738// Attracts the users attention to this window if the application is
1739// inactive (should be called when a background event occurs)
1740
1741static pascal void wxMacNMResponse( NMRecPtr ptr )
1742{
1743 NMRemove( ptr ) ;
1744 DisposePtr( (Ptr)ptr ) ;
1745}
1746
1747void wxTopLevelWindowMac::RequestUserAttention(int WXUNUSED(flags))
1748{
1749 NMRecPtr notificationRequest = (NMRecPtr) NewPtr( sizeof( NMRec) ) ;
1750 static wxMacNMUPP nmupp( wxMacNMResponse );
1751
1752 memset( notificationRequest , 0 , sizeof(*notificationRequest) ) ;
1753 notificationRequest->qType = nmType ;
1754 notificationRequest->nmMark = 1 ;
1755 notificationRequest->nmIcon = 0 ;
1756 notificationRequest->nmSound = 0 ;
1757 notificationRequest->nmStr = NULL ;
1758 notificationRequest->nmResp = nmupp ;
1759
1760 verify_noerr( NMInstall( notificationRequest ) ) ;
1761}
1762
1763// ---------------------------------------------------------------------------
1764// Shape implementation
1765// ---------------------------------------------------------------------------
1766
1767
1768bool wxTopLevelWindowMac::SetShape(const wxRegion& region)
1769{
1770 wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
1771 _T("Shaped windows must be created with the wxFRAME_SHAPED style."));
1772
1773 // The empty region signifies that the shape
1774 // should be removed from the window.
1775 if ( region.IsEmpty() )
1776 {
1777 wxSize sz = GetClientSize();
1778 wxRegion rgn(0, 0, sz.x, sz.y);
1779 if ( rgn.IsEmpty() )
1780 return false ;
1781 else
1782 return SetShape(rgn);
1783 }
1784
1785 // Make a copy of the region
1786 RgnHandle shapeRegion = NewRgn();
1787 CopyRgn( (RgnHandle)region.GetWXHRGN(), shapeRegion );
1788
1789 // Dispose of any shape region we may already have
1790 RgnHandle oldRgn = (RgnHandle)GetWRefCon( (WindowRef)MacGetWindowRef() );
1791 if ( oldRgn )
1792 DisposeRgn(oldRgn);
1793
1794 // Save the region so we can use it later
1795 SetWRefCon((WindowRef)MacGetWindowRef(), (URefCon)shapeRegion);
1796
1797 // inform the window manager that the window has changed shape
1798 ReshapeCustomWindow((WindowRef)MacGetWindowRef());
1799
1800 return true;
1801}
1802
1803// ---------------------------------------------------------------------------
1804// Support functions for shaped windows, based on Apple's CustomWindow sample at
1805// http://developer.apple.com/samplecode/Sample_Code/Human_Interface_Toolbox/Mac_OS_High_Level_Toolbox/CustomWindow.htm
1806// ---------------------------------------------------------------------------
1807
1808static void wxShapedMacWindowGetPos(WindowRef window, Rect* inRect)
1809{
1810 GetWindowPortBounds(window, inRect);
1811 Point pt = { inRect->top ,inRect->left };
1812 wxMacLocalToGlobal( window, &pt ) ;
1813 inRect->bottom += pt.v - inRect->top;
1814 inRect->right += pt.h - inRect->left;
1815 inRect->top = pt.v;
1816 inRect->left = pt.h;
1817}
1818
1819static SInt32 wxShapedMacWindowGetFeatures(WindowRef WXUNUSED(window), SInt32 param)
1820{
1821 /*------------------------------------------------------
1822 Define which options your custom window supports.
1823 --------------------------------------------------------*/
1824 //just enable everything for our demo
1825 *(OptionBits*)param =
1826 //kWindowCanGrow |
1827 //kWindowCanZoom |
1828 //kWindowCanCollapse |
1829 //kWindowCanGetWindowRegion |
1830 //kWindowHasTitleBar |
1831 //kWindowSupportsDragHilite |
1832 kWindowCanDrawInCurrentPort |
1833 //kWindowCanMeasureTitle |
1834 kWindowWantsDisposeAtProcessDeath |
1835 kWindowSupportsGetGrowImageRegion |
1836 kWindowDefSupportsColorGrafPort;
1837
1838 return 1;
1839}
1840
1841// The content region is left as a rectangle matching the window size, this is
1842// so the origin in the paint event, and etc. still matches what the
1843// programmer expects.
1844static void wxShapedMacWindowContentRegion(WindowRef window, RgnHandle rgn)
1845{
1846 SetEmptyRgn(rgn);
1847 wxTopLevelWindowMac* win = wxFindWinFromMacWindow(window);
1848 if (win)
1849 {
1850 Rect r ;
1851 wxShapedMacWindowGetPos( window, &r ) ;
1852 RectRgn( rgn , &r ) ;
1853 }
1854}
1855
1856// The structure region is set to the shape given to the SetShape method.
1857static void wxShapedMacWindowStructureRegion(WindowRef window, RgnHandle rgn)
1858{
1859 RgnHandle cachedRegion = (RgnHandle) GetWRefCon(window);
1860
1861 SetEmptyRgn(rgn);
1862 if (cachedRegion)
1863 {
1864 Rect windowRect;
1865 wxShapedMacWindowGetPos(window, &windowRect); // how big is the window
1866 CopyRgn(cachedRegion, rgn); // make a copy of our cached region
1867 OffsetRgn(rgn, windowRect.left, windowRect.top); // position it over window
1868 //MapRgn(rgn, &mMaskSize, &windowRect); //scale it to our actual window size
1869 }
1870}
1871
1872static SInt32 wxShapedMacWindowGetRegion(WindowRef window, SInt32 param)
1873{
1874 GetWindowRegionPtr rgnRec = (GetWindowRegionPtr)param;
1875
1876 if (rgnRec == NULL)
1877 return paramErr;
1878
1879 switch (rgnRec->regionCode)
1880 {
1881 case kWindowStructureRgn:
1882 wxShapedMacWindowStructureRegion(window, rgnRec->winRgn);
1883 break;
1884
1885 case kWindowContentRgn:
1886 wxShapedMacWindowContentRegion(window, rgnRec->winRgn);
1887 break;
1888
1889 default:
1890 SetEmptyRgn(rgnRec->winRgn);
1891 break;
1892 }
1893
1894 return noErr;
1895}
1896
1897// Determine the region of the window which was hit
1898//
1899static SInt32 wxShapedMacWindowHitTest(WindowRef window, SInt32 param)
1900{
1901 Point hitPoint;
1902 static RgnHandle tempRgn = NULL;
1903
1904 if (tempRgn == NULL)
1905 tempRgn = NewRgn();
1906
1907 // get the point clicked
1908 SetPt( &hitPoint, LoWord(param), HiWord(param) );
1909
1910 // Mac OS 8.5 or later
1911 wxShapedMacWindowStructureRegion(window, tempRgn);
1912 if (PtInRgn( hitPoint, tempRgn )) //in window content region?
1913 return wInContent;
1914
1915 // no significant area was hit
1916 return wNoHit;
1917}
1918
1919static pascal long wxShapedMacWindowDef(short WXUNUSED(varCode), WindowRef window, SInt16 message, SInt32 param)
1920{
1921 switch (message)
1922 {
1923 case kWindowMsgHitTest:
1924 return wxShapedMacWindowHitTest(window, param);
1925
1926 case kWindowMsgGetFeatures:
1927 return wxShapedMacWindowGetFeatures(window, param);
1928
1929 // kWindowMsgGetRegion is sent during CreateCustomWindow and ReshapeCustomWindow
1930 case kWindowMsgGetRegion:
1931 return wxShapedMacWindowGetRegion(window, param);
1932
1933 default:
1934 break;
1935 }
1936
1937 return 0;
1938}