]> git.saurik.com Git - wxWidgets.git/blob - src/osx/cocoa/window.mm
a358f96dcaf13ee125eb14be889adddf66cb0584
[wxWidgets.git] / src / osx / cocoa / window.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/window.mm
3 // Purpose: widgets (non tlw) for cocoa
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 2008-06-20
7 // RCS-ID: $Id: window.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
14 #include <Cocoa/Cocoa.h>
15
16 #ifdef __WXMAC__
17 #include "wx/osx/private.h"
18 #endif
19
20 NSRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin )
21 {
22 int x, y, w, h ;
23
24 window->MacGetBoundsForControl( pos , size , x , y, w, h , adjustForOrigin ) ;
25 wxRect bounds(x,y,w,h);
26 NSView* sv = (window->GetParent()->GetHandle() );
27
28 return wxToNSRect( sv, bounds );
29 }
30
31 @interface wxNSView : NSView
32 {
33 wxWidgetImpl* impl;
34 }
35
36 - (void)drawRect: (NSRect) rect;
37
38 -(void)mouseDown:(NSEvent *)event ;
39 -(void)rightMouseDown:(NSEvent *)event ;
40 -(void)otherMouseDown:(NSEvent *)event ;
41 -(void)mouseUp:(NSEvent *)event ;
42 -(void)rightMouseUp:(NSEvent *)event ;
43 -(void)otherMouseUp:(NSEvent *)event ;
44 -(void)handleMouseEvent:(NSEvent *)event;
45
46 - (void)keyDown:(NSEvent *)event;
47 - (void)keyUp:(NSEvent *)event;
48 - (void)flagsChanged:(NSEvent *)event;
49 - (void)handleKeyEvent:(NSEvent *)event;
50
51 - (void)setImplementation: (wxWidgetImpl *) theImplementation;
52 - (wxWidgetImpl*) implementation;
53 - (BOOL) isFlipped;
54 - (BOOL) becomeFirstResponder;
55 - (BOOL) resignFirstResponder;
56 - (BOOL) canBecomeKeyView;
57
58 @end // wxNSView
59
60 long wxOSXTranslateCocoaKey(unsigned short code, int unichar )
61 {
62 long retval = code;
63 switch( unichar )
64 {
65 case NSUpArrowFunctionKey :
66 retval = WXK_UP;
67 break;
68 case NSDownArrowFunctionKey :
69 retval = WXK_DOWN;
70 break;
71 case NSLeftArrowFunctionKey :
72 retval = WXK_LEFT;
73 break;
74 case NSRightArrowFunctionKey :
75 retval = WXK_RIGHT;
76 break;
77 case NSInsertFunctionKey :
78 retval = WXK_INSERT;
79 break;
80 case NSDeleteFunctionKey :
81 retval = WXK_DELETE;
82 break;
83 case NSHomeFunctionKey :
84 retval = WXK_HOME;
85 break;
86 // case NSBeginFunctionKey :
87 // retval = WXK_BEGIN;
88 // break;
89 case NSEndFunctionKey :
90 retval = WXK_END;
91 break;
92 case NSPageUpFunctionKey :
93 retval = WXK_PAGEUP;
94 break;
95 case NSPageDownFunctionKey :
96 retval = WXK_PAGEDOWN;
97 break;
98 case NSHelpFunctionKey :
99 retval = WXK_HELP;
100 break;
101
102 default :
103 if ( unichar >= NSF1FunctionKey && unichar >= NSF24FunctionKey )
104 retval = WXK_F1 + (unichar - NSF1FunctionKey );
105 break;
106 }
107 return retval;
108 }
109
110 void SetupKeyEvent( wxKeyEvent &wxevent , NSEvent * nsEvent )
111 {
112 UInt32 modifiers = [nsEvent modifierFlags] ;
113
114 wxevent.m_shiftDown = modifiers & NSShiftKeyMask;
115 wxevent.m_controlDown = modifiers & NSControlKeyMask;
116 wxevent.m_altDown = modifiers & NSAlternateKeyMask;
117 wxevent.m_metaDown = modifiers & NSCommandKeyMask;
118
119 wxString chars;
120 NSString* nschars = [nsEvent characters];
121 if ( nschars )
122 {
123 wxCFStringRef cfchars((CFStringRef)[nschars retain]);
124 chars = cfchars.AsString();
125 }
126
127 int unichar = chars.Length() > 0 ? chars[0] : 0;
128
129 #if wxUSE_UNICODE
130 wxevent.m_uniChar = unichar;
131 #endif
132 wxevent.m_keyCode = wxOSXTranslateCocoaKey( [nsEvent keyCode], unichar ) ;
133 // wxevent.m_rawCode = keymessage;
134 wxevent.m_rawFlags = modifiers;
135
136 wxevent.SetTimestamp( [nsEvent timestamp] * 1000.0 ) ;
137 int eventType = [nsEvent type];
138 switch (eventType)
139 {
140 case NSKeyDown :
141 wxevent.SetEventType( wxEVT_KEY_DOWN ) ;
142 break;
143 case NSKeyUp :
144 wxevent.SetEventType( wxEVT_KEY_UP ) ;
145 break;
146 case NSFlagsChanged :
147 // setup common code here
148 break;
149 default :
150 break ;
151 }
152 }
153
154 void SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEvent )
155 {
156 UInt32 modifiers = [nsEvent modifierFlags] ;
157 wxPoint screenMouseLocation = wxFromNSPoint( NULL, [nsEvent locationInWindow]);
158
159 // these parameters are not given for all events
160 UInt32 button = [nsEvent buttonNumber];
161 UInt32 clickCount = [nsEvent clickCount];
162 UInt32 mouseChord = 0; // TODO does this exist for cocoa
163
164 wxevent.m_x = screenMouseLocation.x;
165 wxevent.m_y = screenMouseLocation.y;
166 wxevent.m_shiftDown = modifiers & NSShiftKeyMask;
167 wxevent.m_controlDown = modifiers & NSControlKeyMask;
168 wxevent.m_altDown = modifiers & NSAlternateKeyMask;
169 wxevent.m_metaDown = modifiers & NSCommandKeyMask;
170 wxevent.m_clickCount = clickCount;
171 wxevent.SetTimestamp( [nsEvent timestamp] * 1000.0 ) ;
172 /*
173 // a control click is interpreted as a right click
174 bool thisButtonIsFakeRight = false ;
175 if ( button == kEventMouseButtonPrimary && (modifiers & controlKey) )
176 {
177 button = kEventMouseButtonSecondary ;
178 thisButtonIsFakeRight = true ;
179 }
180
181 // otherwise we report double clicks by connecting a left click with a ctrl-left click
182 if ( clickCount > 1 && button != g_lastButton )
183 clickCount = 1 ;
184 // we must make sure that our synthetic 'right' button corresponds in
185 // mouse down, moved and mouse up, and does not deliver a right down and left up
186
187 if ( cEvent.GetKind() == kEventMouseDown )
188 {
189 g_lastButton = button ;
190 g_lastButtonWasFakeRight = thisButtonIsFakeRight ;
191 }
192
193 if ( button == 0 )
194 {
195 g_lastButton = 0 ;
196 g_lastButtonWasFakeRight = false ;
197 }
198 else if ( g_lastButton == kEventMouseButtonSecondary && g_lastButtonWasFakeRight )
199 button = g_lastButton ;
200
201 // Adjust the chord mask to remove the primary button and add the
202 // secondary button. It is possible that the secondary button is
203 // already pressed, e.g. on a mouse connected to a laptop, but this
204 // possibility is ignored here:
205 if( thisButtonIsFakeRight && ( mouseChord & 1U ) )
206 mouseChord = ((mouseChord & ~1U) | 2U);
207
208 if(mouseChord & 1U)
209 wxevent.m_leftDown = true ;
210 if(mouseChord & 2U)
211 wxevent.m_rightDown = true ;
212 if(mouseChord & 4U)
213 wxevent.m_middleDown = true ;
214
215 */
216 // translate into wx types
217 int eventType = [nsEvent type];
218 switch (eventType)
219 {
220 case NSLeftMouseDown :
221 case NSRightMouseDown :
222 case NSOtherMouseDown :
223 switch ( button )
224 {
225 case 0 :
226 wxevent.SetEventType( clickCount > 1 ? wxEVT_LEFT_DCLICK : wxEVT_LEFT_DOWN ) ;
227 break ;
228
229 case 1 :
230 wxevent.SetEventType( clickCount > 1 ? wxEVT_RIGHT_DCLICK : wxEVT_RIGHT_DOWN ) ;
231 break ;
232
233 case 2 :
234 wxevent.SetEventType( clickCount > 1 ? wxEVT_MIDDLE_DCLICK : wxEVT_MIDDLE_DOWN ) ;
235 break ;
236
237 default:
238 break ;
239 }
240 break ;
241
242 case NSLeftMouseUp :
243 case NSRightMouseUp :
244 case NSOtherMouseUp :
245 switch ( button )
246 {
247 case 0 :
248 wxevent.SetEventType( wxEVT_LEFT_UP ) ;
249 break ;
250
251 case 1 :
252 wxevent.SetEventType( wxEVT_RIGHT_UP ) ;
253 break ;
254
255 case 2 :
256 wxevent.SetEventType( wxEVT_MIDDLE_UP ) ;
257 break ;
258
259 default:
260 break ;
261 }
262 break ;
263
264 case NSScrollWheel :
265 {
266 wxevent.SetEventType( wxEVT_MOUSEWHEEL ) ;
267 /*
268 EventMouseWheelAxis axis = cEvent.GetParameter<EventMouseWheelAxis>(kEventParamMouseWheelAxis, typeMouseWheelAxis) ;
269 SInt32 delta = cEvent.GetParameter<SInt32>(kEventParamMouseWheelDelta, typeSInt32) ;
270 */
271 wxevent.m_wheelRotation = 10; // delta;
272 wxevent.m_wheelDelta = 1;
273 wxevent.m_linesPerAction = 1;
274 if ( 0 /* axis == kEventMouseWheelAxisX*/ )
275 wxevent.m_wheelAxis = 1;
276 }
277 break ;
278
279 case NSMouseEntered :
280 case NSMouseExited :
281 case NSLeftMouseDragged :
282 case NSRightMouseDragged :
283 case NSOtherMouseDragged :
284 case NSMouseMoved :
285 wxevent.SetEventType( wxEVT_MOTION ) ;
286 break;
287 default :
288 break ;
289 }
290 }
291
292 @implementation wxNSView
293
294 #define OSX_DEBUG_DRAWING 0
295
296 - (void)drawRect: (NSRect) rect
297 {
298 if ( impl )
299 {
300 CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
301 CGContextSaveGState( context );
302 #if OSX_DEBUG_DRAWING
303 CGContextBeginPath( context );
304 CGContextMoveToPoint(context, 0, 0);
305 NSRect bounds = [self bounds];
306 CGContextAddLineToPoint(context, 10, 0);
307 CGContextMoveToPoint(context, 0, 0);
308 CGContextAddLineToPoint(context, 0, 10);
309 CGContextMoveToPoint(context, bounds.size.width, bounds.size.height);
310 CGContextAddLineToPoint(context, bounds.size.width, bounds.size.height-10);
311 CGContextMoveToPoint(context, bounds.size.width, bounds.size.height);
312 CGContextAddLineToPoint(context, bounds.size.width-10, bounds.size.height);
313 CGContextClosePath( context );
314 CGContextStrokePath(context);
315 #endif
316
317 if ( [ self isFlipped ] == NO )
318 {
319 CGContextTranslateCTM( context, 0, [self bounds].size.height );
320 CGContextScaleCTM( context, 1, -1 );
321 }
322
323 wxRegion updateRgn;
324 const NSRect *rects;
325 int count ;
326
327 [self getRectsBeingDrawn:&rects count:&count];
328 for ( int i = 0 ; i < count ; ++i )
329 {
330 updateRgn.Union(wxFromNSRect(self, rects[i]) );
331 }
332
333 wxWindow* wxpeer = impl->GetWXPeer();
334 wxpeer->GetUpdateRegion() = updateRgn;
335 wxpeer->MacSetCGContextRef( context );
336
337 wxPaintEvent event;
338 event.SetTimestamp(0); // todo
339 event.SetEventObject(wxpeer);
340 wxpeer->HandleWindowEvent(event);
341
342 CGContextRestoreGState( context );
343 }
344 }
345
346 -(void)mouseDown:(NSEvent *)event
347 {
348 [self handleMouseEvent:event];
349 }
350
351 -(void)rightMouseDown:(NSEvent *)event
352 {
353 [self handleMouseEvent:event];
354 }
355
356 -(void)otherMouseDown:(NSEvent *)event
357 {
358 [self handleMouseEvent:event];
359 }
360
361 -(void)mouseUp:(NSEvent *)event
362 {
363 [self handleMouseEvent:event];
364 }
365
366 -(void)rightMouseUp:(NSEvent *)event
367 {
368 [self handleMouseEvent:event];
369 }
370
371 -(void)otherMouseUp:(NSEvent *)event
372 {
373 [self handleMouseEvent:event];
374 }
375
376 -(void)handleMouseEvent:(NSEvent *)event
377 {
378 NSPoint clickLocation;
379 clickLocation = [self convertPoint:[event locationInWindow] fromView:nil];
380 wxPoint pt = wxFromNSPoint( self, clickLocation );
381 wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
382 SetupMouseEvent( wxevent , event ) ;
383 wxevent.m_x = pt.x;
384 wxevent.m_y = pt.y;
385 impl->GetWXPeer()->HandleWindowEvent(wxevent);
386 }
387
388 - (void)keyDown:(NSEvent *)event
389 {
390 [self handleKeyEvent:event];
391 }
392
393 - (void)keyUp:(NSEvent *)event
394 {
395 [self handleKeyEvent:event];
396 }
397
398 - (void)flagsChanged:(NSEvent *)event
399 {
400 [self handleKeyEvent:event];
401 }
402
403 - (void)handleKeyEvent:(NSEvent *)event
404 {
405 wxKeyEvent wxevent(wxEVT_KEY_DOWN);
406 SetupKeyEvent( wxevent, event );
407 impl->GetWXPeer()->HandleWindowEvent(wxevent);
408 }
409
410
411 - (void)setImplementation: (wxWidgetImpl *) theImplementation
412 {
413 impl = theImplementation;
414 }
415
416 - (wxWidgetImpl*) implementation
417 {
418 return impl;
419 }
420
421 - (BOOL) isFlipped
422 {
423 return YES;
424 }
425
426 - (BOOL) becomeFirstResponder
427 {
428 BOOL r = [super becomeFirstResponder];
429 if ( r )
430 {
431 }
432 return r;
433 }
434
435 - (BOOL) resignFirstResponder
436 {
437 BOOL r = [super resignFirstResponder];
438 if ( r )
439 {
440 }
441 return r;
442 }
443
444 - (BOOL) canBecomeKeyView
445 {
446 return YES;
447 }
448
449 @end // wxNSView
450
451 IMPLEMENT_DYNAMIC_CLASS( wxWidgetCocoaImpl , wxWidgetImpl )
452
453 wxWidgetCocoaImpl::wxWidgetCocoaImpl( wxWindowMac* peer , WXWidget w, bool isRootControl ) :
454 wxWidgetImpl( peer, isRootControl ), m_osxView(w)
455 {
456 }
457
458 wxWidgetCocoaImpl::wxWidgetCocoaImpl()
459 {
460 }
461
462 void wxWidgetCocoaImpl::Init()
463 {
464 m_osxView = NULL;
465 }
466
467 wxWidgetCocoaImpl::~wxWidgetCocoaImpl()
468 {
469 if ( [m_osxView respondsToSelector:@selector(setImplementation:) ] )
470 [m_osxView setImplementation:NULL];
471 if ( !IsRootControl() )
472 {
473 NSView *sv = [m_osxView superview];
474 if ( sv != nil )
475 [m_osxView removeFromSuperview];
476 }
477 [m_osxView release];
478 }
479
480 bool wxWidgetCocoaImpl::IsVisible() const
481 {
482 return [m_osxView isHiddenOrHasHiddenAncestor] == NO;
483 }
484
485 void wxWidgetCocoaImpl::SetVisibility( bool visible )
486 {
487 [m_osxView setHidden:(visible ? NO:YES)];
488 }
489
490 void wxWidgetCocoaImpl::Raise()
491 {
492 }
493
494 void wxWidgetCocoaImpl::Lower()
495 {
496 }
497
498 void wxWidgetCocoaImpl::ScrollRect( const wxRect *rect, int dx, int dy )
499 {
500 }
501
502 void wxWidgetCocoaImpl::Move(int x, int y, int width, int height)
503 {
504 NSRect r = wxToNSRect( [m_osxView superview], wxRect(x,y,width, height) );
505 [m_osxView setFrame:r];
506 }
507
508 void wxWidgetCocoaImpl::GetPosition( int &x, int &y ) const
509 {
510 wxRect r = wxFromNSRect( [m_osxView superview], [m_osxView frame] );
511 x = r.GetLeft();
512 y = r.GetTop();
513 }
514
515 void wxWidgetCocoaImpl::GetSize( int &width, int &height ) const
516 {
517 NSRect rect = [m_osxView frame];
518 width = rect.size.width;
519 height = rect.size.height;
520 }
521
522 void wxWidgetCocoaImpl::GetContentArea( int&left, int &top, int &width, int &height ) const
523 {
524 left = top = 0;
525 GetSize( width, height );
526 }
527
528 void wxWidgetCocoaImpl::SetNeedsDisplay( const wxRect* where )
529 {
530 if ( where )
531 [m_osxView setNeedsDisplayInRect:wxToNSRect(m_osxView, *where )];
532 else
533 [m_osxView setNeedsDisplay:YES];
534 }
535
536 bool wxWidgetCocoaImpl::GetNeedsDisplay() const
537 {
538 return [m_osxView needsDisplay];
539 }
540
541 bool wxWidgetCocoaImpl::CanFocus() const
542 {
543 return [m_osxView canBecomeKeyView] == YES;
544 }
545
546 bool wxWidgetCocoaImpl::HasFocus() const
547 {
548 return ( [[m_osxView window] firstResponder] == m_osxView );
549 }
550
551 bool wxWidgetCocoaImpl::SetFocus()
552 {
553 if ( [m_osxView canBecomeKeyView] == NO )
554 return false;
555
556 [[m_osxView window] makeFirstResponder: m_osxView] ;
557 return true;
558 }
559
560
561 void wxWidgetCocoaImpl::RemoveFromParent()
562 {
563 [m_osxView removeFromSuperview];
564 }
565
566 void wxWidgetCocoaImpl::Embed( wxWidgetImpl *parent )
567 {
568 NSView* container = parent->GetWXWidget() ;
569 wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
570 [container addSubview:m_osxView];
571 }
572
573 void wxWidgetCocoaImpl::SetBackgroundColour( const wxColour &WXUNUSED(col) )
574 {
575 // m_osxView.backgroundColor = [[UIColor alloc] initWithCGColor:col.GetCGColor()];
576 }
577
578 void wxWidgetCocoaImpl::SetLabel( const wxString& title, wxFontEncoding encoding )
579 {
580 if ( [m_osxView respondsToSelector:@selector(setTitle:) ] )
581 {
582 wxCFStringRef cf( title , m_wxPeer->GetFont().GetEncoding() );
583 [m_osxView setTitle:cf.AsNSString()];
584 }
585 }
586
587
588 void wxWidgetImpl::Convert( wxPoint *pt , wxWidgetImpl *from , wxWidgetImpl *to )
589 {
590 NSPoint p = wxToNSPoint( from->GetWXWidget(), *pt );
591 p = [from->GetWXWidget() convertPoint:p toView:to->GetWXWidget() ];
592 *pt = wxFromNSPoint( to->GetWXWidget(), p );
593 }
594
595 wxInt32 wxWidgetCocoaImpl::GetValue() const
596 {
597 return [(NSControl*)m_osxView intValue];
598 }
599
600 void wxWidgetCocoaImpl::SetValue( wxInt32 v )
601 {
602 if ( [m_osxView respondsToSelector:@selector(setIntValue:)] )
603 {
604 [m_osxView setIntValue:v];
605 }
606 else if ( [m_osxView respondsToSelector:@selector(setFloatValue:)] )
607 {
608 [m_osxView setFloatValue:(double)v];
609 }
610 else if ( [m_osxView respondsToSelector:@selector(setDoubleValue:)] )
611 {
612 [m_osxView setDoubleValue:(double)v];
613 }
614 }
615
616 void wxWidgetCocoaImpl::SetMinimum( wxInt32 v )
617 {
618 if ( [m_osxView respondsToSelector:@selector(setMinValue:)] )
619 {
620 [m_osxView setMinValue:(double)v];
621 }
622 }
623
624 void wxWidgetCocoaImpl::SetMaximum( wxInt32 v )
625 {
626 if ( [m_osxView respondsToSelector:@selector(setMaxValue:)] )
627 {
628 [m_osxView setMaxValue:(double)v];
629 }
630 }
631
632 void wxWidgetCocoaImpl::SetBitmap( const wxBitmap& bitmap )
633 {
634 if ( [m_osxView respondsToSelector:@selector(setImage:)] )
635 {
636 [m_osxView setImage:bitmap.GetNSImage()];
637 }
638 }
639
640 void wxWidgetCocoaImpl::SetupTabs( const wxNotebook& notebook)
641 {
642 // implementation in subclass
643 }
644
645 void wxWidgetCocoaImpl::GetBestRect( wxRect *r ) const
646 {
647 r->x = r->y = r->width = r->height = 0;
648 // if ( [m_osxView isKindOfClass:[NSControl class]] )
649 if ( [m_osxView respondsToSelector:@selector(sizeToFit)] )
650 {
651 NSRect former = [m_osxView frame];
652 [m_osxView sizeToFit];
653 NSRect best = [m_osxView frame];
654 [m_osxView setFrame:former];
655 r->width = best.size.width;
656 r->height = best.size.height;
657 }
658 }
659
660 bool wxWidgetCocoaImpl::IsEnabled() const
661 {
662 if ( [m_osxView respondsToSelector:@selector(isEnabled) ] )
663 return [m_osxView isEnabled];
664 return true;
665 }
666
667 void wxWidgetCocoaImpl::Enable( bool enable )
668 {
669 if ( [m_osxView respondsToSelector:@selector(setEnabled:) ] )
670 [m_osxView setEnabled:enable];
671 }
672
673 void wxWidgetCocoaImpl::PulseGauge()
674 {
675 }
676
677 void wxWidgetCocoaImpl::SetScrollThumb( wxInt32 val, wxInt32 view )
678 {
679 }
680
681 void wxWidgetCocoaImpl::SetControlSize( wxWindowVariant variant )
682 {
683 NSControlSize size = NSRegularControlSize;
684
685 switch ( variant )
686 {
687 case wxWINDOW_VARIANT_NORMAL :
688 size = NSRegularControlSize;
689 break ;
690
691 case wxWINDOW_VARIANT_SMALL :
692 size = NSSmallControlSize;
693 break ;
694
695 case wxWINDOW_VARIANT_MINI :
696 size = NSMiniControlSize;
697 break ;
698
699 case wxWINDOW_VARIANT_LARGE :
700 size = NSRegularControlSize;
701 break ;
702
703 default:
704 wxFAIL_MSG(_T("unexpected window variant"));
705 break ;
706 }
707 if ( [m_osxView respondsToSelector:@selector(setControlSize:)] )
708 [m_osxView setControlSize:size];
709 }
710
711 void wxWidgetCocoaImpl::SetFont(wxFont const&, wxColour const&, long, bool)
712 {
713 // TODO
714 }
715
716 //
717 // Factory methods
718 //
719
720 wxWidgetImpl* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer, wxWindowMac* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
721 long style, long extraStyle)
722 {
723 NSView* sv = (wxpeer->GetParent()->GetHandle() );
724
725 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
726 wxNSView* v = [[wxNSView alloc] initWithFrame:r];
727 [sv addSubview:v];
728 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
729 [v setImplementation:c];
730 return c;
731 }
732
733 wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
734 {
735 NSWindow* tlw = now->GetWXWindow();
736 wxNSView* v = [[wxNSView alloc] initWithFrame:[[tlw contentView] frame]];
737 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( now, v, true );
738 [v setImplementation:c];
739 [tlw setContentView:v];
740 return c;
741 }