WarningBox.st
author Claus Gittinger <cg@exept.de>
Thu, 25 Apr 1996 19:26:41 +0200
changeset 585 8f395aba0173
parent 493 64ac6d6270f6
child 593 86dd024ed773
permissions -rw-r--r--
documentation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
InfoBox subclass:#WarningBox
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    14
	instanceVariableNames:''
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    15
	classVariableNames:'WarnBitmap'
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    16
	poolDictionaries:''
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    17
	category:'Views-DialogBoxes'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    18
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    19
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    20
!WarningBox class methodsFor:'documentation'!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    21
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    22
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    23
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    24
 COPYRIGHT (c) 1993 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    25
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    26
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    27
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    28
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    30
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    31
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    32
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    33
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    34
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    35
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    36
documentation
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    37
"
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    38
   Historic note:
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    39
        originally, ST/X had separate classes for the various entry methods;
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    40
        there were YesNoBox, EnterBox, InfoBox and so on.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    41
        In the meantime, the DialogBox class (and therefore its alias: Dialog)
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    42
        is going to duplicate most funcionality found in these classes.
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    43
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    44
        In the future, those existing subclasses' functionality is going to
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    45
        be moved fully into Dialog, and the subclasses will be replaced by dummy
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    46
        delegators. (They will be kept for backward compatibility, though).
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    47
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    48
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    49
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    50
    this class implements a pop-up box to show an information message. 
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    51
    WarningBoxes are basically InfoBoxes with a different bitmap-image.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    52
    (also, they add a beep when popping up)
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    53
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    54
    They are created with:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    55
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    56
        aBox := WarningBox title:'some title'.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    57
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    58
    and shown with:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    59
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    60
        aBox showAtPointer
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    61
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    62
    The default box shows 'yes' in its button; this can be changed with:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    63
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    64
        aBox okText:'some string'.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    65
79
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    66
    Since showing warnings is a common action, a convenient method has been
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    67
    added to Object; thus you can use:
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    68
355
a55f62047156 commentary
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
    69
        self warn:'oops - headcrash'
79
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    70
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    71
    everywhere in your code.
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    72
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    73
    [see also:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    74
        DialogBox InfoBox YesNoBox
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    75
        ( introduction to view programming :html: programming/viewintro.html )
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    76
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    77
    [author:]
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
    78
        Claus Gittinger
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    79
"
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    80
!
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    81
63
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    82
examples
f4eaf04d1eaf *** empty log message ***
claus
parents: 59
diff changeset
    83
"
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    84
    Examples:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    85
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    86
	|aBox|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    87
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    88
	aBox := WarningBox title:'Press ''OK'' to continue'.
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    89
	aBox okText:'OK'.
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
    90
	aBox showAtPointer.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
    91
79
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    92
    since warnboxes are much like infoBoxes, all of look can be changed
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    93
    like described there:
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    94
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    95
	|aBox|
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    96
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    97
	aBox := WarningBox title:'Press ''OK'' to continue'.
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    98
	aBox okText:'yes, continue'.
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
    99
	aBox form:(Image fromFile:'bitmaps/SmalltalkX.xbm').
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
   100
	aBox showAtPointer.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 26
diff changeset
   101
"
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   102
! !
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   103
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   104
!WarningBox class methodsFor:'icon bitmap'!
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   105
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   106
iconBitmap
184
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   107
    "return the bitmap shown as icon in my instances.
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   108
     This is the default image; you can overwrite this in a concrete
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   109
     instance with the image: message"
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   110
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   111
    WarnBitmap isNil ifTrue:[
109
0f014b33eba2 *** empty log message ***
claus
parents: 107
diff changeset
   112
	WarnBitmap := Image fromFile:'bitmaps/Warning.xbm'.
107
97932154b0fd *** empty log message ***
claus
parents: 79
diff changeset
   113
	WarnBitmap notNil ifTrue:[
97932154b0fd *** empty log message ***
claus
parents: 79
diff changeset
   114
	    WarnBitmap := WarnBitmap on:Display
97932154b0fd *** empty log message ***
claus
parents: 79
diff changeset
   115
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   116
    ].
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   117
    ^ WarnBitmap
184
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   118
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   119
    "
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   120
     WarnBitmap := Image fromFile:'bitmaps/WARNING.xpm'.
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   121
     self warn:'foo bar'.
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   122
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   123
     WarnBitmap := Image fromFile:'bitmaps/Warning.xbm'.
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   124
     self warn:'foo bar'.
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   125
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   126
     |box|
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   127
     box := WarningBox title:'foo bar'.
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   128
     box showAtPointer.
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   129
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   130
     |box|
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   131
     box := WarningBox title:'foo bar'.
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   132
     box image:(Image fromFile:'bitmaps/QUESTION.xpm').
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   133
     box showAtPointer.
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   134
    "
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   135
cbc75a3ba885 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   136
    "Created: 17.11.1995 / 18:16:47 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   137
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   138
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   139
!WarningBox class methodsFor:'styles'!
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   140
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   141
updateStyleCache
443
555bb9c7e1be added style resource directive
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   142
    "extract values from the styleSheet and cache them in class variables"
555bb9c7e1be added style resource directive
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   143
555bb9c7e1be added style resource directive
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   144
    <resource: #style (#warningBoxIcon)>
555bb9c7e1be added style resource directive
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   145
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   146
    |img|
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   147
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   148
    img := StyleSheet at:'warningBoxIcon'.
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   149
    img notNil ifTrue:[WarnBitmap := img on:Display].
443
555bb9c7e1be added style resource directive
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   150
555bb9c7e1be added style resource directive
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
   151
    "Modified: 1.3.1996 / 13:51:43 / cg"
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   152
! !
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   153
79
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
   154
!WarningBox methodsFor:'initialization'!
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
   155
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
   156
initialize
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
   157
    super initialize.
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
   158
    label := 'Warning'
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
   159
! !
6d917a89f7b7 *** empty log message ***
claus
parents: 63
diff changeset
   160
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   161
!WarningBox methodsFor:'realization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   162
493
64ac6d6270f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
   163
openModal
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   164
    "added bell to wake up user"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   165
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   166
    device beep.
493
64ac6d6270f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
   167
    super openModal
26
9d08a08ba6a6 *** empty log message ***
claus
parents: 3
diff changeset
   168
493
64ac6d6270f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
   169
    "
64ac6d6270f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
   170
     self warn:'hello'
64ac6d6270f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
   171
    "
26
9d08a08ba6a6 *** empty log message ***
claus
parents: 3
diff changeset
   172
493
64ac6d6270f6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
   173
    "Modified: 7.3.1996 / 17:52:17 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   174
! !
197
00927189c882 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 184
diff changeset
   175
243
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   176
!WarningBox class methodsFor:'documentation'!
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   177
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   178
version
585
8f395aba0173 documentation
Claus Gittinger <cg@exept.de>
parents: 493
diff changeset
   179
    ^ '$Header: /cvs/stx/stx/libwidg/WarningBox.st,v 1.17 1996-04-25 17:20:41 cg Exp $'
243
5c411425097d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 197
diff changeset
   180
! !