author | Claus Gittinger <cg@exept.de> |
Fri, 27 Jun 1997 11:56:45 +0200 | |
changeset 1254 | c9e604f03e6a |
parent 1173 | 86440dfaca06 |
child 1365 | aa6a855b5013 |
permissions | -rw-r--r-- |
0 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
59 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
InfoBox subclass:#WarningBox |
|
355 | 14 |
instanceVariableNames:'' |
15 |
classVariableNames:'WarnBitmap' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-DialogBoxes' |
|
0 | 18 |
! |
19 |
||
38 | 20 |
!WarningBox class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
59 | 25 |
All Rights Reserved |
38 | 26 |
|
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
355 | 38 |
Historic note: |
39 |
originally, ST/X had separate classes for the various entry methods; |
|
40 |
there were YesNoBox, EnterBox, InfoBox and so on. |
|
41 |
In the meantime, the DialogBox class (and therefore its alias: Dialog) |
|
42 |
is going to duplicate most funcionality found in these classes. |
|
43 |
||
44 |
In the future, those existing subclasses' functionality is going to |
|
45 |
be moved fully into Dialog, and the subclasses will be replaced by dummy |
|
46 |
delegators. (They will be kept for backward compatibility, though). |
|
47 |
||
48 |
||
49 |
||
38 | 50 |
this class implements a pop-up box to show an information message. |
51 |
WarningBoxes are basically InfoBoxes with a different bitmap-image. |
|
52 |
(also, they add a beep when popping up) |
|
53 |
||
54 |
They are created with: |
|
55 |
||
355 | 56 |
aBox := WarningBox title:'some title'. |
38 | 57 |
|
58 |
and shown with: |
|
59 |
||
355 | 60 |
aBox showAtPointer |
38 | 61 |
|
62 |
The default box shows 'yes' in its button; this can be changed with: |
|
63 |
||
355 | 64 |
aBox okText:'some string'. |
38 | 65 |
|
79 | 66 |
Since showing warnings is a common action, a convenient method has been |
67 |
added to Object; thus you can use: |
|
68 |
||
355 | 69 |
self warn:'oops - headcrash' |
79 | 70 |
|
71 |
everywhere in your code. |
|
585 | 72 |
|
73 |
[see also:] |
|
74 |
DialogBox InfoBox YesNoBox |
|
75 |
( introduction to view programming :html: programming/viewintro.html ) |
|
76 |
||
77 |
[author:] |
|
78 |
Claus Gittinger |
|
63 | 79 |
" |
80 |
! |
|
38 | 81 |
|
63 | 82 |
examples |
83 |
" |
|
644 | 84 |
standard warning dialogs |
85 |
(recommended, since these are ST-80 compatible interfaces) |
|
86 |
[exBegin] |
|
87 |
Dialog warn:'you should not do this' |
|
88 |
[exEnd] |
|
89 |
since all objects support the #warn message, |
|
90 |
you can also simply use (for any self): |
|
91 |
[exBegin] |
|
92 |
self warn:'you should not do this' |
|
93 |
[exEnd] |
|
94 |
||
95 |
with attributed text: |
|
96 |
[exBegin] |
|
97 |
Dialog warn:(Text string:'you should not do this' |
|
98 |
emphasis:#color->Color red) |
|
99 |
[exEnd] |
|
100 |
||
101 |
specifying more details of the warnBox (low level entries). |
|
102 |
label of OK-button: |
|
593 | 103 |
[exBegin] |
104 |
|aBox| |
|
38 | 105 |
|
593 | 106 |
aBox := WarningBox title:'Press ''OK'' to continue'. |
107 |
aBox okText:'OK'. |
|
108 |
aBox showAtPointer. |
|
109 |
[exEnd] |
|
644 | 110 |
|
111 |
accessing the ok-Button component and changing its color: |
|
112 |
[exBegin] |
|
113 |
|aBox| |
|
114 |
||
115 |
aBox := WarningBox title:'Do you really want to do this ?'. |
|
116 |
aBox okText:'yes, go on'. |
|
117 |
aBox okButton foregroundColor:Color red. |
|
118 |
aBox showAtPointer. |
|
119 |
[exEnd] |
|
79 | 120 |
since warnboxes are much like infoBoxes, all of look can be changed |
121 |
like described there: |
|
593 | 122 |
[exBegin] |
644 | 123 |
|image aBox| |
79 | 124 |
|
593 | 125 |
aBox := WarningBox title:'Press ''OK'' to continue'. |
126 |
aBox okText:'yes, continue'. |
|
644 | 127 |
image := Image fromFile:'bitmaps/SmalltalkX.xbm'. |
128 |
aBox form:image. |
|
593 | 129 |
aBox showAtPointer. |
130 |
[exEnd] |
|
38 | 131 |
" |
59 | 132 |
! ! |
133 |
||
134 |
!WarningBox class methodsFor:'icon bitmap'! |
|
135 |
||
136 |
iconBitmap |
|
184 | 137 |
"return the bitmap shown as icon in my instances. |
138 |
This is the default image; you can overwrite this in a concrete |
|
139 |
instance with the image: message" |
|
59 | 140 |
|
1173
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
141 |
<resource: #style (#warningBoxIcon #warningBoxIconFile)> |
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
142 |
|
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
143 |
|img imgFileName| |
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
144 |
|
0 | 145 |
WarnBitmap isNil ifTrue:[ |
1173
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
146 |
img := StyleSheet at:'warningBoxIcon'. |
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
147 |
img notNil ifTrue:[ |
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
148 |
WarnBitmap := img |
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
149 |
] ifFalse:[ |
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
150 |
imgFileName := StyleSheet at:'warningBoxIconFile' default:'bitmaps/Warning.xbm'. |
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
151 |
WarnBitmap := Image fromFile:imgFileName. |
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
152 |
]. |
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
153 |
WarnBitmap notNil ifTrue:[ |
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
154 |
WarnBitmap := WarnBitmap on:Display |
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
155 |
] |
0 | 156 |
]. |
59 | 157 |
^ WarnBitmap |
184 | 158 |
|
159 |
" |
|
160 |
WarnBitmap := Image fromFile:'bitmaps/WARNING.xpm'. |
|
161 |
self warn:'foo bar'. |
|
162 |
||
163 |
WarnBitmap := Image fromFile:'bitmaps/Warning.xbm'. |
|
164 |
self warn:'foo bar'. |
|
165 |
||
166 |
|box| |
|
167 |
box := WarningBox title:'foo bar'. |
|
168 |
box showAtPointer. |
|
169 |
||
170 |
|box| |
|
171 |
box := WarningBox title:'foo bar'. |
|
172 |
box image:(Image fromFile:'bitmaps/QUESTION.xpm'). |
|
173 |
box showAtPointer. |
|
174 |
" |
|
175 |
||
176 |
"Created: 17.11.1995 / 18:16:47 / cg" |
|
1173
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
177 |
"Modified: 1.4.1997 / 14:28:07 / cg" |
0 | 178 |
! ! |
179 |
||
197 | 180 |
!WarningBox class methodsFor:'styles'! |
181 |
||
182 |
updateStyleCache |
|
1173
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
183 |
"extract values from the styleSheet and cache them in class variables. |
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
184 |
Here, the cached infoBitmap is simply flushed." |
443
555bb9c7e1be
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
355
diff
changeset
|
185 |
|
1173
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
186 |
WarnBitmap := nil |
197 | 187 |
|
1173
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
188 |
"Modified: 1.4.1997 / 14:44:59 / cg" |
197 | 189 |
! ! |
190 |
||
79 | 191 |
!WarningBox methodsFor:'initialization'! |
192 |
||
193 |
initialize |
|
194 |
super initialize. |
|
195 |
label := 'Warning' |
|
196 |
! ! |
|
197 |
||
0 | 198 |
!WarningBox methodsFor:'realization'! |
199 |
||
493 | 200 |
openModal |
0 | 201 |
"added bell to wake up user" |
202 |
||
693 | 203 |
self beep. |
493 | 204 |
super openModal |
26 | 205 |
|
493 | 206 |
" |
207 |
self warn:'hello' |
|
208 |
" |
|
26 | 209 |
|
693 | 210 |
"Modified: 28.5.1996 / 16:59:01 / cg" |
0 | 211 |
! ! |
197 | 212 |
|
243 | 213 |
!WarningBox class methodsFor:'documentation'! |
214 |
||
215 |
version |
|
1173
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
216 |
^ '$Header: /cvs/stx/stx/libwidg/Attic/WarnBox.st,v 1.21 1997-04-01 12:54:23 cg Exp $' |
243 | 217 |
! ! |