]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/nonownedwnd.cpp
Document lack of wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK under OS X.
[wxWidgets.git] / src / osx / carbon / nonownedwnd.cpp
CommitLineData
489468fe 1/////////////////////////////////////////////////////////////////////////////
524c47aa 2// Name: src/osx/carbon/nonownedwnd.cpp
489468fe
SC
3// Purpose: implementation of wxNonOwnedWindow
4// Author: Stefan Csomor
5// Created: 2008-03-24
b5b208a1 6// RCS-ID: $Id$
489468fe
SC
7// Copyright: (c) Stefan Csomor 2008
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifndef WX_PRECOMP
15 #include "wx/app.h"
16#endif // WX_PRECOMP
17
18#include "wx/hashmap.h"
19#include "wx/evtloop.h"
20#include "wx/tooltip.h"
21#include "wx/nonownedwnd.h"
22
1f0c8f31 23#include "wx/osx/private.h"
489468fe
SC
24#include "wx/settings.h"
25#include "wx/frame.h"
26
27#if wxUSE_SYSTEM_OPTIONS
28 #include "wx/sysopt.h"
29#endif
30
524c47aa
SC
31// ============================================================================
32// wxNonOwnedWindow implementation
33// ============================================================================
b2680ced 34
e185a681
SC
35// unified title and toolbar constant - not in Tiger headers, so we duplicate it here
36#define kWindowUnifiedTitleAndToolbarAttribute (1 << 7)
37
b2680ced
SC
38IMPLEMENT_DYNAMIC_CLASS( wxNonOwnedWindowCarbonImpl , wxNonOwnedWindowImpl )
39
b2680ced
SC
40WXWindow wxNonOwnedWindowCarbonImpl::GetWXWindow() const
41{
42 return (WXWindow) m_macWindow;
43}
44void wxNonOwnedWindowCarbonImpl::Raise()
45{
46 ::SelectWindow( m_macWindow ) ;
47}
48
49void wxNonOwnedWindowCarbonImpl::Lower()
50{
51 ::SendBehind( m_macWindow , NULL ) ;
52}
53
dbc7ceb9
KO
54void wxNonOwnedWindowCarbonImpl::ShowWithoutActivating()
55{
56 bool plainTransition = true;
57
58#if wxUSE_SYSTEM_OPTIONS
59 if ( wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) )
60 plainTransition = ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1 ) ;
61#endif
62
63 if ( plainTransition )
64 ::ShowWindow( (WindowRef)m_macWindow );
65 else
66 ::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowShowTransitionAction, NULL );
67}
68
b2680ced
SC
69bool wxNonOwnedWindowCarbonImpl::Show(bool show)
70{
71 bool plainTransition = true;
72
73#if wxUSE_SYSTEM_OPTIONS
74 if ( wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) )
75 plainTransition = ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1 ) ;
76#endif
77
78 if (show)
79 {
dbc7ceb9 80 ShowWithoutActivating();
b2680ced 81 ::SelectWindow( (WindowRef)m_macWindow ) ;
b2680ced
SC
82 }
83 else
84 {
85#if wxOSX_USE_CARBON
86 if ( plainTransition )
87 ::HideWindow( (WindowRef)m_macWindow );
88 else
89 ::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowHideTransitionAction, NULL );
90#endif
91 }
92 return true;
93}
94
95void wxNonOwnedWindowCarbonImpl::Update()
96{
97 HIWindowFlush(m_macWindow) ;
98}
99
100bool wxNonOwnedWindowCarbonImpl::SetTransparent(wxByte alpha)
101{
102 OSStatus result = SetWindowAlpha((WindowRef)m_macWindow, (CGFloat)((alpha)/255.0));
103 return result == noErr;
104}
105
106bool wxNonOwnedWindowCarbonImpl::SetBackgroundColour(const wxColour& col )
107{
108 if ( col == wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDocumentWindowBackground)) )
109 {
110 SetThemeWindowBackground( (WindowRef) m_macWindow, kThemeBrushDocumentWindowBackground, false ) ;
4d949e7f
SC
111 m_wxPeer->SetBackgroundStyle(wxBG_STYLE_SYSTEM);
112 // call directly if object is not yet completely constructed
113 if ( m_wxPeer->GetNonOwnedPeer() == NULL )
114 SetBackgroundStyle(wxBG_STYLE_SYSTEM);
b2680ced
SC
115 }
116 else if ( col == wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDialogBackgroundActive)) )
117 {
118 SetThemeWindowBackground( (WindowRef) m_macWindow, kThemeBrushDialogBackgroundActive, false ) ;
4d949e7f
SC
119 m_wxPeer->SetBackgroundStyle(wxBG_STYLE_SYSTEM);
120 // call directly if object is not yet completely constructed
121 if ( m_wxPeer->GetNonOwnedPeer() == NULL )
122 SetBackgroundStyle(wxBG_STYLE_SYSTEM);
b2680ced
SC
123 }
124 return true;
125}
126
127void wxNonOwnedWindowCarbonImpl::SetExtraStyle( long exStyle )
128{
129 if ( m_macWindow != NULL )
130 {
131 bool metal = exStyle & wxFRAME_EX_METAL ;
132
133 if ( MacGetMetalAppearance() != metal )
134 {
135 if ( MacGetUnifiedAppearance() )
136 MacSetUnifiedAppearance( !metal ) ;
137
138 MacSetMetalAppearance( metal ) ;
139 }
140 }
141}
142
143bool wxNonOwnedWindowCarbonImpl::SetBackgroundStyle(wxBackgroundStyle style)
03647350 144{
b2680ced
SC
145 if ( style == wxBG_STYLE_TRANSPARENT )
146 {
147 OSStatus err = HIWindowChangeFeatures( m_macWindow, 0, kWindowIsOpaque );
148 verify_noerr( err );
149 err = ReshapeCustomWindow( m_macWindow );
52cda80e
SC
150 verify_noerr( err );
151 }
b2680ced
SC
152
153 return true ;
154}
155
156bool wxNonOwnedWindowCarbonImpl::CanSetTransparent()
157{
158 return true;
159}
160
161void wxNonOwnedWindowCarbonImpl::GetContentArea( int &left , int &top , int &width , int &height ) const
162{
163 Rect content, structure ;
164
165 GetWindowBounds( m_macWindow, kWindowStructureRgn , &structure ) ;
166 GetWindowBounds( m_macWindow, kWindowContentRgn , &content ) ;
167
168 left = content.left - structure.left ;
169 top = content.top - structure.top ;
170 width = content.right - content.left ;
171 height = content.bottom - content.top ;
172}
173
174void wxNonOwnedWindowCarbonImpl::MoveWindow(int x, int y, int width, int height)
175{
176 Rect bounds = { y , x , y + height , x + width } ;
177 verify_noerr(SetWindowBounds( (WindowRef) m_macWindow, kWindowStructureRgn , &bounds )) ;
178}
179
180void wxNonOwnedWindowCarbonImpl::GetPosition( int &x, int &y ) const
181{
182 Rect bounds ;
183
184 verify_noerr(GetWindowBounds((WindowRef) m_macWindow, kWindowStructureRgn , &bounds )) ;
185
186 x = bounds.left ;
187 y = bounds.top ;
188}
189
190void wxNonOwnedWindowCarbonImpl::GetSize( int &width, int &height ) const
191{
192 Rect bounds ;
193
194 verify_noerr(GetWindowBounds((WindowRef) m_macWindow, kWindowStructureRgn , &bounds )) ;
195
196 width = bounds.right - bounds.left ;
197 height = bounds.bottom - bounds.top ;
198}
199
200bool wxNonOwnedWindowCarbonImpl::MacGetUnifiedAppearance() const
201{
202 return MacGetWindowAttributes() & kWindowUnifiedTitleAndToolbarAttribute ;
203}
204
205void wxNonOwnedWindowCarbonImpl::MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear )
206{
207 ChangeWindowAttributes( m_macWindow, attributesToSet, attributesToClear ) ;
208}
209
210wxUint32 wxNonOwnedWindowCarbonImpl::MacGetWindowAttributes() const
211{
212 UInt32 attr = 0 ;
213 GetWindowAttributes( m_macWindow, &attr ) ;
214 return attr ;
215}
216
217void wxNonOwnedWindowCarbonImpl::MacSetMetalAppearance( bool set )
218{
219 if ( MacGetUnifiedAppearance() )
220 MacSetUnifiedAppearance( false ) ;
221
222 MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes ,
223 set ? kWindowNoAttributes : kWindowMetalAttribute ) ;
224}
225
226bool wxNonOwnedWindowCarbonImpl::MacGetMetalAppearance() const
227{
228 return MacGetWindowAttributes() & kWindowMetalAttribute ;
229}
230
231void wxNonOwnedWindowCarbonImpl::MacSetUnifiedAppearance( bool set )
232{
233 if ( MacGetMetalAppearance() )
234 MacSetMetalAppearance( false ) ;
235
236 MacChangeWindowAttributes( set ? kWindowUnifiedTitleAndToolbarAttribute : kWindowNoAttributes ,
237 set ? kWindowNoAttributes : kWindowUnifiedTitleAndToolbarAttribute) ;
238
239 // For some reason, Tiger uses white as the background color for this appearance,
4c51a665 240 // while most apps using it use the typical striped background. Restore that behaviour
b2680ced
SC
241 // for wx.
242 // TODO: Determine if we need this on Leopard as well. (should be harmless either way,
243 // though)
03647350 244 // since when creating the peering is not yet completely set-up we call both setters
4c51a665 245 // explicitly
b2680ced 246 m_wxPeer->SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW) ) ;
524c47aa 247 SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW) ) ;
b2680ced 248}
489468fe 249
489468fe
SC
250
251// ----------------------------------------------------------------------------
252// globals
253// ----------------------------------------------------------------------------
254
255static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 message, SInt32 param);
256
9a9fa616 257WXDLLEXPORT void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent );
b2680ced 258
489468fe
SC
259// ---------------------------------------------------------------------------
260// Carbon Events
261// ---------------------------------------------------------------------------
262
263static const EventTypeSpec eventList[] =
264{
265 // TODO: remove control related event like key and mouse (except for WindowLeave events)
266
267 { kEventClassKeyboard, kEventRawKeyDown } ,
268 { kEventClassKeyboard, kEventRawKeyRepeat } ,
269 { kEventClassKeyboard, kEventRawKeyUp } ,
270 { kEventClassKeyboard, kEventRawKeyModifiersChanged } ,
271
272 { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } ,
273 { kEventClassTextInput, kEventTextInputUpdateActiveInputArea } ,
274
275 { kEventClassWindow , kEventWindowShown } ,
276 { kEventClassWindow , kEventWindowActivated } ,
277 { kEventClassWindow , kEventWindowDeactivated } ,
278 { kEventClassWindow , kEventWindowBoundsChanging } ,
279 { kEventClassWindow , kEventWindowBoundsChanged } ,
280 { kEventClassWindow , kEventWindowClose } ,
281 { kEventClassWindow , kEventWindowGetRegion } ,
282
283 // we have to catch these events on the toplevel window level,
284 // as controls don't get the raw mouse events anymore
285
286 { kEventClassMouse , kEventMouseDown } ,
287 { kEventClassMouse , kEventMouseUp } ,
288 { kEventClassMouse , kEventMouseWheelMoved } ,
289 { kEventClassMouse , kEventMouseMoved } ,
290 { kEventClassMouse , kEventMouseDragged } ,
291} ;
292
293static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
294{
295 OSStatus result = eventNotHandledErr ;
296 // call DoFindFocus instead of FindFocus, because for Composite Windows(like WxGenericListCtrl)
297 // FindFocus does not return the actual focus window, but the enclosing window
298 wxWindow* focus = wxWindow::DoFindFocus();
299 if ( focus == NULL )
b2680ced 300 focus = data ? ((wxNonOwnedWindowImpl*) data)->GetWXPeer() : NULL ;
489468fe
SC
301
302 unsigned char charCode ;
303 wxChar uniChar[2] ;
304 uniChar[0] = 0;
305 uniChar[1] = 0;
306
307 UInt32 keyCode ;
308 UInt32 modifiers ;
489468fe
SC
309 UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;
310
311#if wxUSE_UNICODE
312 ByteCount dataSize = 0 ;
313 if ( GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0 , &dataSize, NULL ) == noErr )
314 {
315 UniChar buf[2] ;
316 int numChars = dataSize / sizeof( UniChar) + 1;
317
318 UniChar* charBuf = buf ;
319
320 if ( numChars * 2 > 4 )
321 charBuf = new UniChar[ numChars ] ;
322 GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
323 charBuf[ numChars - 1 ] = 0;
324
489468fe
SC
325 wxMBConvUTF16 converter ;
326 converter.MB2WC( uniChar , (const char*)charBuf , 2 ) ;
489468fe
SC
327
328 if ( numChars * 2 > 4 )
329 delete[] charBuf ;
330 }
b7db3788 331#endif // wxUSE_UNICODE
489468fe 332
784d9056 333 GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode );
489468fe
SC
334 GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
335 GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
489468fe
SC
336
337 UInt32 message = (keyCode << 8) + charCode;
338 switch ( GetEventKind( event ) )
339 {
340 case kEventRawKeyRepeat :
341 case kEventRawKeyDown :
342 {
343 WXEVENTREF formerEvent = wxTheApp->MacGetCurrentEvent() ;
344 WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
345 wxTheApp->MacSetCurrentEvent( event , handler ) ;
346 if ( /* focus && */ wxTheApp->MacSendKeyDownEvent(
2f7baaec 347 focus , message , modifiers , when , uniChar[0] ) )
489468fe
SC
348 {
349 result = noErr ;
350 }
351 wxTheApp->MacSetCurrentEvent( formerEvent , formerHandler ) ;
352 }
353 break ;
354
355 case kEventRawKeyUp :
356 if ( /* focus && */ wxTheApp->MacSendKeyUpEvent(
2f7baaec 357 focus , message , modifiers , when , uniChar[0] ) )
489468fe
SC
358 {
359 result = noErr ;
360 }
361 break ;
362
363 case kEventRawKeyModifiersChanged :
364 {
365 wxKeyEvent event(wxEVT_KEY_DOWN);
366
367 event.m_shiftDown = modifiers & shiftKey;
9a0266bb 368 event.m_rawControlDown = modifiers & controlKey;
489468fe 369 event.m_altDown = modifiers & optionKey;
9a0266bb 370 event.m_controlDown = event.m_metaDown = modifiers & cmdKey;
489468fe
SC
371
372#if wxUSE_UNICODE
373 event.m_uniChar = uniChar[0] ;
374#endif
375
376 event.SetTimestamp(when);
377 event.SetEventObject(focus);
378
379 if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & controlKey )
380 {
9a0266bb 381 event.m_keyCode = WXK_RAW_CONTROL ;
489468fe
SC
382 event.SetEventType( ( modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
383 focus->HandleWindowEvent( event ) ;
384 }
385 if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & shiftKey )
386 {
387 event.m_keyCode = WXK_SHIFT ;
388 event.SetEventType( ( modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
389 focus->HandleWindowEvent( event ) ;
390 }
391 if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & optionKey )
392 {
393 event.m_keyCode = WXK_ALT ;
394 event.SetEventType( ( modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
395 focus->HandleWindowEvent( event ) ;
396 }
397 if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & cmdKey )
398 {
9a0266bb 399 event.m_keyCode = WXK_CONTROL;
489468fe
SC
400 event.SetEventType( ( modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
401 focus->HandleWindowEvent( event ) ;
402 }
403
404 wxApp::s_lastModifiers = modifiers ;
405 }
406 break ;
407
408 default:
409 break;
410 }
411
412 return result ;
413}
414
415// we don't interfere with foreign controls on our toplevel windows, therefore we always give back eventNotHandledErr
416// for windows that we didn't create (like eg Scrollbars in a databrowser), or for controls where we did not handle the
417// mouse down at all
418//
419// This handler can also be called from app level where data (ie target window) may be null or a non wx window
420
489468fe
SC
421EventMouseButton g_lastButton = 0 ;
422bool g_lastButtonWasFakeRight = false ;
423
9a9fa616 424WXDLLEXPORT void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent )
489468fe
SC
425{
426 UInt32 modifiers = cEvent.GetParameter<UInt32>(kEventParamKeyModifiers, typeUInt32) ;
427 Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ;
428
429 // these parameters are not given for all events
430 EventMouseButton button = 0 ;
431 UInt32 clickCount = 0 ;
432 UInt32 mouseChord = 0;
433
434 cEvent.GetParameter<EventMouseButton>( kEventParamMouseButton, typeMouseButton , &button ) ;
435 cEvent.GetParameter<UInt32>( kEventParamClickCount, typeUInt32 , &clickCount ) ;
436 // the chord is the state of the buttons pressed currently
437 cEvent.GetParameter<UInt32>( kEventParamMouseChord, typeUInt32 , &mouseChord ) ;
438
439 wxevent.m_x = screenMouseLocation.h;
440 wxevent.m_y = screenMouseLocation.v;
441 wxevent.m_shiftDown = modifiers & shiftKey;
9a0266bb 442 wxevent.m_rawControlDown = modifiers & controlKey;
489468fe 443 wxevent.m_altDown = modifiers & optionKey;
9a0266bb 444 wxevent.m_controlDown = wxevent.m_metaDown = modifiers & cmdKey;
489468fe
SC
445 wxevent.m_clickCount = clickCount;
446 wxevent.SetTimestamp( cEvent.GetTicks() ) ;
447
448 // a control click is interpreted as a right click
449 bool thisButtonIsFakeRight = false ;
450 if ( button == kEventMouseButtonPrimary && (modifiers & controlKey) )
451 {
452 button = kEventMouseButtonSecondary ;
453 thisButtonIsFakeRight = true ;
454 }
455
456 // otherwise we report double clicks by connecting a left click with a ctrl-left click
457 if ( clickCount > 1 && button != g_lastButton )
458 clickCount = 1 ;
459
460 // we must make sure that our synthetic 'right' button corresponds in
461 // mouse down, moved and mouse up, and does not deliver a right down and left up
462
463 if ( cEvent.GetKind() == kEventMouseDown )
464 {
465 g_lastButton = button ;
466 g_lastButtonWasFakeRight = thisButtonIsFakeRight ;
467 }
468
469 if ( button == 0 )
470 {
471 g_lastButton = 0 ;
472 g_lastButtonWasFakeRight = false ;
473 }
474 else if ( g_lastButton == kEventMouseButtonSecondary && g_lastButtonWasFakeRight )
475 button = g_lastButton ;
476
477 // Adjust the chord mask to remove the primary button and add the
478 // secondary button. It is possible that the secondary button is
479 // already pressed, e.g. on a mouse connected to a laptop, but this
480 // possibility is ignored here:
481 if( thisButtonIsFakeRight && ( mouseChord & 1U ) )
482 mouseChord = ((mouseChord & ~1U) | 2U);
483
484 if(mouseChord & 1U)
485 wxevent.m_leftDown = true ;
486 if(mouseChord & 2U)
487 wxevent.m_rightDown = true ;
488 if(mouseChord & 4U)
489 wxevent.m_middleDown = true ;
490
491 // translate into wx types
492 switch ( cEvent.GetKind() )
493 {
494 case kEventMouseDown :
495 switch ( button )
496 {
497 case kEventMouseButtonPrimary :
498 wxevent.SetEventType( clickCount > 1 ? wxEVT_LEFT_DCLICK : wxEVT_LEFT_DOWN ) ;
499 break ;
500
501 case kEventMouseButtonSecondary :
502 wxevent.SetEventType( clickCount > 1 ? wxEVT_RIGHT_DCLICK : wxEVT_RIGHT_DOWN ) ;
503 break ;
504
505 case kEventMouseButtonTertiary :
506 wxevent.SetEventType( clickCount > 1 ? wxEVT_MIDDLE_DCLICK : wxEVT_MIDDLE_DOWN ) ;
507 break ;
508
509 default:
510 break ;
511 }
512 break ;
513
514 case kEventMouseUp :
515 switch ( button )
516 {
517 case kEventMouseButtonPrimary :
518 wxevent.SetEventType( wxEVT_LEFT_UP ) ;
519 break ;
520
521 case kEventMouseButtonSecondary :
522 wxevent.SetEventType( wxEVT_RIGHT_UP ) ;
523 break ;
524
525 case kEventMouseButtonTertiary :
526 wxevent.SetEventType( wxEVT_MIDDLE_UP ) ;
527 break ;
528
529 default:
530 break ;
531 }
532 break ;
bdb5b32a
SC
533 // TODO http://developer.apple.com/qa/qa2005/qa1453.html
534 // add declaration for 10.4 and change to kEventMouseScroll
535 case kEventMouseWheelMoved :
489468fe
SC
536 {
537 wxevent.SetEventType( wxEVT_MOUSEWHEEL ) ;
538
539 EventMouseWheelAxis axis = cEvent.GetParameter<EventMouseWheelAxis>(kEventParamMouseWheelAxis, typeMouseWheelAxis) ;
540 SInt32 delta = cEvent.GetParameter<SInt32>(kEventParamMouseWheelDelta, typeSInt32) ;
541
542 wxevent.m_wheelRotation = delta;
543 wxevent.m_wheelDelta = 1;
544 wxevent.m_linesPerAction = 1;
545 if ( axis == kEventMouseWheelAxisX )
41469c9e 546 wxevent.m_wheelAxis = wxMOUSE_WHEEL_HORIZONTAL;
489468fe
SC
547 }
548 break ;
549
550 case kEventMouseEntered :
551 case kEventMouseExited :
552 case kEventMouseDragged :
553 case kEventMouseMoved :
554 wxevent.SetEventType( wxEVT_MOTION ) ;
555 break;
556 default :
557 break ;
558 }
559}
560
561#define NEW_CAPTURE_HANDLING 1
562
563pascal OSStatus
564wxMacTopLevelMouseEventHandler(EventHandlerCallRef WXUNUSED(handler),
565 EventRef event,
566 void *data)
567{
b2680ced 568 wxNonOwnedWindow* toplevelWindow = data ? ((wxNonOwnedWindowImpl*) data)->GetWXPeer() : NULL ;
489468fe
SC
569
570 OSStatus result = eventNotHandledErr ;
571
572 wxMacCarbonEvent cEvent( event ) ;
573
574 Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ;
575 Point windowMouseLocation = screenMouseLocation ;
576
577 WindowRef window = NULL;
578 short windowPart = ::FindWindow(screenMouseLocation, &window);
579
580 wxWindow* currentMouseWindow = NULL ;
581 ControlRef control = NULL ;
582
583#if NEW_CAPTURE_HANDLING
584 if ( wxApp::s_captureWindow )
585 {
586 window = (WindowRef) wxApp::s_captureWindow->MacGetTopLevelWindowRef() ;
587 windowPart = inContent ;
588 }
589#endif
590
591 if ( window )
592 {
b2680ced 593 QDGlobalToLocalPoint( GetWindowPort( window ), &windowMouseLocation );
489468fe
SC
594
595 if ( wxApp::s_captureWindow
596#if !NEW_CAPTURE_HANDLING
597 && wxApp::s_captureWindow->MacGetTopLevelWindowRef() == (WXWindow) window && windowPart == inContent
598#endif
599 )
600 {
601 currentMouseWindow = wxApp::s_captureWindow ;
602 }
603 else if ( (IsWindowActive(window) && windowPart == inContent) )
604 {
605 ControlPartCode part ;
606 control = FindControlUnderMouse( windowMouseLocation , window , &part ) ;
607 // if there is no control below the mouse position, send the event to the toplevel window itself
608 if ( control == 0 )
609 {
b2680ced 610 currentMouseWindow = (wxWindow*) toplevelWindow ;
489468fe
SC
611 }
612 else
613 {
b2680ced 614 currentMouseWindow = (wxWindow*) wxFindWindowFromWXWidget( (WXWidget) control ) ;
489468fe
SC
615#ifndef __WXUNIVERSAL__
616 if ( currentMouseWindow == NULL && cEvent.GetKind() == kEventMouseMoved )
617 {
618#if wxUSE_TOOLBAR
619 // for wxToolBar to function we have to send certaint events to it
620 // instead of its children (wxToolBarTools)
621 ControlRef parent ;
622 GetSuperControl(control, &parent );
f742eaaf
RR
623 wxWindow *wxparent = (wxWindow*) wxFindWindowFromWXWidget((WXWidget) parent ) ;
624 if ( wxparent && wxparent->IsKindOf( CLASSINFO( wxToolBar ) ) )
625 currentMouseWindow = wxparent ;
489468fe
SC
626#endif
627 }
628#endif
629 }
630
631 // disabled windows must not get any input messages
632 if ( currentMouseWindow && !currentMouseWindow->MacIsReallyEnabled() )
633 currentMouseWindow = NULL;
634 }
635 }
636
637 wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
638 SetupMouseEvent( wxevent , cEvent ) ;
639
640 // handle all enter / leave events
641
642 if ( currentMouseWindow != g_MacLastWindow )
643 {
644 if ( g_MacLastWindow )
645 {
646 wxMouseEvent eventleave(wxevent);
647 eventleave.SetEventType( wxEVT_LEAVE_WINDOW );
648 g_MacLastWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
649 eventleave.SetEventObject( g_MacLastWindow ) ;
650 wxevent.SetId( g_MacLastWindow->GetId() ) ;
651
652#if wxUSE_TOOLTIPS
653 wxToolTip::RelayEvent( g_MacLastWindow , eventleave);
654#endif
655
656 g_MacLastWindow->HandleWindowEvent(eventleave);
657 }
658
659 if ( currentMouseWindow )
660 {
661 wxMouseEvent evententer(wxevent);
662 evententer.SetEventType( wxEVT_ENTER_WINDOW );
663 currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
664 evententer.SetEventObject( currentMouseWindow ) ;
665 wxevent.SetId( currentMouseWindow->GetId() ) ;
666
667#if wxUSE_TOOLTIPS
668 wxToolTip::RelayEvent( currentMouseWindow , evententer );
669#endif
670
671 currentMouseWindow->HandleWindowEvent(evententer);
672 }
673
674 g_MacLastWindow = currentMouseWindow ;
675 }
676
677 if ( windowPart == inMenuBar )
678 {
679 // special case menu bar, as we are having a low-level runloop we must do it ourselves
680 if ( cEvent.GetKind() == kEventMouseDown )
681 {
682 ::MenuSelect( screenMouseLocation ) ;
683 ::HiliteMenu(0);
684 result = noErr ;
685 }
03647350 686 }
524c47aa
SC
687 else if ( window && windowPart == inProxyIcon )
688 {
689 // special case proxy icon bar, as we are having a low-level runloop we must do it ourselves
690 if ( cEvent.GetKind() == kEventMouseDown )
691 {
692 if ( ::TrackWindowProxyDrag( window, screenMouseLocation ) != errUserWantsToDragWindow )
693 {
694 // TODO Track change of file path and report back
695 result = noErr ;
696 }
697 }
489468fe
SC
698 }
699 else if ( currentMouseWindow )
700 {
701 wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent();
702
703 currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ;
704
705 wxevent.SetEventObject( currentMouseWindow ) ;
706 wxevent.SetId( currentMouseWindow->GetId() ) ;
707
708 // make tooltips current
709
710#if wxUSE_TOOLTIPS
711 if ( wxevent.GetEventType() == wxEVT_MOTION )
712 wxToolTip::RelayEvent( currentMouseWindow , wxevent );
713#endif
714
715 if ( currentMouseWindow->HandleWindowEvent(wxevent) )
716 {
20d88ec6
VZ
717 if ( currentMouseWindowParent &&
718 !currentMouseWindowParent->GetChildren().Member(currentMouseWindow) )
489468fe
SC
719 currentMouseWindow = NULL;
720
721 result = noErr;
722 }
723 else
724 {
725 // if the user code did _not_ handle the event, then perform the
726 // default processing
727 if ( wxevent.GetEventType() == wxEVT_LEFT_DOWN )
728 {
729 // ... that is set focus to this window
730 if (currentMouseWindow->CanAcceptFocus() && wxWindow::FindFocus()!=currentMouseWindow)
731 currentMouseWindow->SetFocus();
732 }
733 }
734
735 if ( cEvent.GetKind() == kEventMouseUp && wxApp::s_captureWindow )
736 {
737 wxApp::s_captureWindow = NULL ;
738 // update cursor ?
739 }
740
741 // update cursor
742
743 wxWindow* cursorTarget = currentMouseWindow ;
744 wxPoint cursorPoint( wxevent.m_x , wxevent.m_y ) ;
03647350 745
489468fe
SC
746 extern wxCursor gGlobalCursor;
747
748 if (!gGlobalCursor.IsOk())
749 {
750 while ( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) )
751 {
752 cursorTarget = cursorTarget->GetParent() ;
753 if ( cursorTarget )
754 cursorPoint += cursorTarget->GetPosition();
755 }
756 }
757
758 }
759 else // currentMouseWindow == NULL
760 {
f742eaaf
RR
761 if (toplevelWindow && !control)
762 {
763 extern wxCursor gGlobalCursor;
764 if (!gGlobalCursor.IsOk())
765 {
766 // update cursor when over toolbar and titlebar etc.
fc1e45d9 767 wxSTANDARD_CURSOR->MacInstall() ;
f742eaaf
RR
768 }
769 }
03647350 770
489468fe
SC
771 // don't mess with controls we don't know about
772 // for some reason returning eventNotHandledErr does not lead to the correct behaviour
773 // so we try sending them the correct control directly
774 if ( cEvent.GetKind() == kEventMouseDown && toplevelWindow && control )
775 {
776 EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
777 Point clickLocation = windowMouseLocation ;
778
779 HIPoint hiPoint ;
780 hiPoint.x = clickLocation.h ;
781 hiPoint.y = clickLocation.v ;
782 HIViewConvertPoint( &hiPoint , (ControlRef) toplevelWindow->GetHandle() , control ) ;
783 clickLocation.h = (int)hiPoint.x ;
784 clickLocation.v = (int)hiPoint.y ;
785
786 HandleControlClick( control , clickLocation , modifiers , (ControlActionUPP ) -1 ) ;
787 result = noErr ;
788 }
789 }
790
791 return result ;
792}
793
794static pascal OSStatus
795wxNonOwnedWindowEventHandler(EventHandlerCallRef WXUNUSED(handler),
796 EventRef event,
797 void *data)
798{
799 OSStatus result = eventNotHandledErr ;
800
801 wxMacCarbonEvent cEvent( event ) ;
802
803 // WindowRef windowRef = cEvent.GetParameter<WindowRef>(kEventParamDirectObject) ;
b2680ced 804 wxNonOwnedWindow* toplevelWindow = data ? ((wxNonOwnedWindowImpl*) data)->GetWXPeer() : NULL;
489468fe
SC
805
806 switch ( GetEventKind( event ) )
807 {
808 case kEventWindowActivated :
809 {
524c47aa 810 toplevelWindow->HandleActivated( cEvent.GetTicks() , true) ;
489468fe
SC
811 // we still sending an eventNotHandledErr in order to allow for default processing
812 }
813 break ;
814
815 case kEventWindowDeactivated :
816 {
524c47aa 817 toplevelWindow->HandleActivated( cEvent.GetTicks() , false) ;
489468fe
SC
818 // we still sending an eventNotHandledErr in order to allow for default processing
819 }
820 break ;
821
822 case kEventWindowShown :
823 toplevelWindow->Refresh() ;
824 result = noErr ;
825 break ;
826
827 case kEventWindowClose :
828 toplevelWindow->Close() ;
829 result = noErr ;
830 break ;
831
832 case kEventWindowBoundsChanged :
833 {
834 UInt32 attributes = cEvent.GetParameter<UInt32>(kEventParamAttributes, typeUInt32) ;
835 Rect newRect = cEvent.GetParameter<Rect>(kEventParamCurrentBounds) ;
836 wxRect r( newRect.left , newRect.top , newRect.right - newRect.left , newRect.bottom - newRect.top ) ;
837 if ( attributes & kWindowBoundsChangeSizeChanged )
838 {
524c47aa 839 toplevelWindow->HandleResized(cEvent.GetTicks() ) ;
489468fe
SC
840 }
841
842 if ( attributes & kWindowBoundsChangeOriginChanged )
843 {
524c47aa 844 toplevelWindow->HandleMoved(cEvent.GetTicks() ) ;
489468fe
SC
845 }
846
847 result = noErr ;
848 }
849 break ;
850
851 case kEventWindowBoundsChanging :
852 {
853 UInt32 attributes = cEvent.GetParameter<UInt32>(kEventParamAttributes,typeUInt32) ;
854 Rect newRect = cEvent.GetParameter<Rect>(kEventParamCurrentBounds) ;
855
856 if ( (attributes & kWindowBoundsChangeSizeChanged) || (attributes & kWindowBoundsChangeOriginChanged) )
857 {
858 // all (Mac) rects are in content area coordinates, all wxRects in structure coordinates
f71d8b3d
SC
859 int left , top , width , height ;
860 // structure width
861 int swidth, sheight;
862
863 toplevelWindow->GetNonOwnedPeer()->GetContentArea(left, top, width, height);
864 toplevelWindow->GetNonOwnedPeer()->GetSize(swidth, sheight);
865 int deltawidth = swidth - width;
866 int deltaheight = sheight - height;
524c47aa 867 wxRect adjustR(
489468fe
SC
868 newRect.left - left,
869 newRect.top - top,
f71d8b3d
SC
870 newRect.right - newRect.left + deltawidth,
871 newRect.bottom - newRect.top + deltaheight ) ;
489468fe 872
524c47aa 873 toplevelWindow->HandleResizing( cEvent.GetTicks(), &adjustR );
03647350
VZ
874
875 const Rect adjustedRect = { adjustR.y + top , adjustR.x + left , adjustR.y + top + adjustR.height - deltaheight ,
f71d8b3d 876 adjustR.x + left + adjustR.width - deltawidth } ;
489468fe
SC
877 if ( !EqualRect( &newRect , &adjustedRect ) )
878 cEvent.SetParameter<Rect>( kEventParamCurrentBounds , &adjustedRect ) ;
489468fe
SC
879 }
880
881 result = noErr ;
882 }
883 break ;
884
885 case kEventWindowGetRegion :
886 {
887 if ( toplevelWindow->GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
888 {
889 WindowRegionCode windowRegionCode ;
890
891 // Fetch the region code that is being queried
892 GetEventParameter( event,
893 kEventParamWindowRegionCode,
894 typeWindowRegionCode, NULL,
895 sizeof windowRegionCode, NULL,
896 &windowRegionCode ) ;
897
898 // If it is the opaque region code then set the
899 // region to empty and return noErr to stop event
900 // propagation
901 if ( windowRegionCode == kWindowOpaqueRgn ) {
902 RgnHandle region;
903 GetEventParameter( event,
904 kEventParamRgnHandle,
905 typeQDRgnHandle, NULL,
906 sizeof region, NULL,
907 &region) ;
908 SetEmptyRgn(region) ;
909 result = noErr ;
910 }
911 }
912 }
913 break ;
914
915 default :
916 break ;
917 }
918
919 return result ;
920}
921
922// mix this in from window.cpp
923pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ;
924
52cda80e 925static pascal OSStatus wxNonOwnedEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
489468fe
SC
926{
927 OSStatus result = eventNotHandledErr ;
928
929 switch ( GetEventClass( event ) )
930 {
931 case kEventClassTextInput :
524c47aa
SC
932 {
933 // TODO remove as soon as all events are on implementation classes only
934 wxNonOwnedWindow* toplevelWindow = data ? ((wxNonOwnedWindowImpl*) data)->GetWXPeer() : NULL;
935
936 result = wxMacUnicodeTextEventHandler( handler, event , toplevelWindow ) ;
937 }
489468fe
SC
938 break ;
939
940 case kEventClassKeyboard :
941 result = KeyboardEventHandler( handler, event , data ) ;
942 break ;
943
944 case kEventClassWindow :
945 result = wxNonOwnedWindowEventHandler( handler, event , data ) ;
946 break ;
947
948 case kEventClassMouse :
949 result = wxMacTopLevelMouseEventHandler( handler, event , data ) ;
950 break ;
951
952 default :
953 break ;
954 }
955
956 return result ;
957}
958
959DEFINE_ONE_SHOT_HANDLER_GETTER( wxNonOwnedEventHandler )
960
961// ---------------------------------------------------------------------------
b2680ced
SC
962// Support functions for shaped windows, based on Apple's CustomWindow sample at
963// http://developer.apple.com/samplecode/Sample_Code/Human_Interface_Toolbox/Mac_OS_High_Level_Toolbox/CustomWindow.htm
489468fe
SC
964// ---------------------------------------------------------------------------
965
b2680ced
SC
966static void wxShapedMacWindowGetPos(WindowRef window, Rect* inRect)
967{
968 GetWindowPortBounds(window, inRect);
969 Point pt = { inRect->top ,inRect->left };
970 QDLocalToGlobalPoint( GetWindowPort( window ), &pt );
971 inRect->bottom += pt.v - inRect->top;
972 inRect->right += pt.h - inRect->left;
973 inRect->top = pt.v;
974 inRect->left = pt.h;
975}
489468fe 976
b2680ced
SC
977static SInt32 wxShapedMacWindowGetFeatures(WindowRef WXUNUSED(window), SInt32 param)
978{
979 /*------------------------------------------------------
980 Define which options your custom window supports.
981 --------------------------------------------------------*/
982 //just enable everything for our demo
983 *(OptionBits*)param =
984 //kWindowCanGrow |
985 //kWindowCanZoom |
986 kWindowCanCollapse |
987 //kWindowCanGetWindowRegion |
988 //kWindowHasTitleBar |
989 //kWindowSupportsDragHilite |
990 kWindowCanDrawInCurrentPort |
991 //kWindowCanMeasureTitle |
992 kWindowWantsDisposeAtProcessDeath |
993 kWindowSupportsGetGrowImageRegion |
994 kWindowDefSupportsColorGrafPort;
489468fe 995
b2680ced
SC
996 return 1;
997}
489468fe 998
b2680ced
SC
999// The content region is left as a rectangle matching the window size, this is
1000// so the origin in the paint event, and etc. still matches what the
1001// programmer expects.
1002static void wxShapedMacWindowContentRegion(WindowRef window, RgnHandle rgn)
489468fe 1003{
b2680ced
SC
1004 SetEmptyRgn(rgn);
1005 wxNonOwnedWindow* win = wxNonOwnedWindow::GetFromWXWindow((WXWindow)window);
1006 if (win)
1007 {
1008 Rect r ;
1009 wxShapedMacWindowGetPos( window, &r ) ;
1010 RectRgn( rgn , &r ) ;
1011 }
489468fe
SC
1012}
1013
b2680ced
SC
1014// The structure region is set to the shape given to the SetShape method.
1015static void wxShapedMacWindowStructureRegion(WindowRef window, RgnHandle rgn)
489468fe 1016{
b2680ced 1017 RgnHandle cachedRegion = (RgnHandle) GetWRefCon(window);
489468fe 1018
b2680ced
SC
1019 SetEmptyRgn(rgn);
1020 if (cachedRegion)
1021 {
1022 Rect windowRect;
1023 wxShapedMacWindowGetPos(window, &windowRect); // how big is the window
1024 CopyRgn(cachedRegion, rgn); // make a copy of our cached region
1025 OffsetRgn(rgn, windowRect.left, windowRect.top); // position it over window
1026 //MapRgn(rgn, &mMaskSize, &windowRect); //scale it to our actual window size
1027 }
489468fe
SC
1028}
1029
b2680ced 1030static SInt32 wxShapedMacWindowGetRegion(WindowRef window, SInt32 param)
489468fe 1031{
b2680ced
SC
1032 GetWindowRegionPtr rgnRec = (GetWindowRegionPtr)param;
1033
1034 if (rgnRec == NULL)
1035 return paramErr;
1036
1037 switch (rgnRec->regionCode)
489468fe 1038 {
b2680ced
SC
1039 case kWindowStructureRgn:
1040 wxShapedMacWindowStructureRegion(window, rgnRec->winRgn);
489468fe 1041 break;
489468fe 1042
b2680ced
SC
1043 case kWindowContentRgn:
1044 wxShapedMacWindowContentRegion(window, rgnRec->winRgn);
1045 break;
489468fe 1046
b2680ced
SC
1047 default:
1048 SetEmptyRgn(rgnRec->winRgn);
1049 break;
1050 }
489468fe 1051
b2680ced 1052 return noErr;
489468fe
SC
1053}
1054
b2680ced
SC
1055// Determine the region of the window which was hit
1056//
1057static SInt32 wxShapedMacWindowHitTest(WindowRef window, SInt32 param)
489468fe 1058{
b2680ced
SC
1059 Point hitPoint;
1060 static RgnHandle tempRgn = NULL;
489468fe 1061
b2680ced
SC
1062 if (tempRgn == NULL)
1063 tempRgn = NewRgn();
1064
1065 // get the point clicked
1066 SetPt( &hitPoint, LoWord(param), HiWord(param) );
1067
1068 // Mac OS 8.5 or later
1069 wxShapedMacWindowStructureRegion(window, tempRgn);
1070 if (PtInRgn( hitPoint, tempRgn )) //in window content region?
1071 return wInContent;
1072
1073 // no significant area was hit
1074 return wNoHit;
489468fe
SC
1075}
1076
b2680ced 1077static pascal long wxShapedMacWindowDef(short WXUNUSED(varCode), WindowRef window, SInt16 message, SInt32 param)
489468fe 1078{
b2680ced
SC
1079 switch (message)
1080 {
1081 case kWindowMsgHitTest:
1082 return wxShapedMacWindowHitTest(window, param);
489468fe 1083
b2680ced
SC
1084 case kWindowMsgGetFeatures:
1085 return wxShapedMacWindowGetFeatures(window, param);
489468fe 1086
b2680ced
SC
1087 // kWindowMsgGetRegion is sent during CreateCustomWindow and ReshapeCustomWindow
1088 case kWindowMsgGetRegion:
1089 return wxShapedMacWindowGetRegion(window, param);
489468fe 1090
b2680ced
SC
1091 default:
1092 break;
1093 }
489468fe 1094
b2680ced
SC
1095 return 0;
1096}
489468fe 1097
b2680ced 1098// implementation
489468fe 1099
b2680ced
SC
1100typedef struct
1101{
1102 wxPoint m_position ;
1103 wxSize m_size ;
1104 bool m_wasResizable ;
1105} FullScreenData ;
489468fe 1106
b2680ced
SC
1107wxNonOwnedWindowCarbonImpl::wxNonOwnedWindowCarbonImpl()
1108{
1109}
489468fe 1110
b2680ced
SC
1111wxNonOwnedWindowCarbonImpl::wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow* nonownedwnd) : wxNonOwnedWindowImpl( nonownedwnd)
1112{
1113 m_macEventHandler = NULL;
1114 m_macWindow = NULL;
1115 m_macFullScreenData = NULL ;
489468fe
SC
1116}
1117
b2680ced 1118wxNonOwnedWindowCarbonImpl::~wxNonOwnedWindowCarbonImpl()
489468fe 1119{
489468fe
SC
1120#if wxUSE_TOOLTIPS
1121 wxToolTip::NotifyWindowDelete(m_macWindow) ;
1122#endif
489468fe
SC
1123
1124 if ( m_macEventHandler )
1125 {
1126 ::RemoveEventHandler((EventHandlerRef) m_macEventHandler);
1127 m_macEventHandler = NULL ;
1128 }
1129
17e2694c 1130 if ( m_macWindow && !m_wxPeer->IsNativeWindowWrapper())
b2680ced 1131 DisposeWindow( m_macWindow );
489468fe 1132
b2680ced
SC
1133 FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
1134 delete data ;
1135 m_macFullScreenData = NULL ;
1136
1137 m_macWindow = NULL;
1138
1139}
1140
0aaa6ace 1141void wxNonOwnedWindowCarbonImpl::WillBeDestroyed()
03647350 1142{
524c47aa
SC
1143 if ( m_macEventHandler )
1144 {
1145 ::RemoveEventHandler((EventHandlerRef) m_macEventHandler);
1146 m_macEventHandler = NULL ;
1147 }
b2680ced 1148}
489468fe 1149
52cda80e 1150static void wxNonOwnedWindowInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
489468fe
SC
1151{
1152 InstallWindowEventHandler(window, GetwxNonOwnedEventHandlerUPP(),
1153 GetEventTypeCount(eventList), eventList, ref, handler );
1154}
1155
b2680ced
SC
1156bool wxNonOwnedWindowCarbonImpl::SetShape(const wxRegion& region)
1157{
1158 // Make a copy of the region
1159 RgnHandle shapeRegion = NewRgn();
1160 HIShapeGetAsQDRgn( region.GetWXHRGN(), shapeRegion );
1161
1162 // Dispose of any shape region we may already have
1163 RgnHandle oldRgn = (RgnHandle)GetWRefCon( (WindowRef) m_wxPeer->GetWXWindow() );
1164 if ( oldRgn )
1165 DisposeRgn(oldRgn);
1166
1167 // Save the region so we can use it later
1168 SetWRefCon((WindowRef) m_wxPeer->GetWXWindow(), (URefCon)shapeRegion);
1169
1170 // inform the window manager that the window has changed shape
1171 ReshapeCustomWindow((WindowRef) m_wxPeer->GetWXWindow());
1172
1173 return true;
1174}
1175
1176
1177void wxNonOwnedWindowCarbonImpl::MacInstallTopLevelWindowEventHandler()
489468fe
SC
1178{
1179 if ( m_macEventHandler != NULL )
1180 {
1181 verify_noerr( ::RemoveEventHandler( (EventHandlerRef) m_macEventHandler ) ) ;
1182 }
1183 wxNonOwnedWindowInstallTopLevelWindowEventHandler(MAC_WXHWND(m_macWindow),(EventHandlerRef *)&m_macEventHandler,this);
1184}
1185
b2680ced 1186void wxNonOwnedWindowCarbonImpl::Create(
ea85e5e0 1187 wxWindow* WXUNUSED(parent),
17e2694c 1188 WXWindow nativeWindow )
489468fe 1189{
17e2694c
SC
1190 m_macWindow = nativeWindow;
1191}
b2680ced 1192
17e2694c
SC
1193void wxNonOwnedWindowCarbonImpl::Create(
1194 wxWindow* parent,
1195 const wxPoint& pos,
1196 const wxSize& size,
1197 long style, long extraStyle,
1198 const wxString& WXUNUSED(name) )
1199{
ea85e5e0 1200
489468fe 1201 OSStatus err = noErr ;
b2680ced 1202 Rect theBoundsRect;
ea85e5e0 1203
489468fe
SC
1204 int x = (int)pos.x;
1205 int y = (int)pos.y;
ea85e5e0 1206
b2680ced
SC
1207 int w = size.x;
1208 int h = size.y;
ea85e5e0 1209
489468fe 1210 ::SetRect(&theBoundsRect, x, y , x + w, y + h);
ea85e5e0 1211
489468fe
SC
1212 // translate the window attributes in the appropriate window class and attributes
1213 WindowClass wclass = 0;
1214 WindowAttributes attr = kWindowNoAttributes ;
1215 WindowGroupRef group = NULL ;
1216 bool activationScopeSet = false;
1217 WindowActivationScope activationScope = kWindowActivationScopeNone;
ea85e5e0 1218
b2680ced 1219 if ( style & wxFRAME_TOOL_WINDOW )
489468fe
SC
1220 {
1221 if (
b2680ced
SC
1222 ( style & wxMINIMIZE_BOX ) || ( style & wxMAXIMIZE_BOX ) ||
1223 ( style & wxSYSTEM_MENU ) || ( style & wxCAPTION ) ||
7282b067 1224 ( style & wxTINY_CAPTION)
489468fe
SC
1225 )
1226 {
b2680ced 1227 if ( ( style & wxSTAY_ON_TOP ) )
489468fe
SC
1228 wclass = kUtilityWindowClass;
1229 else
1230 wclass = kFloatingWindowClass ;
ea85e5e0 1231
7282b067 1232 if ( ( style & wxTINY_CAPTION) )
489468fe
SC
1233 attr |= kWindowSideTitlebarAttribute ;
1234 }
1235 else
1236 {
8f3864f7 1237 if ( style & wxNO_BORDER )
b12a7313
KO
1238 {
1239 wclass = kSimpleWindowClass ;
1240 }
1241 else
1242 {
1243 wclass = kPlainWindowClass ;
1244 }
489468fe
SC
1245 activationScopeSet = true;
1246 activationScope = kWindowActivationScopeNone;
1247 }
1248 }
b2680ced 1249 else if ( ( style & wxPOPUP_WINDOW ) )
489468fe 1250 {
b2680ced 1251 if ( ( style & wxBORDER_NONE ) )
489468fe
SC
1252 {
1253 wclass = kHelpWindowClass ; // has no border
1254 attr |= kWindowNoShadowAttribute;
1255 }
1256 else
1257 {
1258 wclass = kPlainWindowClass ; // has a single line border, it will have to do for now
1259 }
1260 group = GetWindowGroupOfClass(kFloatingWindowClass) ;
1261 // make sure we don't deactivate something
1262 activationScopeSet = true;
1263 activationScope = kWindowActivationScopeNone;
1264 }
b2680ced 1265 else if ( ( style & wxCAPTION ) )
489468fe
SC
1266 {
1267 wclass = kDocumentWindowClass ;
1268 attr |= kWindowInWindowMenuAttribute ;
1269 }
b2680ced 1270 else if ( ( style & wxFRAME_DRAWER ) )
489468fe
SC
1271 {
1272 wclass = kDrawerWindowClass;
1273 }
1274 else
1275 {
b2680ced
SC
1276 if ( ( style & wxMINIMIZE_BOX ) || ( style & wxMAXIMIZE_BOX ) ||
1277 ( style & wxCLOSE_BOX ) || ( style & wxSYSTEM_MENU ) )
489468fe
SC
1278 {
1279 wclass = kDocumentWindowClass ;
1280 }
b2680ced 1281 else if ( ( style & wxNO_BORDER ) )
489468fe
SC
1282 {
1283 wclass = kSimpleWindowClass ;
1284 }
1285 else
1286 {
1287 wclass = kPlainWindowClass ;
1288 }
1289 }
ea85e5e0 1290
489468fe
SC
1291 if ( wclass != kPlainWindowClass )
1292 {
b2680ced 1293 if ( ( style & wxMINIMIZE_BOX ) )
489468fe 1294 attr |= kWindowCollapseBoxAttribute ;
ea85e5e0 1295
b2680ced 1296 if ( ( style & wxMAXIMIZE_BOX ) )
489468fe 1297 attr |= kWindowFullZoomAttribute ;
ea85e5e0 1298
b2680ced 1299 if ( ( style & wxRESIZE_BORDER ) )
489468fe 1300 attr |= kWindowResizableAttribute ;
ea85e5e0 1301
b2680ced 1302 if ( ( style & wxCLOSE_BOX) )
489468fe
SC
1303 attr |= kWindowCloseBoxAttribute ;
1304 }
1305 attr |= kWindowLiveResizeAttribute;
ea85e5e0 1306
b2680ced 1307 if ( ( style &wxSTAY_ON_TOP) )
489468fe 1308 group = GetWindowGroupOfClass(kUtilityWindowClass) ;
ea85e5e0 1309
b2680ced 1310 if ( ( style & wxFRAME_FLOAT_ON_PARENT ) )
489468fe 1311 group = GetWindowGroupOfClass(kFloatingWindowClass) ;
ea85e5e0 1312
489468fe
SC
1313 if ( group == NULL && parent != NULL )
1314 {
1315 WindowRef parenttlw = (WindowRef) parent->MacGetTopLevelWindowRef();
1316 if( parenttlw )
1317 group = GetWindowGroupParent( GetWindowGroup( parenttlw ) );
1318 }
ea85e5e0 1319
489468fe 1320 attr |= kWindowCompositingAttribute;
292e5e1f 1321#if 0 // TODO : decide on overall handling of high dpi screens (pixel vs userscale)
489468fe
SC
1322 attr |= kWindowFrameworkScaledAttribute;
1323#endif
ea85e5e0 1324
b2680ced 1325 if ( ( style &wxFRAME_SHAPED) )
489468fe
SC
1326 {
1327 WindowDefSpec customWindowDefSpec;
1328 customWindowDefSpec.defType = kWindowDefProcPtr;
1329 customWindowDefSpec.u.defProc =
1330#ifdef __LP64__
17e2694c 1331 (WindowDefUPP) wxShapedMacWindowDef;
489468fe 1332#else
17e2694c 1333 NewWindowDefUPP(wxShapedMacWindowDef);
489468fe
SC
1334#endif
1335 err = ::CreateCustomWindow( &customWindowDefSpec, wclass,
17e2694c
SC
1336 attr, &theBoundsRect,
1337 (WindowRef*) &m_macWindow);
489468fe
SC
1338 }
1339 else
1340 {
1341 err = ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ;
1342 }
ea85e5e0 1343
489468fe
SC
1344 if ( err == noErr && m_macWindow != NULL && group != NULL )
1345 SetWindowGroup( (WindowRef) m_macWindow , group ) ;
ea85e5e0 1346
489468fe 1347 wxCHECK_RET( err == noErr, wxT("Mac OS error when trying to create new window") );
ea85e5e0 1348
489468fe 1349 // setup a separate group for each window, so that overlays can be handled easily
ea85e5e0 1350
489468fe
SC
1351 WindowGroupRef overlaygroup = NULL;
1352 verify_noerr( CreateWindowGroup( kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrHideOnCollapse, &overlaygroup ));
1353 verify_noerr( SetWindowGroupParent( overlaygroup, GetWindowGroup( (WindowRef) m_macWindow )));
1354 verify_noerr( SetWindowGroup( (WindowRef) m_macWindow , overlaygroup ));
ea85e5e0 1355
489468fe
SC
1356 if ( activationScopeSet )
1357 {
1358 verify_noerr( SetWindowActivationScope( (WindowRef) m_macWindow , activationScope ));
1359 }
ea85e5e0 1360
489468fe
SC
1361 // the create commands are only for content rect,
1362 // so we have to set the size again as structure bounds
b2680ced 1363 SetWindowBounds( m_macWindow , kWindowStructureRgn , &theBoundsRect ) ;
ea85e5e0 1364
489468fe
SC
1365 // Causes the inner part of the window not to be metal
1366 // if the style is used before window creation.
1367#if 0 // TARGET_API_MAC_OSX
1368 if ( m_macUsesCompositing && m_macWindow != NULL )
1369 {
1370 if ( GetExtraStyle() & wxFRAME_EX_METAL )
1371 MacSetMetalAppearance( true ) ;
1372 }
1373#endif
ea85e5e0 1374
489468fe
SC
1375 if ( m_macWindow != NULL )
1376 {
1377 MacSetUnifiedAppearance( true ) ;
1378 }
ea85e5e0 1379
489468fe 1380 HIViewRef growBoxRef = 0 ;
b2680ced 1381 err = HIViewFindByID( HIViewGetRoot( m_macWindow ), kHIViewWindowGrowBoxID, &growBoxRef );
489468fe
SC
1382 if ( err == noErr && growBoxRef != 0 )
1383 HIGrowBoxViewSetTransparent( growBoxRef, true ) ;
ea85e5e0 1384
489468fe 1385 // the frame window event handler
b2680ced 1386 InstallStandardEventHandler( GetWindowEventTarget(m_macWindow) ) ;
489468fe 1387 MacInstallTopLevelWindowEventHandler() ;
ea85e5e0 1388
b2680ced
SC
1389 if ( extraStyle & wxFRAME_EX_METAL)
1390 MacSetMetalAppearance(true);
ea85e5e0 1391
b2680ced 1392 if ( ( style &wxFRAME_SHAPED) )
489468fe
SC
1393 {
1394 // default shape matches the window size
1395 wxRegion rgn( 0, 0, w, h );
1396 SetShape( rgn );
1397 }
489468fe
SC
1398}
1399
b2680ced 1400bool wxNonOwnedWindowCarbonImpl::ShowWithEffect(bool show,
489468fe
SC
1401 wxShowEffect effect,
1402 unsigned timeout)
1403{
489468fe
SC
1404 WindowTransitionEffect transition = 0 ;
1405 switch( effect )
1406 {
1407 case wxSHOW_EFFECT_ROLL_TO_LEFT:
1408 case wxSHOW_EFFECT_ROLL_TO_RIGHT:
1409 case wxSHOW_EFFECT_ROLL_TO_TOP:
1410 case wxSHOW_EFFECT_ROLL_TO_BOTTOM:
1411 case wxSHOW_EFFECT_SLIDE_TO_LEFT:
1412 case wxSHOW_EFFECT_SLIDE_TO_RIGHT:
1413 case wxSHOW_EFFECT_SLIDE_TO_TOP:
1414 case wxSHOW_EFFECT_SLIDE_TO_BOTTOM:
1415 transition = kWindowGenieTransitionEffect;
1416 break;
1417 case wxSHOW_EFFECT_BLEND:
1418 transition = kWindowFadeTransitionEffect;
1419 break;
1420 case wxSHOW_EFFECT_EXPAND:
1421 // having sheets would be fine, but this might lead to a repositioning
1422#if 0
1423 if ( GetParent() )
1424 transition = kWindowSheetTransitionEffect;
1425 else
1426#endif
1427 transition = kWindowZoomTransitionEffect;
1428 break;
1429
b43914a8
VZ
1430 case wxSHOW_EFFECT_NONE:
1431 // wxNonOwnedWindow is supposed to call Show() itself in this case
1432 wxFAIL_MSG( "ShowWithEffect() shouldn't be called" );
1433 return false;
1434
489468fe
SC
1435 case wxSHOW_EFFECT_MAX:
1436 wxFAIL_MSG( "invalid effect flag" );
1437 return false;
1438 }
1439
1440 TransitionWindowOptions options;
1441 options.version = 0;
1442 options.duration = timeout / 1000.0;
b2680ced 1443 options.window = transition == kWindowSheetTransitionEffect ? (WindowRef) m_wxPeer->GetParent()->MacGetTopLevelWindowRef() :0;
489468fe
SC
1444 options.userData = 0;
1445
1446 wxSize size = wxGetDisplaySize();
b2680ced
SC
1447 Rect bounds;
1448 GetWindowBounds( (WindowRef)m_macWindow, kWindowStructureRgn, &bounds );
1449 CGRect hiBounds = CGRectMake( bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top );
489468fe 1450
b2680ced
SC
1451 switch ( effect )
1452 {
1453 case wxSHOW_EFFECT_ROLL_TO_RIGHT:
1454 case wxSHOW_EFFECT_SLIDE_TO_RIGHT:
1455 hiBounds.origin.x = 0;
1456 hiBounds.size.width = 0;
1457 break;
489468fe 1458
b2680ced
SC
1459 case wxSHOW_EFFECT_ROLL_TO_LEFT:
1460 case wxSHOW_EFFECT_SLIDE_TO_LEFT:
1461 hiBounds.origin.x = size.x;
1462 hiBounds.size.width = 0;
1463 break;
489468fe 1464
b2680ced
SC
1465 case wxSHOW_EFFECT_ROLL_TO_TOP:
1466 case wxSHOW_EFFECT_SLIDE_TO_TOP:
1467 hiBounds.origin.y = size.y;
1468 hiBounds.size.height = 0;
1469 break;
489468fe 1470
b2680ced
SC
1471 case wxSHOW_EFFECT_ROLL_TO_BOTTOM:
1472 case wxSHOW_EFFECT_SLIDE_TO_BOTTOM:
1473 hiBounds.origin.y = 0;
1474 hiBounds.size.height = 0;
1475 break;
489468fe 1476
b2680ced
SC
1477 default:
1478 break; // direction doesn't make sense
1479 }
489468fe 1480
b2680ced
SC
1481 ::TransitionWindowWithOptions
1482 (
1483 (WindowRef)m_macWindow,
1484 transition,
1485 show ? kWindowShowTransitionAction : kWindowHideTransitionAction,
1486 transition == kWindowGenieTransitionEffect ? &hiBounds : NULL,
1487 false,
1488 &options
1489 );
489468fe 1490
b2680ced
SC
1491 if ( show )
1492 {
1493 ::SelectWindow( (WindowRef)m_macWindow ) ;
1494 }
489468fe 1495
b2680ced 1496 return true;
489468fe
SC
1497}
1498
03647350 1499void wxNonOwnedWindowCarbonImpl::SetTitle( const wxString& title, wxFontEncoding encoding )
489468fe 1500{
b2680ced 1501 SetWindowTitleWithCFString( m_macWindow , wxCFStringRef( title , encoding ) ) ;
489468fe 1502}
03647350 1503
b2680ced 1504bool wxNonOwnedWindowCarbonImpl::IsMaximized() const
489468fe 1505{
b2680ced 1506 return IsWindowInStandardState( m_macWindow , NULL , NULL ) ;
489468fe 1507}
03647350 1508
b2680ced 1509bool wxNonOwnedWindowCarbonImpl::IsIconized() const
489468fe 1510{
b2680ced 1511 return IsWindowCollapsed((WindowRef)GetWXWindow() ) ;
489468fe 1512}
03647350 1513
b2680ced 1514void wxNonOwnedWindowCarbonImpl::Iconize( bool iconize )
489468fe 1515{
b2680ced
SC
1516 if ( IsWindowCollapsable( m_macWindow ) )
1517 CollapseWindow( m_macWindow , iconize ) ;
489468fe 1518}
03647350 1519
b2680ced 1520void wxNonOwnedWindowCarbonImpl::Maximize(bool maximize)
489468fe 1521{
b2680ced
SC
1522 Point idealSize = { 0 , 0 } ;
1523 if ( maximize )
1524 {
1525#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
1526 HIRect bounds ;
1527 HIWindowGetAvailablePositioningBounds(kCGNullDirectDisplay,kHICoordSpace72DPIGlobal,
1528 &bounds);
1529 idealSize.h = bounds.size.width;
1530 idealSize.v = bounds.size.height;
1531#else
1532 Rect rect ;
1533 GetAvailableWindowPositioningBounds(GetMainDevice(),&rect) ;
1534 idealSize.h = rect.right - rect.left ;
1535 idealSize.v = rect.bottom - rect.top ;
1536#endif
1537 }
1538 ZoomWindowIdeal( (WindowRef)GetWXWindow() , maximize ? inZoomOut : inZoomIn , &idealSize ) ;
489468fe 1539}
03647350 1540
b2680ced 1541bool wxNonOwnedWindowCarbonImpl::IsFullScreen() const
489468fe 1542{
b2680ced 1543 return m_macFullScreenData != NULL ;
489468fe 1544}
03647350 1545
b2680ced 1546bool wxNonOwnedWindowCarbonImpl::ShowFullScreen(bool show, long style)
489468fe 1547{
b2680ced 1548 if ( show )
489468fe 1549 {
b2680ced
SC
1550 FullScreenData *data = (FullScreenData *)m_macFullScreenData ;
1551 delete data ;
1552 data = new FullScreenData() ;
1553
1554 m_macFullScreenData = data ;
1555 data->m_position = m_wxPeer->GetPosition() ;
1556 data->m_size = m_wxPeer->GetSize() ;
1557#if wxOSX_USE_CARBON
1558 WindowAttributes attr = 0;
1559 GetWindowAttributes((WindowRef) GetWXWindow(), &attr);
1560 data->m_wasResizable = attr & kWindowResizableAttribute;
1561 if ( style & wxFULLSCREEN_NOMENUBAR )
1562 HideMenuBar() ;
1563#endif
489468fe 1564
b2680ced 1565 wxRect client = wxGetClientDisplayRect() ;
489468fe 1566
b4afc5ec 1567 int left, top, width, height ;
b2680ced 1568 int x, y, w, h ;
489468fe 1569
b2680ced
SC
1570 x = client.x ;
1571 y = client.y ;
1572 w = client.width ;
1573 h = client.height ;
489468fe 1574
b4afc5ec
SC
1575 GetContentArea( left, top, width, height ) ;
1576 int outerwidth, outerheight;
1577 GetSize( outerwidth, outerheight );
489468fe 1578
b2680ced
SC
1579 if ( style & wxFULLSCREEN_NOCAPTION )
1580 {
1581 y -= top ;
1582 h += top ;
b4afc5ec 1583 // avoid adding the caption twice to the height
03647350 1584 outerheight -= top;
b2680ced 1585 }
489468fe 1586
b2680ced
SC
1587 if ( style & wxFULLSCREEN_NOBORDER )
1588 {
1589 x -= left ;
b4afc5ec
SC
1590 w += outerwidth - width;
1591 h += outerheight - height;
b2680ced 1592 }
489468fe 1593
b2680ced
SC
1594 if ( style & wxFULLSCREEN_NOTOOLBAR )
1595 {
1596 // TODO
1597 }
489468fe 1598
b2680ced
SC
1599 if ( style & wxFULLSCREEN_NOSTATUSBAR )
1600 {
1601 // TODO
1602 }
489468fe 1603
b2680ced
SC
1604 m_wxPeer->SetSize( x , y , w, h ) ;
1605 if ( data->m_wasResizable )
1606 {
1607#if wxOSX_USE_CARBON
1608 ChangeWindowAttributes( (WindowRef) GetWXWindow() , kWindowNoAttributes , kWindowResizableAttribute ) ;
1609#endif
1610 }
1611 }
1612 else if ( m_macFullScreenData != NULL )
489468fe 1613 {
b2680ced
SC
1614 FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
1615#if wxOSX_USE_CARBON
1616 ShowMenuBar() ;
1617 if ( data->m_wasResizable )
1618 ChangeWindowAttributes( (WindowRef) GetWXWindow() , kWindowResizableAttribute , kWindowNoAttributes ) ;
1619#endif
1620 m_wxPeer->SetPosition( data->m_position ) ;
1621 m_wxPeer->SetSize( data->m_size ) ;
1622
1623 delete data ;
1624 m_macFullScreenData = NULL ;
489468fe 1625 }
b2680ced
SC
1626
1627 return true;
489468fe
SC
1628}
1629
b2680ced
SC
1630// Attracts the users attention to this window if the application is
1631// inactive (should be called when a background event occurs)
489468fe 1632
b2680ced
SC
1633static pascal void wxMacNMResponse( NMRecPtr ptr )
1634{
1635 NMRemove( ptr ) ;
1636 DisposePtr( (Ptr)ptr ) ;
489468fe
SC
1637}
1638
b2680ced 1639void wxNonOwnedWindowCarbonImpl::RequestUserAttention(int WXUNUSED(flags))
489468fe 1640{
b2680ced 1641 NMRecPtr notificationRequest = (NMRecPtr) NewPtr( sizeof( NMRec) ) ;
489468fe 1642
b2680ced
SC
1643 memset( notificationRequest , 0 , sizeof(*notificationRequest) ) ;
1644 notificationRequest->qType = nmType ;
1645 notificationRequest->nmMark = 1 ;
1646 notificationRequest->nmIcon = 0 ;
1647 notificationRequest->nmSound = 0 ;
1648 notificationRequest->nmStr = NULL ;
1649 notificationRequest->nmResp = wxMacNMResponse ;
489468fe 1650
b2680ced 1651 verify_noerr( NMInstall( notificationRequest ) ) ;
489468fe
SC
1652}
1653
b2680ced 1654void wxNonOwnedWindowCarbonImpl::ScreenToWindow( int *x, int *y )
489468fe 1655{
b2680ced
SC
1656 HIPoint p = CGPointMake( (x ? *x : 0), (y ? *y : 0) );
1657 HIViewRef contentView ;
1658 // TODO check toolbar offset
1659 HIViewFindByID( HIViewGetRoot( m_macWindow ), kHIViewWindowContentID , &contentView) ;
1660 HIPointConvert( &p, kHICoordSpace72DPIGlobal, NULL, kHICoordSpaceView, contentView );
1661 if ( x )
8f2a8de6 1662 *x = (int)p.x;
b2680ced 1663 if ( y )
8f2a8de6 1664 *y = (int)p.y;
489468fe
SC
1665}
1666
b2680ced 1667void wxNonOwnedWindowCarbonImpl::WindowToScreen( int *x, int *y )
489468fe 1668{
b2680ced
SC
1669 HIPoint p = CGPointMake( (x ? *x : 0), (y ? *y : 0) );
1670 HIViewRef contentView ;
1671 // TODO check toolbar offset
1672 HIViewFindByID( HIViewGetRoot( m_macWindow ), kHIViewWindowContentID , &contentView) ;
1673 HIPointConvert( &p, kHICoordSpaceView, contentView, kHICoordSpace72DPIGlobal, NULL );
1674 if ( x )
8f2a8de6 1675 *x = (int)p.x;
b2680ced 1676 if ( y )
8f2a8de6 1677 *y = (int)p.y;
489468fe 1678}
524c47aa 1679
dbc7ceb9
KO
1680bool wxNonOwnedWindowCarbonImpl::IsActive()
1681{
1682 return ActiveNonFloatingWindow() == m_macWindow;
1683}
1684
524c47aa
SC
1685wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
1686 long style, long extraStyle, const wxString& name )
1687{
1688 wxNonOwnedWindowImpl* now = new wxNonOwnedWindowCarbonImpl( wxpeer );
1689 now->Create( parent, pos, size, style , extraStyle, name );
1690 return now;
1691}
17e2694c
SC
1692
1693wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow nativeWindow )
1694{
1695 wxNonOwnedWindowCarbonImpl* now = new wxNonOwnedWindowCarbonImpl( wxpeer );
1696 now->Create( parent, nativeWindow );
1697 return now;
1698}
1699