rearranging contentview, adding toolbar
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62865 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "wx/nonownedwnd.h"
|
#include "wx/nonownedwnd.h"
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
CGRect wxToNSRect(UIView* parent, const wxRect& r )
|
CGRect wxToNSRect(UIView* parent, const wxRect& r )
|
||||||
{
|
{
|
||||||
@@ -48,6 +49,26 @@ wxPoint wxFromNSPoint( UIView* parent, const CGPoint& p )
|
|||||||
return wxPoint( x, y);
|
return wxPoint( x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@interface wxUIContentViewController : UIViewController
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface wxUIContentView : wxUIView
|
||||||
|
{
|
||||||
|
wxUIContentViewController* _controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setController: (UIViewController*) controller;
|
||||||
|
- (UIViewController*) controller;
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// c++ impl
|
||||||
|
//
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS( wxNonOwnedWindowIPhoneImpl , wxNonOwnedWindowImpl )
|
IMPLEMENT_DYNAMIC_CLASS( wxNonOwnedWindowIPhoneImpl , wxNonOwnedWindowImpl )
|
||||||
|
|
||||||
@@ -104,6 +125,8 @@ long style, long extraStyle, const wxString& name )
|
|||||||
if ( ( style & wxSTAY_ON_TOP ) )
|
if ( ( style & wxSTAY_ON_TOP ) )
|
||||||
level = UIWindowLevelAlert;
|
level = UIWindowLevelAlert;
|
||||||
CGRect r = CGRectMake( 0, 0, size.x, size.y) ;
|
CGRect r = CGRectMake( 0, 0, size.x, size.y) ;
|
||||||
|
if ( UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) )
|
||||||
|
std::swap(r.size.width,r.size.height);
|
||||||
|
|
||||||
[m_macWindow initWithFrame:r ];
|
[m_macWindow initWithFrame:r ];
|
||||||
|
|
||||||
@@ -175,6 +198,9 @@ bool wxNonOwnedWindowIPhoneImpl::CanSetTransparent()
|
|||||||
void wxNonOwnedWindowIPhoneImpl::MoveWindow(int x, int y, int width, int height)
|
void wxNonOwnedWindowIPhoneImpl::MoveWindow(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
CGRect r = CGRectMake( x,y,width,height) ;
|
CGRect r = CGRectMake( x,y,width,height) ;
|
||||||
|
if ( UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) )
|
||||||
|
std::swap(r.size.width,r.size.height);
|
||||||
|
|
||||||
[m_macWindow setFrame:r];
|
[m_macWindow setFrame:r];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,18 +213,22 @@ void wxNonOwnedWindowIPhoneImpl::GetPosition( int &x, int &y ) const
|
|||||||
|
|
||||||
void wxNonOwnedWindowIPhoneImpl::GetSize( int &width, int &height ) const
|
void wxNonOwnedWindowIPhoneImpl::GetSize( int &width, int &height ) const
|
||||||
{
|
{
|
||||||
CGRect rect = [m_macWindow frame];
|
CGRect r = [m_macWindow frame];
|
||||||
width = rect.size.width;
|
if ( UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) )
|
||||||
height = rect.size.height;
|
std::swap(r.size.width,r.size.height);
|
||||||
|
width = r.size.width;
|
||||||
|
height = r.size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNonOwnedWindowIPhoneImpl::GetContentArea( int& left, int &top, int &width, int &height ) const
|
void wxNonOwnedWindowIPhoneImpl::GetContentArea( int& left, int &top, int &width, int &height ) const
|
||||||
{
|
{
|
||||||
CGRect rect = [m_macWindow bounds];
|
CGRect r = [m_macWindow bounds];
|
||||||
width = rect.size.width;
|
if ( UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) )
|
||||||
height = rect.size.height;
|
std::swap(r.size.width,r.size.height);
|
||||||
left = rect.origin.x;
|
width = r.size.width;
|
||||||
top = rect.origin.y;
|
height = r.size.height;
|
||||||
|
left = r.origin.x;
|
||||||
|
top = r.origin.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxNonOwnedWindowIPhoneImpl::SetShape(const wxRegion& region)
|
bool wxNonOwnedWindowIPhoneImpl::SetShape(const wxRegion& region)
|
||||||
@@ -270,3 +300,91 @@ wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWind
|
|||||||
now->Create( parent, pos, size, style , extraStyle, name );
|
now->Create( parent, pos, size, style , extraStyle, name );
|
||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
|
||||||
|
{
|
||||||
|
UIWindow* toplevelwindow = now->GetWXWindow();
|
||||||
|
CGRect frame = [toplevelwindow bounds];
|
||||||
|
CGRect appframe = [[UIScreen mainScreen] applicationFrame];
|
||||||
|
|
||||||
|
if ( now->GetWindowStyle() == wxDEFAULT_FRAME_STYLE )
|
||||||
|
{
|
||||||
|
double offset = appframe.origin.y;
|
||||||
|
frame.origin.y += offset;
|
||||||
|
frame.size.height -= offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxUIContentView* contentview = [[wxUIContentView alloc] initWithFrame:frame];
|
||||||
|
contentview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||||
|
wxUIContentViewController* controller = [[wxUIContentViewController alloc] init];
|
||||||
|
controller.view = contentview;
|
||||||
|
[contentview setController:controller];
|
||||||
|
|
||||||
|
wxWidgetIPhoneImpl* impl = new wxWidgetIPhoneImpl( now, contentview, true );
|
||||||
|
impl->InstallEventHandler();
|
||||||
|
[toplevelwindow addSubview:contentview];
|
||||||
|
return impl;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// obj-c impl
|
||||||
|
//
|
||||||
|
|
||||||
|
@implementation wxUIContentView
|
||||||
|
|
||||||
|
- (void) setController: (UIViewController*) controller
|
||||||
|
{
|
||||||
|
_controller = controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UIViewController*) controller
|
||||||
|
{
|
||||||
|
return _controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation wxUIContentViewController
|
||||||
|
|
||||||
|
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation
|
||||||
|
{
|
||||||
|
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] );
|
||||||
|
wxNonOwnedWindow* now = dynamic_cast<wxNonOwnedWindow*> (impl->GetWXPeer());
|
||||||
|
|
||||||
|
// TODO: determine NO or YES based on min size requirements (whether it fits on the new orientation)
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
|
||||||
|
{
|
||||||
|
CGRect fr = [self.view frame];
|
||||||
|
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] );
|
||||||
|
wxNonOwnedWindow* now = dynamic_cast<wxNonOwnedWindow*> (impl->GetWXPeer());
|
||||||
|
|
||||||
|
now->HandleResized(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) dealloc
|
||||||
|
{
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UIView*) rotatingFooterView
|
||||||
|
{
|
||||||
|
UIView* footerView = [super rotatingFooterView];
|
||||||
|
if ( footerView == nil )
|
||||||
|
{
|
||||||
|
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] );
|
||||||
|
wxFrame* frame = dynamic_cast<wxFrame*> (impl->GetWXPeer());
|
||||||
|
if ( frame && frame->GetToolBar())
|
||||||
|
{
|
||||||
|
footerView = frame->GetToolBar()->GetHandle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -242,7 +242,6 @@ bool wxToolBar::Create(
|
|||||||
|
|
||||||
m_peer = new wxWidgetIPhoneImpl( this, toolbar );
|
m_peer = new wxWidgetIPhoneImpl( this, toolbar );
|
||||||
MacPostControlCreate(pos, size) ;
|
MacPostControlCreate(pos, size) ;
|
||||||
NSLog(@"toolbar was created %@",toolbar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxToolBar::~wxToolBar()
|
wxToolBar::~wxToolBar()
|
||||||
|
@@ -56,11 +56,6 @@ CGRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const
|
|||||||
return wxToNSRect( sv, bounds );
|
return wxToNSRect( sv, bounds );
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface wxUIView : UIView
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@end // wxUIView
|
|
||||||
|
|
||||||
@interface wxUIView(PossibleMethods)
|
@interface wxUIView(PossibleMethods)
|
||||||
- (void)setTitle:(NSString *)title forState:(UIControlState)state;
|
- (void)setTitle:(NSString *)title forState:(UIControlState)state;
|
||||||
@@ -76,18 +71,6 @@ CGRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const
|
|||||||
- (BOOL) resignFirstResponder;
|
- (BOOL) resignFirstResponder;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface wxUIContentView : wxUIView
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface wxUIContentViewController : UIViewController
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -313,33 +296,6 @@ void wxOSXIPhoneClassAddWXMethods(Class c)
|
|||||||
class_addMethod(c, @selector(drawRect:), (IMP) wxOSX_drawRect, "v@:{_CGRect={_CGPoint=ff}{_CGSize=ff}}" );
|
class_addMethod(c, @selector(drawRect:), (IMP) wxOSX_drawRect, "v@:{_CGRect={_CGPoint=ff}{_CGSize=ff}}" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation wxUIContentView
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation wxUIContentViewController
|
|
||||||
|
|
||||||
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation
|
|
||||||
{
|
|
||||||
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] );
|
|
||||||
wxNonOwnedWindow* now = dynamic_cast<wxNonOwnedWindow*> (impl->GetWXPeer());
|
|
||||||
|
|
||||||
// TODO: determine NO or YES based on min size requirements (whether it fits on the new orientation)
|
|
||||||
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
|
|
||||||
{
|
|
||||||
CGRect fr = [self.view frame];
|
|
||||||
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] );
|
|
||||||
wxNonOwnedWindow* now = dynamic_cast<wxNonOwnedWindow*> (impl->GetWXPeer());
|
|
||||||
|
|
||||||
now->HandleResized(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS( wxWidgetIPhoneImpl , wxWidgetImpl )
|
IMPLEMENT_DYNAMIC_CLASS( wxWidgetIPhoneImpl , wxWidgetImpl )
|
||||||
|
|
||||||
@@ -486,7 +442,7 @@ void wxWidgetImpl::Convert( wxPoint *pt , wxWidgetImpl *from , wxWidgetImpl *to
|
|||||||
|
|
||||||
void wxWidgetIPhoneImpl::SetBackgroundColour( const wxColour &col )
|
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::SetLabel(const wxString& title, wxFontEncoding encoding)
|
||||||
@@ -731,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))
|
void wxWidgetIPhoneImpl::touchEvent(NSSet* touches, UIEvent *event, WXWidget slf, void *WXUNUSED(_cmd))
|
||||||
{
|
{
|
||||||
CGPoint clickLocation;
|
bool inRecursion = false;
|
||||||
|
if ( inRecursion )
|
||||||
|
return;
|
||||||
|
|
||||||
UITouch *touch = [touches anyObject];
|
UITouch *touch = [touches anyObject];
|
||||||
clickLocation = [touch locationInView:slf];
|
CGPoint clickLocation;
|
||||||
wxPoint pt = wxFromNSPoint( m_osxView, clickLocation );
|
if ( [touch view] != slf && IsRootControl() )
|
||||||
|
{
|
||||||
wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
|
NSLog(@"self is %@ and touch view is %@",slf,[touch view]);
|
||||||
SetupMouseEvent( wxevent , touches, event ) ;
|
inRecursion = true;
|
||||||
wxevent.m_x = pt.x;
|
inRecursion = false;
|
||||||
wxevent.m_y = pt.y;
|
}
|
||||||
wxevent.SetEventObject( GetWXPeer() ) ;
|
else
|
||||||
//?wxevent.SetId( GetWXPeer()->GetId() ) ;
|
{
|
||||||
|
clickLocation = [touch locationInView:slf];
|
||||||
GetWXPeer()->HandleWindowEvent(wxevent);
|
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)
|
void wxWidgetIPhoneImpl::touchUpInsideAction(void* sender, WX_UIEvent evt, WXWidget slf, void* _cmd)
|
||||||
@@ -770,27 +739,3 @@ wxWidgetImpl* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer, wxWindowMac* WX
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
|
|
||||||
{
|
|
||||||
UIWindow* toplevelwindow = now->GetWXWindow();
|
|
||||||
CGRect frame = [toplevelwindow bounds];
|
|
||||||
CGRect appframe = [[UIScreen mainScreen] applicationFrame];
|
|
||||||
|
|
||||||
if ( now->GetWindowStyle() == wxDEFAULT_FRAME_STYLE )
|
|
||||||
{
|
|
||||||
double offset = appframe.origin.y;
|
|
||||||
frame.origin.y += offset;
|
|
||||||
frame.size.height -= offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxUIContentView* contentview = [[wxUIContentView alloc] initWithFrame:frame];
|
|
||||||
contentview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
||||||
wxUIContentViewController* controller = [[wxUIContentViewController alloc] init];
|
|
||||||
controller.view = contentview;
|
|
||||||
|
|
||||||
wxWidgetIPhoneImpl* impl = new wxWidgetIPhoneImpl( now, contentview, true );
|
|
||||||
impl->InstallEventHandler();
|
|
||||||
[toplevelwindow addSubview:contentview];
|
|
||||||
return impl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user