]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/notebook.mm
making GetPosition 1:1 symmetrical to Move (respecting contentViews), fixing borderDr...
[wxWidgets.git] / src / osx / cocoa / notebook.mm
index 2c47ce8133fa7ccc49808e642bd54df75673a49c..5dff77fb3c424862c7c28ec8246d5894124b49c4 100644 (file)
@@ -30,7 +30,7 @@
 // controller
 //
 
 // controller
 //
 
-@interface wxTabViewController : NSObject
+@interface wxTabViewController : NSObject wxOSX_10_6_AND_LATER(<NSTabViewDelegate>)
 {
 }
 
 {
 }
 
 
 @interface wxNSTabView : NSTabView
 {
 
 @interface wxNSTabView : NSTabView
 {
-    WXCOCOAIMPL_COMMON_MEMBERS
 }
 
 }
 
-WXCOCOAIMPL_COMMON_INTERFACE
-
 @end
 
 @implementation wxTabViewController
 @end
 
 @implementation wxTabViewController
@@ -58,8 +55,10 @@ WXCOCOAIMPL_COMMON_INTERFACE
 
 - (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(NSTabViewItem *)tabViewItem
 {
 
 - (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(NSTabViewItem *)tabViewItem
 {
+    wxUnusedVar(tabViewItem);
     wxNSTabView* view = (wxNSTabView*) tabView;
     wxNSTabView* view = (wxNSTabView*) tabView;
-    wxWidgetCocoaImpl* viewimpl = [view implementation];
+    wxWidgetCocoaImpl* viewimpl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( view );
+
     if ( viewimpl )
     {
         // wxNotebook* wxpeer = (wxNotebook*) viewimpl->GetWXPeer();
     if ( viewimpl )
     {
         // wxNotebook* wxpeer = (wxNotebook*) viewimpl->GetWXPeer();
@@ -67,11 +66,11 @@ WXCOCOAIMPL_COMMON_INTERFACE
     return YES;
 }
 
     return YES;
 }
 
-- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem;
-
+- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
 {
 {
+    wxUnusedVar(tabViewItem);
     wxNSTabView* view = (wxNSTabView*) tabView;
     wxNSTabView* view = (wxNSTabView*) tabView;
-    wxWidgetCocoaImpl* viewimpl = [view implementation];
+    wxWidgetCocoaImpl* viewimpl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( view );
     if ( viewimpl )
     {
         wxNotebook* wxpeer = (wxNotebook*) viewimpl->GetWXPeer();
     if ( viewimpl )
     {
         wxNotebook* wxpeer = (wxNotebook*) viewimpl->GetWXPeer();
@@ -83,7 +82,15 @@ WXCOCOAIMPL_COMMON_INTERFACE
 
 @implementation wxNSTabView
 
 
 @implementation wxNSTabView
 
-WXCOCOAIMPL_COMMON_IMPLEMENTATION
++ (void)initialize
+{
+    static BOOL initialized = NO;
+    if (!initialized)
+    {
+        initialized = YES;
+        wxOSXCocoaClassAddWXMethods( self );
+    }
+}
 
 @end
 
 
 @end
 
@@ -93,18 +100,18 @@ public:
     wxCocoaTabView( wxWindowMac* peer , WXWidget w ) : wxWidgetCocoaImpl(peer, w)
     {
     }
     wxCocoaTabView( wxWindowMac* peer , WXWidget w ) : wxWidgetCocoaImpl(peer, w)
     {
     }
-    
-    void GetContentArea( int &left , int &top , int &width , int &height ) const 
+
+    void GetContentArea( int &left , int &top , int &width , int &height ) const
     {
         wxNSTabView* slf = (wxNSTabView*) m_osxView;
         NSRect r = [slf contentRect];
     {
         wxNSTabView* slf = (wxNSTabView*) m_osxView;
         NSRect r = [slf contentRect];
-        left = r.origin.x;
-        top = r.origin.y;
-        width = r.size.width;
-        height = r.size.height;
+        left = (int)r.origin.x;
+        top = (int)r.origin.y;
+        width = (int)r.size.width;
+        height = (int)r.size.height;
     }
     }
-    
-    void SetValue( wxInt32 value ) 
+
+    void SetValue( wxInt32 value )
     {
         wxNSTabView* slf = (wxNSTabView*) m_osxView;
         // avoid 'changed' events when setting the tab programmatically
     {
         wxNSTabView* slf = (wxNSTabView*) m_osxView;
         // avoid 'changed' events when setting the tab programmatically
@@ -113,7 +120,7 @@ public:
         [slf selectTabViewItemAtIndex:(value-1)];
         [slf setDelegate:controller];
     }
         [slf selectTabViewItemAtIndex:(value-1)];
         [slf setDelegate:controller];
     }
-    
+
     wxInt32 GetValue() const
     {
         wxNSTabView* slf = (wxNSTabView*) m_osxView;
     wxInt32 GetValue() const
     {
         wxNSTabView* slf = (wxNSTabView*) m_osxView;
@@ -123,7 +130,7 @@ public:
         else
             return [slf indexOfTabViewItem:selectedItem]+1;
     }
         else
             return [slf indexOfTabViewItem:selectedItem]+1;
     }
-    
+
     void SetMaximum( wxInt32 maximum )
     {
         wxNSTabView* slf = (wxNSTabView*) m_osxView;
     void SetMaximum( wxInt32 maximum )
     {
         wxNSTabView* slf = (wxNSTabView*) m_osxView;
@@ -131,7 +138,7 @@ public:
         // avoid 'changed' events when setting the tab programmatically
         wxTabViewController* controller = [slf delegate];
         [slf setDelegate:nil];
         // 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 )
         if ( maximum > cocoacount )
         {
             for ( int i = cocoacount ; i < maximum ; ++i )
@@ -155,9 +162,9 @@ public:
     void SetupTabs( const wxNotebook& notebook)
     {
         int pcount = notebook.GetPageCount();
     void SetupTabs( const wxNotebook& notebook)
     {
         int pcount = notebook.GetPageCount();
-        
+
         SetMaximum( pcount );
         SetMaximum( pcount );
-        
+
         for ( int i = 0 ; i < pcount ; ++i )
         {
             wxNotebookPage* page = notebook.GetPage(i);
         for ( int i = 0 ; i < pcount ; ++i )
         {
             wxNotebookPage* page = notebook.GetPage(i);
@@ -218,13 +225,13 @@ public:
     verify_noerr( err );
 #endif
 */
     verify_noerr( err );
 #endif
 */
-wxWidgetImplType* wxWidgetImpl::CreateTabView( wxWindowMac* wxpeer, 
-                                    wxWindowMac* parent, 
-                                    wxWindowID id, 
-                                    const wxPoint& pos, 
+wxWidgetImplType* wxWidgetImpl::CreateTabView( wxWindowMac* wxpeer,
+                                    wxWindowMac* WXUNUSED(parent),
+                                    wxWindowID WXUNUSED(id),
+                                    const wxPoint& pos,
                                     const wxSize& size,
                                     const wxSize& size,
-                                    long style, 
-                                    long extraStyle)
+                                    long style,
+                                    long WXUNUSED(extraStyle))
 {
     static wxTabViewController* controller = NULL;
 
 {
     static wxTabViewController* controller = NULL;
 
@@ -232,7 +239,7 @@ wxWidgetImplType* wxWidgetImpl::CreateTabView( wxWindowMac* wxpeer,
         controller =[[wxTabViewController alloc] init];
 
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
         controller =[[wxTabViewController alloc] init];
 
     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
-    
+
     NSTabViewType tabstyle = NSTopTabsBezelBorder;
     if ( style & wxBK_LEFT )
         tabstyle = NSLeftTabsBezelBorder;
     NSTabViewType tabstyle = NSTopTabsBezelBorder;
     if ( style & wxBK_LEFT )
         tabstyle = NSLeftTabsBezelBorder;
@@ -240,11 +247,10 @@ wxWidgetImplType* wxWidgetImpl::CreateTabView( wxWindowMac* wxpeer,
         tabstyle = NSRightTabsBezelBorder;
     else if ( style & wxBK_BOTTOM )
         tabstyle = NSBottomTabsBezelBorder;
         tabstyle = NSRightTabsBezelBorder;
     else if ( style & wxBK_BOTTOM )
         tabstyle = NSBottomTabsBezelBorder;
-    
+
     wxNSTabView* v = [[wxNSTabView alloc] initWithFrame:r];
     [v setTabViewType:tabstyle];
     wxWidgetCocoaImpl* c = new wxCocoaTabView( wxpeer, v );
     wxNSTabView* v = [[wxNSTabView alloc] initWithFrame:r];
     [v setTabViewType:tabstyle];
     wxWidgetCocoaImpl* c = new wxCocoaTabView( wxpeer, v );
-    [v setImplementation:c];
     [v setDelegate: controller];
     return c;
 }
     [v setDelegate: controller];
     return c;
 }