class: NoteBookView
authorClaus Gittinger <cg@exept.de>
Fri, 14 Dec 2012 15:22:25 +0100
changeset 4158 dc5245affaeb
parent 4157 67226e0d3d71
child 4159 a4bd3b389805
class: NoteBookView comment/format in: #update:with:from: changed: #buttonRelease:x:y: #isDestroyTabButtonShownFor: allow for individual tabs to have a destroyButton (see Tab>>destroyTabAction)
NoteBookView.st
--- a/NoteBookView.st	Wed Dec 12 15:30:26 2012 +0100
+++ b/NoteBookView.st	Fri Dec 14 15:22:25 2012 +0100
@@ -1171,7 +1171,7 @@
         ].
         ^ self
     ].
-    changedObject == listHolder    ifTrue:[
+    changedObject == listHolder ifTrue:[
         something == #at: ifTrue:[
             "/ a single items label has changed
             self tabAtIndex:aParameter put:(listHolder value at:aParameter).
@@ -1180,6 +1180,7 @@
         self list:(listHolder value).
         ^ self
     ].
+
     changedObject == enableChannel ifTrue:[^ self enabled:enableChannel value].
     changedObject == canvasHolder  ifTrue:[^ self canvas:canvasHolder value].
 
@@ -1816,16 +1817,22 @@
     isDestroyAction := false.
 
     tabWasActiveWhenPressed ifTrue:[    
-        (showDestroyTabButton and:[destroyTabAction notNil]) ifTrue:[
-            idx := list findFirst:[:aTab| aTab containsPointX:x y:y ].
+        idx := list findFirst:[:aTab| 
+                            (self isDestroyTabButtonShownFor:aTab)
+                            and:[ aTab containsPointX:x y:y ]
+                    ].
+        idx ~~ 0 ifTrue:[
             tab := list at:idx ifAbsent:nil.
-
             tab notNil ifTrue:[
                 (    tab == self selectedTab
                  or:[self disableDestroyButtonOfInactiveTabs not]
                 ) ifTrue:[
                     ((self destroyButtonFrameForTab:tab) containsPointX:x y:y) ifTrue:[
-                        destroyTabAction value:idx.
+                        tab destroyTabAction notNil ifTrue:[
+                            tab destroyTabAction valueWithOptionalArgument:idx.
+                        ] ifFalse:[
+                            destroyTabAction valueWith:idx.
+                        ].
                         isDestroyAction := true.
                     ].
                 ].
@@ -3127,6 +3134,8 @@
 isDestroyTabButtonShownFor:aTab
     "returns true if the destroyButton for a tab is shown"
 
+    aTab destroyTabButtonShown ifTrue:[^ true].
+
     (showDestroyTabButton and:[destroyTabAction notNil]) ifFalse:[
         ^ false
     ].
@@ -3380,6 +3389,28 @@
     ^ accessCharacter
 !
 
+destroyTabAction
+    "if non-nil, this tab has its own private destroyButton.
+     This can be used for individual tabs; for an overall tab-destroy capability,
+     change the destroyTab: action of my owning tabView"
+
+    tabItem notNil ifTrue:[
+        ^ tabItem destroyTabAction
+    ].
+    ^ nil
+!
+
+destroyTabButtonShown
+    "returns true, if this tab has its own private destroyButton.
+     This can be used for individual tabs; for an overall tab-destroy capability,
+     change the destroyTab: action of my owning tabView"
+
+    tabItem notNil ifTrue:[
+        ^ tabItem destroyTabAction notNil
+    ].
+    ^ false
+!
+
 foregroundColor
     "returns the foregroundColor or nil"
 
@@ -3738,5 +3769,5 @@
 !NoteBookView class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/NoteBookView.st,v 1.175 2012-12-11 15:44:10 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/NoteBookView.st,v 1.176 2012-12-14 14:22:25 cg Exp $'
 ! !