X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/524c47aa3adf2af11a3069fd5da035a604f08f66..07890fbeb5e65f242e8632ed957c54e188779af2:/src/osx/iphone/nonownedwnd.mm diff --git a/src/osx/iphone/nonownedwnd.mm b/src/osx/iphone/nonownedwnd.mm index 641357a072..6b484a5fda 100644 --- a/src/osx/iphone/nonownedwnd.mm +++ b/src/osx/iphone/nonownedwnd.mm @@ -16,21 +16,54 @@ #include "wx/nonownedwnd.h" #include "wx/frame.h" +CGRect wxToNSRect(UIView* parent, const wxRect& r ) +{ + CGRect frame = parent ? [parent bounds] : [[UIScreen mainScreen] bounds]; + int y = r.y; + int x = r.x ; + return CGRectMake(x, y, r.width , r.height); +} + +wxRect wxFromNSRect( UIView* parent, const CGRect& rect ) +{ + CGRect frame = parent ? [parent bounds] : [[UIScreen mainScreen] bounds]; + int y = rect.origin.y; + int x = rect.origin.x; + return wxRect( x, y, rect.size.width, rect.size.height ); +} + +CGPoint wxToNSPoint( UIView* parent, const wxPoint& p ) +{ + CGRect frame = parent ? [parent bounds] : [[UIScreen mainScreen] bounds]; + int x = p.x ; + int y = p.y; + return CGPointMake(x, y); +} + +wxPoint wxFromNSPoint( UIView* parent, const CGPoint& p ) +{ + CGRect frame = parent ? [parent bounds] : [[UIScreen mainScreen] bounds]; + int x = p.x; + int y = p.y; + return wxPoint( x, y); +} + + IMPLEMENT_DYNAMIC_CLASS( wxNonOwnedWindowIPhoneImpl , wxNonOwnedWindowImpl ) -wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl( wxNonOwnedWindow* nonownedwnd) : +wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl( wxNonOwnedWindow* nonownedwnd) : wxNonOwnedWindowImpl(nonownedwnd) { m_macWindow = NULL; m_macFullScreenData = NULL; } - -wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl() + +wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl() { m_macWindow = NULL; m_macFullScreenData = NULL; } - + wxNonOwnedWindowIPhoneImpl::~wxNonOwnedWindowIPhoneImpl() { [m_macWindow release]; @@ -45,11 +78,11 @@ void wxNonOwnedWindowIPhoneImpl::Create( wxWindow* parent, const wxPoint& pos, c long style, long extraStyle, const wxString& name ) { m_macWindow = [UIWindow alloc]; - + UIWindowLevel level = UIWindowLevelNormal; - + // most styles are not supported on the iphone - + if ( style & wxFRAME_TOOL_WINDOW ) { level = UIWindowLevelAlert; ; @@ -69,11 +102,11 @@ long style, long extraStyle, const wxString& name ) } if ( ( style & wxSTAY_ON_TOP ) ) - level = UIWindowLevelAlert; + level = UIWindowLevelAlert; CGRect r = CGRectMake( 0, 0, size.x, size.y) ; - + [m_macWindow initWithFrame:r ]; - + [m_macWindow setWindowLevel:level]; // [m_macWindow makeKeyAndOrderFront:nil]; } @@ -87,7 +120,7 @@ WXWindow wxNonOwnedWindowIPhoneImpl::GetWXWindow() const void wxNonOwnedWindowIPhoneImpl::Raise() { } - + void wxNonOwnedWindowIPhoneImpl::Lower() { } @@ -102,7 +135,7 @@ bool wxNonOwnedWindowIPhoneImpl::Show(bool show) } return true; } - + bool wxNonOwnedWindowIPhoneImpl::ShowWithEffect(bool show, wxShowEffect effect, unsigned timeout) { return Show(show); @@ -128,12 +161,12 @@ void wxNonOwnedWindowIPhoneImpl::SetExtraStyle( long exStyle ) { // no special styles supported } - + bool wxNonOwnedWindowIPhoneImpl::SetBackgroundStyle(wxBackgroundStyle style) { return true; } - + bool wxNonOwnedWindowIPhoneImpl::CanSetTransparent() { return true; @@ -141,7 +174,7 @@ bool wxNonOwnedWindowIPhoneImpl::CanSetTransparent() void wxNonOwnedWindowIPhoneImpl::MoveWindow(int x, int y, int width, int height) { - CGRect r = CGRectMake( 0,0,width,height) ; + CGRect r = CGRectMake( x,y,width,height) ; [m_macWindow setFrame:r]; } @@ -159,39 +192,39 @@ void wxNonOwnedWindowIPhoneImpl::GetSize( int &width, int &height ) const height = rect.size.height; } -void wxNonOwnedWindowIPhoneImpl::GetContentArea( int& left, int &right, 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 frame]; width = rect.size.width; height = rect.size.height; - left = 0; - right = 0; + left = rect.origin.x; + top = rect.origin.y; } - + bool wxNonOwnedWindowIPhoneImpl::SetShape(const wxRegion& region) { return false; } -void wxNonOwnedWindowIPhoneImpl::SetTitle( const wxString& title, wxFontEncoding encoding ) +void wxNonOwnedWindowIPhoneImpl::SetTitle( const wxString& title, wxFontEncoding encoding ) { // TODO change title of app ? } - + bool wxNonOwnedWindowIPhoneImpl::IsMaximized() const { return false; } - + bool wxNonOwnedWindowIPhoneImpl::IsIconized() const { return false; } - + void wxNonOwnedWindowIPhoneImpl::Iconize( bool iconize ) { } - + void wxNonOwnedWindowIPhoneImpl::Maximize(bool maximize) { } @@ -200,9 +233,9 @@ bool wxNonOwnedWindowIPhoneImpl::IsFullScreen() const { return m_macFullScreenData != NULL ; } - + bool wxNonOwnedWindowIPhoneImpl::ShowFullScreen(bool show, long style) -{ +{ return true; }