// Created: 2004/04/08
// RCS-ID: $Id$
// Copyright: (c) 2004 David Elliott
-// Licence: wxWindows licence
+// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
+
+#if wxUSE_NOTEBOOK
+
#ifndef WX_PRECOMP
#include "wx/app.h"
- #include "wx/notebook.h"
#endif //WX_PRECOMP
+#include "wx/notebook.h"
#include "wx/imaglist.h"
#include "wx/cocoa/autorelease.h"
#include "wx/cocoa/string.h"
+#include "wx/cocoa/objc/objc_uniquifying.h"
#import <AppKit/NSTabView.h>
#import <AppKit/NSTabViewItem.h>
- (NSImage*)image;
- (void)setImage:(NSImage*)image;
@end // interface WXCTabViewImageItem : NSTabViewItem
+WX_DECLARE_GET_OBJC_CLASS(WXCTabViewImageItem,NSTabViewItem)
@implementation WXCTabViewImageItem : NSTabViewItem
- (id)init
- (void)dealloc
{
[m_image release];
+ [super dealloc];
}
- (NSSize)sizeOfLabel:(BOOL)shouldTruncateLabel
}
@end // implementation WXCTabViewImageItem : NSTabViewItem
+WX_IMPLEMENT_GET_OBJC_CLASS(WXCTabViewImageItem,NSTabViewItem)
// ========================================================================
// wxNotebookEvent
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);
[tvitem retain];
[GetNSTabView() removeTabViewItem:tvitem];
// Remove the child window as a notebook page
- wxASSERT([tvitem view] == page->GetNSViewForSuperview());
+ wxASSERT(static_cast<NSView*>([tvitem view]) == page->GetNSViewForSuperview());
[tvitem setView:nil];
[tvitem release];
// Make it back into a normal child window
{
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)];
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];
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];
return !GetEventHandler()->ProcessEvent(event) || event.IsAllowed();
}
+#endif // wxUSE_NOTEBOOK