X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/de7cb655ae8436f02607fd71c85b7fd6483bce15..08670ea85abf4b4946a9ce64971b591d7b1ee30b:/src/osx/iphone/nonownedwnd.mm diff --git a/src/osx/iphone/nonownedwnd.mm b/src/osx/iphone/nonownedwnd.mm index a1dbf134b8..53168f0daf 100644 --- a/src/osx/iphone/nonownedwnd.mm +++ b/src/osx/iphone/nonownedwnd.mm @@ -1,10 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/osx/cocoa/nonownedwnd.mm +// Name: src/osx/iphone/nonownedwnd.mm // Purpose: non owned window for iphone // Author: Stefan Csomor // Modified by: // Created: 2008-06-20 -// RCS-ID: $Id: nonownedwnd.mm 48805 2007-09-19 14:52:25Z SC $ +// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -55,13 +55,13 @@ wxPoint wxFromNSPoint( UIView* parent, const CGPoint& p ) @end -@interface wxUIContentView : wxUIView +@interface wxUIContentView : UIView { wxUIContentViewController* _controller; } -- (void) setController: (UIViewController*) controller; -- (UIViewController*) controller; +- (void) setController: (wxUIContentViewController*) controller; +- (wxUIContentViewController*) controller; @end @@ -77,12 +77,14 @@ wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl( wxNonOwnedWindow* nonown { m_macWindow = NULL; m_macFullScreenData = NULL; + m_initialShowSent = false; } wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl() { m_macWindow = NULL; m_macFullScreenData = NULL; + m_initialShowSent = false; } wxNonOwnedWindowIPhoneImpl::~wxNonOwnedWindowIPhoneImpl() @@ -90,9 +92,8 @@ wxNonOwnedWindowIPhoneImpl::~wxNonOwnedWindowIPhoneImpl() [m_macWindow release]; } -void wxNonOwnedWindowIPhoneImpl::Destroy() +void wxNonOwnedWindowIPhoneImpl::WillBeDestroyed() { - wxPendingDelete.Append( new wxDeferredObjectDeleter( this ) ); } void wxNonOwnedWindowIPhoneImpl::Create( wxWindow* parent, const wxPoint& pos, const wxSize& size, @@ -129,9 +130,14 @@ long style, long extraStyle, const wxString& name ) std::swap(r.size.width,r.size.height); [m_macWindow initWithFrame:r ]; + [m_macWindow setHidden:YES]; [m_macWindow setWindowLevel:level]; - // [m_macWindow makeKeyAndOrderFront:nil]; +} + +void wxNonOwnedWindowIPhoneImpl::Create( wxWindow* WXUNUSED(parent), WXWindow nativeWindow ) +{ + m_macWindow = nativeWindow; } @@ -153,6 +159,16 @@ bool wxNonOwnedWindowIPhoneImpl::Show(bool show) [m_macWindow setHidden:(show ? NO : YES)]; if ( show ) { + if ( !m_initialShowSent ) + { + wxNonOwnedWindow* now = dynamic_cast (GetWXPeer()); + wxShowEvent eventShow(now->GetId(), true); + eventShow.SetEventObject(now); + + now->HandleWindowEvent(eventShow); + + m_initialShowSent = true; + } //[m_macWindow orderFront: self]; [m_macWindow makeKeyWindow]; } @@ -257,6 +273,11 @@ void wxNonOwnedWindowIPhoneImpl::Iconize( bool iconize ) void wxNonOwnedWindowIPhoneImpl::Maximize(bool maximize) { + if ( maximize ) + { + CGRect r = [[UIScreen mainScreen] bounds]; + [m_macWindow setFrame:r]; + } } bool wxNonOwnedWindowIPhoneImpl::IsFullScreen() const @@ -293,6 +314,14 @@ void wxNonOwnedWindowIPhoneImpl::WindowToScreen( int *x, int *y ) *y = p.y; } +wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, WXWindow nativeWindow) +{ + wxNonOwnedWindowIPhoneImpl* now = new wxNonOwnedWindowIPhoneImpl( wxpeer ); + now->Create( parent, nativeWindow ); + return now; +} + + wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size, long style, long extraStyle, const wxString& name ) { @@ -306,19 +335,20 @@ 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]; + BOOL fullscreen = now->GetWindowStyle() == wxDEFAULT_FRAME_STYLE && [[UIApplication sharedApplication] statusBarStyle] == UIStatusBarStyleBlackTranslucent; + + wxUIContentView* contentview = [[wxUIContentView alloc] initWithFrame:( fullscreen ? frame : appframe ) ]; contentview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - wxUIContentViewController* controller = [[wxUIContentViewController alloc] init]; + wxUIContentViewController* controller = [[wxUIContentViewController alloc] initWithNibName:nil bundle:nil]; + +#ifdef __IPHONE_3_0 + controller.wantsFullScreenLayout = fullscreen; +#endif + controller.view = contentview; + [contentview release]; [contentview setController:controller]; + [contentview setHidden:YES]; wxWidgetIPhoneImpl* impl = new wxWidgetIPhoneImpl( now, contentview, true ); impl->InstallEventHandler(); @@ -332,16 +362,26 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now ) @implementation wxUIContentView -- (void) setController: (UIViewController*) controller +- (void) setController: (wxUIContentViewController*) controller { _controller = controller; } -- (UIViewController*) controller +- (wxUIContentViewController*) controller { return _controller; } ++ (void)initialize +{ + static BOOL initialized = NO; + if (!initialized) + { + initialized = YES; + wxOSXIPhoneClassAddWXMethods( self ); + } +} + @end @implementation wxUIContentViewController @@ -358,13 +398,45 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now ) - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { - CGRect fr = [self.view frame]; wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] ); wxNonOwnedWindow* now = dynamic_cast (impl->GetWXPeer()); now->HandleResized(0); } +-(void) viewWillAppear:(BOOL)animated +{ + wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] ); + wxNonOwnedWindow* now = dynamic_cast (impl->GetWXPeer()); + wxNonOwnedWindowIPhoneImpl* nowimpl = dynamic_cast (now->GetNonOwnedPeer()); + + if ( nowimpl->InitialShowEventSent() ) + { + wxShowEvent eventShow(now->GetId(), true); + eventShow.SetEventObject(now); + + now->HandleWindowEvent(eventShow); + } +} + +-(void) viewWillDisappear:(BOOL)animated +{ + wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] ); + if( impl ) + { + wxNonOwnedWindow* now = dynamic_cast (impl->GetWXPeer()); + wxNonOwnedWindowIPhoneImpl* nowimpl = dynamic_cast (now->GetNonOwnedPeer()); + + if ( nowimpl->InitialShowEventSent() ) + { + wxShowEvent eventShow(now->GetId(), false); + eventShow.SetEventObject(now); + + now->HandleWindowEvent(eventShow); + } + } +} + -(void) dealloc { [super dealloc];