using native fullscreen support and ShowEvent triggers
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63620 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -60,8 +60,8 @@ wxPoint wxFromNSPoint( UIView* parent, const CGPoint& p )
|
|||||||
wxUIContentViewController* _controller;
|
wxUIContentViewController* _controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setController: (UIViewController*) controller;
|
- (void) setController: (wxUIContentViewController*) controller;
|
||||||
- (UIViewController*) controller;
|
- (wxUIContentViewController*) controller;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@@ -77,12 +77,14 @@ wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl( wxNonOwnedWindow* nonown
|
|||||||
{
|
{
|
||||||
m_macWindow = NULL;
|
m_macWindow = NULL;
|
||||||
m_macFullScreenData = NULL;
|
m_macFullScreenData = NULL;
|
||||||
|
m_initialShowSent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl()
|
wxNonOwnedWindowIPhoneImpl::wxNonOwnedWindowIPhoneImpl()
|
||||||
{
|
{
|
||||||
m_macWindow = NULL;
|
m_macWindow = NULL;
|
||||||
m_macFullScreenData = NULL;
|
m_macFullScreenData = NULL;
|
||||||
|
m_initialShowSent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxNonOwnedWindowIPhoneImpl::~wxNonOwnedWindowIPhoneImpl()
|
wxNonOwnedWindowIPhoneImpl::~wxNonOwnedWindowIPhoneImpl()
|
||||||
@@ -128,9 +130,9 @@ long style, long extraStyle, const wxString& name )
|
|||||||
std::swap(r.size.width,r.size.height);
|
std::swap(r.size.width,r.size.height);
|
||||||
|
|
||||||
[m_macWindow initWithFrame:r ];
|
[m_macWindow initWithFrame:r ];
|
||||||
|
[m_macWindow setHidden:YES];
|
||||||
|
|
||||||
[m_macWindow setWindowLevel:level];
|
[m_macWindow setWindowLevel:level];
|
||||||
// [m_macWindow makeKeyAndOrderFront:nil];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -152,6 +154,16 @@ bool wxNonOwnedWindowIPhoneImpl::Show(bool show)
|
|||||||
[m_macWindow setHidden:(show ? NO : YES)];
|
[m_macWindow setHidden:(show ? NO : YES)];
|
||||||
if ( show )
|
if ( show )
|
||||||
{
|
{
|
||||||
|
if ( !m_initialShowSent )
|
||||||
|
{
|
||||||
|
wxNonOwnedWindow* now = dynamic_cast<wxNonOwnedWindow*> (GetWXPeer());
|
||||||
|
wxShowEvent eventShow(now->GetId(), true);
|
||||||
|
eventShow.SetEventObject(now);
|
||||||
|
|
||||||
|
now->HandleWindowEvent(eventShow);
|
||||||
|
|
||||||
|
m_initialShowSent = true;
|
||||||
|
}
|
||||||
//[m_macWindow orderFront: self];
|
//[m_macWindow orderFront: self];
|
||||||
[m_macWindow makeKeyWindow];
|
[m_macWindow makeKeyWindow];
|
||||||
}
|
}
|
||||||
@@ -305,19 +317,16 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
|
|||||||
UIWindow* toplevelwindow = now->GetWXWindow();
|
UIWindow* toplevelwindow = now->GetWXWindow();
|
||||||
CGRect frame = [toplevelwindow bounds];
|
CGRect frame = [toplevelwindow bounds];
|
||||||
CGRect appframe = [[UIScreen mainScreen] applicationFrame];
|
CGRect appframe = [[UIScreen mainScreen] applicationFrame];
|
||||||
|
BOOL fullscreen = now->GetWindowStyle() == wxDEFAULT_FRAME_STYLE && [[UIApplication sharedApplication] statusBarStyle] == UIStatusBarStyleBlackTranslucent;
|
||||||
|
|
||||||
if ( now->GetWindowStyle() == wxDEFAULT_FRAME_STYLE && [[UIApplication sharedApplication] statusBarStyle] != UIStatusBarStyleBlackTranslucent)
|
wxUIContentView* contentview = [[wxUIContentView alloc] initWithFrame:( fullscreen ? frame : appframe ) ];
|
||||||
{
|
|
||||||
double offset = appframe.origin.y;
|
|
||||||
frame.origin.y += offset;
|
|
||||||
frame.size.height -= offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxUIContentView* contentview = [[wxUIContentView alloc] initWithFrame:frame];
|
|
||||||
contentview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
contentview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||||
wxUIContentViewController* controller = [[wxUIContentViewController alloc] init];
|
wxUIContentViewController* controller = [[wxUIContentViewController alloc] init];
|
||||||
|
controller.wantsFullScreenLayout = fullscreen;
|
||||||
controller.view = contentview;
|
controller.view = contentview;
|
||||||
|
[contentview release];
|
||||||
[contentview setController:controller];
|
[contentview setController:controller];
|
||||||
|
[contentview setHidden:YES];
|
||||||
|
|
||||||
wxWidgetIPhoneImpl* impl = new wxWidgetIPhoneImpl( now, contentview, true );
|
wxWidgetIPhoneImpl* impl = new wxWidgetIPhoneImpl( now, contentview, true );
|
||||||
impl->InstallEventHandler();
|
impl->InstallEventHandler();
|
||||||
@@ -331,12 +340,12 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
|
|||||||
|
|
||||||
@implementation wxUIContentView
|
@implementation wxUIContentView
|
||||||
|
|
||||||
- (void) setController: (UIViewController*) controller
|
- (void) setController: (wxUIContentViewController*) controller
|
||||||
{
|
{
|
||||||
_controller = controller;
|
_controller = controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIViewController*) controller
|
- (wxUIContentViewController*) controller
|
||||||
{
|
{
|
||||||
return _controller;
|
return _controller;
|
||||||
}
|
}
|
||||||
@@ -357,44 +366,42 @@ wxWidgetImpl* wxWidgetImpl::CreateContentView( wxNonOwnedWindow* now )
|
|||||||
|
|
||||||
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
|
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
|
||||||
{
|
{
|
||||||
CGRect frame = [self.view frame];
|
|
||||||
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] );
|
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] );
|
||||||
wxNonOwnedWindow* now = dynamic_cast<wxNonOwnedWindow*> (impl->GetWXPeer());
|
wxNonOwnedWindow* now = dynamic_cast<wxNonOwnedWindow*> (impl->GetWXPeer());
|
||||||
|
|
||||||
if ( now->GetWindowStyle() == wxDEFAULT_FRAME_STYLE && [[UIApplication sharedApplication] statusBarStyle] == UIStatusBarStyleBlackTranslucent)
|
|
||||||
{
|
|
||||||
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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
now->HandleResized(0);
|
now->HandleResized(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void) viewWillAppear:(BOOL)animated
|
||||||
|
{
|
||||||
|
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] );
|
||||||
|
wxNonOwnedWindow* now = dynamic_cast<wxNonOwnedWindow*> (impl->GetWXPeer());
|
||||||
|
wxNonOwnedWindowIPhoneImpl* nowimpl = dynamic_cast<wxNonOwnedWindowIPhoneImpl*> (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] );
|
||||||
|
wxNonOwnedWindow* now = dynamic_cast<wxNonOwnedWindow*> (impl->GetWXPeer());
|
||||||
|
wxNonOwnedWindowIPhoneImpl* nowimpl = dynamic_cast<wxNonOwnedWindowIPhoneImpl*> (now->GetNonOwnedPeer());
|
||||||
|
|
||||||
|
if ( nowimpl->InitialShowEventSent() )
|
||||||
|
{
|
||||||
|
wxShowEvent eventShow(now->GetId(), false);
|
||||||
|
eventShow.SetEventObject(now);
|
||||||
|
|
||||||
|
now->HandleWindowEvent(eventShow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-(void) dealloc
|
-(void) dealloc
|
||||||
{
|
{
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
|
@@ -1061,10 +1061,16 @@ bool wxWindowMac::Show(bool show)
|
|||||||
if ( m_peer )
|
if ( m_peer )
|
||||||
m_peer->SetVisibility( show ) ;
|
m_peer->SetVisibility( show ) ;
|
||||||
|
|
||||||
|
#ifdef __WXOSX_IPHONE__
|
||||||
|
// only when there's no native event support
|
||||||
|
if ( !IsTopLevel() )
|
||||||
|
#endif
|
||||||
|
{
|
||||||
wxShowEvent eventShow(GetId(), show);
|
wxShowEvent eventShow(GetId(), show);
|
||||||
eventShow.SetEventObject(this);
|
eventShow.SetEventObject(this);
|
||||||
|
|
||||||
HandleWindowEvent(eventShow);
|
HandleWindowEvent(eventShow);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user