]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/nonownedwnd.cpp
notify the event loop that synthesized events are on the queue, wait for them to...
[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;
5833988c 545 wxevent.m_columnsPerAction = 1;
489468fe 546 if ( axis == kEventMouseWheelAxisX )
41469c9e 547 wxevent.m_wheelAxis = wxMOUSE_WHEEL_HORIZONTAL;
489468fe
SC
548 }
549 break ;
550
551 case kEventMouseEntered :
552 case kEventMouseExited :
553 case kEventMouseDragged :
554 case kEventMouseMoved :
555 wxevent.SetEventType( wxEVT_MOTION ) ;
556 break;
557 default :
558 break ;
559 }
560}
561
562#define NEW_CAPTURE_HANDLING 1
563
564pascal OSStatus
565wxMacTopLevelMouseEventHandler(EventHandlerCallRef WXUNUSED(handler),
566 EventRef event,
567 void *data)
568{
b2680ced 569 wxNonOwnedWindow* toplevelWindow = data ? ((wxNonOwnedWindowImpl*) data)->GetWXPeer() : NULL ;
489468fe
SC
570
571 OSStatus result = eventNotHandledErr ;
572
573 wxMacCarbonEvent cEvent( event ) ;
574
575 Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ;
576 Point windowMouseLocation = screenMouseLocation ;
577
578 WindowRef window = NULL;
579 short windowPart = ::FindWindow(screenMouseLocation, &window);
580
581 wxWindow* currentMouseWindow = NULL ;
582 ControlRef control = NULL ;
583
584#if NEW_CAPTURE_HANDLING
585 if ( wxApp::s_captureWindow )
586 {
587 window = (WindowRef) wxApp::s_captureWindow->MacGetTopLevelWindowRef() ;
588 windowPart = inContent ;
589 }
590#endif
591
592 if ( window )
593 {
b2680ced 594 QDGlobalToLocalPoint( GetWindowPort( window ), &windowMouseLocation );
489468fe
SC
595
596 if ( wxApp::s_captureWindow
597#if !NEW_CAPTURE_HANDLING
598 && wxApp::s_captureWindow->MacGetTopLevelWindowRef() == (WXWindow) window && windowPart == inContent
599#endif
600 )
601 {
602 currentMouseWindow = wxApp::s_captureWindow ;
603 }
604 else if ( (IsWindowActive(window) && windowPart == inContent) )
605 {
606 ControlPartCode part ;
607 control = FindControlUnderMouse( windowMouseLocation , window , &part ) ;
608 // if there is no control below the mouse position, send the event to the toplevel window itself
609 if ( control == 0 )
610 {
b2680ced 611 currentMouseWindow = (wxWindow*) toplevelWindow ;
489468fe
SC
612 }
613 else
614 {
b2680ced 615 currentMouseWindow = (wxWindow*) wxFindWindowFromWXWidget( (WXWidget) control ) ;
489468fe
SC
616#ifndef __WXUNIVERSAL__
617 if ( currentMouseWindow == NULL && cEvent.GetKind() == kEventMouseMoved )
618 {
619#if wxUSE_TOOLBAR
620 // for wxToolBar to function we have to send certaint events to it
621 // instead of its children (wxToolBarTools)
622 ControlRef parent ;
623 GetSuperControl(control, &parent );
f742eaaf
RR
624 wxWindow *wxparent = (wxWindow*) wxFindWindowFromWXWidget((WXWidget) parent ) ;
625 if ( wxparent && wxparent->IsKindOf( CLASSINFO( wxToolBar ) ) )
626 currentMouseWindow = wxparent ;
489468fe
SC
627#endif
628 }
629#endif
630 }
631
632 // disabled windows must not get any input messages
633 if ( currentMouseWindow && !currentMouseWindow->MacIsReallyEnabled() )
634 currentMouseWindow = NULL;
635 }
636 }
637
638 wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
639 SetupMouseEvent( wxevent , cEvent ) ;
640
641 // handle all enter / leave events
642
643 if ( currentMouseWindow != g_MacLastWindow )
644 {
645 if ( g_MacLastWindow )
646 {
647 wxMouseEvent eventleave(wxevent);
648 eventleave.SetEventType( wxEVT_LEAVE_WINDOW );
649 g_MacLastWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
650 eventleave.SetEventObject( g_MacLastWindow ) ;
651 wxevent.SetId( g_MacLastWindow->GetId() ) ;
652
653#if wxUSE_TOOLTIPS
654 wxToolTip::RelayEvent( g_MacLastWindow , eventleave);
655#endif
656
657 g_MacLastWindow->HandleWindowEvent(eventleave);
658 }
659
660 if ( currentMouseWindow )
661 {
662 wxMouseEvent evententer(wxevent);
663 evententer.SetEventType( wxEVT_ENTER_WINDOW );
664 currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
665 evententer.SetEventObject( currentMouseWindow ) ;
666 wxevent.SetId( currentMouseWindow->GetId() ) ;
667
668#if wxUSE_TOOLTIPS
669 wxToolTip::RelayEvent( currentMouseWindow , evententer );
670#endif
671
672 currentMouseWindow->HandleWindowEvent(evententer);
673 }
674
675 g_MacLastWindow = currentMouseWindow ;
676 }
677
678 if ( windowPart == inMenuBar )
679 {
680 // special case menu bar, as we are having a low-level runloop we must do it ourselves
681 if ( cEvent.GetKind() == kEventMouseDown )
682 {
683 ::MenuSelect( screenMouseLocation ) ;
684 ::HiliteMenu(0);
685 result = noErr ;
686 }
03647350 687 }
524c47aa
SC
688 else if ( window && windowPart == inProxyIcon )
689 {
690 // special case proxy icon bar, as we are having a low-level runloop we must do it ourselves
691 if ( cEvent.GetKind() == kEventMouseDown )
692 {
693 if ( ::TrackWindowProxyDrag( window, screenMouseLocation ) != errUserWantsToDragWindow )
694 {
695 // TODO Track change of file path and report back
696 result = noErr ;
697 }
698 }
489468fe
SC
699 }
700 else if ( currentMouseWindow )
701 {
702 wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent();
703
704 currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ;
705
706 wxevent.SetEventObject( currentMouseWindow ) ;
707 wxevent.SetId( currentMouseWindow->GetId() ) ;
708
709 // make tooltips current
710
711#if wxUSE_TOOLTIPS
712 if ( wxevent.GetEventType() == wxEVT_MOTION )
713 wxToolTip::RelayEvent( currentMouseWindow , wxevent );
714#endif
715
716 if ( currentMouseWindow->HandleWindowEvent(wxevent) )
717 {
20d88ec6
VZ
718 if ( currentMouseWindowParent &&
719 !currentMouseWindowParent->GetChildren().Member(currentMouseWindow) )
489468fe
SC
720 currentMouseWindow = NULL;
721
722 result = noErr;
723 }
724 else
725 {
726 // if the user code did _not_ handle the event, then perform the
727 // default processing
728 if ( wxevent.GetEventType() == wxEVT_LEFT_DOWN )
729 {
730 // ... that is set focus to this window
731 if (currentMouseWindow->CanAcceptFocus() && wxWindow::FindFocus()!=currentMouseWindow)
732 currentMouseWindow->SetFocus();
733 }
734 }
735
736 if ( cEvent.GetKind() == kEventMouseUp && wxApp::s_captureWindow )
737 {
738 wxApp::s_captureWindow = NULL ;
739 // update cursor ?
740 }
741
742 // update cursor
743
744 wxWindow* cursorTarget = currentMouseWindow ;
745 wxPoint cursorPoint( wxevent.m_x , wxevent.m_y ) ;
03647350 746
489468fe
SC
747 extern wxCursor gGlobalCursor;
748
749 if (!gGlobalCursor.IsOk())
750 {
751 while ( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) )
752 {
753 cursorTarget = cursorTarget->GetParent() ;
754 if ( cursorTarget )
755 cursorPoint += cursorTarget->GetPosition();
756 }
757 }
758
759 }
760 else // currentMouseWindow == NULL
761 {
f742eaaf
RR
762 if (toplevelWindow && !control)
763 {
764 extern wxCursor gGlobalCursor;
765 if (!gGlobalCursor.IsOk())
766 {
767 // update cursor when over toolbar and titlebar etc.
fc1e45d9 768 wxSTANDARD_CURSOR->MacInstall() ;
f742eaaf
RR
769 }
770 }
03647350 771
489468fe
SC
772 // don't mess with controls we don't know about
773 // for some reason returning eventNotHandledErr does not lead to the correct behaviour
774 // so we try sending them the correct control directly
775 if ( cEvent.GetKind() == kEventMouseDown && toplevelWindow && control )
776 {
777 EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
778 Point clickLocation = windowMouseLocation ;
779
780 HIPoint hiPoint ;
781 hiPoint.x = clickLocation.h ;
782 hiPoint.y = clickLocation.v ;
783 HIViewConvertPoint( &hiPoint , (ControlRef) toplevelWindow->GetHandle() , control ) ;
784 clickLocation.h = (int)hiPoint.x ;
785 clickLocation.v = (int)hiPoint.y ;
786
787 HandleControlClick( control , clickLocation , modifiers , (ControlActionUPP ) -1 ) ;
788 result = noErr ;
789 }
790 }
791
792 return result ;
793}
794
795static pascal OSStatus
796wxNonOwnedWindowEventHandler(EventHandlerCallRef WXUNUSED(handler),
797 EventRef event,
798 void *data)
799{
800 OSStatus result = eventNotHandledErr ;
801
802 wxMacCarbonEvent cEvent( event ) ;
803
804 // WindowRef windowRef = cEvent.GetParameter<WindowRef>(kEventParamDirectObject) ;
b2680ced 805 wxNonOwnedWindow* toplevelWindow = data ? ((wxNonOwnedWindowImpl*) data)->GetWXPeer() : NULL;
489468fe
SC
806
807 switch ( GetEventKind( event ) )
808 {
809 case kEventWindowActivated :
810 {
524c47aa 811 toplevelWindow->HandleActivated( cEvent.GetTicks() , true) ;
489468fe
SC
812 // we still sending an eventNotHandledErr in order to allow for default processing
813 }
814 break ;
815
816 case kEventWindowDeactivated :
817 {
524c47aa 818 toplevelWindow->HandleActivated( cEvent.GetTicks() , false) ;
489468fe
SC
819 // we still sending an eventNotHandledErr in order to allow for default processing
820 }
821 break ;
822
823 case kEventWindowShown :
824 toplevelWindow->Refresh() ;
825 result = noErr ;
826 break ;
827
828 case kEventWindowClose :
829 toplevelWindow->Close() ;
830 result = noErr ;
831 break ;
832
833 case kEventWindowBoundsChanged :
834 {
835 UInt32 attributes = cEvent.GetParameter<UInt32>(kEventParamAttributes, typeUInt32) ;
836 Rect newRect = cEvent.GetParameter<Rect>(kEventParamCurrentBounds) ;
837 wxRect r( newRect.left , newRect.top , newRect.right - newRect.left , newRect.bottom - newRect.top ) ;
838 if ( attributes & kWindowBoundsChangeSizeChanged )
839 {
524c47aa 840 toplevelWindow->HandleResized(cEvent.GetTicks() ) ;
489468fe
SC
841 }
842
843 if ( attributes & kWindowBoundsChangeOriginChanged )
844 {
524c47aa 845 toplevelWindow->HandleMoved(cEvent.GetTicks() ) ;
489468fe
SC
846 }
847
848 result = noErr ;
849 }
850 break ;
851
852 case kEventWindowBoundsChanging :
853 {
854 UInt32 attributes = cEvent.GetParameter<UInt32>(kEventParamAttributes,typeUInt32) ;
855 Rect newRect = cEvent.GetParameter<Rect>(kEventParamCurrentBounds) ;
856
857 if ( (attributes & kWindowBoundsChangeSizeChanged) || (attributes & kWindowBoundsChangeOriginChanged) )
858 {
859 // all (Mac) rects are in content area coordinates, all wxRects in structure coordinates
f71d8b3d
SC
860 int left , top , width , height ;
861 // structure width
862 int swidth, sheight;
863
864 toplevelWindow->GetNonOwnedPeer()->GetContentArea(left, top, width, height);
865 toplevelWindow->GetNonOwnedPeer()->GetSize(swidth, sheight);
866 int deltawidth = swidth - width;
867 int deltaheight = sheight - height;
524c47aa 868 wxRect adjustR(
489468fe
SC
869 newRect.left - left,
870 newRect.top - top,
f71d8b3d
SC
871 newRect.right - newRect.left + deltawidth,
872 newRect.bottom - newRect.top + deltaheight ) ;
489468fe 873
524c47aa 874 toplevelWindow->HandleResizing( cEvent.GetTicks(), &adjustR );
03647350
VZ
875
876 const Rect adjustedRect = { adjustR.y + top , adjustR.x + left , adjustR.y + top + adjustR.height - deltaheight ,
f71d8b3d 877 adjustR.x + left + adjustR.width - deltawidth } ;
489468fe
SC
878 if ( !EqualRect( &newRect , &adjustedRect ) )
879 cEvent.SetParameter<Rect>( kEventParamCurrentBounds , &adjustedRect ) ;
489468fe
SC
880 }
881
882 result = noErr ;
883 }
884 break ;
885
886 case kEventWindowGetRegion :
887 {
888 if ( toplevelWindow->GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
889 {
890 WindowRegionCode windowRegionCode ;
891
892 // Fetch the region code that is being queried
893 GetEventParameter( event,
894 kEventParamWindowRegionCode,
895 typeWindowRegionCode, NULL,
896 sizeof windowRegionCode, NULL,
897 &windowRegionCode ) ;
898
899 // If it is the opaque region code then set the
900 // region to empty and return noErr to stop event
901 // propagation
902 if ( windowRegionCode == kWindowOpaqueRgn ) {
903 RgnHandle region;
904 GetEventParameter( event,
905 kEventParamRgnHandle,
906 typeQDRgnHandle, NULL,
907 sizeof region, NULL,
908 &region) ;
909 SetEmptyRgn(region) ;
910 result = noErr ;
911 }
912 }
913 }
914 break ;
915
916 default :
917 break ;
918 }
919
920 return result ;
921}
922
923// mix this in from window.cpp
924pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ;
925
52cda80e 926static pascal OSStatus wxNonOwnedEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
489468fe
SC
927{
928 OSStatus result = eventNotHandledErr ;
929
930 switch ( GetEventClass( event ) )
931 {
932 case kEventClassTextInput :
524c47aa
SC
933 {
934 // TODO remove as soon as all events are on implementation classes only
935 wxNonOwnedWindow* toplevelWindow = data ? ((wxNonOwnedWindowImpl*) data)->GetWXPeer() : NULL;
936
937 result = wxMacUnicodeTextEventHandler( handler, event , toplevelWindow ) ;
938 }
489468fe
SC
939 break ;
940
941 case kEventClassKeyboard :
942 result = KeyboardEventHandler( handler, event , data ) ;
943 break ;
944
945 case kEventClassWindow :
946 result = wxNonOwnedWindowEventHandler( handler, event , data ) ;
947 break ;
948
949 case kEventClassMouse :
950 result = wxMacTopLevelMouseEventHandler( handler, event , data ) ;
951 break ;
952
953 default :
954 break ;
955 }
956
957 return result ;
958}
959
960DEFINE_ONE_SHOT_HANDLER_GETTER( wxNonOwnedEventHandler )
961
962// ---------------------------------------------------------------------------
b2680ced
SC
963// Support functions for shaped windows, based on Apple's CustomWindow sample at
964// http://developer.apple.com/samplecode/Sample_Code/Human_Interface_Toolbox/Mac_OS_High_Level_Toolbox/CustomWindow.htm
489468fe
SC
965// ---------------------------------------------------------------------------
966
b2680ced
SC
967static void wxShapedMacWindowGetPos(WindowRef window, Rect* inRect)
968{
969 GetWindowPortBounds(window, inRect);
970 Point pt = { inRect->top ,inRect->left };
971 QDLocalToGlobalPoint( GetWindowPort( window ), &pt );
972 inRect->bottom += pt.v - inRect->top;
973 inRect->right += pt.h - inRect->left;
974 inRect->top = pt.v;
975 inRect->left = pt.h;
976}
489468fe 977
b2680ced
SC
978static SInt32 wxShapedMacWindowGetFeatures(WindowRef WXUNUSED(window), SInt32 param)
979{
980 /*------------------------------------------------------
981 Define which options your custom window supports.
982 --------------------------------------------------------*/
983 //just enable everything for our demo
984 *(OptionBits*)param =
985 //kWindowCanGrow |
986 //kWindowCanZoom |
987 kWindowCanCollapse |
988 //kWindowCanGetWindowRegion |
989 //kWindowHasTitleBar |
990 //kWindowSupportsDragHilite |
991 kWindowCanDrawInCurrentPort |
992 //kWindowCanMeasureTitle |
993 kWindowWantsDisposeAtProcessDeath |
994 kWindowSupportsGetGrowImageRegion |
995 kWindowDefSupportsColorGrafPort;
489468fe 996
b2680ced
SC
997 return 1;
998}
489468fe 999
b2680ced
SC
1000// The content region is left as a rectangle matching the window size, this is
1001// so the origin in the paint event, and etc. still matches what the
1002// programmer expects.
1003static void wxShapedMacWindowContentRegion(WindowRef window, RgnHandle rgn)
489468fe 1004{
b2680ced
SC
1005 SetEmptyRgn(rgn);
1006 wxNonOwnedWindow* win = wxNonOwnedWindow::GetFromWXWindow((WXWindow)window);
1007 if (win)
1008 {
1009 Rect r ;
1010 wxShapedMacWindowGetPos( window, &r ) ;
1011 RectRgn( rgn , &r ) ;
1012 }
489468fe
SC
1013}
1014
b2680ced
SC
1015// The structure region is set to the shape given to the SetShape method.
1016static void wxShapedMacWindowStructureRegion(WindowRef window, RgnHandle rgn)
489468fe 1017{
b2680ced 1018 RgnHandle cachedRegion = (RgnHandle) GetWRefCon(window);
489468fe 1019
b2680ced
SC
1020 SetEmptyRgn(rgn);
1021 if (cachedRegion)
1022 {
1023 Rect windowRect;
1024 wxShapedMacWindowGetPos(window, &windowRect); // how big is the window
1025 CopyRgn(cachedRegion, rgn); // make a copy of our cached region
1026 OffsetRgn(rgn, windowRect.left, windowRect.top); // position it over window
1027 //MapRgn(rgn, &mMaskSize, &windowRect); //scale it to our actual window size
1028 }
489468fe
SC
1029}
1030
b2680ced 1031static SInt32 wxShapedMacWindowGetRegion(WindowRef window, SInt32 param)
489468fe 1032{
b2680ced
SC
1033 GetWindowRegionPtr rgnRec = (GetWindowRegionPtr)param;
1034
1035 if (rgnRec == NULL)
1036 return paramErr;
1037
1038 switch (rgnRec->regionCode)
489468fe 1039 {
b2680ced
SC
1040 case kWindowStructureRgn:
1041 wxShapedMacWindowStructureRegion(window, rgnRec->winRgn);
489468fe 1042 break;
489468fe 1043
b2680ced
SC
1044 case kWindowContentRgn:
1045 wxShapedMacWindowContentRegion(window, rgnRec->winRgn);
1046 break;
489468fe 1047
b2680ced
SC
1048 default:
1049 SetEmptyRgn(rgnRec->winRgn);
1050 break;
1051 }
489468fe 1052
b2680ced 1053 return noErr;
489468fe
SC
1054}
1055
b2680ced
SC
1056// Determine the region of the window which was hit
1057//
1058static SInt32 wxShapedMacWindowHitTest(WindowRef window, SInt32 param)
489468fe 1059{
b2680ced
SC
1060 Point hitPoint;
1061 static RgnHandle tempRgn = NULL;
489468fe 1062
b2680ced
SC
1063 if (tempRgn == NULL)
1064 tempRgn = NewRgn();
1065
1066 // get the point clicked
1067 SetPt( &hitPoint, LoWord(param), HiWord(param) );
1068
1069 // Mac OS 8.5 or later
1070 wxShapedMacWindowStructureRegion(window, tempRgn);
1071 if (PtInRgn( hitPoint, tempRgn )) //in window content region?
1072 return wInContent;
1073
1074 // no significant area was hit
1075 return wNoHit;
489468fe
SC
1076}
1077
b2680ced 1078static pascal long wxShapedMacWindowDef(short WXUNUSED(varCode), WindowRef window, SInt16 message, SInt32 param)
489468fe 1079{
b2680ced
SC
1080 switch (message)
1081 {
1082 case kWindowMsgHitTest:
1083 return wxShapedMacWindowHitTest(window, param);
489468fe 1084
b2680ced
SC
1085 case kWindowMsgGetFeatures:
1086 return wxShapedMacWindowGetFeatures(window, param);
489468fe 1087
b2680ced
SC
1088 // kWindowMsgGetRegion is sent during CreateCustomWindow and ReshapeCustomWindow
1089 case kWindowMsgGetRegion:
1090 return wxShapedMacWindowGetRegion(window, param);
489468fe 1091
b2680ced
SC
1092 default:
1093 break;
1094 }
489468fe 1095
b2680ced
SC
1096 return 0;
1097}
489468fe 1098
b2680ced 1099// implementation
489468fe 1100
b2680ced
SC
1101typedef struct
1102{
1103 wxPoint m_position ;
1104 wxSize m_size ;
1105 bool m_wasResizable ;
1106} FullScreenData ;
489468fe 1107
b2680ced
SC
1108wxNonOwnedWindowCarbonImpl::wxNonOwnedWindowCarbonImpl()
1109{
1110}
489468fe 1111
b2680ced
SC
1112wxNonOwnedWindowCarbonImpl::wxNonOwnedWindowCarbonImpl( wxNonOwnedWindow* nonownedwnd) : wxNonOwnedWindowImpl( nonownedwnd)
1113{
1114 m_macEventHandler = NULL;
1115 m_macWindow = NULL;
1116 m_macFullScreenData = NULL ;
489468fe
SC
1117}
1118
b2680ced 1119wxNonOwnedWindowCarbonImpl::~wxNonOwnedWindowCarbonImpl()
489468fe 1120{
489468fe
SC
1121#if wxUSE_TOOLTIPS
1122 wxToolTip::NotifyWindowDelete(m_macWindow) ;
1123#endif
489468fe
SC
1124
1125 if ( m_macEventHandler )
1126 {
1127 ::RemoveEventHandler((EventHandlerRef) m_macEventHandler);
1128 m_macEventHandler = NULL ;
1129 }
1130
17e2694c 1131 if ( m_macWindow && !m_wxPeer->IsNativeWindowWrapper())
b2680ced 1132 DisposeWindow( m_macWindow );
489468fe 1133
b2680ced
SC
1134 FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
1135 delete data ;
1136 m_macFullScreenData = NULL ;
1137
1138 m_macWindow = NULL;
1139
1140}
1141
0aaa6ace 1142void wxNonOwnedWindowCarbonImpl::WillBeDestroyed()
03647350 1143{
524c47aa
SC
1144 if ( m_macEventHandler )
1145 {
1146 ::RemoveEventHandler((EventHandlerRef) m_macEventHandler);
1147 m_macEventHandler = NULL ;
1148 }
b2680ced 1149}
489468fe 1150
52cda80e 1151static void wxNonOwnedWindowInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
489468fe
SC
1152{
1153 InstallWindowEventHandler(window, GetwxNonOwnedEventHandlerUPP(),
1154 GetEventTypeCount(eventList), eventList, ref, handler );
1155}
1156
b2680ced
SC
1157bool wxNonOwnedWindowCarbonImpl::SetShape(const wxRegion& region)
1158{
1159 // Make a copy of the region
1160 RgnHandle shapeRegion = NewRgn();
1161 HIShapeGetAsQDRgn( region.GetWXHRGN(), shapeRegion );
1162
1163 // Dispose of any shape region we may already have
1164 RgnHandle oldRgn = (RgnHandle)GetWRefCon( (WindowRef) m_wxPeer->GetWXWindow() );
1165 if ( oldRgn )
1166 DisposeRgn(oldRgn);
1167
1168 // Save the region so we can use it later
1169 SetWRefCon((WindowRef) m_wxPeer->GetWXWindow(), (URefCon)shapeRegion);
1170
1171 // inform the window manager that the window has changed shape
1172 ReshapeCustomWindow((WindowRef) m_wxPeer->GetWXWindow());
1173
1174 return true;
1175}
1176
1177
1178void wxNonOwnedWindowCarbonImpl::MacInstallTopLevelWindowEventHandler()
489468fe
SC
1179{
1180 if ( m_macEventHandler != NULL )
1181 {
1182 verify_noerr( ::RemoveEventHandler( (EventHandlerRef) m_macEventHandler ) ) ;
1183 }
1184 wxNonOwnedWindowInstallTopLevelWindowEventHandler(MAC_WXHWND(m_macWindow),(EventHandlerRef *)&m_macEventHandler,this);
1185}
1186
b2680ced 1187void wxNonOwnedWindowCarbonImpl::Create(
ea85e5e0 1188 wxWindow* WXUNUSED(parent),
17e2694c 1189 WXWindow nativeWindow )
489468fe 1190{
17e2694c
SC
1191 m_macWindow = nativeWindow;
1192}
b2680ced 1193
17e2694c
SC
1194void wxNonOwnedWindowCarbonImpl::Create(
1195 wxWindow* parent,
1196 const wxPoint& pos,
1197 const wxSize& size,
1198 long style, long extraStyle,
1199 const wxString& WXUNUSED(name) )
1200{
ea85e5e0 1201
489468fe 1202 OSStatus err = noErr ;
b2680ced 1203 Rect theBoundsRect;
ea85e5e0 1204
489468fe
SC
1205 int x = (int)pos.x;
1206 int y = (int)pos.y;
ea85e5e0 1207
b2680ced
SC
1208 int w = size.x;
1209 int h = size.y;
ea85e5e0 1210
489468fe 1211 ::SetRect(&theBoundsRect, x, y , x + w, y + h);
ea85e5e0 1212
489468fe
SC
1213 // translate the window attributes in the appropriate window class and attributes
1214 WindowClass wclass = 0;
1215 WindowAttributes attr = kWindowNoAttributes ;
1216 WindowGroupRef group = NULL ;
1217 bool activationScopeSet = false;
1218 WindowActivationScope activationScope = kWindowActivationScopeNone;
ea85e5e0 1219
b2680ced 1220 if ( style & wxFRAME_TOOL_WINDOW )
489468fe
SC
1221 {
1222 if (
b2680ced
SC
1223 ( style & wxMINIMIZE_BOX ) || ( style & wxMAXIMIZE_BOX ) ||
1224 ( style & wxSYSTEM_MENU ) || ( style & wxCAPTION ) ||
7282b067 1225 ( style & wxTINY_CAPTION)
489468fe
SC
1226 )
1227 {
b2680ced 1228 if ( ( style & wxSTAY_ON_TOP ) )
489468fe
SC
1229 wclass = kUtilityWindowClass;
1230 else
1231 wclass = kFloatingWindowClass ;
ea85e5e0 1232
7282b067 1233 if ( ( style & wxTINY_CAPTION) )
489468fe
SC
1234 attr |= kWindowSideTitlebarAttribute ;
1235 }
1236 else
1237 {
8f3864f7 1238 if ( style & wxNO_BORDER )
b12a7313
KO
1239 {
1240 wclass = kSimpleWindowClass ;
1241 }
1242 else
1243 {
1244 wclass = kPlainWindowClass ;
1245 }
489468fe
SC
1246 activationScopeSet = true;
1247 activationScope = kWindowActivationScopeNone;
1248 }
1249 }
b2680ced 1250 else if ( ( style & wxPOPUP_WINDOW ) )
489468fe 1251 {
b2680ced 1252 if ( ( style & wxBORDER_NONE ) )
489468fe
SC
1253 {
1254 wclass = kHelpWindowClass ; // has no border
1255 attr |= kWindowNoShadowAttribute;
1256 }
1257 else
1258 {
1259 wclass = kPlainWindowClass ; // has a single line border, it will have to do for now
1260 }
1261 group = GetWindowGroupOfClass(kFloatingWindowClass) ;
1262 // make sure we don't deactivate something
1263 activationScopeSet = true;
1264 activationScope = kWindowActivationScopeNone;
1265 }
b2680ced 1266 else if ( ( style & wxCAPTION ) )
489468fe
SC
1267 {
1268 wclass = kDocumentWindowClass ;
1269 attr |= kWindowInWindowMenuAttribute ;
1270 }
b2680ced 1271 else if ( ( style & wxFRAME_DRAWER ) )
489468fe
SC
1272 {
1273 wclass = kDrawerWindowClass;
1274 }
1275 else
1276 {
b2680ced
SC
1277 if ( ( style & wxMINIMIZE_BOX ) || ( style & wxMAXIMIZE_BOX ) ||
1278 ( style & wxCLOSE_BOX ) || ( style & wxSYSTEM_MENU ) )
489468fe
SC
1279 {
1280 wclass = kDocumentWindowClass ;
1281 }
b2680ced 1282 else if ( ( style & wxNO_BORDER ) )
489468fe
SC
1283 {
1284 wclass = kSimpleWindowClass ;
1285 }
1286 else
1287 {
1288 wclass = kPlainWindowClass ;
1289 }
1290 }
ea85e5e0 1291
489468fe
SC
1292 if ( wclass != kPlainWindowClass )
1293 {
b2680ced 1294 if ( ( style & wxMINIMIZE_BOX ) )
489468fe 1295 attr |= kWindowCollapseBoxAttribute ;
ea85e5e0 1296
b2680ced 1297 if ( ( style & wxMAXIMIZE_BOX ) )
489468fe 1298 attr |= kWindowFullZoomAttribute ;
ea85e5e0 1299
b2680ced 1300 if ( ( style & wxRESIZE_BORDER ) )
489468fe 1301 attr |= kWindowResizableAttribute ;
ea85e5e0 1302
b2680ced 1303 if ( ( style & wxCLOSE_BOX) )
489468fe
SC
1304 attr |= kWindowCloseBoxAttribute ;
1305 }
1306 attr |= kWindowLiveResizeAttribute;
ea85e5e0 1307
b2680ced 1308 if ( ( style &wxSTAY_ON_TOP) )
489468fe 1309 group = GetWindowGroupOfClass(kUtilityWindowClass) ;
ea85e5e0 1310
b2680ced 1311 if ( ( style & wxFRAME_FLOAT_ON_PARENT ) )
489468fe 1312 group = GetWindowGroupOfClass(kFloatingWindowClass) ;
ea85e5e0 1313
489468fe
SC
1314 if ( group == NULL && parent != NULL )
1315 {
1316 WindowRef parenttlw = (WindowRef) parent->MacGetTopLevelWindowRef();
1317 if( parenttlw )
1318 group = GetWindowGroupParent( GetWindowGroup( parenttlw ) );
1319 }
ea85e5e0 1320
489468fe 1321 attr |= kWindowCompositingAttribute;
292e5e1f 1322#if 0 // TODO : decide on overall handling of high dpi screens (pixel vs userscale)
489468fe
SC
1323 attr |= kWindowFrameworkScaledAttribute;
1324#endif
ea85e5e0 1325
b2680ced 1326 if ( ( style &wxFRAME_SHAPED) )
489468fe
SC
1327 {
1328 WindowDefSpec customWindowDefSpec;
1329 customWindowDefSpec.defType = kWindowDefProcPtr;
1330 customWindowDefSpec.u.defProc =
1331#ifdef __LP64__
17e2694c 1332 (WindowDefUPP) wxShapedMacWindowDef;
489468fe 1333#else
17e2694c 1334 NewWindowDefUPP(wxShapedMacWindowDef);
489468fe
SC
1335#endif
1336 err = ::CreateCustomWindow( &customWindowDefSpec, wclass,
17e2694c
SC
1337 attr, &theBoundsRect,
1338 (WindowRef*) &m_macWindow);
489468fe
SC
1339 }
1340 else
1341 {
1342 err = ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ;
1343 }
ea85e5e0 1344
489468fe
SC
1345 if ( err == noErr && m_macWindow != NULL && group != NULL )
1346 SetWindowGroup( (WindowRef) m_macWindow , group ) ;
ea85e5e0 1347
489468fe 1348 wxCHECK_RET( err == noErr, wxT("Mac OS error when trying to create new window") );
ea85e5e0 1349
489468fe 1350 // setup a separate group for each window, so that overlays can be handled easily
ea85e5e0 1351
489468fe
SC
1352 WindowGroupRef overlaygroup = NULL;
1353 verify_noerr( CreateWindowGroup( kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrHideOnCollapse, &overlaygroup ));
1354 verify_noerr( SetWindowGroupParent( overlaygroup, GetWindowGroup( (WindowRef) m_macWindow )));
1355 verify_noerr( SetWindowGroup( (WindowRef) m_macWindow , overlaygroup ));
ea85e5e0 1356
489468fe
SC
1357 if ( activationScopeSet )
1358 {
1359 verify_noerr( SetWindowActivationScope( (WindowRef) m_macWindow , activationScope ));
1360 }
ea85e5e0 1361
489468fe
SC
1362 // the create commands are only for content rect,
1363 // so we have to set the size again as structure bounds
b2680ced 1364 SetWindowBounds( m_macWindow , kWindowStructureRgn , &theBoundsRect ) ;
ea85e5e0 1365
489468fe
SC
1366 // Causes the inner part of the window not to be metal
1367 // if the style is used before window creation.
1368#if 0 // TARGET_API_MAC_OSX
1369 if ( m_macUsesCompositing && m_macWindow != NULL )
1370 {
1371 if ( GetExtraStyle() & wxFRAME_EX_METAL )
1372 MacSetMetalAppearance( true ) ;
1373 }
1374#endif
ea85e5e0 1375
489468fe
SC
1376 if ( m_macWindow != NULL )
1377 {
1378 MacSetUnifiedAppearance( true ) ;
1379 }
ea85e5e0 1380
489468fe 1381 HIViewRef growBoxRef = 0 ;
b2680ced 1382 err = HIViewFindByID( HIViewGetRoot( m_macWindow ), kHIViewWindowGrowBoxID, &growBoxRef );
489468fe
SC
1383 if ( err == noErr && growBoxRef != 0 )
1384 HIGrowBoxViewSetTransparent( growBoxRef, true ) ;
ea85e5e0 1385
489468fe 1386 // the frame window event handler
b2680ced 1387 InstallStandardEventHandler( GetWindowEventTarget(m_macWindow) ) ;
489468fe 1388 MacInstallTopLevelWindowEventHandler() ;
ea85e5e0 1389
b2680ced
SC
1390 if ( extraStyle & wxFRAME_EX_METAL)
1391 MacSetMetalAppearance(true);
ea85e5e0 1392
b2680ced 1393 if ( ( style &wxFRAME_SHAPED) )
489468fe
SC
1394 {
1395 // default shape matches the window size
1396 wxRegion rgn( 0, 0, w, h );
1397 SetShape( rgn );
1398 }
489468fe
SC
1399}
1400
b2680ced 1401bool wxNonOwnedWindowCarbonImpl::ShowWithEffect(bool show,
489468fe
SC
1402 wxShowEffect effect,
1403 unsigned timeout)
1404{
489468fe
SC
1405 WindowTransitionEffect transition = 0 ;
1406 switch( effect )
1407 {
1408 case wxSHOW_EFFECT_ROLL_TO_LEFT:
1409 case wxSHOW_EFFECT_ROLL_TO_RIGHT:
1410 case wxSHOW_EFFECT_ROLL_TO_TOP:
1411 case wxSHOW_EFFECT_ROLL_TO_BOTTOM:
1412 case wxSHOW_EFFECT_SLIDE_TO_LEFT:
1413 case wxSHOW_EFFECT_SLIDE_TO_RIGHT:
1414 case wxSHOW_EFFECT_SLIDE_TO_TOP:
1415 case wxSHOW_EFFECT_SLIDE_TO_BOTTOM:
1416 transition = kWindowGenieTransitionEffect;
1417 break;
1418 case wxSHOW_EFFECT_BLEND:
1419 transition = kWindowFadeTransitionEffect;
1420 break;
1421 case wxSHOW_EFFECT_EXPAND:
1422 // having sheets would be fine, but this might lead to a repositioning
1423#if 0
1424 if ( GetParent() )
1425 transition = kWindowSheetTransitionEffect;
1426 else
1427#endif
1428 transition = kWindowZoomTransitionEffect;
1429 break;
1430
b43914a8
VZ
1431 case wxSHOW_EFFECT_NONE:
1432 // wxNonOwnedWindow is supposed to call Show() itself in this case
1433 wxFAIL_MSG( "ShowWithEffect() shouldn't be called" );
1434 return false;
1435
489468fe
SC
1436 case wxSHOW_EFFECT_MAX:
1437 wxFAIL_MSG( "invalid effect flag" );
1438 return false;
1439 }
1440
1441 TransitionWindowOptions options;
1442 options.version = 0;
1443 options.duration = timeout / 1000.0;
b2680ced 1444 options.window = transition == kWindowSheetTransitionEffect ? (WindowRef) m_wxPeer->GetParent()->MacGetTopLevelWindowRef() :0;
489468fe
SC
1445 options.userData = 0;
1446
1447 wxSize size = wxGetDisplaySize();
b2680ced
SC
1448 Rect bounds;
1449 GetWindowBounds( (WindowRef)m_macWindow, kWindowStructureRgn, &bounds );
1450 CGRect hiBounds = CGRectMake( bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top );
489468fe 1451
b2680ced
SC
1452 switch ( effect )
1453 {
1454 case wxSHOW_EFFECT_ROLL_TO_RIGHT:
1455 case wxSHOW_EFFECT_SLIDE_TO_RIGHT:
1456 hiBounds.origin.x = 0;
1457 hiBounds.size.width = 0;
1458 break;
489468fe 1459
b2680ced
SC
1460 case wxSHOW_EFFECT_ROLL_TO_LEFT:
1461 case wxSHOW_EFFECT_SLIDE_TO_LEFT:
1462 hiBounds.origin.x = size.x;
1463 hiBounds.size.width = 0;
1464 break;
489468fe 1465
b2680ced
SC
1466 case wxSHOW_EFFECT_ROLL_TO_TOP:
1467 case wxSHOW_EFFECT_SLIDE_TO_TOP:
1468 hiBounds.origin.y = size.y;
1469 hiBounds.size.height = 0;
1470 break;
489468fe 1471
b2680ced
SC
1472 case wxSHOW_EFFECT_ROLL_TO_BOTTOM:
1473 case wxSHOW_EFFECT_SLIDE_TO_BOTTOM:
1474 hiBounds.origin.y = 0;
1475 hiBounds.size.height = 0;
1476 break;
489468fe 1477
b2680ced
SC
1478 default:
1479 break; // direction doesn't make sense
1480 }
489468fe 1481
b2680ced
SC
1482 ::TransitionWindowWithOptions
1483 (
1484 (WindowRef)m_macWindow,
1485 transition,
1486 show ? kWindowShowTransitionAction : kWindowHideTransitionAction,
1487 transition == kWindowGenieTransitionEffect ? &hiBounds : NULL,
1488 false,
1489 &options
1490 );
489468fe 1491
b2680ced
SC
1492 if ( show )
1493 {
1494 ::SelectWindow( (WindowRef)m_macWindow ) ;
1495 }
489468fe 1496
b2680ced 1497 return true;
489468fe
SC
1498}
1499
03647350 1500void wxNonOwnedWindowCarbonImpl::SetTitle( const wxString& title, wxFontEncoding encoding )
489468fe 1501{
b2680ced 1502 SetWindowTitleWithCFString( m_macWindow , wxCFStringRef( title , encoding ) ) ;
489468fe 1503}
03647350 1504
b2680ced 1505bool wxNonOwnedWindowCarbonImpl::IsMaximized() const
489468fe 1506{
b2680ced 1507 return IsWindowInStandardState( m_macWindow , NULL , NULL ) ;
489468fe 1508}
03647350 1509
b2680ced 1510bool wxNonOwnedWindowCarbonImpl::IsIconized() const
489468fe 1511{
b2680ced 1512 return IsWindowCollapsed((WindowRef)GetWXWindow() ) ;
489468fe 1513}
03647350 1514
b2680ced 1515void wxNonOwnedWindowCarbonImpl::Iconize( bool iconize )
489468fe 1516{
b2680ced
SC
1517 if ( IsWindowCollapsable( m_macWindow ) )
1518 CollapseWindow( m_macWindow , iconize ) ;
489468fe 1519}
03647350 1520
b2680ced 1521void wxNonOwnedWindowCarbonImpl::Maximize(bool maximize)
489468fe 1522{
b2680ced
SC
1523 Point idealSize = { 0 , 0 } ;
1524 if ( maximize )
1525 {
1526#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
1527 HIRect bounds ;
1528 HIWindowGetAvailablePositioningBounds(kCGNullDirectDisplay,kHICoordSpace72DPIGlobal,
1529 &bounds);
1530 idealSize.h = bounds.size.width;
1531 idealSize.v = bounds.size.height;
1532#else
1533 Rect rect ;
1534 GetAvailableWindowPositioningBounds(GetMainDevice(),&rect) ;
1535 idealSize.h = rect.right - rect.left ;
1536 idealSize.v = rect.bottom - rect.top ;
1537#endif
1538 }
1539 ZoomWindowIdeal( (WindowRef)GetWXWindow() , maximize ? inZoomOut : inZoomIn , &idealSize ) ;
489468fe 1540}
03647350 1541
b2680ced 1542bool wxNonOwnedWindowCarbonImpl::IsFullScreen() const
489468fe 1543{
b2680ced 1544 return m_macFullScreenData != NULL ;
489468fe 1545}
03647350 1546
b2680ced 1547bool wxNonOwnedWindowCarbonImpl::ShowFullScreen(bool show, long style)
489468fe 1548{
b2680ced 1549 if ( show )
489468fe 1550 {
b2680ced
SC
1551 FullScreenData *data = (FullScreenData *)m_macFullScreenData ;
1552 delete data ;
1553 data = new FullScreenData() ;
1554
1555 m_macFullScreenData = data ;
1556 data->m_position = m_wxPeer->GetPosition() ;
1557 data->m_size = m_wxPeer->GetSize() ;
1558#if wxOSX_USE_CARBON
1559 WindowAttributes attr = 0;
1560 GetWindowAttributes((WindowRef) GetWXWindow(), &attr);
1561 data->m_wasResizable = attr & kWindowResizableAttribute;
1562 if ( style & wxFULLSCREEN_NOMENUBAR )
1563 HideMenuBar() ;
1564#endif
489468fe 1565
b2680ced 1566 wxRect client = wxGetClientDisplayRect() ;
489468fe 1567
b4afc5ec 1568 int left, top, width, height ;
b2680ced 1569 int x, y, w, h ;
489468fe 1570
b2680ced
SC
1571 x = client.x ;
1572 y = client.y ;
1573 w = client.width ;
1574 h = client.height ;
489468fe 1575
b4afc5ec
SC
1576 GetContentArea( left, top, width, height ) ;
1577 int outerwidth, outerheight;
1578 GetSize( outerwidth, outerheight );
489468fe 1579
b2680ced
SC
1580 if ( style & wxFULLSCREEN_NOCAPTION )
1581 {
1582 y -= top ;
1583 h += top ;
b4afc5ec 1584 // avoid adding the caption twice to the height
03647350 1585 outerheight -= top;
b2680ced 1586 }
489468fe 1587
b2680ced
SC
1588 if ( style & wxFULLSCREEN_NOBORDER )
1589 {
1590 x -= left ;
b4afc5ec
SC
1591 w += outerwidth - width;
1592 h += outerheight - height;
b2680ced 1593 }
489468fe 1594
b2680ced
SC
1595 if ( style & wxFULLSCREEN_NOTOOLBAR )
1596 {
1597 // TODO
1598 }
489468fe 1599
b2680ced
SC
1600 if ( style & wxFULLSCREEN_NOSTATUSBAR )
1601 {
1602 // TODO
1603 }
489468fe 1604
b2680ced
SC
1605 m_wxPeer->SetSize( x , y , w, h ) ;
1606 if ( data->m_wasResizable )
1607 {
1608#if wxOSX_USE_CARBON
1609 ChangeWindowAttributes( (WindowRef) GetWXWindow() , kWindowNoAttributes , kWindowResizableAttribute ) ;
1610#endif
1611 }
1612 }
1613 else if ( m_macFullScreenData != NULL )
489468fe 1614 {
b2680ced
SC
1615 FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
1616#if wxOSX_USE_CARBON
1617 ShowMenuBar() ;
1618 if ( data->m_wasResizable )
1619 ChangeWindowAttributes( (WindowRef) GetWXWindow() , kWindowResizableAttribute , kWindowNoAttributes ) ;
1620#endif
1621 m_wxPeer->SetPosition( data->m_position ) ;
1622 m_wxPeer->SetSize( data->m_size ) ;
1623
1624 delete data ;
1625 m_macFullScreenData = NULL ;
489468fe 1626 }
b2680ced
SC
1627
1628 return true;
489468fe
SC
1629}
1630
b2680ced
SC
1631// Attracts the users attention to this window if the application is
1632// inactive (should be called when a background event occurs)
489468fe 1633
b2680ced
SC
1634static pascal void wxMacNMResponse( NMRecPtr ptr )
1635{
1636 NMRemove( ptr ) ;
1637 DisposePtr( (Ptr)ptr ) ;
489468fe
SC
1638}
1639
b2680ced 1640void wxNonOwnedWindowCarbonImpl::RequestUserAttention(int WXUNUSED(flags))
489468fe 1641{
b2680ced 1642 NMRecPtr notificationRequest = (NMRecPtr) NewPtr( sizeof( NMRec) ) ;
489468fe 1643
b2680ced
SC
1644 memset( notificationRequest , 0 , sizeof(*notificationRequest) ) ;
1645 notificationRequest->qType = nmType ;
1646 notificationRequest->nmMark = 1 ;
1647 notificationRequest->nmIcon = 0 ;
1648 notificationRequest->nmSound = 0 ;
1649 notificationRequest->nmStr = NULL ;
1650 notificationRequest->nmResp = wxMacNMResponse ;
489468fe 1651
b2680ced 1652 verify_noerr( NMInstall( notificationRequest ) ) ;
489468fe
SC
1653}
1654
b2680ced 1655void wxNonOwnedWindowCarbonImpl::ScreenToWindow( int *x, int *y )
489468fe 1656{
b2680ced
SC
1657 HIPoint p = CGPointMake( (x ? *x : 0), (y ? *y : 0) );
1658 HIViewRef contentView ;
1659 // TODO check toolbar offset
1660 HIViewFindByID( HIViewGetRoot( m_macWindow ), kHIViewWindowContentID , &contentView) ;
1661 HIPointConvert( &p, kHICoordSpace72DPIGlobal, NULL, kHICoordSpaceView, contentView );
1662 if ( x )
8f2a8de6 1663 *x = (int)p.x;
b2680ced 1664 if ( y )
8f2a8de6 1665 *y = (int)p.y;
489468fe
SC
1666}
1667
b2680ced 1668void wxNonOwnedWindowCarbonImpl::WindowToScreen( int *x, int *y )
489468fe 1669{
b2680ced
SC
1670 HIPoint p = CGPointMake( (x ? *x : 0), (y ? *y : 0) );
1671 HIViewRef contentView ;
1672 // TODO check toolbar offset
1673 HIViewFindByID( HIViewGetRoot( m_macWindow ), kHIViewWindowContentID , &contentView) ;
1674 HIPointConvert( &p, kHICoordSpaceView, contentView, kHICoordSpace72DPIGlobal, NULL );
1675 if ( x )
8f2a8de6 1676 *x = (int)p.x;
b2680ced 1677 if ( y )
8f2a8de6 1678 *y = (int)p.y;
489468fe 1679}
524c47aa 1680
dbc7ceb9
KO
1681bool wxNonOwnedWindowCarbonImpl::IsActive()
1682{
1683 return ActiveNonFloatingWindow() == m_macWindow;
1684}
1685
524c47aa
SC
1686wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
1687 long style, long extraStyle, const wxString& name )
1688{
1689 wxNonOwnedWindowImpl* now = new wxNonOwnedWindowCarbonImpl( wxpeer );
1690 now->Create( parent, pos, size, style , extraStyle, name );
1691 return now;
1692}
17e2694c
SC
1693
1694wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow nativeWindow )
1695{
1696 wxNonOwnedWindowCarbonImpl* now = new wxNonOwnedWindowCarbonImpl( wxpeer );
1697 now->Create( parent, nativeWindow );
1698 return now;
1699}
1700