+
+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];
+ contentview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ wxUIContentViewController* controller = [[wxUIContentViewController alloc] init];
+ controller.view = contentview;
+ [contentview setController:controller];
+
+ wxWidgetIPhoneImpl* impl = new wxWidgetIPhoneImpl( now, contentview, true );
+ impl->InstallEventHandler();
+ [toplevelwindow addSubview:contentview];
+ return impl;
+}
+
+//
+// obj-c impl
+//
+
+@implementation wxUIContentView
+
+- (void) setController: (UIViewController*) controller
+{
+ _controller = controller;
+}
+
+- (UIViewController*) controller
+{
+ return _controller;
+}
+
+@end
+
+@implementation wxUIContentViewController
+
+- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation
+{
+ wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] );
+ wxNonOwnedWindow* now = dynamic_cast<wxNonOwnedWindow*> (impl->GetWXPeer());
+
+ // TODO: determine NO or YES based on min size requirements (whether it fits on the new orientation)
+
+ return YES;
+}
+
+- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
+{
+ CGRect fr = [self.view frame];
+ wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] );
+ wxNonOwnedWindow* now = dynamic_cast<wxNonOwnedWindow*> (impl->GetWXPeer());
+
+ now->HandleResized(0);
+}
+
+-(void) dealloc
+{
+ [super dealloc];
+}
+
+- (UIView*) rotatingFooterView
+{
+ UIView* footerView = [super rotatingFooterView];
+ if ( footerView == nil )
+ {
+ wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( [self view] );
+ wxFrame* frame = dynamic_cast<wxFrame*> (impl->GetWXPeer());
+ if ( frame && frame->GetToolBar())
+ {
+ footerView = frame->GetToolBar()->GetHandle();
+ }
+ }
+}
+
+@end
+
+
+