WarningBox.st
changeset 2474 c297943dc3d7
parent 2469 da097548025a
child 2785 ac6eb18aa58e
--- a/WarningBox.st	Fri Nov 16 15:09:40 2001 +0100
+++ b/WarningBox.st	Fri Nov 16 15:18:59 2001 +0100
@@ -14,7 +14,7 @@
 
 InfoBox subclass:#WarningBox
 	instanceVariableNames:''
-	classVariableNames:'WarnBitmap'
+	classVariableNames:'WarnBitmap ErrorBitmap'
 	poolDictionaries:''
 	category:'Views-DialogBoxes'
 !
@@ -146,11 +146,72 @@
 
 !WarningBox class methodsFor:'icon bitmap'!
 
+errorIconBitmap
+    "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"
+
+    <resource: #style (#'errorBox.icon' #'errorBox.iconFile')>
+
+    |img imgFileName|
+
+    ErrorBitmap isNil ifTrue:[
+        img := StyleSheet at:'errorBox.icon'.
+        img isNil ifTrue:[
+            imgFileName := StyleSheet at:'errorBox.iconFile' default:'bitmaps/Error.xbm'.
+            img := Smalltalk imageFromFileNamed:imgFileName forClass:self.
+        ].
+        img notNil ifTrue:[
+            img := img onDevice:Display
+        ].
+        img isNil ifTrue:[
+            img := self warnIconBitmap.
+        ].
+        ErrorBitmap := img
+    ].
+    ^ ErrorBitmap
+
+    "
+     |box|
+
+     box := WarningBox title:'foo bar'.
+     box image:(WarningBox errorIconBitmap).
+     box showAtPointer.
+    "
+
+    "Created: / 17.11.1995 / 18:16:47 / cg"
+    "Modified: / 16.11.2001 / 15:02:54 / cg"
+!
+
 iconBitmap
     "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"
 
+    ^ self warnIconBitmap
+
+    "
+     self warn:'foo bar'.
+
+     |box|
+     box := WarningBox title:'foo bar'.
+     box showAtPointer.
+
+     |box|
+     box := WarningBox title:'foo bar'.
+     box image:(Image fromFile:'QUESTION.xpm' inPackage:'stx:goodies/bitmaps/xpmBitmaps').
+     box showAtPointer.
+    "
+
+    "Created: / 17.11.1995 / 18:16:47 / cg"
+    "Modified: / 16.11.2001 / 15:02:38 / cg"
+!
+
+warnIconBitmap
+    "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"
+
     <resource: #style (#'warningBox.icon' #'warningBox.iconFile')>
 
     |img imgFileName|
@@ -181,8 +242,8 @@
      box showAtPointer.
     "
 
-    "Created: / 17.11.1995 / 18:16:47 / cg"
     "Modified: / 25.5.1999 / 15:22:25 / cg"
+    "Created: / 16.11.2001 / 15:02:24 / cg"
 ! !
 
 !WarningBox class methodsFor:'styles'!
@@ -191,9 +252,10 @@
     "extract values from the styleSheet and cache them in class variables.
      Here, the cached infoBitmap is simply flushed."
 
-    WarnBitmap := nil
+    WarnBitmap := nil.
+    ErrorBitmap := nil.
 
-    "Modified: 1.4.1997 / 14:44:59 / cg"
+    "Modified: / 16.11.2001 / 15:00:43 / cg"
 ! !
 
 !WarningBox methodsFor:'initialization'!
@@ -221,5 +283,5 @@
 !WarningBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/WarningBox.st,v 1.30 2001-11-15 21:03:50 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/WarningBox.st,v 1.31 2001-11-16 14:18:59 cg Exp $'
 ! !