X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fa7de3b09a1f6a87a9c3de6adc58132cab93d139..9d5507f7a2701395e1d5c121bd877bb9066ee6ea:/src/cocoa/notebook.mm diff --git a/src/cocoa/notebook.mm b/src/cocoa/notebook.mm index 28e0978ef7..10e04d98e7 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 @@ -64,6 +66,7 @@ - (void)dealloc { [m_image release]; + [super dealloc]; } - (NSSize)sizeOfLabel:(BOOL)shouldTruncateLabel @@ -119,6 +122,7 @@ } @end // implementation WXCTabViewImageItem : NSTabViewItem +WX_IMPLEMENT_GET_OBJC_CLASS(WXCTabViewImageItem,NSTabViewItem) // ======================================================================== // wxNotebookEvent @@ -146,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); @@ -180,7 +201,7 @@ wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage) [tvitem retain]; [GetNSTabView() removeTabViewItem:tvitem]; // Remove the child window as a notebook page - wxASSERT([tvitem view] == page->GetNSViewForSuperview()); + wxASSERT(static_cast([tvitem view]) == page->GetNSViewForSuperview()); [tvitem setView:nil]; [tvitem release]; // Make it back into a normal child window @@ -200,9 +221,9 @@ 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->GetBitmap(imageId):NULL; + const wxBitmap *bmp = (imageId!=-1)?m_imageList->GetBitmapPtr(imageId):NULL; if(bmp) [(WXCTabViewImageItem*) tvitem setImage: bmp->GetNSImage(true)]; @@ -250,7 +271,7 @@ int wxNotebook::GetPageImage(size_t nPage) const bool wxNotebook::SetPageImage(size_t nPage, int nImage) { - const wxBitmap *bmp = nImage!=-1?m_imageList->GetBitmap(nImage):NULL; + const wxBitmap *bmp = nImage!=-1?m_imageList->GetBitmapPtr(nImage):NULL; if(!bmp) return false; NSTabViewItem *tvitem = [GetNSTabView() tabViewItemAtIndex: nPage]; @@ -260,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]; @@ -289,7 +325,7 @@ bool wxNotebook::CocoaDelegate_tabView_shouldSelectTabViewItem(WX_NSTabViewItem wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, GetId(), [GetNSTabView() indexOfTabViewItem:tabViewItem], GetSelection()); event.SetEventObject(this); - return !GetEventHandler()->ProcessEvent(event) || event.IsAllowed(); + return !HandleWindowEvent(event) || event.IsAllowed(); } #endif // wxUSE_NOTEBOOK