]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/toplevel.cpp
support undo patch applied
[wxWidgets.git] / src / mac / carbon / toplevel.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: mac/toplevel.cpp
3 // Purpose: implements wxTopLevelWindow for MSW
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 24.09.01
7 // RCS-ID: $Id$
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "toplevel.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/app.h"
33 #include "wx/toplevel.h"
34 #include "wx/frame.h"
35 #include "wx/string.h"
36 #include "wx/log.h"
37 #include "wx/intl.h"
38 #endif //WX_PRECOMP
39
40 #include "wx/mac/uma.h"
41 #include "wx/mac/aga.h"
42 #include "wx/app.h"
43 #include "wx/tooltip.h"
44 #include "wx/dnd.h"
45
46 #include "ToolUtils.h"
47
48
49 #define wxMAC_DEBUG_REDRAW 0
50 #ifndef wxMAC_DEBUG_REDRAW
51 #define wxMAC_DEBUG_REDRAW 0
52 #endif
53
54 // ----------------------------------------------------------------------------
55 // globals
56 // ----------------------------------------------------------------------------
57
58 // list of all frames and modeless dialogs
59 wxWindowList wxModelessWindows;
60
61 // double click testing
62 static Point gs_lastWhere;
63 static long gs_lastWhen = 0;
64
65
66 #if TARGET_CARBON
67 static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param);
68 #endif
69
70 // ============================================================================
71 // wxTopLevelWindowMac implementation
72 // ============================================================================
73
74 // ---------------------------------------------------------------------------
75 // Carbon Events
76 // ---------------------------------------------------------------------------
77
78 #if TARGET_CARBON
79
80 extern long wxMacTranslateKey(unsigned char key, unsigned char code) ;
81
82 static const EventTypeSpec eventList[] =
83 {
84 { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } ,
85
86 { kEventClassKeyboard, kEventRawKeyDown } ,
87 { kEventClassKeyboard, kEventRawKeyRepeat } ,
88 { kEventClassKeyboard, kEventRawKeyUp } ,
89 { kEventClassKeyboard, kEventRawKeyModifiersChanged } ,
90
91 { kEventClassWindow , kEventWindowUpdate } ,
92 { kEventClassWindow , kEventWindowActivated } ,
93 { kEventClassWindow , kEventWindowDeactivated } ,
94 { kEventClassWindow , kEventWindowBoundsChanging } ,
95 { kEventClassWindow , kEventWindowBoundsChanged } ,
96 { kEventClassWindow , kEventWindowClose } ,
97
98 { kEventClassMouse , kEventMouseDown } ,
99 { kEventClassMouse , kEventMouseUp } ,
100 { kEventClassMouse , kEventMouseMoved } ,
101 { kEventClassMouse , kEventMouseDragged } ,
102
103 } ;
104
105 static pascal OSStatus TextInputEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
106 {
107 OSStatus result = eventNotHandledErr ;
108
109 wxWindow* focus = wxWindow::FindFocus() ;
110 char charCode ;
111 UInt32 keyCode ;
112 UInt32 modifiers ;
113 Point point ;
114
115 EventRef rawEvent ;
116
117 GetEventParameter( event , kEventParamTextInputSendKeyboardEvent ,typeEventRef,NULL,sizeof(rawEvent),NULL,&rawEvent ) ;
118
119 GetEventParameter( rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode );
120 GetEventParameter( rawEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
121 GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
122 GetEventParameter( rawEvent, kEventParamMouseLocation, typeQDPoint, NULL,
123 sizeof( Point ), NULL, &point );
124
125 switch ( GetEventKind( event ) )
126 {
127 case kEventTextInputUnicodeForKeyEvent :
128 // this is only called when no default handler has jumped in, eg a wxControl on a floater window does not
129 // get its own kEventTextInputUnicodeForKeyEvent, so we route back the
130 wxControl* control = wxDynamicCast( focus , wxControl ) ;
131 if ( control )
132 {
133 ControlHandle macControl = (ControlHandle) control->GetMacControl() ;
134 if ( macControl )
135 {
136 ::HandleControlKey( macControl , keyCode , charCode , modifiers ) ;
137 result = noErr ;
138 }
139 }
140 /*
141 // this may lead to double events sent to a window in case all handlers have skipped the key down event
142 UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;
143 UInt32 message = (keyCode << 8) + charCode;
144
145 if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
146 focus , message , modifiers , when , point.h , point.v ) )
147 {
148 result = noErr ;
149 }
150 */
151 break ;
152 }
153
154 return result ;
155 }
156
157 static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
158 {
159 OSStatus result = eventNotHandledErr ;
160
161 wxWindow* focus = wxWindow::FindFocus() ;
162 char charCode ;
163 UInt32 keyCode ;
164 UInt32 modifiers ;
165 Point point ;
166 UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;
167
168 GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode );
169 GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
170 GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
171 GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
172 sizeof( Point ), NULL, &point );
173
174 UInt32 message = (keyCode << 8) + charCode;
175 switch( GetEventKind( event ) )
176 {
177 case kEventRawKeyRepeat :
178 case kEventRawKeyDown :
179 if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
180 focus , message , modifiers , when , point.h , point.v ) )
181 {
182 result = noErr ;
183 }
184 break ;
185 case kEventRawKeyUp :
186 if ( (focus != NULL) && wxTheApp->MacSendKeyUpEvent(
187 focus , message , modifiers , when , point.h , point.v ) )
188 {
189 result = noErr ;
190 }
191 break ;
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
201 event.m_x = point.h;
202 event.m_y = point.v;
203 event.m_timeStamp = when;
204 wxWindow* focus = wxWindow::FindFocus() ;
205 event.SetEventObject(focus);
206
207 if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & controlKey )
208 {
209 event.m_keyCode = WXK_CONTROL ;
210 event.SetEventType( ( modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
211 focus->GetEventHandler()->ProcessEvent( event ) ;
212 }
213 if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & shiftKey )
214 {
215 event.m_keyCode = WXK_SHIFT ;
216 event.SetEventType( ( modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
217 focus->GetEventHandler()->ProcessEvent( event ) ;
218 }
219 if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & optionKey )
220 {
221 event.m_keyCode = WXK_ALT ;
222 event.SetEventType( ( modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
223 focus->GetEventHandler()->ProcessEvent( event ) ;
224 }
225 wxTheApp->s_lastModifiers = modifiers ;
226 }
227 break ;
228 }
229
230 return result ;
231 }
232
233 static pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
234 {
235 OSStatus result = eventNotHandledErr ;
236
237 wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
238 Point point ;
239 UInt32 modifiers = 0;
240 EventMouseButton button = 0 ;
241 UInt32 click = 0 ;
242
243 GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
244 sizeof( Point ), NULL, &point );
245 GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL,
246 sizeof( UInt32 ), NULL, &modifiers );
247 GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL,
248 sizeof( EventMouseButton ), NULL, &button );
249 GetEventParameter( event, kEventParamClickCount, typeUInt32, NULL,
250 sizeof( UInt32 ), NULL, &click );
251
252 if ( button == 0 || GetEventKind( event ) == kEventMouseUp )
253 modifiers += btnState ;
254
255 WindowRef window ;
256 short windowPart = ::FindWindow(point, &window);
257
258 if ( IsWindowActive(window) && windowPart == inContent )
259 {
260 switch ( GetEventKind( event ) )
261 {
262 case kEventMouseDown :
263 toplevelWindow->MacFireMouseEvent( mouseDown , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
264 result = noErr ;
265 break ;
266 case kEventMouseUp :
267 toplevelWindow->MacFireMouseEvent( mouseUp , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
268 result = noErr ;
269 break ;
270 case kEventMouseMoved :
271 toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
272 result = noErr ;
273 break ;
274 case kEventMouseDragged :
275 toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
276 result = noErr ;
277 break ;
278 default :
279 break ;
280 }
281 }
282
283 return result ;
284
285
286 }
287 static pascal OSStatus WindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
288 {
289 OSStatus result = eventNotHandledErr ;
290 OSStatus err = noErr ;
291
292 UInt32 attributes;
293 WindowRef windowRef ;
294 wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
295
296 GetEventParameter( event, kEventParamDirectObject, typeWindowRef, NULL,
297 sizeof( WindowRef ), NULL, &windowRef );
298
299 switch( GetEventKind( event ) )
300 {
301 case kEventWindowUpdate :
302 if ( !wxPendingDelete.Member(toplevelWindow) )
303 toplevelWindow->MacUpdate( EventTimeToTicks( GetEventTime( event ) ) ) ;
304 result = noErr ;
305 break ;
306 case kEventWindowActivated :
307 toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , true) ;
308 result = noErr ;
309 break ;
310 case kEventWindowDeactivated :
311 toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , false) ;
312 result = noErr ;
313 break ;
314 case kEventWindowClose :
315 toplevelWindow->Close() ;
316 result = noErr ;
317 break ;
318 case kEventWindowBoundsChanged :
319 err = GetEventParameter( event, kEventParamAttributes, typeUInt32,
320 NULL, sizeof( UInt32 ), NULL, &attributes );
321 if ( err == noErr )
322 {
323 Rect newContentRect ;
324
325 GetEventParameter( event, kEventParamCurrentBounds, typeQDRectangle, NULL,
326 sizeof( newContentRect ), NULL, &newContentRect );
327
328 toplevelWindow->SetSize( newContentRect.left , newContentRect.top ,
329 newContentRect.right - newContentRect.left ,
330 newContentRect.bottom - newContentRect.top, wxSIZE_USE_EXISTING);
331
332 result = noErr;
333 }
334 break ;
335 default :
336 break ;
337 }
338 return result ;
339 }
340
341 pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
342 {
343 OSStatus result = eventNotHandledErr ;
344
345 switch ( GetEventClass( event ) )
346 {
347 case kEventClassKeyboard :
348 result = KeyboardEventHandler( handler, event , data ) ;
349 break ;
350 case kEventClassTextInput :
351 result = TextInputEventHandler( handler, event , data ) ;
352 break ;
353 case kEventClassWindow :
354 result = WindowEventHandler( handler, event , data ) ;
355 break ;
356 case kEventClassMouse :
357 result = MouseEventHandler( handler, event , data ) ;
358 break ;
359 default :
360 break ;
361 }
362 return result ;
363 }
364
365 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler )
366
367 // Patch 531199 defined a window event handler, as follows.
368 // TODO: merge the moving/sizing event handling with the event
369 // handler above.
370 #if 0
371 static pascal OSStatus
372 WindowHandler( EventHandlerCallRef inHandler, EventRef inEvent, void* userData )
373 {
374 Rect bounds;
375 SInt16 height, width;
376 UInt32 attributes;
377 OSStatus result = eventNotHandledErr;
378
379 GetEventParameter( inEvent, kEventParamAttributes, typeUInt32, NULL, sizeof( UInt32 ), NULL, &attributes );
380
381 if ((attributes & (kWindowBoundsChangeSizeChanged | kWindowBoundsChangeOriginChanged)) != 0)
382 {
383 // Extract the current bounds. This is the paramter you get to modify to
384 // alter the window position or size during a window resizing.
385 GetEventParameter( inEvent, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof( bounds ), NULL, &bounds );
386
387 wxRect rect;
388 rect.SetLeft(bounds.left);
389 rect.SetTop(bounds.top);
390 rect.SetRight(bounds.right);
391 rect.SetBottom(bounds.bottom);
392
393 bool rc;
394 wxWindowMac *pWindow = (wxWindowMac*)userData;
395 if ((attributes & kWindowBoundsChangeSizeChanged) != 0) {
396 wxSizeEvent event(rect, pWindow->GetId());
397 event.SetEventObject(pWindow);
398 rc = pWindow->GetEventHandler()->ProcessEvent(event);
399 rect = event.GetRect();
400 }
401 else {
402 wxMoveEvent event(rect, pWindow->GetId());
403 event.SetEventObject(pWindow);
404 rc = pWindow->GetEventHandler()->ProcessEvent(event);
405 rect = event.GetRect();
406 }
407
408 if (rc) {
409 bounds.left = rect.GetLeft();
410 bounds.top = rect.GetTop();
411 bounds.right = rect.GetRight();
412 bounds.bottom = rect.GetBottom();
413 }
414
415 // Set the current bounds parameter to our adjusted bounds. Return
416 // noErr to indicate we handled this event.
417 SetEventParameter( inEvent, kEventParamCurrentBounds, typeQDRectangle, sizeof( bounds ), &bounds );
418 result = noErr;
419 }
420 return result;
421 }
422 #endif
423 // WindowHandler
424
425 #endif
426
427 // ---------------------------------------------------------------------------
428 // wxWindowMac utility functions
429 // ---------------------------------------------------------------------------
430
431 // Find an item given the Macintosh Window Reference
432
433 wxList *wxWinMacWindowList = NULL;
434 wxTopLevelWindowMac *wxFindWinFromMacWindow(WXWindow inWindowRef)
435 {
436 wxNode *node = wxWinMacWindowList->Find((long)inWindowRef);
437 if (!node)
438 return NULL;
439 return (wxTopLevelWindowMac *)node->GetData();
440 }
441
442 void wxAssociateWinWithMacWindow(WXWindow inWindowRef, wxTopLevelWindowMac *win)
443 {
444 // adding NULL WindowRef is (first) surely a result of an error and
445 // (secondly) breaks menu command processing
446 wxCHECK_RET( inWindowRef != (WindowRef) NULL, wxT("attempt to add a NULL WindowRef to window list") );
447
448 if ( !wxWinMacWindowList->Find((long)inWindowRef) )
449 wxWinMacWindowList->Append((long)inWindowRef, win);
450 }
451
452 void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win)
453 {
454 wxWinMacWindowList->DeleteObject(win);
455 }
456
457
458 // ----------------------------------------------------------------------------
459 // wxTopLevelWindowMac creation
460 // ----------------------------------------------------------------------------
461
462 WXHWND wxTopLevelWindowMac::s_macWindowInUpdate = NULL;
463
464 void wxTopLevelWindowMac::Init()
465 {
466 m_iconized =
467 m_maximizeOnShow = FALSE;
468 m_macNoEraseUpdateRgn = NewRgn() ;
469 m_macNeedsErasing = false ;
470 m_macWindow = NULL ;
471 #if TARGET_CARBON
472 m_macEventHandler = NULL ;
473 #endif
474 }
475
476 class wxMacDeferredWindowDeleter : public wxObject
477 {
478 public :
479 wxMacDeferredWindowDeleter( WindowRef windowRef )
480 {
481 m_macWindow = windowRef ;
482 }
483 virtual ~wxMacDeferredWindowDeleter()
484 {
485 UMADisposeWindow( (WindowRef) m_macWindow ) ;
486 }
487 protected :
488 WindowRef m_macWindow ;
489 } ;
490
491 bool wxTopLevelWindowMac::Create(wxWindow *parent,
492 wxWindowID id,
493 const wxString& title,
494 const wxPoint& pos,
495 const wxSize& size,
496 long style,
497 const wxString& name)
498 {
499 // init our fields
500 Init();
501
502 m_windowStyle = style;
503
504 SetName(name);
505
506 m_windowId = id == -1 ? NewControlId() : id;
507
508 wxTopLevelWindows.Append(this);
509
510 if ( parent )
511 parent->AddChild(this);
512
513 return TRUE;
514 }
515
516 wxTopLevelWindowMac::~wxTopLevelWindowMac()
517 {
518 if ( m_macWindow )
519 {
520 wxToolTip::NotifyWindowDelete(m_macWindow) ;
521 wxPendingDelete.Append( new wxMacDeferredWindowDeleter( (WindowRef) m_macWindow ) ) ;
522 }
523
524 #if TARGET_CARBON
525 if ( m_macEventHandler )
526 {
527 ::RemoveEventHandler((EventHandlerRef) m_macEventHandler);
528 m_macEventHandler = NULL ;
529 }
530 #endif
531
532 wxRemoveMacWindowAssociation( this ) ;
533
534 if ( wxModelessWindows.Find(this) )
535 wxModelessWindows.DeleteObject(this);
536
537 DisposeRgn( (RgnHandle) m_macNoEraseUpdateRgn ) ;
538 }
539
540
541 // ----------------------------------------------------------------------------
542 // wxTopLevelWindowMac maximize/minimize
543 // ----------------------------------------------------------------------------
544
545 void wxTopLevelWindowMac::Maximize(bool maximize)
546 {
547 // not available on mac
548 }
549
550 bool wxTopLevelWindowMac::IsMaximized() const
551 {
552 return false ;
553 }
554
555 void wxTopLevelWindowMac::Iconize(bool iconize)
556 {
557 // not available on mac
558 }
559
560 bool wxTopLevelWindowMac::IsIconized() const
561 {
562 // mac dialogs cannot be iconized
563 return FALSE;
564 }
565
566 void wxTopLevelWindowMac::Restore()
567 {
568 // not available on mac
569 }
570
571 // ----------------------------------------------------------------------------
572 // wxTopLevelWindowMac misc
573 // ----------------------------------------------------------------------------
574
575 void wxTopLevelWindowMac::SetIcon(const wxIcon& icon)
576 {
577 // this sets m_icon
578 wxTopLevelWindowBase::SetIcon(icon);
579 }
580
581 void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
582 const wxPoint& pos,
583 const wxSize& size,
584 long style,
585 const wxString& name )
586 {
587 SetName(name);
588 m_windowStyle = style;
589 m_isShown = FALSE;
590
591 // create frame.
592
593 Rect theBoundsRect;
594
595 m_x = (int)pos.x;
596 m_y = (int)pos.y;
597 if ( m_y < 50 )
598 m_y = 50 ;
599 if ( m_x < 20 )
600 m_x = 20 ;
601
602 m_width = size.x;
603 if (m_width == -1)
604 m_width = 20;
605 m_height = size.y;
606 if (m_height == -1)
607 m_height = 20;
608
609 ::SetRect(&theBoundsRect, m_x, m_y , m_x + m_width, m_y + m_height);
610
611 // translate the window attributes in the appropriate window class and attributes
612
613 WindowClass wclass = 0;
614 WindowAttributes attr = kWindowNoAttributes ;
615
616 if ( HasFlag( wxFRAME_TOOL_WINDOW) )
617 {
618 if (
619 HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) ||
620 HasFlag( wxSYSTEM_MENU ) || HasFlag( wxCAPTION ) ||
621 HasFlag(wxTINY_CAPTION_HORIZ) || HasFlag(wxTINY_CAPTION_VERT)
622 )
623 {
624 wclass = kFloatingWindowClass ;
625 if ( HasFlag(wxTINY_CAPTION_VERT) )
626 {
627 attr |= kWindowSideTitlebarAttribute ;
628 }
629 }
630 else
631 {
632 #if TARGET_CARBON
633 wclass = kPlainWindowClass ;
634 #else
635 wclass = kFloatingWindowClass ;
636 #endif
637 }
638 }
639 else if ( HasFlag( wxCAPTION ) )
640 {
641 wclass = kDocumentWindowClass ;
642 }
643 else
644 {
645 if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) ||
646 HasFlag( wxSYSTEM_MENU ) )
647 {
648 wclass = kDocumentWindowClass ;
649 }
650 else
651 {
652 #if TARGET_CARBON
653 wclass = kPlainWindowClass ;
654 #else
655 wclass = kModalWindowClass ;
656 #endif
657 }
658 }
659
660 if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) )
661 {
662 attr |= kWindowFullZoomAttribute ;
663 attr |= kWindowCollapseBoxAttribute ;
664 }
665 if ( HasFlag( wxRESIZE_BORDER ) )
666 {
667 attr |= kWindowResizableAttribute ;
668 }
669 if ( HasFlag( wxSYSTEM_MENU ) )
670 {
671 attr |= kWindowCloseBoxAttribute ;
672 }
673
674 #if TARGET_CARBON
675 #if 0 // having problems right now with that
676 if (HasFlag(wxSTAY_ON_TOP))
677 wclass = kUtilityWindowClass;
678 #endif
679 #endif
680
681 #if TARGET_CARBON
682 if ( HasFlag(wxFRAME_SHAPED) )
683 {
684 WindowDefSpec customWindowDefSpec;
685 customWindowDefSpec.defType = kWindowDefProcPtr;
686 customWindowDefSpec.u.defProc = NewWindowDefUPP(wxShapedMacWindowDef);
687
688 ::CreateCustomWindow( &customWindowDefSpec, wclass,
689 attr, &theBoundsRect,
690 (WindowRef*) &m_macWindow);
691 }
692 else
693 #endif
694 {
695 ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ;
696 }
697
698 wxAssociateWinWithMacWindow( m_macWindow , this ) ;
699 UMASetWTitle( (WindowRef)m_macWindow , title ) ;
700 ::CreateRootControl( (WindowRef)m_macWindow , (ControlHandle*)&m_macRootControl ) ;
701 #if TARGET_CARBON
702 InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ;
703 InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacWindowEventHandlerUPP(),
704 GetEventTypeCount(eventList), eventList, this, &((EventHandlerRef)m_macEventHandler));
705
706 // Patch 531199 also defined a window event handler, as follows:
707 #if 0
708 // install a window event handler to send wxEVT_MOVING and wxEVT_SIZING events
709 EventTypeSpec events[] = { { kEventClassWindow, kEventWindowBoundsChanging } };
710 EventHandlerUPP handlerProc = NewEventHandlerUPP( WindowHandler );
711 EventHandlerRef eventHandlerRef;
712 InstallWindowEventHandler( m_macWindowData->m_macWindow, handlerProc, GetEventTypeCount(events),
713 events, (void*)this, &eventHandlerRef);
714 #endif
715
716 #endif
717 m_macFocus = NULL ;
718
719
720 #if TARGET_CARBON
721 if ( HasFlag(wxFRAME_SHAPED) )
722 {
723 // default shape matches the window size
724 wxRegion rgn(0, 0, m_width, m_height);
725 SetShape(rgn);
726 }
727 #endif
728 }
729
730 void wxTopLevelWindowMac::MacGetPortParams(WXPOINTPTR localOrigin, WXRECTPTR clipRect, WXHWND *window , wxWindowMac** rootwin)
731 {
732 ((Point*)localOrigin)->h = 0;
733 ((Point*)localOrigin)->v = 0;
734 ((Rect*)clipRect)->left = 0;
735 ((Rect*)clipRect)->top = 0;
736 ((Rect*)clipRect)->right = m_width;
737 ((Rect*)clipRect)->bottom = m_height;
738 *window = m_macWindow ;
739 *rootwin = this ;
740 }
741
742 void wxTopLevelWindowMac::Clear()
743 {
744 wxWindow::Clear() ;
745 }
746
747 WXWidget wxTopLevelWindowMac::MacGetContainerForEmbedding()
748 {
749 return m_macRootControl ;
750 }
751
752
753 void wxTopLevelWindowMac::MacUpdate( long timestamp)
754 {
755 wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ;
756
757 RgnHandle visRgn = NewRgn() ;
758 GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), visRgn );
759 BeginUpdate( (WindowRef)m_macWindow ) ;
760
761 RgnHandle updateRgn = NewRgn();
762 RgnHandle diffRgn = NewRgn() ;
763
764 if ( updateRgn && diffRgn )
765 {
766 #if 1
767 // macos internal control redraws clean up areas we'd like to redraw ourselves
768 // therefore we pick the boundary rect and make sure we can redraw it
769 // this has to be intersected by the visRgn in order to avoid drawing over its own
770 // boundaries
771 RgnHandle trueUpdateRgn = NewRgn() ;
772 Rect trueUpdateRgnBoundary ;
773 GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), trueUpdateRgn );
774 GetRegionBounds( trueUpdateRgn , &trueUpdateRgnBoundary ) ;
775 RectRgn( updateRgn , &trueUpdateRgnBoundary ) ;
776 SectRgn( updateRgn , visRgn , updateRgn ) ;
777 if ( trueUpdateRgn )
778 DisposeRgn( trueUpdateRgn ) ;
779 SetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn ) ;
780 #else
781 GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn );
782 #endif
783 DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ;
784 if ( !EmptyRgn( updateRgn ) )
785 {
786 MacRedraw( updateRgn , timestamp , m_macNeedsErasing || !EmptyRgn( diffRgn ) ) ;
787 }
788 }
789 if ( updateRgn )
790 DisposeRgn( updateRgn );
791 if ( diffRgn )
792 DisposeRgn( diffRgn );
793 if ( visRgn )
794 DisposeRgn( visRgn ) ;
795
796 EndUpdate( (WindowRef)m_macWindow ) ;
797 SetEmptyRgn( (RgnHandle) m_macNoEraseUpdateRgn ) ;
798 m_macNeedsErasing = false ;
799 }
800
801
802 // Raise the window to the top of the Z order
803 void wxTopLevelWindowMac::Raise()
804 {
805 ::SelectWindow( (WindowRef)m_macWindow ) ;
806 }
807
808 // Lower the window to the bottom of the Z order
809 void wxTopLevelWindowMac::Lower()
810 {
811 ::SendBehind( (WindowRef)m_macWindow , NULL ) ;
812 }
813
814 void wxTopLevelWindowMac::MacFireMouseEvent(
815 wxUint16 kind , wxInt32 x , wxInt32 y ,wxUint32 modifiers , long timestamp )
816 {
817 wxMouseEvent event(wxEVT_LEFT_DOWN);
818 bool isDown = !(modifiers & btnState) ; // 1 is for up
819 bool controlDown = modifiers & controlKey ; // for simulating right mouse
820
821 event.m_leftDown = isDown && !controlDown;
822
823 event.m_middleDown = FALSE;
824 event.m_rightDown = isDown && controlDown;
825
826 if ( kind == mouseDown )
827 {
828 if ( controlDown )
829 event.SetEventType(wxEVT_RIGHT_DOWN ) ;
830 else
831 event.SetEventType(wxEVT_LEFT_DOWN ) ;
832 }
833 else if ( kind == mouseUp )
834 {
835 if ( controlDown )
836 event.SetEventType(wxEVT_RIGHT_UP ) ;
837 else
838 event.SetEventType(wxEVT_LEFT_UP ) ;
839 }
840 else
841 {
842 event.SetEventType(wxEVT_MOTION ) ;
843 }
844
845 event.m_shiftDown = modifiers & shiftKey;
846 event.m_controlDown = modifiers & controlKey;
847 event.m_altDown = modifiers & optionKey;
848 event.m_metaDown = modifiers & cmdKey;
849
850 Point localwhere ;
851 localwhere.h = x ;
852 localwhere.v = y ;
853
854 GrafPtr port ;
855 ::GetPort( &port ) ;
856 ::SetPort( UMAGetWindowPort( (WindowRef)m_macWindow ) ) ;
857 ::GlobalToLocal( &localwhere ) ;
858 ::SetPort( port ) ;
859
860 if ( kind == mouseDown )
861 {
862 if ( timestamp - gs_lastWhen <= (long) GetDblTime() )
863 {
864 if ( abs( localwhere.h - gs_lastWhere.h ) < 3 && abs( localwhere.v - gs_lastWhere.v ) < 3 )
865 {
866 // This is not right if the second mouse down
867 // event occured in a differen window. We
868 // correct this in MacDispatchMouseEvent.
869 if ( controlDown )
870 event.SetEventType(wxEVT_RIGHT_DCLICK ) ;
871 else
872 event.SetEventType(wxEVT_LEFT_DCLICK ) ;
873 }
874 gs_lastWhen = 0 ;
875 }
876 else
877 {
878 gs_lastWhen = timestamp ;
879 }
880 gs_lastWhere = localwhere ;
881 }
882
883 event.m_x = localwhere.h;
884 event.m_y = localwhere.v;
885 event.m_x += m_x;
886 event.m_y += m_y;
887
888 event.m_timeStamp = timestamp;
889 event.SetEventObject(this);
890 if ( wxTheApp->s_captureWindow )
891 {
892 int x = event.m_x ;
893 int y = event.m_y ;
894 wxTheApp->s_captureWindow->ScreenToClient( &x , &y ) ;
895 event.m_x = x ;
896 event.m_y = y ;
897 event.SetEventObject( wxTheApp->s_captureWindow ) ;
898 wxTheApp->s_captureWindow->GetEventHandler()->ProcessEvent( event ) ;
899
900 if ( kind == mouseUp )
901 {
902 wxTheApp->s_captureWindow = NULL ;
903 if ( !wxIsBusy() )
904 {
905 m_cursor.MacInstall() ;
906 }
907 }
908 }
909 else
910 {
911 MacDispatchMouseEvent( event ) ;
912 }
913 }
914
915 #if !TARGET_CARBON
916
917 void wxTopLevelWindowMac::MacMouseDown( WXEVENTREF ev , short part)
918 {
919 MacFireMouseEvent( mouseDown , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v ,
920 ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ;
921 }
922
923 void wxTopLevelWindowMac::MacMouseUp( WXEVENTREF ev , short part)
924 {
925 switch (part)
926 {
927 case inContent:
928 {
929 MacFireMouseEvent( mouseUp , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v ,
930 ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ;
931 }
932 break ;
933 }
934 }
935
936 void wxTopLevelWindowMac::MacMouseMoved( WXEVENTREF ev , short part)
937 {
938 switch (part)
939 {
940 case inContent:
941 {
942 MacFireMouseEvent( nullEvent /*moved*/ , ((EventRecord*)ev)->where.h , ((EventRecord*)ev)->where.v ,
943 ((EventRecord*)ev)->modifiers , ((EventRecord*)ev)->when ) ;
944 }
945 break ;
946 }
947 }
948
949 #endif
950
951 void wxTopLevelWindowMac::MacActivate( long timestamp , bool inIsActivating )
952 {
953 wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId);
954 event.m_timeStamp = timestamp ;
955 event.SetEventObject(this);
956
957 GetEventHandler()->ProcessEvent(event);
958
959 UMAHighlightAndActivateWindow( (WindowRef)m_macWindow , inIsActivating ) ;
960
961 // Early versions of MacOS X don't refresh backgrounds properly,
962 // so refresh the whole window on activation and deactivation.
963 long osVersion = UMAGetSystemVersion();
964 if (osVersion >= 0x1000 && osVersion < 0x1020 )
965 {
966 Refresh(TRUE);
967 }
968 else
969 {
970 // for the moment we have to resolve some redrawing issues like this
971 // the OS is stealing some redrawing areas as soon as it draws a control
972 Refresh(TRUE);
973 }
974 }
975
976 #if !TARGET_CARBON
977
978 void wxTopLevelWindowMac::MacKeyDown( WXEVENTREF ev )
979 {
980 }
981
982 #endif
983
984 void wxTopLevelWindowMac::SetTitle(const wxString& title)
985 {
986 wxWindow::SetTitle( title ) ;
987 UMASetWTitle( (WindowRef)m_macWindow , title ) ;
988 }
989
990 bool wxTopLevelWindowMac::Show(bool show)
991 {
992 if ( !wxWindow::Show(show) )
993 return FALSE;
994
995 if (show)
996 {
997 ::TransitionWindow((WindowRef)m_macWindow,kWindowZoomTransitionEffect,kWindowShowTransitionAction,nil);
998 ::SelectWindow( (WindowRef)m_macWindow ) ;
999 // no need to generate events here, they will get them triggered by macos
1000 // actually they should be , but apparently they are not
1001 wxSize size(m_width, m_height);
1002 wxSizeEvent event(size, m_windowId);
1003 event.SetEventObject(this);
1004 GetEventHandler()->ProcessEvent(event);
1005 }
1006 else
1007 {
1008 ::TransitionWindow((WindowRef)m_macWindow,kWindowZoomTransitionEffect,kWindowHideTransitionAction,nil);
1009 }
1010
1011 if ( !show )
1012 {
1013 }
1014 else
1015 {
1016 Refresh() ;
1017 }
1018
1019 return TRUE;
1020 }
1021
1022 void wxTopLevelWindowMac::DoMoveWindow(int x, int y, int width, int height)
1023 {
1024 int former_x = m_x ;
1025 int former_y = m_y ;
1026 int former_w = m_width ;
1027 int former_h = m_height ;
1028
1029 int actualWidth = width;
1030 int actualHeight = height;
1031 int actualX = x;
1032 int actualY = y;
1033
1034 if ((m_minWidth != -1) && (actualWidth < m_minWidth))
1035 actualWidth = m_minWidth;
1036 if ((m_minHeight != -1) && (actualHeight < m_minHeight))
1037 actualHeight = m_minHeight;
1038 if ((m_maxWidth != -1) && (actualWidth > m_maxWidth))
1039 actualWidth = m_maxWidth;
1040 if ((m_maxHeight != -1) && (actualHeight > m_maxHeight))
1041 actualHeight = m_maxHeight;
1042
1043 bool doMove = false ;
1044 bool doResize = false ;
1045
1046 if ( actualX != former_x || actualY != former_y )
1047 {
1048 doMove = true ;
1049 }
1050 if ( actualWidth != former_w || actualHeight != former_h )
1051 {
1052 doResize = true ;
1053 }
1054
1055 if ( doMove || doResize )
1056 {
1057 m_x = actualX ;
1058 m_y = actualY ;
1059 m_width = actualWidth ;
1060 m_height = actualHeight ;
1061
1062 if ( doMove )
1063 ::MoveWindow((WindowRef)m_macWindow, m_x, m_y , false); // don't make frontmost
1064
1065 if ( doResize )
1066 ::SizeWindow((WindowRef)m_macWindow, m_width, m_height , true);
1067
1068 // the OS takes care of invalidating and erasing the new area so we only have to
1069 // take care of refreshing for full repaints
1070
1071 if ( doResize && !HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) )
1072 Refresh() ;
1073
1074
1075 if ( IsKindOf( CLASSINFO( wxFrame ) ) )
1076 {
1077 wxFrame* frame = (wxFrame*) this ;
1078 frame->PositionStatusBar();
1079 frame->PositionToolBar();
1080 }
1081 if ( doMove )
1082 wxWindowMac::MacTopLevelWindowChangedPosition() ; // like this only children will be notified
1083
1084 MacRepositionScrollBars() ;
1085 if ( doMove )
1086 {
1087 wxPoint point(m_x, m_y);
1088 wxMoveEvent event(point, m_windowId);
1089 event.SetEventObject(this);
1090 GetEventHandler()->ProcessEvent(event) ;
1091 }
1092 if ( doResize )
1093 {
1094 MacRepositionScrollBars() ;
1095 wxSize size(m_width, m_height);
1096 wxSizeEvent event(size, m_windowId);
1097 event.SetEventObject(this);
1098 GetEventHandler()->ProcessEvent(event);
1099 }
1100 }
1101
1102 }
1103
1104 /*
1105 * Invalidation Mechanism
1106 *
1107 * The update mechanism reflects exactely the windows mechanism
1108 * the rect gets added to the window invalidate region, if the eraseBackground flag
1109 * has been true for any part of the update rgn the background is erased in the entire region
1110 * not just in the specified rect.
1111 *
1112 * In order to achive this, we also have an internal m_macNoEraseUpdateRgn, all rects that have
1113 * the eraseBackground flag set to false are also added to this rgn. upon receiving an update event
1114 * the update rgn is compared to the m_macNoEraseUpdateRgn and in case they differ, every window
1115 * will get the eraseBackground event first
1116 */
1117
1118 void wxTopLevelWindowMac::MacInvalidate( const WXRECTPTR rect, bool eraseBackground )
1119 {
1120 GrafPtr formerPort ;
1121 GetPort( &formerPort ) ;
1122 SetPortWindowPort( (WindowRef)m_macWindow ) ;
1123
1124 m_macNeedsErasing |= eraseBackground ;
1125
1126 // if we already know that we will have to erase, there's no need to track the rest
1127 if ( !m_macNeedsErasing)
1128 {
1129 // we end only here if eraseBackground is false
1130 // if we already have a difference between m_macNoEraseUpdateRgn and UpdateRgn
1131 // we will have to erase anyway
1132
1133 RgnHandle updateRgn = NewRgn();
1134 RgnHandle diffRgn = NewRgn() ;
1135 if ( updateRgn && diffRgn )
1136 {
1137 GetWindowUpdateRgn( (WindowRef)m_macWindow , updateRgn );
1138 Point pt = {0,0} ;
1139 LocalToGlobal( &pt ) ;
1140 OffsetRgn( updateRgn , -pt.h , -pt.v ) ;
1141 DiffRgn( updateRgn , (RgnHandle) m_macNoEraseUpdateRgn , diffRgn ) ;
1142 if ( !EmptyRgn( diffRgn ) )
1143 {
1144 m_macNeedsErasing = true ;
1145 }
1146 }
1147 if ( updateRgn )
1148 DisposeRgn( updateRgn );
1149 if ( diffRgn )
1150 DisposeRgn( diffRgn );
1151
1152 if ( !m_macNeedsErasing )
1153 {
1154 RgnHandle rectRgn = NewRgn() ;
1155 SetRectRgn( rectRgn , ((Rect*)rect)->left , ((Rect*)rect)->top , ((Rect*)rect)->right , ((Rect*)rect)->bottom ) ;
1156 UnionRgn( (RgnHandle) m_macNoEraseUpdateRgn , rectRgn , (RgnHandle) m_macNoEraseUpdateRgn ) ;
1157 DisposeRgn( rectRgn ) ;
1158 }
1159 }
1160 InvalWindowRect( (WindowRef)m_macWindow , (Rect*)rect ) ;
1161 // turn this on to debug the refreshing cycle
1162 #if wxMAC_DEBUG_REDRAW
1163 PaintRect( rect ) ;
1164 #endif
1165 SetPort( formerPort ) ;
1166 }
1167
1168
1169 bool wxTopLevelWindowMac::SetShape(const wxRegion& region)
1170 {
1171 wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), FALSE,
1172 _T("Shaped windows must be created with the wxFRAME_SHAPED style."));
1173
1174 #if TARGET_CARBON
1175 // The empty region signifies that the shape should be removed from the
1176 // window.
1177 if ( region.IsEmpty() )
1178 {
1179 wxSize sz = GetClientSize();
1180 wxRegion rgn(0, 0, sz.x, sz.y);
1181 return SetShape(rgn);
1182 }
1183
1184 // Make a copy of the region
1185 RgnHandle shapeRegion = NewRgn();
1186 CopyRgn( (RgnHandle)region.GetWXHRGN(), shapeRegion );
1187
1188 // Dispose of any shape region we may already have
1189 RgnHandle oldRgn = (RgnHandle)GetWRefCon( (WindowRef)MacGetWindowRef() );
1190 if ( oldRgn )
1191 DisposeRgn(oldRgn);
1192
1193 // Save the region so we can use it later
1194 SetWRefCon((WindowRef)MacGetWindowRef(), (SInt32)shapeRegion);
1195
1196 // Tell the window manager that the window has changed shape
1197 ReshapeCustomWindow((WindowRef)MacGetWindowRef());
1198 return TRUE;
1199 #else
1200 return FALSE;
1201 #endif
1202 }
1203
1204 // ---------------------------------------------------------------------------
1205 // Support functions for shaped windows, based on Apple's CustomWindow sample at
1206 // http://developer.apple.com/samplecode/Sample_Code/Human_Interface_Toolbox/Mac_OS_High_Level_Toolbox/CustomWindow.htm
1207 // ---------------------------------------------------------------------------
1208
1209 #if TARGET_CARBON
1210
1211 static void wxShapedMacWindowGetPos(WindowRef window, Rect* inRect)
1212 {
1213 GetWindowPortBounds(window, inRect);
1214 Point pt = {inRect->left, inRect->top};
1215 SetPort((GrafPtr) GetWindowPort(window));
1216 LocalToGlobal(&pt);
1217 inRect->top = pt.v;
1218 inRect->left = pt.h;
1219 inRect->bottom += pt.v;
1220 inRect->right += pt.h;
1221 }
1222
1223
1224 static SInt32 wxShapedMacWindowGetFeatures(WindowRef window, SInt32 param)
1225 {
1226 /*------------------------------------------------------
1227 Define which options your custom window supports.
1228 --------------------------------------------------------*/
1229 //just enable everything for our demo
1230 *(OptionBits*)param=//kWindowCanGrow|
1231 //kWindowCanZoom|
1232 //kWindowCanCollapse|
1233 //kWindowCanGetWindowRegion|
1234 //kWindowHasTitleBar|
1235 //kWindowSupportsDragHilite|
1236 kWindowCanDrawInCurrentPort|
1237 //kWindowCanMeasureTitle|
1238 kWindowWantsDisposeAtProcessDeath|
1239 kWindowSupportsSetGrowImageRegion|
1240 kWindowDefSupportsColorGrafPort;
1241 return 1;
1242 }
1243
1244 // The content region is left as a rectangle matching the window size, this is
1245 // so the origin in the paint event, and etc. still matches what the
1246 // programmer expects.
1247 static void wxShapedMacWindowContentRegion(WindowRef window, RgnHandle rgn)
1248 {
1249 SetEmptyRgn(rgn);
1250 wxTopLevelWindowMac* win = wxFindWinFromMacWindow(window);
1251 if (win)
1252 {
1253 wxRect r = win->GetRect();
1254 SetRectRgn(rgn, r.GetLeft(), r.GetTop(), r.GetRight(), r.GetBottom());
1255 }
1256 }
1257
1258 // The structure region is set to the shape given to the SetShape method.
1259 static void wxShapedMacWindowStructureRegion(WindowRef window, RgnHandle rgn)
1260 {
1261 RgnHandle cachedRegion = (RgnHandle) GetWRefCon(window);
1262
1263 SetEmptyRgn(rgn);
1264 if (cachedRegion)
1265 {
1266 Rect windowRect;
1267 wxShapedMacWindowGetPos(window, &windowRect); //how big is the window
1268 CopyRgn(cachedRegion, rgn); //make a copy of our cached region
1269 OffsetRgn(rgn, windowRect.left, windowRect.top); // position it over window
1270 //MapRgn(rgn, &mMaskSize, &windowRect); //scale it to our actual window size
1271 }
1272 }
1273
1274
1275
1276 static SInt32 wxShapedMacWindowGetRegion(WindowRef window, SInt32 param)
1277 {
1278 GetWindowRegionPtr rgnRec=(GetWindowRegionPtr)param;
1279
1280 switch(rgnRec->regionCode)
1281 {
1282 case kWindowStructureRgn:
1283 wxShapedMacWindowStructureRegion(window, rgnRec->winRgn);
1284 break;
1285 case kWindowContentRgn:
1286 wxShapedMacWindowContentRegion(window, rgnRec->winRgn);
1287 break;
1288 default:
1289 SetEmptyRgn(rgnRec->winRgn);
1290 } //switch
1291
1292 return noErr;
1293 }
1294
1295
1296 static SInt32 wxShapedMacWindowHitTest(WindowRef window,SInt32 param)
1297 {
1298 /*------------------------------------------------------
1299 Determine the region of the window which was hit
1300 --------------------------------------------------------*/
1301 Point hitPoint;
1302 static RgnHandle tempRgn=nil;
1303
1304 if(!tempRgn)
1305 tempRgn=NewRgn();
1306
1307 SetPt(&hitPoint,LoWord(param),HiWord(param));//get the point clicked
1308
1309 //Mac OS 8.5 or later
1310 wxShapedMacWindowStructureRegion(window, tempRgn);
1311 if (PtInRgn(hitPoint, tempRgn)) //in window content region?
1312 return wInContent;
1313
1314 return wNoHit;//no significant area was hit.
1315 }
1316
1317
1318 static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param)
1319 {
1320 switch(message)
1321 {
1322 case kWindowMsgHitTest:
1323 return wxShapedMacWindowHitTest(window,param);
1324
1325 case kWindowMsgGetFeatures:
1326 return wxShapedMacWindowGetFeatures(window,param);
1327
1328 // kWindowMsgGetRegion is sent during CreateCustomWindow and ReshapeCustomWindow
1329 case kWindowMsgGetRegion:
1330 return wxShapedMacWindowGetRegion(window,param);
1331 }
1332
1333 return 0;
1334 }
1335
1336 #endif
1337 // ---------------------------------------------------------------------------
1338