support for auto-rotate on iphone
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62496 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -194,7 +194,7 @@ void wxNonOwnedWindowIPhoneImpl::GetSize( int &width, int &height ) const
|
|||||||
|
|
||||||
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 frame];
|
CGRect rect = [m_macWindow bounds];
|
||||||
width = rect.size.width;
|
width = rect.size.width;
|
||||||
height = rect.size.height;
|
height = rect.size.height;
|
||||||
left = rect.origin.x;
|
left = rect.origin.x;
|
||||||
|
@@ -136,6 +136,7 @@ extern CGSize MeasureTextInContext( UIFont *font, NSString* text )
|
|||||||
|
|
||||||
void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
CGRect r = [[UIScreen mainScreen] applicationFrame];
|
CGRect r = [[UIScreen mainScreen] applicationFrame];
|
||||||
CGRect bounds = [[UIScreen mainScreen] bounds];
|
CGRect bounds = [[UIScreen mainScreen] bounds];
|
||||||
if ( bounds.size.height > r.size.height )
|
if ( bounds.size.height > r.size.height )
|
||||||
@@ -162,6 +163,15 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
|||||||
if ( height )
|
if ( height )
|
||||||
*height = r.size.width;
|
*height = r.size.width;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// it's easier to treat the status bar as an element of the toplevel window
|
||||||
|
// instead of the desktop in order to support easy rotation
|
||||||
|
if ( x )
|
||||||
|
*x = 0;
|
||||||
|
if ( y )
|
||||||
|
*y = 0;
|
||||||
|
wxDisplaySize(width, height);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGetMousePosition( int* x, int* y )
|
void wxGetMousePosition( int* x, int* y )
|
||||||
|
@@ -321,17 +321,21 @@ void wxOSXIPhoneClassAddWXMethods(Class c)
|
|||||||
|
|
||||||
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation
|
- (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;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
|
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
|
||||||
{
|
{
|
||||||
CGRect fr = [self.view frame];
|
CGRect fr = [self.view frame];
|
||||||
// CGRect cv = [[self.view superview] frame];
|
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] );
|
||||||
// CGRect bounds = CGRectMake( 0,0,fr.size.width, fr.size.height);
|
wxNonOwnedWindow* now = dynamic_cast<wxNonOwnedWindow*> (impl->GetWXPeer());
|
||||||
// [[self.view superview] setFrame: fr ];
|
|
||||||
// [self.view setFrame: bounds];
|
now->HandleResized(0);
|
||||||
// [self.view setNeedsDisplayInRect:bounds];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -419,7 +423,9 @@ void wxWidgetIPhoneImpl::GetSize( int &width, int &height ) const
|
|||||||
void wxWidgetIPhoneImpl::GetContentArea( int&left, int &top, int &width, int &height ) const
|
void wxWidgetIPhoneImpl::GetContentArea( int&left, int &top, int &width, int &height ) const
|
||||||
{
|
{
|
||||||
left = top = 0;
|
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::SetNeedsDisplay( const wxRect* where )
|
||||||
@@ -767,31 +773,21 @@ wxWidgetImpl* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer, wxWindowMac* WX
|
|||||||
wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
|
wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
|
||||||
{
|
{
|
||||||
UIWindow* toplevelwindow = now->GetWXWindow();
|
UIWindow* toplevelwindow = now->GetWXWindow();
|
||||||
|
CGRect frame = [toplevelwindow bounds];
|
||||||
|
CGRect appframe = [[UIScreen mainScreen] applicationFrame];
|
||||||
|
|
||||||
wxUIContentView* contentview = [[wxUIContentView alloc] initWithFrame:[toplevelwindow bounds]];
|
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;
|
contentview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||||
wxUIContentViewController* controller = [[wxUIContentViewController alloc] init];
|
wxUIContentViewController* controller = [[wxUIContentViewController alloc] init];
|
||||||
controller.view = contentview;
|
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 );
|
wxWidgetIPhoneImpl* impl = new wxWidgetIPhoneImpl( now, contentview, true );
|
||||||
impl->InstallEventHandler();
|
impl->InstallEventHandler();
|
||||||
[toplevelwindow addSubview:contentview];
|
[toplevelwindow addSubview:contentview];
|
||||||
|
@@ -399,8 +399,13 @@ void wxNonOwnedWindow::DoGetClientSize( int *width, int *height ) const
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int left, top, w, h;
|
int left, top, w, h;
|
||||||
|
// perhaps we should do this for all ?
|
||||||
|
#ifdef __WXOSX_IPHONE__
|
||||||
|
m_peer->GetContentArea(left, top, w, h);
|
||||||
|
#else
|
||||||
m_nowpeer->GetContentArea(left, top, w, h);
|
m_nowpeer->GetContentArea(left, top, w, h);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (width)
|
if (width)
|
||||||
*width = w ;
|
*width = w ;
|
||||||
if (height)
|
if (height)
|
||||||
|
Reference in New Issue
Block a user