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