]> git.saurik.com Git - wxWidgets.git/blob - src/osx/cocoa/nonownedwnd.mm
64bit builds had problems with full circles, as we can use 10.4+ only APIs, use new...
[wxWidgets.git] / src / osx / cocoa / nonownedwnd.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/nonownedwnd.mm
3 // Purpose: non owned window for cocoa
4 // Author: DavidStefan Csomor
5 // Modified by:
6 // Created: 2008-06-20
7 // RCS-ID: $Id: nonownedwnd.mm 48805 2007-09-19 14:52:25Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13 #ifndef WX_PRECOMP
14 #include "wx/nonownedwnd.h"
15 #include "wx/frame.h"
16 #endif
17
18 #include "wx/osx/private.h"
19
20 NSRect wxToNSRect( NSView* parent, const wxRect& r )
21 {
22 NSRect frame = parent ? [parent bounds] : [[NSScreen mainScreen] frame];
23 int y = r.y;
24 int x = r.x ;
25 if ( parent == NULL || ![ parent isFlipped ] )
26 y = (int)(frame.size.height - ( r.y + r.height ));
27 return NSMakeRect(x, y, r.width , r.height);
28 }
29
30 wxRect wxFromNSRect( NSView* parent, const NSRect& rect )
31 {
32 NSRect frame = parent ? [parent bounds] : [[NSScreen mainScreen] frame];
33 int y = (int)rect.origin.y;
34 int x = (int)rect.origin.x;
35 if ( parent == NULL || ![ parent isFlipped ] )
36 y = (int)(frame.size.height - (rect.origin.y + rect.size.height));
37 return wxRect( x, y, (int)rect.size.width, (int)rect.size.height );
38 }
39
40 NSPoint wxToNSPoint( NSView* parent, const wxPoint& p )
41 {
42 NSRect frame = parent ? [parent bounds] : [[NSScreen mainScreen] frame];
43 int x = p.x ;
44 int y = p.y;
45 if ( parent == NULL || ![ parent isFlipped ] )
46 y = (int)(frame.size.height - ( p.y ));
47 return NSMakePoint(x, y);
48 }
49
50 wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p )
51 {
52 NSRect frame = parent ? [parent bounds] : [[NSScreen mainScreen] frame];
53 int x = (int)p.x;
54 int y = (int)p.y;
55 if ( parent == NULL || ![ parent isFlipped ] )
56 y = (int)(frame.size.height - ( p.y ));
57 return wxPoint( x, y);
58 }
59
60 bool shouldHandleSelector(SEL selector)
61 {
62 if (selector == @selector(noop:)
63 || selector == @selector(complete:)
64 || selector == @selector(deleteBackward:)
65 || selector == @selector(deleteForward:)
66 || selector == @selector(insertNewline:)
67 || selector == @selector(insertTab:)
68 || selector == @selector(keyDown:)
69 || selector == @selector(keyUp:)
70 || selector == @selector(scrollPageUp:)
71 || selector == @selector(scrollPageDown:)
72 || selector == @selector(scrollToBeginningOfDocument:)
73 || selector == @selector(scrollToEndOfDocument:))
74 return false;
75
76 return true;
77
78 }
79
80 //
81 // wx native implementation classes
82 //
83
84 typedef void (*wxOSX_NoResponderHandlerPtr)(NSView* self, SEL _cmd, SEL selector);
85
86 @interface wxNSWindow : NSWindow
87 {
88 wxNonOwnedWindowCocoaImpl* impl;
89 }
90
91 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen;
92 - (void)setImplementation: (wxNonOwnedWindowCocoaImpl *) theImplementation;
93 - (wxNonOwnedWindowCocoaImpl*) implementation;
94 - (void)noResponderFor: (SEL) selector;
95 @end
96
97 @implementation wxNSWindow
98
99 // The default implementation always moves the window back onto the screen,
100 // even when the programmer explicitly wants to hide it.
101 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
102 {
103 return frameRect;
104 }
105
106 - (void)setImplementation: (wxNonOwnedWindowCocoaImpl *) theImplementation
107 {
108 impl = theImplementation;
109 }
110
111 - (wxNonOwnedWindowCocoaImpl*) implementation
112 {
113 return impl;
114 }
115
116 - (void)doCommandBySelector:(SEL)selector
117 {
118 if (shouldHandleSelector(selector) &&
119 !(selector == @selector(cancel:) || selector == @selector(cancelOperation:)) )
120 [super doCommandBySelector:selector];
121 }
122
123
124 // NB: if we don't do this, all key downs that get handled lead to a NSBeep
125 - (void)noResponderFor: (SEL) selector
126 {
127 if (selector != @selector(keyDown:) && selector != @selector(keyUp:))
128 {
129 [super noResponderFor:selector];
130 // wxOSX_NoResponderHandlerPtr superimpl = (wxOSX_NoResponderHandlerPtr) [[self superclass] instanceMethodForSelector:@selector(noResponderFor:)];
131 // superimpl(self, @selector(noResponderFor:), selector);
132 }
133 }
134
135 @end
136
137 @interface wxNSPanel : NSPanel
138
139 {
140 wxNonOwnedWindowCocoaImpl* impl;
141 }
142
143 - (void)setImplementation: (wxNonOwnedWindowCocoaImpl *) theImplementation;
144 - (wxNonOwnedWindowCocoaImpl*) implementation;
145 - (void)noResponderFor: (SEL) selector;
146 @end
147
148 @implementation wxNSPanel
149
150 - (void)setImplementation: (wxNonOwnedWindowCocoaImpl *) theImplementation
151 {
152 impl = theImplementation;
153 }
154
155 - (BOOL)canBecomeKeyWindow
156 {
157 return YES;
158 }
159
160 - (wxNonOwnedWindowCocoaImpl*) implementation
161 {
162 return impl;
163 }
164
165 - (void)doCommandBySelector:(SEL)selector
166 {
167 if (shouldHandleSelector(selector))
168 [super doCommandBySelector:selector];
169 }
170
171 // NB: if we don't do this, it seems that all events that end here lead to a NSBeep
172 - (void)noResponderFor: (SEL) selector
173 {
174 if (selector != @selector(keyDown:) && selector != @selector(keyUp:))
175 {
176 [super noResponderFor:selector];
177 // wxOSX_NoResponderHandlerPtr superimpl = (wxOSX_NoResponderHandlerPtr) [[self superclass] instanceMethodForSelector:@selector(noResponderFor:)];
178 // superimpl(self, @selector(noResponderFor:), selector);
179 }
180 }
181
182 @end
183
184
185 //
186 // controller
187 //
188
189 @interface wxNonOwnedWindowController : NSObject
190 {
191 }
192
193 - (void)windowDidResize:(NSNotification *)notification;
194 - (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
195 - (void)windowDidResignKey:(NSNotification *)notification;
196 - (void)windowDidBecomeKey:(NSNotification *)notification;
197 - (void)windowDidMove:(NSNotification *)notification;
198 - (BOOL)windowShouldClose:(id)window;
199
200 @end
201
202 @implementation wxNonOwnedWindowController
203
204 - (id) init
205 {
206 [super init];
207 return self;
208 }
209
210 - (BOOL)windowShouldClose:(id)nwindow
211 {
212 wxNSWindow* window = (wxNSWindow*) nwindow;
213 wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
214 if ( windowimpl )
215 {
216 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
217 if ( wxpeer )
218 wxpeer->Close();
219 }
220 return NO;
221 }
222
223 - (NSSize)windowWillResize:(NSWindow *)win
224 toSize:(NSSize)proposedFrameSize
225 {
226 NSRect frame = [win frame];
227 wxRect wxframe = wxFromNSRect( NULL, frame );
228 wxframe.SetWidth( (int)proposedFrameSize.width );
229 wxframe.SetHeight( (int)proposedFrameSize.height );
230 wxNSWindow* window = (wxNSWindow*) win;
231 wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
232 if ( windowimpl )
233 {
234 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
235 if ( wxpeer )
236 {
237 wxpeer->HandleResizing( 0, &wxframe );
238 NSSize newSize = NSMakeSize(wxframe.GetWidth(), wxframe.GetHeight());
239 return newSize;
240 }
241 }
242
243 return proposedFrameSize;
244 }
245
246 - (void)windowDidResize:(NSNotification *)notification
247 {
248 wxNSWindow* window = (wxNSWindow*) [notification object];
249 wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
250 if ( windowimpl )
251 {
252 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
253 if ( wxpeer )
254 wxpeer->HandleResized(0);
255 }
256 }
257
258 - (void)windowDidMove:(NSNotification *)notification
259 {
260 wxNSWindow* window = (wxNSWindow*) [notification object];
261 wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
262 if ( windowimpl )
263 {
264 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
265 if ( wxpeer )
266 wxpeer->HandleMoved(0);
267 }
268 }
269
270 - (void)windowDidBecomeKey:(NSNotification *)notification
271 {
272 wxNSWindow* window = (wxNSWindow*) [notification object];
273 wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
274 if ( windowimpl )
275 {
276 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
277 if ( wxpeer )
278 wxpeer->HandleActivated(0, true);
279 }
280 }
281
282 - (void)windowDidResignKey:(NSNotification *)notification
283 {
284 wxNSWindow* window = (wxNSWindow*) [notification object];
285 wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation];
286 if ( windowimpl )
287 {
288 wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer();
289 if ( wxpeer )
290 {
291 wxpeer->HandleActivated(0, false);
292 // Needed for popup window since the firstResponder
293 // (focus in wx) doesn't change when this
294 // TLW becomes inactive.
295 wxFocusEvent event( wxEVT_KILL_FOCUS, wxpeer->GetId());
296 event.SetEventObject(wxpeer);
297 wxpeer->HandleWindowEvent(event);
298 }
299 }
300 }
301
302 - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject
303 {
304 wxUnusedVar(sender);
305
306 if ([anObject isKindOfClass:[wxNSTextField class]])
307 {
308 wxNSTextField* tf = (wxNSTextField*) anObject;
309 wxNSTextFieldEditor* editor = [tf fieldEditor];
310 if ( editor == nil )
311 {
312 editor = [[wxNSTextFieldEditor alloc] init];
313 [editor setFieldEditor:YES];
314 [tf setFieldEditor:editor];
315 }
316 return editor;
317 }
318
319 return nil;
320 }
321
322 @end
323
324 IMPLEMENT_DYNAMIC_CLASS( wxNonOwnedWindowCocoaImpl , wxNonOwnedWindowImpl )
325
326 wxNonOwnedWindowCocoaImpl::wxNonOwnedWindowCocoaImpl( wxNonOwnedWindow* nonownedwnd) :
327 wxNonOwnedWindowImpl(nonownedwnd)
328 {
329 m_macWindow = NULL;
330 m_macFullScreenData = NULL;
331 }
332
333 wxNonOwnedWindowCocoaImpl::wxNonOwnedWindowCocoaImpl()
334 {
335 m_macWindow = NULL;
336 m_macFullScreenData = NULL;
337 }
338
339 wxNonOwnedWindowCocoaImpl::~wxNonOwnedWindowCocoaImpl()
340 {
341 [m_macWindow setImplementation:nil];
342 [m_macWindow setDelegate:nil];
343 [m_macWindow release];
344 }
345
346 void wxNonOwnedWindowCocoaImpl::Destroy()
347 {
348 wxPendingDelete.Append( new wxDeferredObjectDeleter( this ) );
349 }
350
351 void wxNonOwnedWindowCocoaImpl::Create( wxWindow* WXUNUSED(parent), const wxPoint& pos, const wxSize& size,
352 long style, long extraStyle, const wxString& WXUNUSED(name) )
353 {
354 static wxNonOwnedWindowController* controller = NULL;
355
356 if ( !controller )
357 controller =[[wxNonOwnedWindowController alloc] init];
358
359
360 int windowstyle = NSBorderlessWindowMask;
361
362 if ( style & wxFRAME_TOOL_WINDOW || ( style & wxPOPUP_WINDOW ) ||
363 GetWXPeer()->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG )
364 {
365 m_macWindow = [wxNSPanel alloc];
366 }
367 else
368 m_macWindow = [wxNSWindow alloc];
369
370 CGWindowLevel level = kCGNormalWindowLevel;
371
372 if ( style & wxFRAME_TOOL_WINDOW )
373 {
374 windowstyle |= NSUtilityWindowMask;
375 if ( ( style & wxMINIMIZE_BOX ) || ( style & wxMAXIMIZE_BOX ) ||
376 ( style & wxCLOSE_BOX ) || ( style & wxSYSTEM_MENU ) )
377 {
378 windowstyle |= NSTitledWindowMask ;
379 }
380 }
381 else if ( ( style & wxPOPUP_WINDOW ) )
382 {
383 level = kCGPopUpMenuWindowLevel;
384 /*
385 if ( ( style & wxBORDER_NONE ) )
386 {
387 wclass = kHelpWindowClass ; // has no border
388 attr |= kWindowNoShadowAttribute;
389 }
390 else
391 {
392 wclass = kPlainWindowClass ; // has a single line border, it will have to do for now
393 }
394 */
395 }
396 else if ( ( style & wxCAPTION ) )
397 {
398 windowstyle |= NSTitledWindowMask ;
399 }
400 else if ( ( style & wxFRAME_DRAWER ) )
401 {
402 /*
403 wclass = kDrawerWindowClass;
404 */
405 }
406 else
407 {
408 // set these even if we have no title, otherwise the controls won't be visible
409 if ( ( style & wxMINIMIZE_BOX ) || ( style & wxMAXIMIZE_BOX ) ||
410 ( style & wxCLOSE_BOX ) || ( style & wxSYSTEM_MENU ) )
411 {
412 windowstyle |= NSTitledWindowMask ;
413 }
414 /*
415 else if ( ( style & wxNO_BORDER ) )
416 {
417 wclass = kSimpleWindowClass ;
418 }
419 else
420 {
421 wclass = kPlainWindowClass ;
422 }
423 */
424 }
425
426 if ( windowstyle & NSTitledWindowMask )
427 {
428 if ( ( style & wxMINIMIZE_BOX ) )
429 windowstyle |= NSMiniaturizableWindowMask ;
430
431 if ( ( style & wxMAXIMIZE_BOX ) )
432 windowstyle |= NSResizableWindowMask ; // TODO showing ZOOM ?
433
434 if ( ( style & wxRESIZE_BORDER ) )
435 windowstyle |= NSResizableWindowMask ;
436
437 if ( ( style & wxCLOSE_BOX) )
438 windowstyle |= NSClosableWindowMask ;
439 }
440 if ( extraStyle & wxFRAME_EX_METAL)
441 windowstyle |= NSTexturedBackgroundWindowMask;
442
443 if ( ( style & wxFRAME_FLOAT_ON_PARENT ) || ( style & wxFRAME_TOOL_WINDOW ) )
444 level = kCGFloatingWindowLevel;
445
446 if ( ( style & wxSTAY_ON_TOP ) )
447 level = kCGUtilityWindowLevel;
448
449 NSRect r = wxToNSRect( NULL, wxRect( pos, size) );
450
451 [m_macWindow setImplementation:this];
452 r = [NSWindow contentRectForFrameRect:r styleMask:windowstyle];
453
454 [m_macWindow initWithContentRect:r
455 styleMask:windowstyle
456 backing:NSBackingStoreBuffered
457 defer:NO
458 ];
459
460 [m_macWindow setLevel:level];
461
462 [m_macWindow setDelegate:controller];
463
464 [m_macWindow setAcceptsMouseMovedEvents: YES];
465 }
466
467
468 WXWindow wxNonOwnedWindowCocoaImpl::GetWXWindow() const
469 {
470 return m_macWindow;
471 }
472
473 void wxNonOwnedWindowCocoaImpl::Raise()
474 {
475 [m_macWindow orderWindow:NSWindowAbove relativeTo:0];
476 }
477
478 void wxNonOwnedWindowCocoaImpl::Lower()
479 {
480 [m_macWindow orderWindow:NSWindowBelow relativeTo:0];
481 }
482
483 void wxNonOwnedWindowCocoaImpl::ShowWithoutActivating()
484 {
485 [m_macWindow orderBack:nil];
486 [[m_macWindow contentView] setNeedsDisplay: YES];
487 }
488
489 bool wxNonOwnedWindowCocoaImpl::Show(bool show)
490 {
491 if ( show )
492 {
493 wxNonOwnedWindow* wxpeer = GetWXPeer();
494 if (wxpeer && !(wxpeer->GetWindowStyle() & wxFRAME_TOOL_WINDOW))
495 [m_macWindow makeKeyAndOrderFront:nil];
496 else
497 [m_macWindow orderFront:nil];
498 [[m_macWindow contentView] setNeedsDisplay: YES];
499 }
500 else
501 [m_macWindow orderOut:nil];
502 return true;
503 }
504
505 bool wxNonOwnedWindowCocoaImpl::ShowWithEffect(bool show,
506 wxShowEffect effect,
507 unsigned timeout)
508 {
509 return wxWidgetCocoaImpl::
510 ShowViewOrWindowWithEffect(m_wxPeer, show, effect, timeout);
511 }
512
513 void wxNonOwnedWindowCocoaImpl::Update()
514 {
515 [m_macWindow displayIfNeeded];
516 }
517
518 bool wxNonOwnedWindowCocoaImpl::SetTransparent(wxByte alpha)
519 {
520 [m_macWindow setAlphaValue:(CGFloat) alpha/255.0];
521 return true;
522 }
523
524 bool wxNonOwnedWindowCocoaImpl::SetBackgroundColour(const wxColour& WXUNUSED(col) )
525 {
526 return true;
527 }
528
529 void wxNonOwnedWindowCocoaImpl::SetExtraStyle( long exStyle )
530 {
531 if ( m_macWindow )
532 {
533 bool metal = exStyle & wxFRAME_EX_METAL ;
534 int windowStyle = [ m_macWindow styleMask];
535 if ( metal && !(windowStyle & NSTexturedBackgroundWindowMask) )
536 {
537 wxFAIL_MSG( wxT("Metal Style cannot be changed after creation") );
538 }
539 else if ( !metal && (windowStyle & NSTexturedBackgroundWindowMask ) )
540 {
541 wxFAIL_MSG( wxT("Metal Style cannot be changed after creation") );
542 }
543 }
544 }
545
546 void wxNonOwnedWindowCocoaImpl::SetWindowStyleFlag( long style )
547 {
548 if (m_macWindow)
549 {
550 CGWindowLevel level = kCGNormalWindowLevel;
551
552 if (style & wxSTAY_ON_TOP)
553 level = kCGUtilityWindowLevel;
554 else if (( style & wxFRAME_FLOAT_ON_PARENT ) || ( style & wxFRAME_TOOL_WINDOW ))
555 level = kCGFloatingWindowLevel;
556
557 [m_macWindow setLevel: level];
558 }
559 }
560
561 bool wxNonOwnedWindowCocoaImpl::SetBackgroundStyle(wxBackgroundStyle style)
562 {
563 if ( style == wxBG_STYLE_TRANSPARENT )
564 {
565 [m_macWindow setOpaque:NO];
566 [m_macWindow setBackgroundColor:[NSColor clearColor]];
567 }
568
569 return true;
570 }
571
572 bool wxNonOwnedWindowCocoaImpl::CanSetTransparent()
573 {
574 return true;
575 }
576
577 void wxNonOwnedWindowCocoaImpl::MoveWindow(int x, int y, int width, int height)
578 {
579 NSRect r = wxToNSRect( NULL, wxRect(x,y,width, height) );
580 // do not trigger refreshes upon invisible and possible partly created objects
581 [m_macWindow setFrame:r display:GetWXPeer()->IsShownOnScreen()];
582 }
583
584 void wxNonOwnedWindowCocoaImpl::GetPosition( int &x, int &y ) const
585 {
586 wxRect r = wxFromNSRect( NULL, [m_macWindow frame] );
587 x = r.GetLeft();
588 y = r.GetTop();
589 }
590
591 void wxNonOwnedWindowCocoaImpl::GetSize( int &width, int &height ) const
592 {
593 NSRect rect = [m_macWindow frame];
594 width = (int)rect.size.width;
595 height = (int)rect.size.height;
596 }
597
598 void wxNonOwnedWindowCocoaImpl::GetContentArea( int& left, int &top, int &width, int &height ) const
599 {
600 NSRect outer = NSMakeRect(100,100,100,100);
601 NSRect content = [NSWindow contentRectForFrameRect:outer styleMask:[m_macWindow styleMask] ];
602 NSRect rect = [[m_macWindow contentView] frame];
603 left = (int)rect.origin.x;
604 top = (int)rect.origin.y;
605 width = (int)rect.size.width;
606 height = (int)rect.size.height;
607 }
608
609 bool wxNonOwnedWindowCocoaImpl::SetShape(const wxRegion& WXUNUSED(region))
610 {
611 [m_macWindow setOpaque:NO];
612 [m_macWindow setBackgroundColor:[NSColor clearColor]];
613
614 return true;
615 }
616
617 void wxNonOwnedWindowCocoaImpl::SetTitle( const wxString& title, wxFontEncoding encoding )
618 {
619 [m_macWindow setTitle:wxCFStringRef( title , encoding ).AsNSString()];
620 }
621
622 bool wxNonOwnedWindowCocoaImpl::IsMaximized() const
623 {
624 return [m_macWindow isZoomed];
625 }
626
627 bool wxNonOwnedWindowCocoaImpl::IsIconized() const
628 {
629 return [m_macWindow isMiniaturized];
630 }
631
632 void wxNonOwnedWindowCocoaImpl::Iconize( bool iconize )
633 {
634 if ( iconize )
635 [m_macWindow miniaturize:nil];
636 else
637 [m_macWindow deminiaturize:nil];
638 }
639
640 void wxNonOwnedWindowCocoaImpl::Maximize(bool WXUNUSED(maximize))
641 {
642 [m_macWindow zoom:nil];
643 }
644
645
646 // http://cocoadevcentral.com/articles/000028.php
647
648 typedef struct
649 {
650 int m_formerLevel;
651 NSRect m_formerFrame;
652 } FullScreenData ;
653
654 bool wxNonOwnedWindowCocoaImpl::IsFullScreen() const
655 {
656 return m_macFullScreenData != NULL ;
657 }
658
659 bool wxNonOwnedWindowCocoaImpl::ShowFullScreen(bool show, long WXUNUSED(style))
660 {
661 if ( show )
662 {
663 FullScreenData *data = (FullScreenData *)m_macFullScreenData ;
664 delete data ;
665 data = new FullScreenData();
666
667 m_macFullScreenData = data ;
668 data->m_formerLevel = [m_macWindow level];
669 data->m_formerFrame = [m_macWindow frame];
670 CGDisplayCapture( kCGDirectMainDisplay );
671 [m_macWindow setLevel:CGShieldingWindowLevel()];
672 [m_macWindow setFrame:[[NSScreen mainScreen] frame] display:YES];
673 }
674 else if ( m_macFullScreenData != NULL )
675 {
676 FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
677 CGDisplayRelease( kCGDirectMainDisplay );
678 [m_macWindow setLevel:data->m_formerLevel];
679 [m_macWindow setFrame:data->m_formerFrame display:YES];
680 delete data ;
681 m_macFullScreenData = NULL ;
682 }
683
684 return true;
685 }
686
687 void wxNonOwnedWindowCocoaImpl::RequestUserAttention(int WXUNUSED(flags))
688 {
689 }
690
691 void wxNonOwnedWindowCocoaImpl::ScreenToWindow( int *x, int *y )
692 {
693 wxPoint p((x ? *x : 0), (y ? *y : 0) );
694 NSPoint nspt = wxToNSPoint( NULL, p );
695 nspt = [m_macWindow convertScreenToBase:nspt];
696 nspt = [[m_macWindow contentView] convertPoint:nspt fromView:nil];
697 p = wxFromNSPoint([m_macWindow contentView], nspt);
698 if ( x )
699 *x = p.x;
700 if ( y )
701 *y = p.y;
702 }
703
704 void wxNonOwnedWindowCocoaImpl::WindowToScreen( int *x, int *y )
705 {
706 wxPoint p((x ? *x : 0), (y ? *y : 0) );
707 NSPoint nspt = wxToNSPoint( [m_macWindow contentView], p );
708 nspt = [[m_macWindow contentView] convertPoint:nspt toView:nil];
709 nspt = [m_macWindow convertBaseToScreen:nspt];
710 p = wxFromNSPoint( NULL, nspt);
711 if ( x )
712 *x = p.x;
713 if ( y )
714 *y = p.y;
715 }
716
717 bool wxNonOwnedWindowCocoaImpl::IsActive()
718 {
719 return [m_macWindow isKeyWindow];
720 }
721
722 wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
723 long style, long extraStyle, const wxString& name )
724 {
725 wxNonOwnedWindowImpl* now = new wxNonOwnedWindowCocoaImpl( wxpeer );
726 now->Create( parent, pos, size, style , extraStyle, name );
727 return now;
728 }