supporting rotated display correctly for display size

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61911 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2009-09-13 17:33:46 +00:00
parent 4e16d05a28
commit 62018605a1

View File

@@ -77,8 +77,8 @@ bool wxApp::CallOnInit()
int wxApp::OnRun() int wxApp::OnRun()
{ {
wxMacAutoreleasePool pool; wxMacAutoreleasePool pool;
char* appname = "test"; const char* appname = "app";
UIApplicationMain( 1, &appname, nil, @"wxAppDelegate" ); UIApplicationMain( 1, (char**) &appname, nil, @"wxAppDelegate" );
return 1; return 1;
} }
@@ -137,15 +137,31 @@ 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)
{ {
CGRect r = [[UIScreen mainScreen] applicationFrame]; CGRect r = [[UIScreen mainScreen] applicationFrame];
if ( x ) CGRect bounds = [[UIScreen mainScreen] bounds];
*x = r.origin.x; if ( bounds.size.height > r.size.height )
if ( y ) {
*y = r.origin.y; // portrait
if ( width ) if ( x )
*width = r.size.width; *x = r.origin.x;
if ( height ) if ( y )
*height = r.size.height; *y = r.origin.y;
if ( width )
*width = r.size.width;
if ( height )
*height = r.size.height;
}
else
{
// landscape
if ( x )
*x = r.origin.y;
if ( y )
*y = r.origin.x;
if ( width )
*width = r.size.height;
if ( height )
*height = r.size.width;
}
} }
void wxGetMousePosition( int* x, int* y ) void wxGetMousePosition( int* x, int* y )
@@ -162,12 +178,25 @@ int wxDisplayDepth()
// Get size of display // Get size of display
void wxDisplaySize(int *width, int *height) void wxDisplaySize(int *width, int *height)
{ {
CGRect r = [[UIScreen mainScreen] applicationFrame];
CGRect bounds = [[UIScreen mainScreen] bounds]; CGRect bounds = [[UIScreen mainScreen] bounds];
if ( width ) if ( bounds.size.height > r.size.height )
*width = (int)bounds.size.width ; {
if ( height ) // portrait
*height = (int)bounds.size.height; if ( width )
*width = (int)bounds.size.width ;
if ( height )
*height = (int)bounds.size.height;
}
else
{
// landscape
if ( width )
*width = (int)bounds.size.height ;
if ( height )
*height = (int)bounds.size.width;
}
} }
wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer) wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)