mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-22 06:05:36 +08:00
Minimal wxMoNotebook implementation (now sort of works)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WXIOS@68105 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -56,7 +56,7 @@ public:
|
||||
|
||||
virtual ~wxMoPanel();
|
||||
|
||||
// Ignore attempts to hide too
|
||||
// Ignore attempts to hide panel
|
||||
bool Show(bool show = true);
|
||||
|
||||
// calls layout for layout constraints and sizers
|
||||
|
||||
@@ -375,26 +375,25 @@ void DemoFrame::CreateControls()
|
||||
wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
|
||||
SetSizer(topSizer);
|
||||
|
||||
wxMoStaticText *testStaticText = new wxMoStaticText(this, wxID_ANY, "Hello.", wxDefaultPosition, wxSize(-1, -1), wxNO_BORDER);
|
||||
|
||||
return;
|
||||
|
||||
wxMoNotebook* notebook = new wxMoNotebook(this, wxID_ANY, wxDefaultPosition, wxSize(-1, -1), wxBK_BOTTOM|wxBK_TEXT|wxBK_BITMAP|wxNO_BORDER);
|
||||
topSizer->Add(notebook, 1, wxEXPAND);
|
||||
|
||||
wxMoPanel* page1 = new wxMoPanel(notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
|
||||
wxMoPanel* page1 = new wxMoPanel(notebook, wxID_ANY, wxPoint(0, 0), wxSize(320, 411), wxNO_BORDER);
|
||||
notebook->AddPage(page1, _("Demo"), true, wxID_TOPRATED);
|
||||
// Items for page 1
|
||||
{
|
||||
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
||||
page1->SetSizer(sizer);
|
||||
|
||||
wxMoStaticText *testStaticText = new wxMoStaticText(page1, wxID_ANY, "Hello.", wxPoint(40, 40), wxSize(100, 100), wxNO_BORDER);
|
||||
|
||||
wxMoNavigationCtrl* navCtrl = new wxMoNavigationCtrl(page1, wxID_ANY);
|
||||
sizer->Add(navCtrl, 1, wxEXPAND, 0);
|
||||
|
||||
navCtrl->PushController(new TableDemoController(_("iPhone Demo"), navCtrl));
|
||||
}
|
||||
|
||||
wxMoPanel* page2 = new wxMoPanel(notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
|
||||
|
||||
wxMoPanel* page2 = new wxMoPanel(notebook, wxID_ANY, wxPoint(0, 0), wxSize(320, 411), wxNO_BORDER);
|
||||
notebook->AddPage(page2, _("Navigation"), false, wxID_SEARCH);
|
||||
|
||||
// Items for page 2
|
||||
@@ -408,7 +407,7 @@ void DemoFrame::CreateControls()
|
||||
navCtrl->PushController(new DemoViewController(_("Demo View 1"), navCtrl, 1));
|
||||
}
|
||||
|
||||
wxMoPanel* page3 = new wxMoPanel(notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
|
||||
wxMoPanel* page3 = new wxMoPanel(notebook, wxID_ANY, wxPoint(0, 0), wxSize(320, 411), wxNO_BORDER);
|
||||
notebook->AddPage(page3, _("Scrolling"), false, wxID_CONTACTS);
|
||||
notebook->SetBadge(2, wxT("1"));
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
406DAC1F13B508E0002E4240 /* demoframe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 406DAC1D13B508E0002E4240 /* demoframe.cpp */; };
|
||||
407EE18312F04CD500D0F171 /* libwx_osx_iphone.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4074F5E912ED969C00693A3F /* libwx_osx_iphone.a */; };
|
||||
407EE18A12F04CF900D0F171 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 407EE18912F04CF900D0F171 /* AudioToolbox.framework */; };
|
||||
B9133F9513BBC9FB0024E59E /* srchctrl.mm in Sources */ = {isa = PBXBuildFile; fileRef = B9133F9413BBC9FB0024E59E /* srchctrl.mm */; };
|
||||
B9DF073E13B9FCF700D6F0D8 /* button.mm in Sources */ = {isa = PBXBuildFile; fileRef = B9DF072E13B9FCF700D6F0D8 /* button.mm */; };
|
||||
B9DF073F13B9FCF700D6F0D8 /* checkbox.mm in Sources */ = {isa = PBXBuildFile; fileRef = B9DF072F13B9FCF700D6F0D8 /* checkbox.mm */; };
|
||||
B9DF074013B9FCF700D6F0D8 /* dialog.mm in Sources */ = {isa = PBXBuildFile; fileRef = B9DF073013B9FCF700D6F0D8 /* dialog.mm */; };
|
||||
@@ -91,6 +92,7 @@
|
||||
407EE18912F04CF900D0F171 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
|
||||
409CBDC913B13C7100AB1F39 /* wxdebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = wxdebug.xcconfig; path = ../../build/osx/wxdebug.xcconfig; sourceTree = SOURCE_ROOT; };
|
||||
409CBDCA13B13C7100AB1F39 /* wxrelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = wxrelease.xcconfig; path = ../../build/osx/wxrelease.xcconfig; sourceTree = SOURCE_ROOT; };
|
||||
B9133F9413BBC9FB0024E59E /* srchctrl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = srchctrl.mm; path = ../../src/osx/iphone/srchctrl.mm; sourceTree = SOURCE_ROOT; };
|
||||
B9DF070813B9FCD800D6F0D8 /* app.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = app.h; sourceTree = "<group>"; };
|
||||
B9DF070913B9FCD800D6F0D8 /* barbutton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = barbutton.h; sourceTree = "<group>"; };
|
||||
B9DF070A13B9FCD800D6F0D8 /* bmpbutton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bmpbutton.h; sourceTree = "<group>"; };
|
||||
@@ -274,6 +276,7 @@
|
||||
B9DF073613B9FCF700D6F0D8 /* notebook.mm */,
|
||||
B9DF073713B9FCF700D6F0D8 /* scrolbar.mm */,
|
||||
B9DF073813B9FCF700D6F0D8 /* slider.mm */,
|
||||
B9133F9413BBC9FB0024E59E /* srchctrl.mm */,
|
||||
B9DF073913B9FCF700D6F0D8 /* stattext.mm */,
|
||||
B9DF073A13B9FCF700D6F0D8 /* textctrl.mm */,
|
||||
B9DF073B13B9FCF700D6F0D8 /* toolbar.mm */,
|
||||
@@ -501,6 +504,7 @@
|
||||
B9DF074B13B9FCF700D6F0D8 /* toolbar.mm in Sources */,
|
||||
B9DF074C13B9FCF700D6F0D8 /* utils.mm in Sources */,
|
||||
B9DF074D13B9FCF700D6F0D8 /* window.mm in Sources */,
|
||||
B9133F9513BBC9FB0024E59E /* srchctrl.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -87,9 +87,7 @@ void wxMoPanel::DoSetSize(int x, int y,
|
||||
UIView *view = (UIView *)GetPeer()->GetWXWidget();
|
||||
|
||||
NSLog(@"attempt to set size; curr. panel: %@", view);
|
||||
[view setFrame:CGRectMake(20, 20, 80, 80)];
|
||||
[view setBackgroundColor:[UIColor redColor]];
|
||||
[view setOpaque:YES];
|
||||
//[view setFrame:CGRectMake(20, 20, 80, 80)];
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
+21
-34
@@ -33,9 +33,10 @@
|
||||
#pragma mark -
|
||||
#pragma mark Cocoa
|
||||
|
||||
|
||||
#pragma mark UITabBarController
|
||||
|
||||
@interface wxUITabBarController : UITabBarController <UITabBarControllerDelegate, UITabBarDelegate>
|
||||
@interface wxUITabBarController : UITabBarController <UITabBarControllerDelegate>
|
||||
{
|
||||
|
||||
}
|
||||
@@ -64,9 +65,9 @@
|
||||
class wxNotebookIPhoneImpl : public wxWidgetIPhoneImpl
|
||||
{
|
||||
public:
|
||||
wxNotebookIPhoneImpl( wxWindowMac* peer , WXWidget w ) : wxWidgetIPhoneImpl(peer, w)
|
||||
wxNotebookIPhoneImpl( wxWindowMac* peer , wxUITabBarController *tabBarController, WXWidget w ) : wxWidgetIPhoneImpl(peer, w)
|
||||
{
|
||||
|
||||
m_tabBarController = tabBarController;
|
||||
}
|
||||
|
||||
// Ignore attempts to set position/size
|
||||
@@ -83,9 +84,7 @@ public:
|
||||
|
||||
void GetContentArea( int &left , int &top , int &width , int &height ) const
|
||||
{
|
||||
UITabBar *tabBar = (UITabBar *)m_osxView;
|
||||
|
||||
CGRect r = tabBar.bounds;
|
||||
CGRect r = m_osxView.bounds;
|
||||
left = (int)r.origin.x;
|
||||
top = (int)r.origin.y;
|
||||
width = (int)r.size.width;
|
||||
@@ -94,35 +93,27 @@ public:
|
||||
|
||||
void SetValue( wxInt32 value )
|
||||
{
|
||||
UITabBar *tabBar = (UITabBar *) m_osxView;
|
||||
wxUITabBarController *tabBarController = (wxUITabBarController *)[tabBar delegate];
|
||||
|
||||
// avoid 'changed' events when setting the tab programmatically
|
||||
[tabBarController setDelegate:nil];
|
||||
[tabBarController setSelectedIndex:(value-1)];
|
||||
[tabBarController setDelegate:tabBarController];
|
||||
[m_tabBarController setDelegate:nil];
|
||||
[m_tabBarController setSelectedIndex:(value-1)];
|
||||
[m_tabBarController setDelegate:m_tabBarController];
|
||||
}
|
||||
|
||||
wxInt32 GetValue() const
|
||||
{
|
||||
UITabBar *tabBar = (UITabBar *) m_osxView;
|
||||
wxUITabBarController *tabBarController = (wxUITabBarController *)[tabBar delegate];
|
||||
return [tabBarController selectedIndex]+1;
|
||||
return [m_tabBarController selectedIndex]+1;
|
||||
}
|
||||
|
||||
void SetMaximum( wxInt32 maximum )
|
||||
{
|
||||
UITabBar *tabBar = (UITabBar *) m_osxView;
|
||||
wxUITabBarController *tabBarController = (wxUITabBarController *)[tabBar delegate];
|
||||
|
||||
int tabCount = [[tabBarController viewControllers] count];
|
||||
int tabCount = [[m_tabBarController viewControllers] count];
|
||||
|
||||
if (maximum != tabCount) {
|
||||
|
||||
NSMutableArray *controllers = [NSMutableArray arrayWithArray:[tabBarController viewControllers]];
|
||||
NSMutableArray *controllers = [NSMutableArray arrayWithArray:[m_tabBarController viewControllers]];
|
||||
|
||||
// avoid 'changed' events when setting the tab programmatically
|
||||
[tabBarController setDelegate:nil];
|
||||
[m_tabBarController setDelegate:nil];
|
||||
|
||||
if ( maximum > tabCount )
|
||||
{
|
||||
@@ -142,8 +133,8 @@ public:
|
||||
[controllers removeObjectsInRange:removeRange];
|
||||
}
|
||||
|
||||
[tabBarController setViewControllers:controllers];
|
||||
[tabBarController setDelegate:tabBarController];
|
||||
[m_tabBarController setViewControllers:controllers];
|
||||
[m_tabBarController setDelegate:m_tabBarController];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,17 +143,14 @@ public:
|
||||
int pageCount = notebook.GetPageCount();
|
||||
|
||||
SetMaximum( pageCount );
|
||||
|
||||
UITabBar *tabBar = (UITabBar *) m_osxView;
|
||||
wxUITabBarController *tabBarController = (wxUITabBarController *)[tabBar delegate];
|
||||
|
||||
|
||||
// avoid 'changed' events when setting the tab programmatically
|
||||
[tabBarController setDelegate:nil];
|
||||
[m_tabBarController setDelegate:nil];
|
||||
|
||||
for ( int i = 0 ; i < pageCount ; ++i )
|
||||
{
|
||||
wxNotebookPage* page = notebook.GetPage(i);
|
||||
UIViewController *controller = [[tabBarController viewControllers] objectAtIndex:i];
|
||||
UIViewController *controller = [[m_tabBarController viewControllers] objectAtIndex:i];
|
||||
|
||||
int pageImage = notebook.GetPageImage(i);
|
||||
UITabBarSystemItem systemItem = UITabBarSystemItemHistory;
|
||||
@@ -191,9 +179,11 @@ public:
|
||||
[controller setTitle:tabTitle];
|
||||
}
|
||||
|
||||
[tabBarController setDelegate:tabBarController];
|
||||
[m_tabBarController setDelegate:m_tabBarController];
|
||||
}
|
||||
|
||||
private:
|
||||
wxUITabBarController *m_tabBarController;
|
||||
};
|
||||
|
||||
wxWidgetImplType* wxWidgetImpl::CreateTabView( wxWindowMac* wxpeer,
|
||||
@@ -210,12 +200,9 @@ wxWidgetImplType* wxWidgetImpl::CreateTabView( wxWindowMac* wxpeer,
|
||||
CGRect tabBarFrame = controller.tabBar.frame;
|
||||
tabBarFrame.origin.y -= 20;
|
||||
[controller.tabBar setFrame:tabBarFrame];
|
||||
|
||||
[controller setDelegate:controller];
|
||||
|
||||
CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
|
||||
|
||||
wxWidgetIPhoneImpl* c = new wxNotebookIPhoneImpl( wxpeer, controller.tabBar );
|
||||
wxWidgetIPhoneImpl* c = new wxNotebookIPhoneImpl( wxpeer, controller, controller.view );
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@@ -317,6 +317,7 @@ bool wxToolBar::Create(
|
||||
toolbar.barStyle = UIBarStyleDefault;
|
||||
break;
|
||||
}
|
||||
|
||||
m_macToolbar = toolbar;
|
||||
|
||||
SetPeer(new wxWidgetIPhoneImpl( this, toolbar ));
|
||||
|
||||
+40
-15
@@ -71,6 +71,9 @@ CGRect wxOSXGetFrameForControl( wxWindowMac* window , const wxPoint& pos , const
|
||||
|
||||
- (BOOL) becomeFirstResponder;
|
||||
- (BOOL) resignFirstResponder;
|
||||
|
||||
- (NSString *)description;
|
||||
|
||||
@end
|
||||
|
||||
//
|
||||
@@ -287,6 +290,27 @@ void wxOSX_drawRect(UIView* self, SEL _cmd, CGRect rect)
|
||||
return impl->drawRect(&rect, self, _cmd);
|
||||
}
|
||||
|
||||
NSString *wxOSX_description(UIView* self, SEL _cmd)
|
||||
{
|
||||
wxWidgetIPhoneImpl* impl = (wxWidgetIPhoneImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||
if (impl == NULL)
|
||||
return @"N/A";
|
||||
|
||||
NSMutableString *description = [NSMutableString stringWithString:@""];
|
||||
[description appendFormat:@"<%@: 0x%08x; superClass = %@; frame = %@; hidden = %@; opaque = %@; alpha = %f; backgroundColor = %@>",
|
||||
NSStringFromClass([self class]),
|
||||
self,
|
||||
NSStringFromClass([self superclass]),
|
||||
NSStringFromCGRect(self.frame),
|
||||
(self.hidden ? @"YES" : @"NO"),
|
||||
(self.opaque ? @"YES" : @"NO"),
|
||||
self.alpha,
|
||||
[self.backgroundColor description]];
|
||||
|
||||
return [NSString stringWithString:description];
|
||||
|
||||
// <UIWindow: 0x541b910; frame = (0 0; 768 1024); layer = <CALayer: 0x541b9c0>>
|
||||
}
|
||||
|
||||
void wxOSXIPhoneClassAddWXMethods(Class c)
|
||||
{
|
||||
@@ -296,6 +320,7 @@ void wxOSXIPhoneClassAddWXMethods(Class c)
|
||||
class_addMethod(c, @selector(becomeFirstResponder), (IMP) wxOSX_becomeFirstResponder, "c@:" );
|
||||
class_addMethod(c, @selector(resignFirstResponder), (IMP) wxOSX_resignFirstResponder, "c@:" );
|
||||
class_addMethod(c, @selector(drawRect:), (IMP) wxOSX_drawRect, "v@:{_CGRect={_CGPoint=ff}{_CGSize=ff}}" );
|
||||
class_addMethod(c, @selector(description), (IMP) wxOSX_description, "c@:" );
|
||||
}
|
||||
|
||||
//
|
||||
@@ -481,17 +506,11 @@ void wxWidgetImpl::Convert( wxPoint *pt , wxWidgetImpl *from , wxWidgetImpl *to
|
||||
|
||||
void wxWidgetIPhoneImpl::SetBackgroundColour( const wxColour &col )
|
||||
{
|
||||
CGFloat red = (CGFloat)random()/(CGFloat)RAND_MAX;
|
||||
CGFloat blue = (CGFloat)random()/(CGFloat)RAND_MAX;
|
||||
CGFloat green = (CGFloat)random()/(CGFloat)RAND_MAX;
|
||||
|
||||
m_osxView.backgroundColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
|
||||
//m_osxView.backgroundColor = [[UIColor alloc] initWithCGColor:col.GetCGColor()];
|
||||
m_osxView.backgroundColor = [[UIColor alloc] initWithCGColor:col.GetCGColor()];
|
||||
}
|
||||
|
||||
bool wxWidgetIPhoneImpl::SetBackgroundStyle(wxBackgroundStyle style)
|
||||
{
|
||||
/*
|
||||
if ( style == wxBG_STYLE_PAINT )
|
||||
[m_osxView setOpaque: YES ];
|
||||
else
|
||||
@@ -499,7 +518,6 @@ bool wxWidgetIPhoneImpl::SetBackgroundStyle(wxBackgroundStyle style)
|
||||
[m_osxView setOpaque: NO ];
|
||||
m_osxView.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -508,7 +526,8 @@ void wxWidgetIPhoneImpl::SetLabel(const wxString& title, wxFontEncoding encoding
|
||||
if ( [m_osxView respondsToSelector:@selector(setTitle:forState:) ] )
|
||||
{
|
||||
wxCFStringRef cf( title , encoding );
|
||||
[m_osxView setTitle:cf.AsNSString() forState:UIControlStateNormal ];
|
||||
[m_osxView setTitle:cf.AsNSString()
|
||||
forState:UIControlStateNormal ];
|
||||
}
|
||||
else if ( [m_osxView respondsToSelector:@selector(setStringValue:) ] )
|
||||
{
|
||||
@@ -806,19 +825,25 @@ void wxWidgetIPhoneImpl::controlTextDidChange()
|
||||
// Factory methods
|
||||
//
|
||||
|
||||
wxWidgetImpl* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(parent),
|
||||
wxWindowID WXUNUSED(id), const wxPoint& pos, const wxSize& size,
|
||||
long WXUNUSED(style), long WXUNUSED(extraStyle))
|
||||
wxWidgetImpl* wxWidgetImpl::CreateUserPane( wxWindowMac* wxpeer,
|
||||
wxWindowMac* WXUNUSED(parent),
|
||||
wxWindowID WXUNUSED(id),
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long WXUNUSED(style),
|
||||
long WXUNUSED(extraStyle))
|
||||
{
|
||||
UIView* sv = (wxpeer->GetParent()->GetHandle() );
|
||||
|
||||
CGRect r = CGRectMake( pos.x, pos.y, size.x, size.y) ;
|
||||
// Rect bounds = wxMacGetBoundsForControl( wxpeer, pos , size ) ;
|
||||
wxUIView* v = [[wxUIView alloc] initWithFrame:r];
|
||||
//wxUIView* v = [[wxUIView alloc] initWithFrame:r];
|
||||
UIView* v = [[UIView alloc] initWithFrame:r];
|
||||
sv.clipsToBounds = YES;
|
||||
sv.contentMode = UIViewContentModeRedraw;
|
||||
sv.clearsContextBeforeDrawing = NO;
|
||||
//sv.clearsContextBeforeDrawing = NO;
|
||||
//sv.backgroundColor = [UIColor greenColor];
|
||||
sv.clearsContextBeforeDrawing = YES;
|
||||
wxWidgetIPhoneImpl* c = new wxWidgetIPhoneImpl( wxpeer, v, false, true );
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user