return wxToNSRect( sv, bounds );
}
-@interface wxUIView : UIView
-{
-}
-
-@end // wxUIView
@interface wxUIView(PossibleMethods)
- (void)setTitle:(NSString *)title forState:(UIControlState)state;
- (BOOL) resignFirstResponder;
@end
-@interface wxUIContentView : wxUIView
-{
-}
-
-@end
-
-@interface wxUIContentViewController : UIViewController
-{
-}
-
-@end
-
//
//
//
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 )
while ( view != nil && [view isHidden] == NO )
{
view = [view superview];
- if (view != nil && [view isHidden])
- NSLog(@"visible test failed for %@",view);
}
return view == nil;
}
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 )
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)
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)
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;
-}
-