+class wxCocoaTabView : public wxWidgetCocoaImpl
+{
+public:
+ wxCocoaTabView( wxWindowMac* peer , WXWidget w ) : wxWidgetCocoaImpl(peer, w)
+ {
+ }
+
+ void GetContentArea( int &left , int &top , int &width , int &height ) const
+ {
+ wxNSTabView* slf = (wxNSTabView*) m_osxView;
+ NSRect r = [slf contentRect];
+ left = (int)r.origin.x;
+ top = (int)r.origin.y;
+ width = (int)r.size.width;
+ height = (int)r.size.height;
+ }
+
+ void SetValue( wxInt32 value )
+ {
+ wxNSTabView* slf = (wxNSTabView*) m_osxView;
+ // avoid 'changed' events when setting the tab programmatically
+ wxTabViewController* controller = [slf delegate];
+ [slf setDelegate:nil];
+ [slf selectTabViewItemAtIndex:(value-1)];
+ [slf setDelegate:controller];
+ }
+
+ wxInt32 GetValue() const
+ {
+ wxNSTabView* slf = (wxNSTabView*) m_osxView;
+ NSTabViewItem* selectedItem = [slf selectedTabViewItem];
+ if ( selectedItem == nil )
+ return 0;
+ else
+ return [slf indexOfTabViewItem:selectedItem]+1;
+ }
+
+ void SetMaximum( wxInt32 maximum )
+ {
+ wxNSTabView* slf = (wxNSTabView*) m_osxView;
+ int cocoacount = [slf numberOfTabViewItems ];
+ // avoid 'changed' events when setting the tab programmatically
+ wxTabViewController* controller = [slf delegate];
+ [slf setDelegate:nil];
+
+ if ( maximum > cocoacount )
+ {
+ for ( int i = cocoacount ; i < maximum ; ++i )
+ {
+ NSTabViewItem* item = [[NSTabViewItem alloc] init];
+ [slf addTabViewItem:item];
+ [item release];
+ }
+ }
+ else if ( maximum < cocoacount )
+ {
+ for ( int i = cocoacount -1 ; i >= maximum ; --i )
+ {
+ NSTabViewItem* item = [(wxNSTabView*) m_osxView tabViewItemAtIndex:i];
+ [slf removeTabViewItem:item];
+ }
+ }
+ [slf setDelegate:controller];
+ }
+
+ void SetupTabs( const wxNotebook& notebook)
+ {
+ int pcount = notebook.GetPageCount();
+
+ SetMaximum( pcount );
+
+ for ( int i = 0 ; i < pcount ; ++i )
+ {
+ wxNotebookPage* page = notebook.GetPage(i);
+ NSTabViewItem* item = [(wxNSTabView*) m_osxView tabViewItemAtIndex:i];
+ [item setView:page->GetHandle() ];
+ wxCFStringRef cf( page->GetLabel() , notebook.GetFont().GetEncoding() );
+ [item setLabel:cf.AsNSString()];
+ if ( notebook.GetImageList() && notebook.GetPageImage(i) >= 0 )
+ {
+ const wxBitmap bmap = notebook.GetImageList()->GetBitmap( notebook.GetPageImage( i ) ) ;
+ if ( bmap.IsOk() )
+ {
+ // TODO how to set an image on a tab
+ }
+ }
+ }
+ }
+};
+
+