change messages when icon or label changes
authorClaus Gittinger <cg@exept.de>
Tue, 13 Jan 2015 11:31:50 +0100
changeset 4694 7f830911e3aa
parent 4693 67625df32bdc
child 4695 cf3b8a82392b
change messages when icon or label changes
HierarchicalItemWithLabelAndIcon.st
--- a/HierarchicalItemWithLabelAndIcon.st	Tue Jan 13 11:31:49 2015 +0100
+++ b/HierarchicalItemWithLabelAndIcon.st	Tue Jan 13 11:31:50 2015 +0100
@@ -9,8 +9,9 @@
  other person.  No title to or ownership of the software is
  hereby transferred.
 "
+"{ Package: 'stx:libwidg2' }"
 
-"{ Package: 'stx:libwidg2' }"
+"{ NameSpace: Smalltalk }"
 
 HierarchicalItemWithLabel subclass:#HierarchicalItemWithLabelAndIcon
 	instanceVariableNames:'icon'
@@ -43,26 +44,39 @@
     ^ icon
 !
 
-icon:something
+icon:anIcon
     "set the value of the instance variable 'icon' (automatically generated)"
 
-    icon := something.
+    icon ~= anIcon ifTrue:[
+        icon := anIcon.
+        self iconChanged
+    ].
 !
 
 label:aLabel icon:anIcon
-    label := aLabel.
-    icon  := anIcon.
+    |anyChange|
+
+    anyChange := false.
+    (icon ~= anIcon) ifTrue:[
+        icon := anIcon.
+        anyChange := true
+    ].
+    (label ~= anIcon) ifTrue:[
+        icon := anIcon.
+        anyChange := true
+    ].
+    anyChange ifTrue:[ self changed ].
 !
 
 labeled:aLabel icon:anIcon
-    label := aLabel.
-    icon  := anIcon.
+    "backward compatibility"
 
-
+    self label:aLabel icon:anIcon
 ! !
 
 !HierarchicalItemWithLabelAndIcon class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItemWithLabelAndIcon.st,v 1.1 2006-03-14 13:08:56 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItemWithLabelAndIcon.st,v 1.2 2015-01-13 10:31:50 cg Exp $'
 ! !
+