X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/524c47aa3adf2af11a3069fd5da035a604f08f66..089ca539acced38d70e750e4a9589cf8d175ec5d:/src/osx/iphone/utils.mm diff --git a/src/osx/iphone/utils.mm b/src/osx/iphone/utils.mm index 6f1cb5dc33..738b52dffa 100644 --- a/src/osx/iphone/utils.mm +++ b/src/osx/iphone/utils.mm @@ -77,11 +77,20 @@ bool wxApp::CallOnInit() int wxApp::OnRun() { wxMacAutoreleasePool pool; - char* appname = "test"; - UIApplicationMain( 1, &appname, nil, @"wxAppDelegate" ); + const char* appname = "app"; + UIApplicationMain( 1, (char**) &appname, nil, @"wxAppDelegate" ); return 1; } +bool wxApp::DoInitGui() +{ + return true; +} + +void wxApp::DoCleanUp() +{ +} + void wxMacWakeUp() { // TODO @@ -128,15 +137,31 @@ extern CGSize MeasureTextInContext( UIFont *font, NSString* text ) void wxClientDisplayRect(int *x, int *y, int *width, int *height) { CGRect r = [[UIScreen mainScreen] applicationFrame]; - if ( x ) - *x = r.origin.x; - if ( y ) - *y = r.origin.y; - if ( width ) - *width = r.size.width; - if ( height ) - *height = r.size.height; - + CGRect bounds = [[UIScreen mainScreen] bounds]; + if ( bounds.size.height > r.size.height ) + { + // portrait + if ( x ) + *x = r.origin.x; + if ( y ) + *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 ) @@ -153,12 +178,25 @@ int wxDisplayDepth() // Get size of display void wxDisplaySize(int *width, int *height) { + CGRect r = [[UIScreen mainScreen] applicationFrame]; CGRect bounds = [[UIScreen mainScreen] bounds]; - - if ( width ) - *width = (int)bounds.size.width ; - if ( height ) - *height = (int)bounds.size.height; + + if ( bounds.size.height > r.size.height ) + { + // portrait + 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) @@ -215,21 +253,21 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const // call this method when a Blit is performed with it as a source. if (!m_window) return wxNullBitmap; - + wxSize sz = m_window->GetSize(); - + int left = subrect != NULL ? subrect->x : 0 ; int top = subrect != NULL ? subrect->y : 0 ; int width = subrect != NULL ? subrect->width : sz.x; int height = subrect != NULL ? subrect->height : sz.y ; - + wxBitmap bmp = wxBitmap(width, height, 32); - + CGContextRef context = (CGContextRef)bmp.GetHBITMAP(); - + CGContextSaveGState(context); - - + + CGContextTranslateCTM( context, 0, height ); CGContextScaleCTM( context, 1, -1 ); @@ -251,10 +289,11 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) // get OS version int major, minor; - wxString release = wxCFStringRef( [ [UIDevice currentDevice] systemVersion] ).AsString() ; + wxString release = wxCFStringRef( wxCFRetain( [ [UIDevice currentDevice] systemVersion] ) ).AsString() ; if ( release.empty() || - wxSscanf(release.c_str(), wxT("%d.%d"), &major, &minor) != 2 ) + // TODO use wx method + scanf(release.c_str(), wxT("%d.%d"), &major, &minor) != 2 ) { // failed to get version string or unrecognized format major = @@ -271,7 +310,7 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) wxString wxGetOsDescription() { - wxString release = wxCFStringRef( [ [UIDevice currentDevice] systemName] ).AsString() ; + wxString release = wxCFStringRef( wxCFRetain([ [UIDevice currentDevice] systemName] )).AsString() ; return release; }