X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8996460cb98aadf153a61d749b009e436dbb0fd7..f7d32bb716ba2191d52cbf3ada5b3ff72103dfea:/src/osx/iphone/window.mm?ds=sidebyside diff --git a/src/osx/iphone/window.mm b/src/osx/iphone/window.mm index 2858e3ccc3..81d03166aa 100644 --- a/src/osx/iphone/window.mm +++ b/src/osx/iphone/window.mm @@ -56,11 +56,6 @@ CGRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const return wxToNSRect( sv, bounds ); } -@interface wxUIView : UIView -{ -} - -@end // wxUIView @interface wxUIView(PossibleMethods) - (void)setTitle:(NSString *)title forState:(UIControlState)state; @@ -76,18 +71,6 @@ CGRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const - (BOOL) resignFirstResponder; @end -@interface wxUIContentView : wxUIView -{ -} - -@end - -@interface wxUIContentViewController : UIViewController -{ -} - -@end - // // // @@ -313,29 +296,6 @@ void wxOSXIPhoneClassAddWXMethods(Class c) class_addMethod(c, @selector(drawRect:), (IMP) wxOSX_drawRect, "v@:{_CGRect={_CGPoint=ff}{_CGSize=ff}}" ); } -@implementation wxUIContentView - -@end - -@implementation wxUIContentViewController - -- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation -{ - return YES; -} - -- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation -{ - CGRect fr = [self.view frame]; -// CGRect cv = [[self.view superview] frame]; -// CGRect bounds = CGRectMake( 0,0,fr.size.width, fr.size.height); -// [[self.view superview] setFrame: fr ]; -// [self.view setFrame: bounds]; -// [self.view setNeedsDisplayInRect:bounds]; -} - -@end - IMPLEMENT_DYNAMIC_CLASS( wxWidgetIPhoneImpl , wxWidgetImpl ) @@ -372,8 +332,6 @@ bool wxWidgetIPhoneImpl::IsVisible() const while ( view != nil && [view isHidden] == NO ) { view = [view superview]; - if (view != nil && [view isHidden]) - NSLog(@"visible test failed for %@",view); } return view == nil; } @@ -421,7 +379,9 @@ void wxWidgetIPhoneImpl::GetSize( int &width, int &height ) const void wxWidgetIPhoneImpl::GetContentArea( int&left, int &top, int &width, int &height ) const { left = top = 0; - GetSize( width, height ); + CGRect rect = [m_osxView bounds]; + width = rect.size.width; + height = rect.size.height; } void wxWidgetIPhoneImpl::SetNeedsDisplay( const wxRect* where ) @@ -482,7 +442,7 @@ void wxWidgetImpl::Convert( wxPoint *pt , wxWidgetImpl *from , wxWidgetImpl *to void wxWidgetIPhoneImpl::SetBackgroundColour( const wxColour &col ) { - // m_osxView.backgroundColor = [[UIColor alloc] initWithCGColor:col.GetCGColor()]; + m_osxView.backgroundColor = [[UIColor alloc] initWithCGColor:col.GetCGColor()]; } void wxWidgetIPhoneImpl::SetLabel(const wxString& title, wxFontEncoding encoding) @@ -727,19 +687,32 @@ void wxWidgetIPhoneImpl::drawRect(CGRect* rect, WXWidget slf, void *WXUNUSED(_cm void wxWidgetIPhoneImpl::touchEvent(NSSet* touches, UIEvent *event, WXWidget slf, void *WXUNUSED(_cmd)) { - CGPoint clickLocation; + bool inRecursion = false; + if ( inRecursion ) + return; + UITouch *touch = [touches anyObject]; - clickLocation = [touch locationInView:slf]; - wxPoint pt = wxFromNSPoint( m_osxView, clickLocation ); - - wxMouseEvent wxevent(wxEVT_LEFT_DOWN); - SetupMouseEvent( wxevent , touches, event ) ; - wxevent.m_x = pt.x; - wxevent.m_y = pt.y; - wxevent.SetEventObject( GetWXPeer() ) ; - //?wxevent.SetId( GetWXPeer()->GetId() ) ; - - GetWXPeer()->HandleWindowEvent(wxevent); + CGPoint clickLocation; + if ( [touch view] != slf && IsRootControl() ) + { + NSLog(@"self is %@ and touch view is %@",slf,[touch view]); + inRecursion = true; + inRecursion = false; + } + else + { + clickLocation = [touch locationInView:slf]; + wxPoint pt = wxFromNSPoint( m_osxView, clickLocation ); + + wxMouseEvent wxevent(wxEVT_LEFT_DOWN); + SetupMouseEvent( wxevent , touches, event ) ; + wxevent.m_x = pt.x; + wxevent.m_y = pt.y; + wxevent.SetEventObject( GetWXPeer() ) ; + //?wxevent.SetId( GetWXPeer()->GetId() ) ; + + GetWXPeer()->HandleWindowEvent(wxevent); + } } void wxWidgetIPhoneImpl::touchUpInsideAction(void* sender, WX_UIEvent evt, WXWidget slf, void* _cmd) @@ -766,37 +739,3 @@ wxWidgetImpl* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer, wxWindowMac* WX return c; } -wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now ) -{ - UIWindow* toplevelwindow = now->GetWXWindow(); - - wxUIContentView* contentview = [[wxUIContentView alloc] initWithFrame:[toplevelwindow bounds]]; - contentview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - wxUIContentViewController* controller = [[wxUIContentViewController alloc] init]; - controller.view = contentview; - /* - UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; - // left orientation not yet implemented ! - if (orientation == UIInterfaceOrientationLandscapeRight ) - { - CGAffineTransform transform = v.transform; - - // Use the status bar frame to determine the center point of the window's content area. - CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame]; - CGRect bounds = CGRectMake(0, 0, statusBarFrame.size.height, statusBarFrame.origin.x); - CGPoint center = CGPointMake(bounds.size.height / 2.0, bounds.size.width / 2.0); - - // Set the center point of the view to the center point of the window's content area. - v.center = center; - - // Rotate the view 90 degrees around its new center point. - transform = CGAffineTransformRotate(transform, ( M_PI / 2.0)); - v.transform = transform; - } - */ - wxWidgetIPhoneImpl* impl = new wxWidgetIPhoneImpl( now, contentview, true ); - impl->InstallEventHandler(); - [toplevelwindow addSubview:contentview]; - return impl; -} -