#include "wx/log.h"
#endif
-#include <objc/objc-runtime.h>
-
+#include <objc/runtime.h>
WXWidget wxWidgetImpl::FindFocus()
{
{
/*
NSResponder* responder = [keyWindow firstResponder];
- if ( [responder isKindOfClass:[NSTextView class]] &&
+ if ( [responder isKindOfClass:[NSTextView class]] &&
[keyWindow fieldEditor:NO forObject:nil] != nil )
{
focusedView = [(NSTextView*)responder delegate];
UITouch *touch = [touches anyObject];
// these parameters are not given for all events
- UInt32 button = 0; // no secondary button
+ UInt32 button = 0; // no secondary button
UInt32 clickCount = [touch tapCount];
UInt32 mouseChord = 0; // TODO does this exist for cocoa
+ (void)initialize
{
static BOOL initialized = NO;
- if (!initialized)
+ if (!initialized)
{
initialized = YES;
wxOSXIPhoneClassAddWXMethods( self );
CGContextRef context = (CGContextRef) UIGraphicsGetCurrentContext();
CGContextSaveGState( context );
// draw background
-
+
CGContextSetFillColorWithColor( context, impl->GetWXPeer()->GetBackgroundColour().GetCGColor());
CGContextFillRect(context, rect );
impl->GetWXPeer()->MacSetCGContextRef( context );
- impl->GetWXPeer()->GetUpdateRegion() =
+ impl->GetWXPeer()->GetUpdateRegion() =
wxRegion(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height) ;
wxPaintEvent event;
}
-- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
+- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self handleTouchEvent:touches withEvent:event];
}
-- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
+- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[self handleTouchEvent:touches withEvent:event];
}
-- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
+- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self handleTouchEvent:touches withEvent:event];
}
--(void)handleTouchEvent:(NSSet *)touches withEvent:(UIEvent *)event
-{
+-(void)handleTouchEvent:(NSSet *)touches withEvent:(UIEvent *)event
+{
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
- CGPoint clickLocation;
+ CGPoint clickLocation;
UITouch *touch = [touches anyObject];
clickLocation = [touch locationInView:self];
*/
-void wxOSX_touchEvent(UIView* self, SEL _cmd, NSSet* touches, UIEvent *event )
+void wxOSX_touchEvent(UIView* self, SEL _cmd, NSSet* touches, UIEvent *event )
{
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
if (impl == NULL)
return;
-
+
impl->touchEvent(touches, event, self, _cmd);
}
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
if (impl == NULL)
return NO;
-
+
return impl->becomeFirstResponder(self, _cmd);
}
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
if (impl == NULL)
return NO;
-
+
return impl->resignFirstResponder(self, _cmd);
}
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
if (impl == NULL)
return;
-
+
return impl->drawRect(&rect, self, _cmd);
}
{
}
-wxWidgetIPhoneImpl::wxWidgetIPhoneImpl()
+wxWidgetIPhoneImpl::wxWidgetIPhoneImpl()
{
}
}
[m_osxView release];
}
-
-bool wxWidgetIPhoneImpl::IsVisible() const
+
+bool wxWidgetIPhoneImpl::IsVisible() const
{
- // TODO reflect Superviews state
- return [m_osxView isHidden] == NO;
+ UIView* view = m_osxView;
+ while ( view != nil && [view isHidden] == NO )
+ {
+ view = [view superview];
+ }
+ return view == nil;
}
void wxWidgetIPhoneImpl::SetVisibility( bool visible )
{
[[m_osxView superview] bringSubviewToFront:m_osxView];
}
-
+
void wxWidgetIPhoneImpl::Lower()
{
[[m_osxView superview] sendSubviewToBack:m_osxView];
return [m_osxView isFirstResponder] == YES;
}
-bool wxWidgetIPhoneImpl::SetFocus()
+bool wxWidgetIPhoneImpl::SetFocus()
{
// [m_osxView makeKeyWindow] ;
// TODO
void wxWidgetImpl::Convert( wxPoint *pt , wxWidgetImpl *from , wxWidgetImpl *to )
{
CGPoint p = CGPointMake( pt->x , pt->y );
- p = [from->GetWXWidget() convertPoint:p toView:to->GetWXWidget() ];
+ p = [from->GetWXWidget() convertPoint:p toView:to->GetWXWidget() ];
pt->x = (int)p.x;
pt->y = (int)p.y;
}
{
}
+wxBitmap wxWidgetIPhoneImpl::GetBitmap() const
+{
+ wxBitmap bmp;
+ return bmp;
+}
+
+void wxWidgetIPhoneImpl::SetBitmapPosition( wxDirection dir )
+{
+}
+
void wxWidgetIPhoneImpl::SetupTabs( const wxNotebook ¬ebook )
{
}
{
}
-void wxWidgetIPhoneImpl::SetControlSize( wxWindowVariant variant )
+void wxWidgetIPhoneImpl::SetControlSize( wxWindowVariant variant )
{
}
if ( receivedFocus )
{
- wxLogTrace(_T("Focus"), _T("focus set(%p)"), static_cast<void*>(thisWindow));
+ wxLogTrace(wxT("Focus"), wxT("focus set(%p)"), static_cast<void*>(thisWindow));
wxChildFocusEvent eventFocus((wxWindow*)thisWindow);
thisWindow->HandleWindowEvent(eventFocus);
thisWindow->GetCaret()->OnKillFocus();
#endif
- wxLogTrace(_T("Focus"), _T("focus lost(%p)"), static_cast<void*>(thisWindow));
-
+ wxLogTrace(wxT("Focus"), wxT("focus lost(%p)"), static_cast<void*>(thisWindow));
+
wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId());
event.SetEventObject(thisWindow);
if (otherWindow)
{
wxOSX_FocusHandlerPtr superimpl = (wxOSX_FocusHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
// get the current focus before running becomeFirstResponder
- UIView* otherView = FindFocus();
+ UIView* otherView = FindFocus();
wxWidgetImpl* otherWindow = FindFromWXWidget(otherView);
BOOL r = superimpl(slf, (SEL)_cmd);
if ( r )
wxOSX_FocusHandlerPtr superimpl = (wxOSX_FocusHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
BOOL r = superimpl(slf, (SEL)_cmd);
// get the current focus after running resignFirstResponder
- UIView* otherView = FindFocus();
+ UIView* otherView = FindFocus();
wxWidgetImpl* otherWindow = FindFromWXWidget(otherView);
// NSTextViews have an editor as true responder, therefore the might get the
// resign notification if their editor takes over, don't trigger any event hen
CGContextRef context = (CGContextRef) UIGraphicsGetCurrentContext();
CGContextSaveGState( context );
// draw background
-
+
CGContextSetFillColorWithColor( context, GetWXPeer()->GetBackgroundColour().GetCGColor());
CGContextFillRect(context, *rect );
GetWXPeer()->MacSetCGContextRef( context );
- GetWXPeer()->GetUpdateRegion() =
+ GetWXPeer()->GetUpdateRegion() =
wxRegion(rect->origin.x,rect->origin.y,rect->size.width,rect->size.height) ;
wxRegion updateRgn( wxFromNSRect( slf, *rect ) );
wxWindow* wxpeer = GetWXPeer();
wxpeer->GetUpdateRegion() = updateRgn;
wxpeer->MacSetCGContextRef( context );
-
+
bool handled = wxpeer->MacDoRedraw( 0 );
-
+
CGContextRestoreGState( context );
CGContextSaveGState( context );
// call super
SEL _cmd = @selector(drawRect:);
wxOSX_DrawRectHandlerPtr superimpl = (wxOSX_DrawRectHandlerPtr) [[slf superclass] instanceMethodForSelector:_cmd];
- superimpl(slf, _cmd, *rect);
- CGContextRestoreGState( context );
- CGContextSaveGState( context );
+ if ( superimpl != wxOSX_drawRect )
+ {
+ superimpl(slf, _cmd, *rect);
+ CGContextRestoreGState( context );
+ CGContextSaveGState( context );
+ }
}
wxpeer->MacPaintChildrenBorders();
wxpeer->MacSetCGContextRef( NULL );
void wxWidgetIPhoneImpl::touchEvent(NSSet* touches, UIEvent *event, WXWidget slf, void *WXUNUSED(_cmd))
{
- CGPoint clickLocation;
+ CGPoint clickLocation;
UITouch *touch = [touches anyObject];
clickLocation = [touch locationInView:slf];
wxPoint pt = wxFromNSPoint( m_osxView, clickLocation );
// Factory methods
//
-wxWidgetImpl* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(parent),
+wxWidgetImpl* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(parent),
wxWindowID WXUNUSED(id), const wxPoint& pos, const wxSize& size,
long WXUNUSED(style), long WXUNUSED(extraStyle))
{
UIView* sv = (wxpeer->GetParent()->GetHandle() );
-
+
CGRect r = CGRectMake( pos.x, pos.y, size.x, size.y) ;
// Rect bounds = wxMacGetBoundsForControl( wxpeer, pos , size ) ;
wxUIView* v = [[wxUIView alloc] initWithFrame:r];
return c;
}
-wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
+wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
{
UIWindow* toplevelwindow = now->GetWXWindow();
/*
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
// left orientation not yet implemented !
- if (orientation == UIInterfaceOrientationLandscapeRight )
+ 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;