From 4cc16dcb8b8bf027af89c0c4d73f97ffdd44b997 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 3 Mar 2010 16:53:34 +0000 Subject: [PATCH] using native fullscreen support and ShowEvent triggers git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63620 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/iphone/nonownedwnd.mm | 95 +++++++++++++++++++---------------- src/osx/window_osx.cpp | 12 +++-- 2 files changed, 60 insertions(+), 47 deletions(-) diff --git a/src/osx/iphone/nonownedwnd.mm b/src/osx/iphone/nonownedwnd.mm index 75b87eb70e..8fe020d158 100644 --- a/src/osx/iphone/nonownedwnd.mm +++ b/src/osx/iphone/nonownedwnd.mm @@ -60,8 +60,8 @@ wxPoint wxFromNSPoint( UIView* parent, const CGPoint& p ) 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() @@ -128,9 +130,9 @@ 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]; } @@ -152,6 +154,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]; } @@ -305,19 +317,16 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now ) UIWindow* toplevelwindow = now->GetWXWindow(); CGRect frame = [toplevelwindow bounds]; CGRect appframe = [[UIScreen mainScreen] applicationFrame]; - - if ( now->GetWindowStyle() == wxDEFAULT_FRAME_STYLE && [[UIApplication sharedApplication] statusBarStyle] != UIStatusBarStyleBlackTranslucent) - { - 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]; + controller.wantsFullScreenLayout = fullscreen; controller.view = contentview; + [contentview release]; [contentview setController:controller]; + [contentview setHidden:YES]; wxWidgetIPhoneImpl* impl = new wxWidgetIPhoneImpl( now, contentview, true ); impl->InstallEventHandler(); @@ -331,12 +340,12 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now ) @implementation wxUIContentView -- (void) setController: (UIViewController*) controller +- (void) setController: (wxUIContentViewController*) controller { _controller = controller; } -- (UIViewController*) controller +- (wxUIContentViewController*) controller { return _controller; } @@ -357,42 +366,40 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now ) - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { - CGRect frame = [self.view frame]; wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] ); wxNonOwnedWindow* now = dynamic_cast (impl->GetWXPeer()); + + now->HandleResized(0); +} - if ( now->GetWindowStyle() == wxDEFAULT_FRAME_STYLE && [[UIApplication sharedApplication] statusBarStyle] == UIStatusBarStyleBlackTranslucent) +-(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() ) { - CGRect appframe = [[UIScreen mainScreen] applicationFrame]; - CGRect bounds = [[UIScreen mainScreen] bounds]; - if ( CGRectEqualToRect(appframe, frame) ) - { - if ( appframe.origin.y != 0 ) - { - double offset = appframe.origin.y; - frame.origin.y -= offset; - frame.size.height += offset; - } - else if ( appframe.origin.x != 0 ) - { - double offset = appframe.origin.x; - frame.origin.x -= offset; - frame.size.width += offset; - } - else if ( appframe.size.height < bounds.size.height ) - { - frame.size.height = bounds.size.height; - } - else if ( appframe.size.width < bounds.size.width ) - { - frame.size.width = bounds.size.width; - } - - [self.view setFrame:frame]; - } + wxShowEvent eventShow(now->GetId(), true); + eventShow.SetEventObject(now); + + now->HandleWindowEvent(eventShow); } +} + +-(void) viewWillDisappear:(BOOL)animated +{ + wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] ); + wxNonOwnedWindow* now = dynamic_cast (impl->GetWXPeer()); + wxNonOwnedWindowIPhoneImpl* nowimpl = dynamic_cast (now->GetNonOwnedPeer()); - now->HandleResized(0); + if ( nowimpl->InitialShowEventSent() ) + { + wxShowEvent eventShow(now->GetId(), false); + eventShow.SetEventObject(now); + + now->HandleWindowEvent(eventShow); + } } -(void) dealloc diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index 0eeb0df526..20af778038 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -1061,10 +1061,16 @@ bool wxWindowMac::Show(bool show) if ( m_peer ) m_peer->SetVisibility( show ) ; - wxShowEvent eventShow(GetId(), show); - eventShow.SetEventObject(this); +#ifdef __WXOSX_IPHONE__ + // only when there's no native event support + if ( !IsTopLevel() ) +#endif + { + wxShowEvent eventShow(GetId(), show); + eventShow.SetEventObject(this); - HandleWindowEvent(eventShow); + HandleWindowEvent(eventShow); + } return true; } -- 2.45.2