code shared
authorClaus Gittinger <cg@exept.de>
Mon, 18 Aug 2003 19:23:10 +0200
changeset 2786 06de7ca4b263
parent 2785 ac6eb18aa58e
child 2787 401103ebccb7
code shared
InfoBox.st
WarningBox.st
YesNoBox.st
--- a/InfoBox.st	Mon Aug 18 19:13:54 2003 +0200
+++ b/InfoBox.st	Mon Aug 18 19:23:10 2003 +0200
@@ -209,21 +209,30 @@
 
     <resource: #style (#'infoBox.icon' #'infoBox.iconFile')>
 
+    InfoBitmap isNil ifTrue:[
+        InfoBitmap := self iconBitmapFromStyle:'infoBox.icon' orStyleFile:'infoBox.iconFile' orFilename:'bitmaps/Information.xbm'.
+    ].
+    ^ InfoBitmap
+
+    "Modified: / 26.10.1997 / 17:02:51 / cg"
+!
+
+iconBitmapFromStyle:styleName orStyleFile:styleFile orFilename:fileName
+    "return the bitmap shown as icon in my instances.
+     This is the default image; you can overwrite this in a concrete
+     instance with the #image: message"
+
     |img imgFileName|
 
-    InfoBitmap isNil ifTrue:[
-        img := self styleSheet at:'infoBox.icon'.
-        img notNil ifTrue:[
-            InfoBitmap := img
-        ] ifFalse:[
-            imgFileName := StyleSheet at:'infoBox.iconFile' default:'bitmaps/Information.xbm'.
-            InfoBitmap := Smalltalk imageFromFileNamed:imgFileName forClass:self.
-        ].
-        InfoBitmap notNil ifTrue:[
-            InfoBitmap := InfoBitmap onDevice:Display
-        ]
+    img := self styleSheet at:styleName.
+    img isNil ifTrue:[
+        imgFileName := StyleSheet at:styleFile default:fileName.
+        img := Smalltalk imageFromFileNamed:imgFileName forClass:self.
     ].
-    ^ InfoBitmap
+    img notNil ifTrue:[
+        img := img onDevice:Display
+    ].
+    ^ img
 
     "Modified: / 26.10.1997 / 17:02:51 / cg"
 ! !
@@ -383,5 +392,5 @@
 !InfoBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/InfoBox.st,v 1.39 2003-08-18 17:13:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/InfoBox.st,v 1.40 2003-08-18 17:23:00 cg Exp $'
 ! !
--- a/WarningBox.st	Mon Aug 18 19:13:54 2003 +0200
+++ b/WarningBox.st	Mon Aug 18 19:23:10 2003 +0200
@@ -153,21 +153,11 @@
 
     <resource: #style (#'errorBox.icon' #'errorBox.iconFile')>
 
-    |img imgFileName|
-
     ErrorBitmap isNil ifTrue:[
-        img := self styleSheet at:'errorBox.icon'.
-        img isNil ifTrue:[
-            imgFileName := StyleSheet at:'errorBox.iconFile' default:'bitmaps/Error.xbm'.
-            img := Smalltalk imageFromFileNamed:imgFileName forClass:self.
+        ErrorBitmap := self iconBitmapFromStyle:'errorBox.icon' orStyleFile:'errorBox.iconFile' orFilename:'bitmaps/Error.xbm'.
+        ErrorBitmap isNil ifTrue:[
+            ErrorBitmap := self warnIconBitmap.
         ].
-        img notNil ifTrue:[
-            img := img onDevice:Display
-        ].
-        img isNil ifTrue:[
-            img := self warnIconBitmap.
-        ].
-        ErrorBitmap := img
     ].
     ^ ErrorBitmap
 
@@ -214,18 +204,8 @@
 
     <resource: #style (#'warningBox.icon' #'warningBox.iconFile')>
 
-    |img imgFileName|
-
     WarnBitmap isNil ifTrue:[
-        img := self styleSheet at:'warningBox.icon'.
-        img isNil ifTrue:[
-            imgFileName := StyleSheet at:'warningBox.iconFile' default:'bitmaps/Warning.xbm'.
-            img := Smalltalk imageFromFileNamed:imgFileName forClass:self.
-        ].
-        img notNil ifTrue:[
-            img := img onDevice:Display
-        ].
-        WarnBitmap := img
+        WarnBitmap := self iconBitmapFromStyle:'warningBox.icon' orStyleFile:'warningBox.iconFile' orFilename:'bitmaps/Warning.xbm'.
     ].
     ^ WarnBitmap
 
@@ -283,5 +263,5 @@
 !WarningBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/WarningBox.st,v 1.32 2003-08-18 17:13:54 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/WarningBox.st,v 1.33 2003-08-18 17:23:10 cg Exp $'
 ! !
--- a/YesNoBox.st	Mon Aug 18 19:13:54 2003 +0200
+++ b/YesNoBox.st	Mon Aug 18 19:23:10 2003 +0200
@@ -182,19 +182,8 @@
 
     <resource: #style (#'requestBox.icon' #'requestBox.iconFile')>
 
-    |img imgFileName|
-
     RequestBitmap isNil ifTrue:[
-        img := self styleSheet at:'requestBox.icon'.
-        img notNil ifTrue:[
-            RequestBitmap := img
-        ] ifFalse:[
-            imgFileName := StyleSheet at:'requestBox.iconFile' default:'bitmaps/Request.xbm'.
-            RequestBitmap := Smalltalk imageFromFileNamed:imgFileName forClass:self.
-        ].
-        RequestBitmap notNil ifTrue:[
-            RequestBitmap := RequestBitmap onDevice:Screen current
-        ]
+        RequestBitmap := self iconBitmapFromStyle:'requestBox.icon' orStyleFile:'requestBox.iconFile' orFilename:'bitmaps/Request.xbm'.
     ].
     ^ RequestBitmap
 
@@ -328,5 +317,5 @@
 !YesNoBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/YesNoBox.st,v 1.51 2003-08-18 17:13:39 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/YesNoBox.st,v 1.52 2003-08-18 17:23:07 cg Exp $'
 ! !