Commits

Virgil Dupras committed 2d4bba4

Added TabView.tabViewType and fixed layout deltas for cases where there's no tabs.

Comments (0)

Files changed (2)

docs/api/tabview.rst

     
     :param parent: A :class:`View` instance. Same as :attr:`View.parent`.
     
+    .. attribute:: tabViewType
+    
+        :ref:`Cocoa constant <literal-consts>`. Determines where the tabs, if any, are located. Use
+        with ``NSTabViewType`` constants.
+    
     .. method:: addTab(label[, identifier=None])
         
         :param label: String. See :attr:`TabViewItem.label`.

xibless/tabview.py

-from .base import GeneratedItem, convertValueToObjc
+from .base import GeneratedItem, convertValueToObjc, const
 from .view import View, Pack
 
 # Views in tab items have different margins than normal views.
 
 class TabView(View):
     OBJC_CLASS = 'NSTabView'
+    PROPERTIES = View.PROPERTIES + ['tabViewType']
     OVERHEAD_W = 6
     OVERHEAD_H = 30
     
     def __init__(self, parent):
         View.__init__(self, parent, 160, 110)
         self.tabs = []
-        
-        self.layoutDeltaX = -7
-        self.layoutDeltaY = -10
-        self.layoutDeltaW = 14
-        self.layoutDeltaH = 16
+        self._tabViewType = const.NSTopTabsBezelBorder
+        self._updateLayoutDeltas()
     
     def _updatePos(self):
         for tab in self.tabs:
             tab.view.width = self.width - self.OVERHEAD_W
             tab.view.height = self.height - self.OVERHEAD_H
     
+    def _updateLayoutDeltas(self):
+        if self.tabViewType == const.NSNoTabsNoBorder:
+            self.layoutDeltaX = 0
+            self.layoutDeltaY = 0
+            self.layoutDeltaW = 0
+            self.layoutDeltaH = 0
+        else:
+            self.layoutDeltaX = -7
+            self.layoutDeltaY = -10
+            self.layoutDeltaW = 14
+            self.layoutDeltaH = 16
+        
     def innerMarginDelta(self, side):
         if side == Pack.Above:
             return -12
         self.tabs.append(tab)
         return tab
     
+    @property
+    def tabViewType(self):
+        return self._tabViewType
+    
+    @tabViewType.setter
+    def tabViewType(self, value):
+        self._tabViewType = value
+        self._updateLayoutDeltas()
+    
     def generateInit(self):
         tmpl = View.generateInit(self)
         viewsetup = ""