1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/nonownedwnd.mm
3 // Purpose: non owned window for cocoa
4 // Author: DavidStefan Csomor
7 // RCS-ID: $Id: nonownedwnd.mm 48805 2007-09-19 14:52:25Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/nonownedwnd.h"
17 #include "wx/dialog.h"
20 #include "wx/osx/private.h"
22 NSScreen* wxOSXGetMenuScreen()
24 if ( [NSScreen screens] == nil )
25 return [NSScreen mainScreen];
28 return [[NSScreen screens] objectAtIndex:0];
32 NSRect wxToNSRect( NSView* parent, const wxRect& r )
34 NSRect frame = parent ? [parent bounds] : [wxOSXGetMenuScreen() frame];
37 if ( parent == NULL || ![ parent isFlipped ] )
38 y = (int)(frame.size.height - ( r.y + r.height ));
39 return NSMakeRect(x, y, r.width , r.height);
42 wxRect wxFromNSRect( NSView* parent, const NSRect& rect )
44 NSRect frame = parent ? [parent bounds] : [wxOSXGetMenuScreen() frame];
45 int y = (int)rect.origin.y;
46 int x = (int)rect.origin.x;
47 if ( parent == NULL || ![ parent isFlipped ] )
48 y = (int)(frame.size.height - (rect.origin.y + rect.size.height));
49 return wxRect( x, y, (int)rect.size.width, (int)rect.size.height );
52 NSPoint wxToNSPoint( NSView* parent, const wxPoint& p )
54 NSRect frame = parent ? [parent bounds] : [wxOSXGetMenuScreen() frame];
57 if ( parent == NULL || ![ parent isFlipped ] )
58 y = (int)(frame.size.height - ( p.y ));
59 return NSMakePoint(x, y);
62 wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p )
64 NSRect frame = parent ? [parent bounds] : [wxOSXGetMenuScreen() frame];
67 if ( parent == NULL || ![ parent isFlipped ] )
68 y = (int)(frame.size.height - ( p.y ));
69 return wxPoint( x, y);
72 bool shouldHandleSelector(SEL selector)
74 if (selector == @selector(noop:)
75 || selector == @selector(complete:)
76 || selector == @selector(deleteBackward:)
77 || selector == @selector(deleteForward:)
78 || selector == @selector(insertNewline:)
79 || selector == @selector(insertTab:)
80 || selector == @selector(keyDown:)
81 || selector == @selector(keyUp:)
82 || selector == @selector(scrollPageUp:)
83 || selector == @selector(scrollPageDown:)
84 || selector == @selector(scrollToBeginningOfDocument:)
85 || selector == @selector(scrollToEndOfDocument:))
93 // wx category for NSWindow (our own and wrapped instances)
96 @interface NSWindow (wxNSWindowSupport)
98 - (wxNonOwnedWindowCocoaImpl*) WX_implementation;
100 - (bool) WX_filterSendEvent:(NSEvent *) event;
104 @implementation NSWindow (wxNSWindowSupport)
106 - (wxNonOwnedWindowCocoaImpl*) WX_implementation
108 return (wxNonOwnedWindowCocoaImpl*) wxNonOwnedWindowImpl::FindFromWXWindow( self );
111 // TODO in cocoa everything during a drag is sent to the NSWindow the mouse down occured,
112 // this does not conform to the wx behaviour if the window is not captured, so try to resend
113 // or capture all wx mouse event handling at the tlw as we did for carbon
115 - (bool) WX_filterSendEvent:(NSEvent *) event
117 bool handled = false;
118 if ( ([event type] >= NSLeftMouseDown) && ([event type] <= NSMouseExited) )
120 wxWindow* cw = wxWindow::GetCapture();
123 ((wxWidgetCocoaImpl*)cw->GetPeer())->DoHandleMouseEvent( event);
132 // wx native implementation
135 @interface wxNSWindow : NSWindow
139 - (void) sendEvent:(NSEvent *)event;
140 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen;
141 - (void)noResponderFor: (SEL) selector;
144 @implementation wxNSWindow
146 - (void)sendEvent:(NSEvent *) event
148 if ( ![self WX_filterSendEvent: event] )
150 WXEVENTREF formerEvent = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEvent();
151 WXEVENTHANDLERCALLREF formerHandler = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEventHandlerCallRef();
154 wxTheApp->MacSetCurrentEvent(event, NULL);
156 [super sendEvent: event];
159 wxTheApp->MacSetCurrentEvent(formerEvent , formerHandler);
163 // The default implementation always moves the window back onto the screen,
164 // even when the programmer explicitly wants to hide it.
165 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
171 - (void)doCommandBySelector:(SEL)selector
173 if (shouldHandleSelector(selector) &&
174 !(selector == @selector(cancel:) || selector == @selector(cancelOperation:)) )
175 [super doCommandBySelector:selector];
179 // NB: if we don't do this, all key downs that get handled lead to a NSBeep
180 - (void)noResponderFor: (SEL) selector
182 if (selector != @selector(keyDown:) && selector != @selector(keyUp:))
184 [super noResponderFor:selector];
188 // We need this for borderless windows, i.e. shaped windows or windows without
189 // a title bar. For more info, see:
190 // http://lists.apple.com/archives/cocoa-dev/2008/May/msg02091.html
191 - (BOOL)canBecomeKeyWindow
198 @interface wxNSPanel : NSPanel
202 - (void)noResponderFor: (SEL) selector;
203 - (void)sendEvent:(NSEvent *)event;
206 @implementation wxNSPanel
208 - (BOOL)canBecomeKeyWindow
213 - (void)doCommandBySelector:(SEL)selector
215 if (shouldHandleSelector(selector))
216 [super doCommandBySelector:selector];
219 // NB: if we don't do this, it seems that all events that end here lead to a NSBeep
220 - (void)noResponderFor: (SEL) selector
222 if (selector != @selector(keyDown:) && selector != @selector(keyUp:))
224 [super noResponderFor:selector];
228 - (void)sendEvent:(NSEvent *) event
230 if ( ![self WX_filterSendEvent: event] )
231 [super sendEvent: event];
241 @interface wxNonOwnedWindowController : NSObject wxOSX_10_6_AND_LATER(<NSWindowDelegate>)
245 - (void)windowDidResize:(NSNotification *)notification;
246 - (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
247 - (void)windowDidResignKey:(NSNotification *)notification;
248 - (void)windowDidBecomeKey:(NSNotification *)notification;
249 - (void)windowDidMove:(NSNotification *)notification;
250 - (BOOL)windowShouldClose:(id)window;
251 - (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
255 @implementation wxNonOwnedWindowController
263 - (BOOL)windowShouldClose:(id)nwindow
265 wxNonOwnedWindowCocoaImpl* windowimpl = [(NSWindow*) nwindow WX_implementation];
268 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
275 - (NSSize)windowWillResize:(NSWindow *)window
276 toSize:(NSSize)proposedFrameSize
278 NSRect frame = [window frame];
279 wxRect wxframe = wxFromNSRect( NULL, frame );
280 wxframe.SetWidth( (int)proposedFrameSize.width );
281 wxframe.SetHeight( (int)proposedFrameSize.height );
283 wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
286 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
289 wxpeer->HandleResizing( 0, &wxframe );
290 NSSize newSize = NSMakeSize(wxframe.GetWidth(), wxframe.GetHeight());
295 return proposedFrameSize;
298 - (void)windowDidResize:(NSNotification *)notification
300 NSWindow* window = (NSWindow*) [notification object];
301 wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
304 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
306 wxpeer->HandleResized(0);
310 - (void)windowDidMove:(NSNotification *)notification
312 wxNSWindow* window = (wxNSWindow*) [notification object];
313 wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
316 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
318 wxpeer->HandleMoved(0);
322 - (void)windowDidBecomeKey:(NSNotification *)notification
324 NSWindow* window = (NSWindow*) [notification object];
325 wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
328 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
330 wxpeer->HandleActivated(0, true);
334 - (void)windowDidResignKey:(NSNotification *)notification
336 NSWindow* window = (NSWindow*) [notification object];
337 wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
340 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
343 wxpeer->HandleActivated(0, false);
344 // Needed for popup window since the firstResponder
345 // (focus in wx) doesn't change when this
346 // TLW becomes inactive.
347 wxFocusEvent event( wxEVT_KILL_FOCUS, wxpeer->GetId());
348 event.SetEventObject(wxpeer);
349 wxpeer->HandleWindowEvent(event);
354 - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject
358 if ([anObject isKindOfClass:[wxNSTextField class]])
360 wxNSTextField* tf = (wxNSTextField*) anObject;
361 wxNSTextFieldEditor* editor = [tf fieldEditor];
364 editor = [[wxNSTextFieldEditor alloc] init];
365 [editor setFieldEditor:YES];
366 [tf setFieldEditor:editor];
374 - (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame
376 wxUnusedVar(newFrame);
377 wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
380 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
381 wxMaximizeEvent event(wxpeer->GetId());
382 event.SetEventObject(wxpeer);
383 return !wxpeer->HandleWindowEvent(event);
390 IMPLEMENT_DYNAMIC_CLASS( wxNonOwnedWindowCocoaImpl , wxNonOwnedWindowImpl )
392 wxNonOwnedWindowCocoaImpl::wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) :
393 wxNonOwnedWindowImpl(nonownedwnd)
396 m_macFullScreenData = NULL;
399 wxNonOwnedWindowCocoaImpl::wxNonOwnedWindowCocoaImpl()
402 m_macFullScreenData = NULL;
405 wxNonOwnedWindowCocoaImpl::~wxNonOwnedWindowCocoaImpl()
407 if ( !m_wxPeer->IsNativeWindowWrapper() )
409 [m_macWindow setDelegate:nil];
410 [m_macWindow release];
414 void wxNonOwnedWindowCocoaImpl::WillBeDestroyed()
416 if ( !m_wxPeer->IsNativeWindowWrapper() )
418 [m_macWindow setDelegate:nil];
422 void wxNonOwnedWindowCocoaImpl::Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
423 long style, long extraStyle, const wxString& WXUNUSED(name) )
425 static wxNonOwnedWindowController* controller = NULL;
428 controller =[[wxNonOwnedWindowController alloc] init];
431 int windowstyle = NSBorderlessWindowMask;
433 if ( style & wxFRAME_TOOL_WINDOW || ( style & wxPOPUP_WINDOW ) ||
434 GetWXPeer()->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG )
436 m_macWindow = [wxNSPanel alloc];
439 m_macWindow = [wxNSWindow alloc];
441 CGWindowLevel level = kCGNormalWindowLevel;
443 if ( style & wxFRAME_TOOL_WINDOW )
445 windowstyle |= NSUtilityWindowMask;
446 if ( ( style & wxMINIMIZE_BOX ) || ( style & wxMAXIMIZE_BOX ) ||
447 ( style & wxCLOSE_BOX ) || ( style & wxSYSTEM_MENU ) )
449 windowstyle |= NSTitledWindowMask ;
452 else if ( ( style & wxPOPUP_WINDOW ) )
454 level = kCGPopUpMenuWindowLevel;
456 if ( ( style & wxBORDER_NONE ) )
458 wclass = kHelpWindowClass ; // has no border
459 attr |= kWindowNoShadowAttribute;
463 wclass = kPlainWindowClass ; // has a single line border, it will have to do for now
467 else if ( ( style & wxCAPTION ) )
469 windowstyle |= NSTitledWindowMask ;
471 else if ( ( style & wxFRAME_DRAWER ) )
474 wclass = kDrawerWindowClass;
479 // set these even if we have no title, otherwise the controls won't be visible
480 if ( ( style & wxMINIMIZE_BOX ) || ( style & wxMAXIMIZE_BOX ) ||
481 ( style & wxCLOSE_BOX ) || ( style & wxSYSTEM_MENU ) )
483 windowstyle |= NSTitledWindowMask ;
486 else if ( ( style & wxNO_BORDER ) )
488 wclass = kSimpleWindowClass ;
492 wclass = kPlainWindowClass ;
497 if ( windowstyle & NSTitledWindowMask )
499 if ( ( style & wxMINIMIZE_BOX ) )
500 windowstyle |= NSMiniaturizableWindowMask ;
502 if ( ( style & wxMAXIMIZE_BOX ) )
503 windowstyle |= NSResizableWindowMask ; // TODO showing ZOOM ?
505 if ( ( style & wxRESIZE_BORDER ) )
506 windowstyle |= NSResizableWindowMask ;
508 if ( ( style & wxCLOSE_BOX) )
509 windowstyle |= NSClosableWindowMask ;
511 if ( extraStyle & wxFRAME_EX_METAL)
512 windowstyle |= NSTexturedBackgroundWindowMask;
514 if ( ( style & wxFRAME_FLOAT_ON_PARENT ) || ( style & wxFRAME_TOOL_WINDOW ) )
515 level = kCGFloatingWindowLevel;
517 if ( ( style & wxSTAY_ON_TOP ) )
518 level = kCGUtilityWindowLevel;
520 NSRect r = wxToNSRect( NULL, wxRect( pos, size) );
522 r = [NSWindow contentRectForFrameRect:r styleMask:windowstyle];
524 [m_macWindow initWithContentRect:r
525 styleMask:windowstyle
526 backing:NSBackingStoreBuffered
530 // If the parent is modal, windows with wxFRAME_FLOAT_ON_PARENT style need
531 // to be in kCGUtilityWindowLevel and not kCGFloatingWindowLevel to stay
533 wxDialog * const parentDialog = wxDynamicCast(parent, wxDialog);
534 if (parentDialog && parentDialog->IsModal())
536 if (level == kCGFloatingWindowLevel)
538 level = kCGUtilityWindowLevel;
541 // Cocoa's modal loop does not process other windows by default, but
542 // don't call this on normal window levels so nested modal dialogs will
543 // still behave modally.
544 if (level != kCGNormalWindowLevel)
546 if ([m_macWindow isKindOfClass:[NSPanel class]])
548 [(NSPanel*)m_macWindow setWorksWhenModal:YES];
553 [m_macWindow setLevel:level];
555 [m_macWindow setDelegate:controller];
557 [m_macWindow setAcceptsMouseMovedEvents: YES];
559 if ( ( style & wxFRAME_SHAPED) )
561 [m_macWindow setOpaque:NO];
562 [m_macWindow setAlphaValue:1.0];
565 if ( !(style & wxFRAME_TOOL_WINDOW) )
566 [m_macWindow setHidesOnDeactivate:NO];
569 void wxNonOwnedWindowCocoaImpl::Create( wxWindow* WXUNUSED(parent), WXWindow nativeWindow )
571 m_macWindow = nativeWindow;
574 WXWindow wxNonOwnedWindowCocoaImpl::GetWXWindow() const
579 void wxNonOwnedWindowCocoaImpl::Raise()
581 [m_macWindow orderWindow:NSWindowAbove relativeTo:0];
584 void wxNonOwnedWindowCocoaImpl::Lower()
586 [m_macWindow orderWindow:NSWindowBelow relativeTo:0];
589 void wxNonOwnedWindowCocoaImpl::ShowWithoutActivating()
591 [m_macWindow orderFront:nil];
592 [[m_macWindow contentView] setNeedsDisplay: YES];
595 bool wxNonOwnedWindowCocoaImpl::Show(bool show)
599 wxNonOwnedWindow* wxpeer = GetWXPeer();
600 if (wxpeer && !(wxpeer->GetWindowStyle() & wxFRAME_TOOL_WINDOW))
601 [m_macWindow makeKeyAndOrderFront:nil];
603 [m_macWindow orderFront:nil];
604 [[m_macWindow contentView] setNeedsDisplay: YES];
607 [m_macWindow orderOut:nil];
611 bool wxNonOwnedWindowCocoaImpl::ShowWithEffect(bool show,
615 return wxWidgetCocoaImpl::
616 ShowViewOrWindowWithEffect(m_wxPeer, show, effect, timeout);
619 void wxNonOwnedWindowCocoaImpl::Update()
621 [m_macWindow displayIfNeeded];
624 bool wxNonOwnedWindowCocoaImpl::SetTransparent(wxByte alpha)
626 [m_macWindow setAlphaValue:(CGFloat) alpha/255.0];
630 bool wxNonOwnedWindowCocoaImpl::SetBackgroundColour(const wxColour& WXUNUSED(col) )
635 void wxNonOwnedWindowCocoaImpl::SetExtraStyle( long exStyle )
639 bool metal = exStyle & wxFRAME_EX_METAL ;
640 int windowStyle = [ m_macWindow styleMask];
641 if ( metal && !(windowStyle & NSTexturedBackgroundWindowMask) )
643 wxFAIL_MSG( wxT("Metal Style cannot be changed after creation") );
645 else if ( !metal && (windowStyle & NSTexturedBackgroundWindowMask ) )
647 wxFAIL_MSG( wxT("Metal Style cannot be changed after creation") );
652 void wxNonOwnedWindowCocoaImpl::SetWindowStyleFlag( long style )
656 CGWindowLevel level = kCGNormalWindowLevel;
658 if (style & wxSTAY_ON_TOP)
659 level = kCGUtilityWindowLevel;
660 else if (( style & wxFRAME_FLOAT_ON_PARENT ) || ( style & wxFRAME_TOOL_WINDOW ))
661 level = kCGFloatingWindowLevel;
663 [m_macWindow setLevel: level];
667 bool wxNonOwnedWindowCocoaImpl::SetBackgroundStyle(wxBackgroundStyle style)
669 if ( style == wxBG_STYLE_TRANSPARENT )
671 [m_macWindow setOpaque:NO];
672 [m_macWindow setBackgroundColor:[NSColor clearColor]];
678 bool wxNonOwnedWindowCocoaImpl::CanSetTransparent()
683 void wxNonOwnedWindowCocoaImpl::MoveWindow(int x, int y, int width, int height)
685 NSRect r = wxToNSRect( NULL, wxRect(x,y,width, height) );
686 // do not trigger refreshes upon invisible and possible partly created objects
687 [m_macWindow setFrame:r display:GetWXPeer()->IsShownOnScreen()];
690 void wxNonOwnedWindowCocoaImpl::GetPosition( int &x, int &y ) const
692 wxRect r = wxFromNSRect( NULL, [m_macWindow frame] );
697 void wxNonOwnedWindowCocoaImpl::GetSize( int &width, int &height ) const
699 NSRect rect = [m_macWindow frame];
700 width = (int)rect.size.width;
701 height = (int)rect.size.height;
704 void wxNonOwnedWindowCocoaImpl::GetContentArea( int& left, int &top, int &width, int &height ) const
706 NSRect outer = NSMakeRect(100,100,100,100);
707 NSRect content = [NSWindow contentRectForFrameRect:outer styleMask:[m_macWindow styleMask] ];
708 NSRect rect = [[m_macWindow contentView] frame];
709 left = (int)rect.origin.x;
710 top = (int)rect.origin.y;
711 width = (int)rect.size.width;
712 height = (int)rect.size.height;
715 bool wxNonOwnedWindowCocoaImpl::SetShape(const wxRegion& WXUNUSED(region))
717 [m_macWindow setOpaque:NO];
718 [m_macWindow setBackgroundColor:[NSColor clearColor]];
723 void wxNonOwnedWindowCocoaImpl::SetTitle( const wxString& title, wxFontEncoding encoding )
725 [m_macWindow setTitle:wxCFStringRef( title , encoding ).AsNSString()];
728 bool wxNonOwnedWindowCocoaImpl::IsMaximized() const
730 if (([m_macWindow styleMask] & NSResizableWindowMask) != 0)
732 return [m_macWindow isZoomed];
736 NSRect rectScreen = [[NSScreen mainScreen] visibleFrame];
737 NSRect rectWindow = [m_macWindow frame];
738 return (rectScreen.origin.x == rectWindow.origin.x &&
739 rectScreen.origin.y == rectWindow.origin.y &&
740 rectScreen.size.width == rectWindow.size.width &&
741 rectScreen.size.height == rectWindow.size.height);
745 bool wxNonOwnedWindowCocoaImpl::IsIconized() const
747 return [m_macWindow isMiniaturized];
750 void wxNonOwnedWindowCocoaImpl::Iconize( bool iconize )
753 [m_macWindow miniaturize:nil];
755 [m_macWindow deminiaturize:nil];
758 void wxNonOwnedWindowCocoaImpl::Maximize(bool WXUNUSED(maximize))
760 [m_macWindow zoom:nil];
764 // http://cocoadevcentral.com/articles/000028.php
769 NSRect m_formerFrame;
772 bool wxNonOwnedWindowCocoaImpl::IsFullScreen() const
774 return m_macFullScreenData != NULL ;
777 bool wxNonOwnedWindowCocoaImpl::ShowFullScreen(bool show, long WXUNUSED(style))
781 FullScreenData *data = (FullScreenData *)m_macFullScreenData ;
783 data = new FullScreenData();
785 m_macFullScreenData = data ;
786 data->m_formerLevel = [m_macWindow level];
787 data->m_formerFrame = [m_macWindow frame];
788 CGDisplayCapture( kCGDirectMainDisplay );
789 [m_macWindow setLevel:CGShieldingWindowLevel()];
790 [m_macWindow setFrame:[[NSScreen mainScreen] frame] display:YES];
792 else if ( m_macFullScreenData != NULL )
794 FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
795 CGDisplayRelease( kCGDirectMainDisplay );
796 [m_macWindow setLevel:data->m_formerLevel];
797 [m_macWindow setFrame:data->m_formerFrame display:YES];
799 m_macFullScreenData = NULL ;
805 void wxNonOwnedWindowCocoaImpl::RequestUserAttention(int flagsWX)
807 NSRequestUserAttentionType flagsOSX;
810 case wxUSER_ATTENTION_INFO:
811 flagsOSX = NSInformationalRequest;
814 case wxUSER_ATTENTION_ERROR:
815 flagsOSX = NSCriticalRequest;
819 wxFAIL_MSG( "invalid RequestUserAttention() flags" );
823 [NSApp requestUserAttention:flagsOSX];
826 void wxNonOwnedWindowCocoaImpl::ScreenToWindow( int *x, int *y )
828 wxPoint p((x ? *x : 0), (y ? *y : 0) );
829 NSPoint nspt = wxToNSPoint( NULL, p );
830 nspt = [m_macWindow convertScreenToBase:nspt];
831 nspt = [[m_macWindow contentView] convertPoint:nspt fromView:nil];
832 p = wxFromNSPoint([m_macWindow contentView], nspt);
839 void wxNonOwnedWindowCocoaImpl::WindowToScreen( int *x, int *y )
841 wxPoint p((x ? *x : 0), (y ? *y : 0) );
842 NSPoint nspt = wxToNSPoint( [m_macWindow contentView], p );
843 nspt = [[m_macWindow contentView] convertPoint:nspt toView:nil];
844 nspt = [m_macWindow convertBaseToScreen:nspt];
845 p = wxFromNSPoint( NULL, nspt);
852 bool wxNonOwnedWindowCocoaImpl::IsActive()
854 return [m_macWindow isKeyWindow];
857 void wxNonOwnedWindowCocoaImpl::SetModified(bool modified)
859 [m_macWindow setDocumentEdited:modified];
862 bool wxNonOwnedWindowCocoaImpl::IsModified() const
864 return [m_macWindow isDocumentEdited];
867 wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow nativeWindow)
869 wxNonOwnedWindowCocoaImpl* now = new wxNonOwnedWindowCocoaImpl( wxpeer );
870 now->Create( parent, nativeWindow );
874 wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
875 long style, long extraStyle, const wxString& name )
877 wxNonOwnedWindowImpl* now = new wxNonOwnedWindowCocoaImpl( wxpeer );
878 now->Create( parent, pos, size, style , extraStyle, name );