1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/iphone/window.mm
3 // Purpose: widgets (non tlw) for iphone
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
13 #include "wx/osx/private.h"
16 #include "wx/nonownedwnd.h"
22 #include "wx/textctrl.h"
24 #include <objc/runtime.h>
26 WXWidget wxWidgetImpl::FindFocus()
28 UIView* focusedView = nil;
29 UIWindow* keyWindow = [[UIApplication sharedApplication] keyWindow];
30 if ( keyWindow != nil )
33 NSResponder* responder = [keyWindow firstResponder];
34 if ( [responder isKindOfClass:[NSTextView class]] &&
35 [keyWindow fieldEditor:NO forObject:nil] != nil )
37 focusedView = [(NSTextView*)responder delegate];
41 if ( [responder isKindOfClass:[NSView class]] )
42 focusedView = (NSView*) responder;
49 CGRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin )
53 window->MacGetBoundsForControl( pos , size , x , y, w, h , adjustForOrigin ) ;
54 wxRect bounds(x,y,w,h);
55 UIView* sv = (window->GetParent()->GetHandle() );
57 return wxToNSRect( sv, bounds );
61 @interface wxUIView(PossibleMethods)
62 - (void)setTitle:(NSString *)title forState:(UIControlState)state;
64 - (void)drawRect: (CGRect) rect;
66 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
67 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
68 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
69 - (void)handleTouchEvent:(NSSet *)touches withEvent:(UIEvent *)event;
71 - (BOOL) becomeFirstResponder;
72 - (BOOL) resignFirstResponder;
79 void SetupMouseEvent( wxMouseEvent &wxevent , NSSet* touches, UIEvent * nsEvent )
81 UInt32 modifiers = 0 ;
82 UITouch *touch = [touches anyObject];
84 // these parameters are not given for all events
85 UInt32 button = 0; // no secondary button
86 UInt32 clickCount = [touch tapCount];
87 UInt32 mouseChord = 0; // TODO does this exist for cocoa
92 wxevent.m_shiftDown = 0;
93 wxevent.m_controlDown = 0;
94 wxevent.m_altDown = 0;
95 wxevent.m_metaDown = 0;
96 wxevent.m_clickCount = clickCount;
97 wxevent.SetTimestamp( [touch timestamp] ) ;
99 // a control click is interpreted as a right click
100 bool thisButtonIsFakeRight = false ;
101 if ( button == kEventMouseButtonPrimary && (modifiers & controlKey) )
103 button = kEventMouseButtonSecondary ;
104 thisButtonIsFakeRight = true ;
107 // otherwise we report double clicks by connecting a left click with a ctrl-left click
108 if ( clickCount > 1 && button != g_lastButton )
110 // we must make sure that our synthetic 'right' button corresponds in
111 // mouse down, moved and mouse up, and does not deliver a right down and left up
113 if ( cEvent.GetKind() == kEventMouseDown )
115 g_lastButton = button ;
116 g_lastButtonWasFakeRight = thisButtonIsFakeRight ;
122 g_lastButtonWasFakeRight = false ;
124 else if ( g_lastButton == kEventMouseButtonSecondary && g_lastButtonWasFakeRight )
125 button = g_lastButton ;
127 // Adjust the chord mask to remove the primary button and add the
128 // secondary button. It is possible that the secondary button is
129 // already pressed, e.g. on a mouse connected to a laptop, but this
130 // possibility is ignored here:
131 if( thisButtonIsFakeRight && ( mouseChord & 1U ) )
132 mouseChord = ((mouseChord & ~1U) | 2U);
135 wxevent.m_leftDown = true ;
137 wxevent.m_rightDown = true ;
139 wxevent.m_middleDown = true ;
142 // translate into wx types
143 int eventType = [touch phase];
146 case UITouchPhaseBegan :
150 wxevent.SetEventType( clickCount > 1 ? wxEVT_LEFT_DCLICK : wxEVT_LEFT_DOWN ) ;
158 case UITouchPhaseEnded :
162 wxevent.SetEventType( wxEVT_LEFT_UP ) ;
170 case UITouchPhaseMoved :
171 wxevent.SetEventType( wxEVT_MOTION ) ;
178 @implementation wxUIView
182 static BOOL initialized = NO;
186 wxOSXIPhoneClassAddWXMethods( self );
193 - (void)drawRect: (CGRect) rect
195 wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
198 CGContextRef context = (CGContextRef) UIGraphicsGetCurrentContext();
199 CGContextSaveGState( context );
202 CGContextSetFillColorWithColor( context, impl->GetWXPeer()->GetBackgroundColour().GetCGColor());
203 CGContextFillRect(context, rect );
205 impl->GetWXPeer()->MacSetCGContextRef( context );
207 impl->GetWXPeer()->GetUpdateRegion() =
208 wxRegion(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height) ;
211 event.SetTimestamp(0); // todo
212 event.SetEventObject(impl->GetWXPeer());
213 impl->GetWXPeer()->HandleWindowEvent(event);
215 CGContextRestoreGState( context );
220 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
222 [self handleTouchEvent:touches withEvent:event];
225 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
227 [self handleTouchEvent:touches withEvent:event];
230 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
232 [self handleTouchEvent:touches withEvent:event];
235 -(void)handleTouchEvent:(NSSet *)touches withEvent:(UIEvent *)event
237 wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
238 CGPoint clickLocation;
239 UITouch *touch = [touches anyObject];
240 clickLocation = [touch locationInView:self];
242 wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
243 SetupMouseEvent( wxevent , touches, event ) ;
244 wxevent.m_x = clickLocation.x;
245 wxevent.m_y = clickLocation.y;
246 wxevent.SetEventObject( impl->GetWXPeer() ) ;
247 wxevent.SetId( impl->GetWXPeer()->GetId() ) ;
248 impl->GetWXPeer()->HandleWindowEvent(wxevent);
253 void wxOSX_touchEvent(UIView* self, SEL _cmd, NSSet* touches, UIEvent *event )
255 wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
259 impl->touchEvent(touches, event, self, _cmd);
262 BOOL wxOSX_becomeFirstResponder(UIView* self, SEL _cmd)
264 wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
268 return impl->becomeFirstResponder(self, _cmd);
271 BOOL wxOSX_resignFirstResponder(UIView* self, SEL _cmd)
273 wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
277 return impl->resignFirstResponder(self, _cmd);
280 void wxOSX_drawRect(UIView* self, SEL _cmd, CGRect rect)
282 wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
286 return impl->drawRect(&rect, self, _cmd);
290 void wxOSXIPhoneClassAddWXMethods(Class c)
292 class_addMethod(c, @selector(touchesBegan:withEvent:), (IMP) wxOSX_touchEvent, "v@:@@");
293 class_addMethod(c, @selector(touchesMoved:withEvent:), (IMP) wxOSX_touchEvent, "v@:@@");
294 class_addMethod(c, @selector(touchesEnded:withEvent:), (IMP) wxOSX_touchEvent, "v@:@@");
295 class_addMethod(c, @selector(becomeFirstResponder), (IMP) wxOSX_becomeFirstResponder, "c@:" );
296 class_addMethod(c, @selector(resignFirstResponder), (IMP) wxOSX_resignFirstResponder, "c@:" );
297 class_addMethod(c, @selector(drawRect:), (IMP) wxOSX_drawRect, "v@:{_CGRect={_CGPoint=ff}{_CGSize=ff}}" );
301 // UIControl extensions
304 @interface UIControl (wxUIControlActionSupport)
306 - (void) WX_touchUpInsideAction:(id)sender event:(UIEvent*)event;
307 - (void) WX_valueChangedAction:(id)sender event:(UIEvent*)event;
311 @implementation UIControl (wxUIControlActionSupport)
313 - (void) WX_touchUpInsideAction:(id)sender event:(UIEvent*)event
315 wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
317 impl->controlAction(sender, UIControlEventTouchUpInside, event);
320 - (void) WX_valueChangedAction:(id)sender event:(UIEvent*)event
322 wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
324 impl->controlAction(sender, UIControlEventValueChanged, event);
329 IMPLEMENT_DYNAMIC_CLASS( wxWidgetIPhoneImpl , wxWidgetImpl )
331 wxWidgetIPhoneImpl::wxWidgetIPhoneImpl( wxWindowMac* peer , WXWidget w, bool isRootControl, bool isUserPane ) :
332 wxWidgetImpl( peer, isRootControl, isUserPane ), m_osxView(w)
336 wxWidgetIPhoneImpl::wxWidgetIPhoneImpl()
340 void wxWidgetIPhoneImpl::Init()
345 wxWidgetIPhoneImpl::~wxWidgetIPhoneImpl()
347 RemoveAssociations( this );
349 if ( !IsRootControl() )
351 UIView *sv = [m_osxView superview];
353 [m_osxView removeFromSuperview];
358 bool wxWidgetIPhoneImpl::IsVisible() const
360 UIView* view = m_osxView;
361 while ( view != nil && [view isHidden] == NO )
363 view = [view superview];
368 void wxWidgetIPhoneImpl::SetVisibility( bool visible )
370 [m_osxView setHidden:(visible ? NO:YES)];
373 void wxWidgetIPhoneImpl::Raise()
375 [[m_osxView superview] bringSubviewToFront:m_osxView];
378 void wxWidgetIPhoneImpl::Lower()
380 [[m_osxView superview] sendSubviewToBack:m_osxView];
383 void wxWidgetIPhoneImpl::ScrollRect( const wxRect *rect, int dx, int dy )
388 void wxWidgetIPhoneImpl::Move(int x, int y, int width, int height)
390 CGRect r = CGRectMake( x, y, width, height) ;
391 [m_osxView setFrame:r];
396 void wxWidgetIPhoneImpl::GetPosition( int &x, int &y ) const
398 CGRect r = [m_osxView frame];
403 void wxWidgetIPhoneImpl::GetSize( int &width, int &height ) const
405 CGRect rect = [m_osxView frame];
406 width = rect.size.width;
407 height = rect.size.height;
410 void wxWidgetIPhoneImpl::GetContentArea( int&left, int &top, int &width, int &height ) const
413 CGRect rect = [m_osxView bounds];
414 width = rect.size.width;
415 height = rect.size.height;
418 void wxWidgetIPhoneImpl::SetNeedsDisplay( const wxRect* where )
422 CGRect r = CGRectMake( where->x, where->y, where->width, where->height) ;
423 [m_osxView setNeedsDisplayInRect:r];
426 [m_osxView setNeedsDisplay];
429 bool wxWidgetIPhoneImpl::GetNeedsDisplay() const
432 // return [m_osxView needsDisplay];
435 bool wxWidgetIPhoneImpl::CanFocus() const
437 return [m_osxView canBecomeFirstResponder] == YES;
438 // ? return [m_osxView isUserInteractionEnabled] == YES;
441 bool wxWidgetIPhoneImpl::HasFocus() const
443 return [m_osxView isFirstResponder] == YES;
446 bool wxWidgetIPhoneImpl::SetFocus()
448 // [m_osxView makeKeyWindow] ;
454 void wxWidgetIPhoneImpl::RemoveFromParent()
456 [m_osxView removeFromSuperview];
459 void wxWidgetIPhoneImpl::Embed( wxWidgetImpl *parent )
461 UIView* container = parent->GetWXWidget() ;
462 wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
463 [container addSubview:m_osxView];
466 void wxWidgetImpl::Convert( wxPoint *pt , wxWidgetImpl *from , wxWidgetImpl *to )
468 CGPoint p = CGPointMake( pt->x , pt->y );
469 p = [from->GetWXWidget() convertPoint:p toView:to->GetWXWidget() ];
474 void wxWidgetIPhoneImpl::SetBackgroundColour( const wxColour &col )
476 m_osxView.backgroundColor = [[UIColor alloc] initWithCGColor:col.GetCGColor()];
479 bool wxWidgetIPhoneImpl::SetBackgroundStyle(wxBackgroundStyle style)
481 if ( style == wxBG_STYLE_PAINT )
482 [m_osxView setOpaque: YES ];
485 [m_osxView setOpaque: NO ];
486 m_osxView.backgroundColor = [UIColor clearColor];
491 void wxWidgetIPhoneImpl::SetLabel(const wxString& title, wxFontEncoding encoding)
493 if ( [m_osxView respondsToSelector:@selector(setTitle:forState:) ] )
495 wxCFStringRef cf( title , encoding );
496 [m_osxView setTitle:cf.AsNSString() forState:UIControlStateNormal ];
498 #if 0 // nonpublic API problems
499 else if ( [m_osxView respondsToSelector:@selector(setStringValue:) ] )
501 wxCFStringRef cf( title , encoding );
502 [m_osxView setStringValue:cf.AsNSString()];
508 void wxWidgetIPhoneImpl::SetCursor( const wxCursor & cursor )
512 void wxWidgetIPhoneImpl::CaptureMouse()
516 void wxWidgetIPhoneImpl::ReleaseMouse()
520 wxInt32 wxWidgetIPhoneImpl::GetValue() const
524 void wxWidgetIPhoneImpl::SetValue( wxInt32 v )
528 void wxWidgetIPhoneImpl::SetBitmap( const wxBitmap& bitmap )
532 wxBitmap wxWidgetIPhoneImpl::GetBitmap() const
538 void wxWidgetIPhoneImpl::SetBitmapPosition( wxDirection dir )
542 void wxWidgetIPhoneImpl::SetupTabs( const wxNotebook ¬ebook )
546 void wxWidgetIPhoneImpl::GetBestRect( wxRect *r ) const
548 r->x = r->y = r->width = r->height = 0;
550 if ( [m_osxView respondsToSelector:@selector(sizeToFit)] )
552 CGRect former = [m_osxView frame];
553 [m_osxView sizeToFit];
554 CGRect best = [m_osxView frame];
555 [m_osxView setFrame:former];
556 r->width = best.size.width;
557 r->height = best.size.height;
561 bool wxWidgetIPhoneImpl::IsEnabled() const
563 UIView* targetView = m_osxView;
564 // TODO add support for documentViews
566 if ( [targetView respondsToSelector:@selector(isEnabled) ] )
567 return [targetView isEnabled];
572 void wxWidgetIPhoneImpl::Enable( bool enable )
574 UIView* targetView = m_osxView;
575 // TODO add support for documentViews
577 if ( [targetView respondsToSelector:@selector(setEnabled:) ] )
578 [targetView setEnabled:enable];
581 void wxWidgetIPhoneImpl::SetMinimum( wxInt32 v )
585 void wxWidgetIPhoneImpl::SetMaximum( wxInt32 v )
589 wxInt32 wxWidgetIPhoneImpl::GetMinimum() const
594 wxInt32 wxWidgetIPhoneImpl::GetMaximum() const
599 void wxWidgetIPhoneImpl::PulseGauge()
603 void wxWidgetIPhoneImpl::SetScrollThumb( wxInt32 value, wxInt32 thumbSize )
607 void wxWidgetIPhoneImpl::SetControlSize( wxWindowVariant variant )
611 double wxWidgetIPhoneImpl::GetContentScaleFactor() const
613 if ( [m_osxView respondsToSelector:@selector(contentScaleFactor) ])
614 return [m_osxView contentScaleFactor];
619 void wxWidgetIPhoneImpl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack )
623 void wxWidgetIPhoneImpl::InstallEventHandler( WXWidget control )
625 WXWidget c = control ? control : (WXWidget) m_osxView;
626 wxWidgetImpl::Associate( c, this ) ;
628 if ([c isKindOfClass:[UIControl class] ])
630 UIControl* cc = (UIControl*) c;
631 [cc addTarget:cc action:@selector(WX_touchUpInsideAction:event:) forControlEvents:UIControlEventTouchUpInside];
632 [cc addTarget:cc action:@selector(WX_valueChangedAction:event:) forControlEvents:UIControlEventValueChanged];
636 void wxWidgetIPhoneImpl::DoNotifyFocusEvent(bool receivedFocus, wxWidgetImpl* otherWindow)
638 wxWindow* thisWindow = GetWXPeer();
639 if ( thisWindow->MacGetTopLevelWindow() && NeedsFocusRect() )
641 thisWindow->MacInvalidateBorders();
646 wxLogTrace(wxT("Focus"), wxT("focus set(%p)"), static_cast<void*>(thisWindow));
647 wxChildFocusEvent eventFocus((wxWindow*)thisWindow);
648 thisWindow->HandleWindowEvent(eventFocus);
651 if ( thisWindow->GetCaret() )
652 thisWindow->GetCaret()->OnSetFocus();
655 wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId());
656 event.SetEventObject(thisWindow);
658 event.SetWindow(otherWindow->GetWXPeer());
659 thisWindow->HandleWindowEvent(event) ;
661 else // !receivedFocuss
664 if ( thisWindow->GetCaret() )
665 thisWindow->GetCaret()->OnKillFocus();
668 wxLogTrace(wxT("Focus"), wxT("focus lost(%p)"), static_cast<void*>(thisWindow));
670 wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId());
671 event.SetEventObject(thisWindow);
673 event.SetWindow(otherWindow->GetWXPeer());
674 thisWindow->HandleWindowEvent(event) ;
678 typedef void (*wxOSX_DrawRectHandlerPtr)(UIView* self, SEL _cmd, CGRect rect);
679 typedef BOOL (*wxOSX_FocusHandlerPtr)(UIView* self, SEL _cmd);
681 bool wxWidgetIPhoneImpl::becomeFirstResponder(WXWidget slf, void *_cmd)
683 wxOSX_FocusHandlerPtr superimpl = (wxOSX_FocusHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
684 // get the current focus before running becomeFirstResponder
685 UIView* otherView = FindFocus();
686 wxWidgetImpl* otherWindow = FindFromWXWidget(otherView);
687 BOOL r = superimpl(slf, (SEL)_cmd);
690 DoNotifyFocusEvent( true, otherWindow );
695 bool wxWidgetIPhoneImpl::resignFirstResponder(WXWidget slf, void *_cmd)
697 wxOSX_FocusHandlerPtr superimpl = (wxOSX_FocusHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
698 BOOL r = superimpl(slf, (SEL)_cmd);
699 // get the current focus after running resignFirstResponder
700 UIView* otherView = FindFocus();
701 wxWidgetImpl* otherWindow = FindFromWXWidget(otherView);
702 // NSTextViews have an editor as true responder, therefore the might get the
703 // resign notification if their editor takes over, don't trigger any event hen
704 if ( r && otherWindow != this)
706 DoNotifyFocusEvent( false, otherWindow );
711 void wxWidgetIPhoneImpl::drawRect(CGRect* rect, WXWidget slf, void *WXUNUSED(_cmd))
713 CGContextRef context = (CGContextRef) UIGraphicsGetCurrentContext();
714 CGContextSaveGState( context );
717 CGContextSetFillColorWithColor( context, GetWXPeer()->GetBackgroundColour().GetCGColor());
718 CGContextFillRect(context, *rect );
720 GetWXPeer()->MacSetCGContextRef( context );
722 GetWXPeer()->GetUpdateRegion() =
723 wxRegion(rect->origin.x,rect->origin.y,rect->size.width,rect->size.height) ;
725 wxRegion updateRgn( wxFromNSRect( slf, *rect ) );
727 wxWindow* wxpeer = GetWXPeer();
728 wxpeer->GetUpdateRegion() = updateRgn;
729 wxpeer->MacSetCGContextRef( context );
731 bool handled = wxpeer->MacDoRedraw( 0 );
733 CGContextRestoreGState( context );
735 CGContextSaveGState( context );
739 SEL _cmd = @selector(drawRect:);
740 wxOSX_DrawRectHandlerPtr superimpl = (wxOSX_DrawRectHandlerPtr) [[slf superclass] instanceMethodForSelector:_cmd];
741 if ( superimpl != wxOSX_drawRect )
743 superimpl(slf, _cmd, *rect);
744 CGContextRestoreGState( context );
745 CGContextSaveGState( context );
748 wxpeer->MacPaintChildrenBorders();
749 wxpeer->MacSetCGContextRef( NULL );
751 CGContextRestoreGState( context );
754 void wxWidgetIPhoneImpl::touchEvent(NSSet* touches, UIEvent *event, WXWidget slf, void *WXUNUSED(_cmd))
756 bool inRecursion = false;
760 UITouch *touch = [touches anyObject];
761 CGPoint clickLocation;
762 if ( [touch view] != slf && IsRootControl() )
764 NSLog(@"self is %@ and touch view is %@",slf,[touch view]);
770 clickLocation = [touch locationInView:slf];
771 wxPoint pt = wxFromNSPoint( m_osxView, clickLocation );
773 wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
774 SetupMouseEvent( wxevent , touches, event ) ;
777 wxevent.SetEventObject( GetWXPeer() ) ;
778 //?wxevent.SetId( GetWXPeer()->GetId() ) ;
780 GetWXPeer()->HandleWindowEvent(wxevent);
784 void wxWidgetIPhoneImpl::controlAction(void* sender, wxUint32 controlEvent, WX_UIEvent rawEvent)
786 if ( controlEvent == UIControlEventTouchUpInside )
787 GetWXPeer()->OSXHandleClicked(0);
790 void wxWidgetIPhoneImpl::controlTextDidChange()
792 wxTextCtrl* wxpeer = wxDynamicCast((wxWindow*)GetWXPeer(),wxTextCtrl);
795 wxCommandEvent event(wxEVT_TEXT, wxpeer->GetId());
796 event.SetEventObject( wxpeer );
797 event.SetString( wxpeer->GetValue() );
798 wxpeer->HandleWindowEvent( event );
806 wxWidgetImpl* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(parent),
807 wxWindowID WXUNUSED(id), const wxPoint& pos, const wxSize& size,
808 long WXUNUSED(style), long WXUNUSED(extraStyle))
810 UIView* sv = (wxpeer->GetParent()->GetHandle() );
812 CGRect r = CGRectMake( pos.x, pos.y, size.x, size.y) ;
813 // Rect bounds = wxMacGetBoundsForControl( wxpeer, pos , size ) ;
814 wxUIView* v = [[wxUIView alloc] initWithFrame:r];
815 sv.clipsToBounds = YES;
816 sv.contentMode = UIViewContentModeRedraw;
817 sv.clearsContextBeforeDrawing = NO;
818 wxWidgetIPhoneImpl* c = new wxWidgetIPhoneImpl( wxpeer, v, false, true );