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