X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a7247f0e941c83cba9e620ca8541c60ec135a0b..0962839d231c7ae1250337c9a22c1384dd0285ea:/src/cocoa/notebook.mm?ds=inline diff --git a/src/cocoa/notebook.mm b/src/cocoa/notebook.mm index d79c9bd875..7c7d648541 100644 --- a/src/cocoa/notebook.mm +++ b/src/cocoa/notebook.mm @@ -21,6 +21,7 @@ #include "wx/cocoa/autorelease.h" #include "wx/cocoa/string.h" +#include "wx/cocoa/objc/objc_uniquifying.h" #import #import @@ -48,6 +49,7 @@ - (NSImage*)image; - (void)setImage:(NSImage*)image; @end // interface WXCTabViewImageItem : NSTabViewItem +WX_DECLARE_GET_OBJC_CLASS(WXCTabViewImageItem,NSTabViewItem) @implementation WXCTabViewImageItem : NSTabViewItem - (id)init @@ -120,6 +122,7 @@ } @end // implementation WXCTabViewImageItem : NSTabViewItem +WX_IMPLEMENT_GET_OBJC_CLASS(WXCTabViewImageItem,NSTabViewItem) // ======================================================================== // wxNotebookEvent @@ -147,6 +150,23 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID winid, return false; m_cocoaNSView = NULL; SetNSTabView([[NSTabView alloc] initWithFrame:MakeDefaultNSRect(size)]); + + do + { + NSTabViewType tabViewType; + if(style & wxNB_TOP) + tabViewType = NSTopTabsBezelBorder; + else if(style & wxNB_LEFT) + tabViewType = NSLeftTabsBezelBorder; + else if(style & wxNB_RIGHT) + tabViewType = NSRightTabsBezelBorder; + else if(style & wxNB_BOTTOM) + tabViewType = NSBottomTabsBezelBorder; + else + break; + [GetNSTabView() setTabViewType:tabViewType]; + } while(0); + if(m_parent) m_parent->CocoaAddChild(this); SetInitialFrameRect(pos,size); @@ -201,7 +221,7 @@ bool wxNotebook::InsertPage( size_t pos, { wxAutoNSAutoreleasePool pool; m_pages.Insert(page,pos); - NSTabViewItem *tvitem = [[WXCTabViewImageItem alloc] initWithIdentifier:nil]; + NSTabViewItem *tvitem = [[WX_GET_OBJC_CLASS(WXCTabViewImageItem) alloc] initWithIdentifier:nil]; [tvitem setLabel: wxNSStringWithWxString(title)]; const wxBitmap *bmp = (imageId!=-1)?m_imageList->GetBitmapPtr(imageId):NULL; if(bmp) @@ -261,8 +281,23 @@ bool wxNotebook::SetPageImage(size_t nPage, int nImage) return true; } - int wxNotebook::SetSelection(size_t nPage) +{ + const int pageOld = GetSelection(); + + if ( !SendPageChangingEvent(nPage) ) + return pageOld; + + int page = ChangeSelection(nPage); + if ( page != wxNOT_FOUND ) + { + SendPageChangedEvent(pageOld); + } + + return page; +} + +int wxNotebook::ChangeSelection(size_t nPage) { wxAutoNSAutoreleasePool pool; [GetNSTabView() selectTabViewItemAtIndex:nPage];