WarningBox.st
author Claus Gittinger <cg@exept.de>
Fri, 01 Mar 1996 14:03:56 +0100
changeset 443 555bb9c7e1be
parent 355 a55f62047156
child 493 64ac6d6270f6
permissions -rw-r--r--
added style resource directive

"
 COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

InfoBox subclass:#WarningBox
	instanceVariableNames:''
	classVariableNames:'WarnBitmap'
	poolDictionaries:''
	category:'Views-DialogBoxes'
!

!WarningBox class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
   Historic note:
        originally, ST/X had separate classes for the various entry methods;
        there were YesNoBox, EnterBox, InfoBox and so on.
        In the meantime, the DialogBox class (and therefore its alias: Dialog)
        is going to duplicate most funcionality found in these classes.

        In the future, those existing subclasses' functionality is going to
        be moved fully into Dialog, and the subclasses will be replaced by dummy
        delegators. (They will be kept for backward compatibility, though).



    this class implements a pop-up box to show an information message. 
    WarningBoxes are basically InfoBoxes with a different bitmap-image.
    (also, they add a beep when popping up)

    They are created with:

        aBox := WarningBox title:'some title'.

    and shown with:

        aBox showAtPointer

    The default box shows 'yes' in its button; this can be changed with:

        aBox okText:'some string'.

    Since showing warnings is a common action, a convenient method has been
    added to Object; thus you can use:

        self warn:'oops - headcrash'

    everywhere in your code.
"
!

examples
"
    Examples:

	|aBox|

	aBox := WarningBox title:'Press ''OK'' to continue'.
	aBox okText:'OK'.
	aBox showAtPointer.

    since warnboxes are much like infoBoxes, all of look can be changed
    like described there:

	|aBox|

	aBox := WarningBox title:'Press ''OK'' to continue'.
	aBox okText:'yes, continue'.
	aBox form:(Image fromFile:'bitmaps/SmalltalkX.xbm').
	aBox showAtPointer.
"
! !

!WarningBox class methodsFor:'icon bitmap'!

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"

    WarnBitmap isNil ifTrue:[
	WarnBitmap := Image fromFile:'bitmaps/Warning.xbm'.
	WarnBitmap notNil ifTrue:[
	    WarnBitmap := WarnBitmap on:Display
	]
    ].
    ^ WarnBitmap

    "
     WarnBitmap := Image fromFile:'bitmaps/WARNING.xpm'.
     self warn:'foo bar'.

     WarnBitmap := Image fromFile:'bitmaps/Warning.xbm'.
     self warn:'foo bar'.

     |box|
     box := WarningBox title:'foo bar'.
     box showAtPointer.

     |box|
     box := WarningBox title:'foo bar'.
     box image:(Image fromFile:'bitmaps/QUESTION.xpm').
     box showAtPointer.
    "

    "Created: 17.11.1995 / 18:16:47 / cg"
! !

!WarningBox class methodsFor:'styles'!

updateStyleCache
    "extract values from the styleSheet and cache them in class variables"

    <resource: #style (#warningBoxIcon)>

    |img|

    img := StyleSheet at:'warningBoxIcon'.
    img notNil ifTrue:[WarnBitmap := img on:Display].

    "Modified: 1.3.1996 / 13:51:43 / cg"
! !

!WarningBox methodsFor:'initialization'!

initialize
    super initialize.
    label := 'Warning'
! !

!WarningBox methodsFor:'realization'!

show
    "added bell to wake up user"

    device beep.
    super show
!

showAtPointer
    "added bell to wake up user"

    device beep.
    super showAtPointer
! !

!WarningBox class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libwidg/WarningBox.st,v 1.15 1996-03-01 13:03:56 cg Exp $'
! !