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(insertBacktab:)
81 || selector == @selector(keyDown:)
82 || selector == @selector(keyUp:)
83 || selector == @selector(scrollPageUp:)
84 || selector == @selector(scrollPageDown:)
85 || selector == @selector(scrollToBeginningOfDocument:)
86 || selector == @selector(scrollToEndOfDocument:))
94 // wx category for NSWindow (our own and wrapped instances)
97 @interface NSWindow (wxNSWindowSupport)
99 - (wxNonOwnedWindowCocoaImpl*) WX_implementation;
101 - (bool) WX_filterSendEvent:(NSEvent *) event;
105 @implementation NSWindow (wxNSWindowSupport)
107 - (wxNonOwnedWindowCocoaImpl*) WX_implementation
109 return (wxNonOwnedWindowCocoaImpl*) wxNonOwnedWindowImpl::FindFromWXWindow( self );
112 // TODO in cocoa everything during a drag is sent to the NSWindow the mouse down occured,
113 // this does not conform to the wx behaviour if the window is not captured, so try to resend
114 // or capture all wx mouse event handling at the tlw as we did for carbon
116 - (bool) WX_filterSendEvent:(NSEvent *) event
118 bool handled = false;
119 if ( ([event type] >= NSLeftMouseDown) && ([event type] <= NSMouseExited) )
121 wxWindow* cw = wxWindow::GetCapture();
124 ((wxWidgetCocoaImpl*)cw->GetPeer())->DoHandleMouseEvent( event);
133 // wx native implementation
136 @interface wxNSWindow : NSWindow
140 - (void) sendEvent:(NSEvent *)event;
141 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen;
142 - (void)noResponderFor: (SEL) selector;
145 @implementation wxNSWindow
147 - (void)sendEvent:(NSEvent *) event
149 if ( ![self WX_filterSendEvent: event] )
151 WXEVENTREF formerEvent = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEvent();
152 WXEVENTHANDLERCALLREF formerHandler = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEventHandlerCallRef();
155 wxTheApp->MacSetCurrentEvent(event, NULL);
157 [super sendEvent: event];
160 wxTheApp->MacSetCurrentEvent(formerEvent , formerHandler);
164 // The default implementation always moves the window back onto the screen,
165 // even when the programmer explicitly wants to hide it.
166 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
172 - (void)doCommandBySelector:(SEL)selector
174 if (shouldHandleSelector(selector) &&
175 !(selector == @selector(cancel:) || selector == @selector(cancelOperation:)) )
176 [super doCommandBySelector:selector];
180 // NB: if we don't do this, all key downs that get handled lead to a NSBeep
181 - (void)noResponderFor: (SEL) selector
183 if (selector != @selector(keyDown:) && selector != @selector(keyUp:))
185 [super noResponderFor:selector];
189 // We need this for borderless windows, i.e. shaped windows or windows without
190 // a title bar. For more info, see:
191 // http://lists.apple.com/archives/cocoa-dev/2008/May/msg02091.html
192 - (BOOL)canBecomeKeyWindow
199 @interface wxNSPanel : NSPanel
203 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen;
204 - (void)noResponderFor: (SEL) selector;
205 - (void)sendEvent:(NSEvent *)event;
208 @implementation wxNSPanel
210 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
212 wxNonOwnedWindowCocoaImpl* impl = (wxNonOwnedWindowCocoaImpl*) wxNonOwnedWindowImpl::FindFromWXWindow( self );
213 if (impl && impl->IsFullScreen())
216 return [super constrainFrameRect:frameRect toScreen:screen];
219 - (BOOL)canBecomeKeyWindow
224 - (void)doCommandBySelector:(SEL)selector
226 if (shouldHandleSelector(selector))
227 [super doCommandBySelector:selector];
230 // NB: if we don't do this, it seems that all events that end here lead to a NSBeep
231 - (void)noResponderFor: (SEL) selector
233 if (selector != @selector(keyDown:) && selector != @selector(keyUp:))
235 [super noResponderFor:selector];
239 - (void)sendEvent:(NSEvent *) event
241 if ( ![self WX_filterSendEvent: event] )
242 [super sendEvent: event];
252 @interface wxNonOwnedWindowController : NSObject wxOSX_10_6_AND_LATER(<NSWindowDelegate>)
256 - (void)windowDidResize:(NSNotification *)notification;
257 - (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
258 - (void)windowDidResignKey:(NSNotification *)notification;
259 - (void)windowDidBecomeKey:(NSNotification *)notification;
260 - (void)windowDidMove:(NSNotification *)notification;
261 - (BOOL)windowShouldClose:(id)window;
262 - (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
266 @implementation wxNonOwnedWindowController
274 - (BOOL)windowShouldClose:(id)nwindow
276 wxNonOwnedWindowCocoaImpl* windowimpl = [(NSWindow*) nwindow WX_implementation];
279 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
286 - (NSSize)windowWillResize:(NSWindow *)window
287 toSize:(NSSize)proposedFrameSize
289 NSRect frame = [window frame];
290 wxRect wxframe = wxFromNSRect( NULL, frame );
291 wxframe.SetWidth( (int)proposedFrameSize.width );
292 wxframe.SetHeight( (int)proposedFrameSize.height );
294 wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
297 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
300 wxpeer->HandleResizing( 0, &wxframe );
301 NSSize newSize = NSMakeSize(wxframe.GetWidth(), wxframe.GetHeight());
306 return proposedFrameSize;
309 - (void)windowDidResize:(NSNotification *)notification
311 NSWindow* window = (NSWindow*) [notification object];
312 wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
315 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
317 wxpeer->HandleResized(0);
321 - (void)windowDidMove:(NSNotification *)notification
323 wxNSWindow* window = (wxNSWindow*) [notification object];
324 wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
327 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
329 wxpeer->HandleMoved(0);
333 - (void)windowDidBecomeKey:(NSNotification *)notification
335 NSWindow* window = (NSWindow*) [notification object];
336 wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
339 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
341 wxpeer->HandleActivated(0, true);
345 - (void)windowDidResignKey:(NSNotification *)notification
347 NSWindow* window = (NSWindow*) [notification object];
348 wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
351 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
354 wxpeer->HandleActivated(0, false);
355 // Needed for popup window since the firstResponder
356 // (focus in wx) doesn't change when this
357 // TLW becomes inactive.
358 wxFocusEvent event( wxEVT_KILL_FOCUS, wxpeer->GetId());
359 event.SetEventObject(wxpeer);
360 wxpeer->HandleWindowEvent(event);
365 - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject
369 if ([anObject isKindOfClass:[wxNSTextField class]])
371 wxNSTextField* tf = (wxNSTextField*) anObject;
372 wxNSTextFieldEditor* editor = [tf fieldEditor];
375 editor = [[wxNSTextFieldEditor alloc] init];
376 [editor setFieldEditor:YES];
377 [tf setFieldEditor:editor];
385 - (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame
387 wxUnusedVar(newFrame);
388 wxNonOwnedWindowCocoaImpl* windowimpl = [window WX_implementation];
391 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
392 wxMaximizeEvent event(wxpeer->GetId());
393 event.SetEventObject(wxpeer);
394 return !wxpeer->HandleWindowEvent(event);
401 IMPLEMENT_DYNAMIC_CLASS( wxNonOwnedWindowCocoaImpl , wxNonOwnedWindowImpl )
403 wxNonOwnedWindowCocoaImpl::wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) :
404 wxNonOwnedWindowImpl(nonownedwnd)
407 m_macFullScreenData = NULL;
410 wxNonOwnedWindowCocoaImpl::wxNonOwnedWindowCocoaImpl()
413 m_macFullScreenData = NULL;
416 wxNonOwnedWindowCocoaImpl::~wxNonOwnedWindowCocoaImpl()
418 if ( !m_wxPeer->IsNativeWindowWrapper() )
420 [m_macWindow setDelegate:nil];
421 [m_macWindow release];
425 void wxNonOwnedWindowCocoaImpl::WillBeDestroyed()
427 if ( !m_wxPeer->IsNativeWindowWrapper() )
429 [m_macWindow setDelegate:nil];
433 void wxNonOwnedWindowCocoaImpl::Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
434 long style, long extraStyle, const wxString& WXUNUSED(name) )
436 static wxNonOwnedWindowController* controller = NULL;
439 controller =[[wxNonOwnedWindowController alloc] init];
442 int windowstyle = NSBorderlessWindowMask;
444 if ( style & wxFRAME_TOOL_WINDOW || ( style & wxPOPUP_WINDOW ) ||
445 GetWXPeer()->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG )
447 m_macWindow = [wxNSPanel alloc];
450 m_macWindow = [wxNSWindow alloc];
452 CGWindowLevel level = kCGNormalWindowLevel;
454 if ( style & wxFRAME_TOOL_WINDOW )
456 windowstyle |= NSUtilityWindowMask;
457 if ( ( style & wxMINIMIZE_BOX ) || ( style & wxMAXIMIZE_BOX ) ||
458 ( style & wxCLOSE_BOX ) || ( style & wxSYSTEM_MENU ) )
460 windowstyle |= NSTitledWindowMask ;
463 else if ( ( style & wxPOPUP_WINDOW ) )
465 level = kCGPopUpMenuWindowLevel;
467 if ( ( style & wxBORDER_NONE ) )
469 wclass = kHelpWindowClass ; // has no border
470 attr |= kWindowNoShadowAttribute;
474 wclass = kPlainWindowClass ; // has a single line border, it will have to do for now
478 else if ( ( style & wxCAPTION ) )
480 windowstyle |= NSTitledWindowMask ;
482 else if ( ( style & wxFRAME_DRAWER ) )
485 wclass = kDrawerWindowClass;
490 // set these even if we have no title, otherwise the controls won't be visible
491 if ( ( style & wxMINIMIZE_BOX ) || ( style & wxMAXIMIZE_BOX ) ||
492 ( style & wxCLOSE_BOX ) || ( style & wxSYSTEM_MENU ) )
494 windowstyle |= NSTitledWindowMask ;
497 else if ( ( style & wxNO_BORDER ) )
499 wclass = kSimpleWindowClass ;
503 wclass = kPlainWindowClass ;
508 if ( windowstyle & NSTitledWindowMask )
510 if ( ( style & wxMINIMIZE_BOX ) )
511 windowstyle |= NSMiniaturizableWindowMask ;
513 if ( ( style & wxMAXIMIZE_BOX ) )
514 windowstyle |= NSResizableWindowMask ; // TODO showing ZOOM ?
516 if ( ( style & wxRESIZE_BORDER ) )
517 windowstyle |= NSResizableWindowMask ;
519 if ( ( style & wxCLOSE_BOX) )
520 windowstyle |= NSClosableWindowMask ;
522 if ( extraStyle & wxFRAME_EX_METAL)
523 windowstyle |= NSTexturedBackgroundWindowMask;
525 if ( ( style & wxFRAME_FLOAT_ON_PARENT ) || ( style & wxFRAME_TOOL_WINDOW ) )
526 level = kCGFloatingWindowLevel;
528 if ( ( style & wxSTAY_ON_TOP ) )
529 level = kCGUtilityWindowLevel;
531 NSRect r = wxToNSRect( NULL, wxRect( pos, size) );
533 r = [NSWindow contentRectForFrameRect:r styleMask:windowstyle];
535 [m_macWindow initWithContentRect:r
536 styleMask:windowstyle
537 backing:NSBackingStoreBuffered
541 // If the parent is modal, windows with wxFRAME_FLOAT_ON_PARENT style need
542 // to be in kCGUtilityWindowLevel and not kCGFloatingWindowLevel to stay
544 wxDialog * const parentDialog = wxDynamicCast(parent, wxDialog);
545 if (parentDialog && parentDialog->IsModal())
547 if (level == kCGFloatingWindowLevel)
549 level = kCGUtilityWindowLevel;
552 // Cocoa's modal loop does not process other windows by default, but
553 // don't call this on normal window levels so nested modal dialogs will
554 // still behave modally.
555 if (level != kCGNormalWindowLevel)
557 if ([m_macWindow isKindOfClass:[NSPanel class]])
559 [(NSPanel*)m_macWindow setWorksWhenModal:YES];
564 [m_macWindow setLevel:level];
566 [m_macWindow setDelegate:controller];
568 [m_macWindow setAcceptsMouseMovedEvents: YES];
570 if ( ( style & wxFRAME_SHAPED) )
572 [m_macWindow setOpaque:NO];
573 [m_macWindow setAlphaValue:1.0];
576 if ( !(style & wxFRAME_TOOL_WINDOW) )
577 [m_macWindow setHidesOnDeactivate:NO];
580 void wxNonOwnedWindowCocoaImpl::Create( wxWindow* WXUNUSED(parent), WXWindow nativeWindow )
582 m_macWindow = nativeWindow;
585 WXWindow wxNonOwnedWindowCocoaImpl::GetWXWindow() const
590 void wxNonOwnedWindowCocoaImpl::Raise()
592 [m_macWindow makeKeyAndOrderFront:nil];
595 void wxNonOwnedWindowCocoaImpl::Lower()
597 [m_macWindow orderWindow:NSWindowBelow relativeTo:0];
600 void wxNonOwnedWindowCocoaImpl::ShowWithoutActivating()
602 [m_macWindow orderFront:nil];
603 [[m_macWindow contentView] setNeedsDisplay: YES];
606 bool wxNonOwnedWindowCocoaImpl::Show(bool show)
610 wxNonOwnedWindow* wxpeer = GetWXPeer();
611 if (wxpeer && !(wxpeer->GetWindowStyle() & wxFRAME_TOOL_WINDOW))
612 [m_macWindow makeKeyAndOrderFront:nil];
614 [m_macWindow orderFront:nil];
615 [[m_macWindow contentView] setNeedsDisplay: YES];
618 [m_macWindow orderOut:nil];
622 bool wxNonOwnedWindowCocoaImpl::ShowWithEffect(bool show,
626 return wxWidgetCocoaImpl::
627 ShowViewOrWindowWithEffect(m_wxPeer, show, effect, timeout);
630 void wxNonOwnedWindowCocoaImpl::Update()
632 [m_macWindow displayIfNeeded];
635 bool wxNonOwnedWindowCocoaImpl::SetTransparent(wxByte alpha)
637 [m_macWindow setAlphaValue:(CGFloat) alpha/255.0];
641 bool wxNonOwnedWindowCocoaImpl::SetBackgroundColour(const wxColour& WXUNUSED(col) )
646 void wxNonOwnedWindowCocoaImpl::SetExtraStyle( long exStyle )
650 bool metal = exStyle & wxFRAME_EX_METAL ;
651 int windowStyle = [ m_macWindow styleMask];
652 if ( metal && !(windowStyle & NSTexturedBackgroundWindowMask) )
654 wxFAIL_MSG( wxT("Metal Style cannot be changed after creation") );
656 else if ( !metal && (windowStyle & NSTexturedBackgroundWindowMask ) )
658 wxFAIL_MSG( wxT("Metal Style cannot be changed after creation") );
663 void wxNonOwnedWindowCocoaImpl::SetWindowStyleFlag( long style )
667 CGWindowLevel level = kCGNormalWindowLevel;
669 if (style & wxSTAY_ON_TOP)
670 level = kCGUtilityWindowLevel;
671 else if (( style & wxFRAME_FLOAT_ON_PARENT ) || ( style & wxFRAME_TOOL_WINDOW ))
672 level = kCGFloatingWindowLevel;
674 [m_macWindow setLevel: level];
678 bool wxNonOwnedWindowCocoaImpl::SetBackgroundStyle(wxBackgroundStyle style)
680 if ( style == wxBG_STYLE_TRANSPARENT )
682 [m_macWindow setOpaque:NO];
683 [m_macWindow setBackgroundColor:[NSColor clearColor]];
689 bool wxNonOwnedWindowCocoaImpl::CanSetTransparent()
694 void wxNonOwnedWindowCocoaImpl::MoveWindow(int x, int y, int width, int height)
696 NSRect r = wxToNSRect( NULL, wxRect(x,y,width, height) );
697 // do not trigger refreshes upon invisible and possible partly created objects
698 [m_macWindow setFrame:r display:GetWXPeer()->IsShownOnScreen()];
701 void wxNonOwnedWindowCocoaImpl::GetPosition( int &x, int &y ) const
703 wxRect r = wxFromNSRect( NULL, [m_macWindow frame] );
708 void wxNonOwnedWindowCocoaImpl::GetSize( int &width, int &height ) const
710 NSRect rect = [m_macWindow frame];
711 width = (int)rect.size.width;
712 height = (int)rect.size.height;
715 void wxNonOwnedWindowCocoaImpl::GetContentArea( int& left, int &top, int &width, int &height ) const
717 NSRect outer = NSMakeRect(100,100,100,100);
718 NSRect content = [NSWindow contentRectForFrameRect:outer styleMask:[m_macWindow styleMask] ];
719 NSRect rect = [[m_macWindow contentView] frame];
720 left = (int)rect.origin.x;
721 top = (int)rect.origin.y;
722 width = (int)rect.size.width;
723 height = (int)rect.size.height;
726 bool wxNonOwnedWindowCocoaImpl::SetShape(const wxRegion& WXUNUSED(region))
728 [m_macWindow setOpaque:NO];
729 [m_macWindow setBackgroundColor:[NSColor clearColor]];
734 void wxNonOwnedWindowCocoaImpl::SetTitle( const wxString& title, wxFontEncoding encoding )
736 [m_macWindow setTitle:wxCFStringRef( title , encoding ).AsNSString()];
739 bool wxNonOwnedWindowCocoaImpl::IsMaximized() const
741 if (([m_macWindow styleMask] & NSResizableWindowMask) != 0)
743 return [m_macWindow isZoomed];
747 NSRect rectScreen = [[NSScreen mainScreen] visibleFrame];
748 NSRect rectWindow = [m_macWindow frame];
749 return (rectScreen.origin.x == rectWindow.origin.x &&
750 rectScreen.origin.y == rectWindow.origin.y &&
751 rectScreen.size.width == rectWindow.size.width &&
752 rectScreen.size.height == rectWindow.size.height);
756 bool wxNonOwnedWindowCocoaImpl::IsIconized() const
758 return [m_macWindow isMiniaturized];
761 void wxNonOwnedWindowCocoaImpl::Iconize( bool iconize )
764 [m_macWindow miniaturize:nil];
766 [m_macWindow deminiaturize:nil];
769 void wxNonOwnedWindowCocoaImpl::Maximize(bool WXUNUSED(maximize))
771 [m_macWindow zoom:nil];
775 // http://cocoadevcentral.com/articles/000028.php
780 NSRect m_formerFrame;
783 bool wxNonOwnedWindowCocoaImpl::IsFullScreen() const
785 return m_macFullScreenData != NULL ;
788 bool wxNonOwnedWindowCocoaImpl::ShowFullScreen(bool show, long WXUNUSED(style))
792 FullScreenData *data = (FullScreenData *)m_macFullScreenData ;
794 data = new FullScreenData();
796 m_macFullScreenData = data ;
797 data->m_formerLevel = [m_macWindow level];
798 data->m_formerFrame = [m_macWindow frame];
799 CGDisplayCapture( kCGDirectMainDisplay );
800 [m_macWindow setLevel:CGShieldingWindowLevel()];
801 NSRect screenframe = [[NSScreen mainScreen] frame];
802 NSRect frame = NSMakeRect (0, 0, 100, 100);
804 contentRect = [NSWindow contentRectForFrameRect: frame
805 styleMask: NSTitledWindowMask];
806 screenframe.origin.y += (frame.origin.y - contentRect.origin.y);
807 screenframe.size.height += (frame.size.height - contentRect.size.height);
808 [m_macWindow setFrame:screenframe display:YES];
810 else if ( m_macFullScreenData != NULL )
812 FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
813 CGDisplayRelease( kCGDirectMainDisplay );
814 [m_macWindow setLevel:data->m_formerLevel];
815 [m_macWindow setFrame:data->m_formerFrame display:YES];
817 m_macFullScreenData = NULL ;
823 void wxNonOwnedWindowCocoaImpl::RequestUserAttention(int flagsWX)
825 NSRequestUserAttentionType flagsOSX;
828 case wxUSER_ATTENTION_INFO:
829 flagsOSX = NSInformationalRequest;
832 case wxUSER_ATTENTION_ERROR:
833 flagsOSX = NSCriticalRequest;
837 wxFAIL_MSG( "invalid RequestUserAttention() flags" );
841 [NSApp requestUserAttention:flagsOSX];
844 void wxNonOwnedWindowCocoaImpl::ScreenToWindow( int *x, int *y )
846 wxPoint p((x ? *x : 0), (y ? *y : 0) );
847 NSPoint nspt = wxToNSPoint( NULL, p );
848 nspt = [m_macWindow convertScreenToBase:nspt];
849 nspt = [[m_macWindow contentView] convertPoint:nspt fromView:nil];
850 p = wxFromNSPoint([m_macWindow contentView], nspt);
857 void wxNonOwnedWindowCocoaImpl::WindowToScreen( int *x, int *y )
859 wxPoint p((x ? *x : 0), (y ? *y : 0) );
860 NSPoint nspt = wxToNSPoint( [m_macWindow contentView], p );
861 nspt = [[m_macWindow contentView] convertPoint:nspt toView:nil];
862 nspt = [m_macWindow convertBaseToScreen:nspt];
863 p = wxFromNSPoint( NULL, nspt);
870 bool wxNonOwnedWindowCocoaImpl::IsActive()
872 return [m_macWindow isKeyWindow];
875 void wxNonOwnedWindowCocoaImpl::SetModified(bool modified)
877 [m_macWindow setDocumentEdited:modified];
880 bool wxNonOwnedWindowCocoaImpl::IsModified() const
882 return [m_macWindow isDocumentEdited];
885 wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow nativeWindow)
887 wxNonOwnedWindowCocoaImpl* now = new wxNonOwnedWindowCocoaImpl( wxpeer );
888 now->Create( parent, nativeWindow );
892 wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
893 long style, long extraStyle, const wxString& name )
895 wxNonOwnedWindowImpl* now = new wxNonOwnedWindowCocoaImpl( wxpeer );
896 now->Create( parent, pos, size, style , extraStyle, name );