author | Claus Gittinger <cg@exept.de> |
Mon, 18 Aug 2003 19:23:10 +0200 | |
changeset 2786 | 06de7ca4b263 |
parent 2785 | ac6eb18aa58e |
child 3121 | 8e4d21e008c9 |
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 |
||
2362
f6ace7307e4d
examples fixed (bitmaps access)
Claus Gittinger <cg@exept.de>
parents:
2073
diff
changeset
|
13 |
"{ Package: 'stx:libwidg' }" |
f6ace7307e4d
examples fixed (bitmaps access)
Claus Gittinger <cg@exept.de>
parents:
2073
diff
changeset
|
14 |
|
0 | 15 |
InfoBox subclass:#WarningBox |
355 | 16 |
instanceVariableNames:'' |
2474 | 17 |
classVariableNames:'WarnBitmap ErrorBitmap' |
355 | 18 |
poolDictionaries:'' |
19 |
category:'Views-DialogBoxes' |
|
0 | 20 |
! |
21 |
||
38 | 22 |
!WarningBox class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
59 | 27 |
All Rights Reserved |
38 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
355 | 40 |
Historic note: |
41 |
originally, ST/X had separate classes for the various entry methods; |
|
42 |
there were YesNoBox, EnterBox, InfoBox and so on. |
|
43 |
In the meantime, the DialogBox class (and therefore its alias: Dialog) |
|
44 |
is going to duplicate most funcionality found in these classes. |
|
45 |
||
2468 | 46 |
In the future, those existing subclasses' functionality might |
47 |
be moved fully into Dialog, and the subclasses be replaced by dummy |
|
355 | 48 |
delegators. (They will be kept for backward compatibility, though). |
49 |
||
50 |
||
51 |
||
38 | 52 |
this class implements a pop-up box to show an information message. |
53 |
WarningBoxes are basically InfoBoxes with a different bitmap-image. |
|
54 |
(also, they add a beep when popping up) |
|
55 |
||
56 |
They are created with: |
|
57 |
||
355 | 58 |
aBox := WarningBox title:'some title'. |
38 | 59 |
|
60 |
and shown with: |
|
61 |
||
355 | 62 |
aBox showAtPointer |
38 | 63 |
|
64 |
The default box shows 'yes' in its button; this can be changed with: |
|
65 |
||
355 | 66 |
aBox okText:'some string'. |
38 | 67 |
|
79 | 68 |
Since showing warnings is a common action, a convenient method has been |
69 |
added to Object; thus you can use: |
|
70 |
||
355 | 71 |
self warn:'oops - headcrash' |
79 | 72 |
|
73 |
everywhere in your code. |
|
585 | 74 |
|
75 |
[see also:] |
|
76 |
DialogBox InfoBox YesNoBox |
|
77 |
( introduction to view programming :html: programming/viewintro.html ) |
|
78 |
||
79 |
[author:] |
|
80 |
Claus Gittinger |
|
63 | 81 |
" |
82 |
! |
|
38 | 83 |
|
63 | 84 |
examples |
85 |
" |
|
2468 | 86 |
Notice, the preferred use is via the DialogBox class messages, |
87 |
such as |
|
88 |
[exBegin] |
|
2469 | 89 |
Dialog warn:'Attention !!' |
2468 | 90 |
[exEnd] |
91 |
these (DialogBox) mesages are compatible with VW and should therefore |
|
92 |
be used for portability. |
|
93 |
||
94 |
Direct reference to WarnBox is only required for highly specialized boxes. |
|
95 |
||
96 |
||
644 | 97 |
standard warning dialogs |
98 |
(recommended, since these are ST-80 compatible interfaces) |
|
99 |
[exBegin] |
|
100 |
Dialog warn:'you should not do this' |
|
101 |
[exEnd] |
|
102 |
since all objects support the #warn message, |
|
103 |
you can also simply use (for any self): |
|
104 |
[exBegin] |
|
105 |
self warn:'you should not do this' |
|
106 |
[exEnd] |
|
107 |
||
108 |
with attributed text: |
|
109 |
[exBegin] |
|
110 |
Dialog warn:(Text string:'you should not do this' |
|
111 |
emphasis:#color->Color red) |
|
112 |
[exEnd] |
|
113 |
||
114 |
specifying more details of the warnBox (low level entries). |
|
115 |
label of OK-button: |
|
593 | 116 |
[exBegin] |
117 |
|aBox| |
|
38 | 118 |
|
593 | 119 |
aBox := WarningBox title:'Press ''OK'' to continue'. |
120 |
aBox okText:'OK'. |
|
121 |
aBox showAtPointer. |
|
122 |
[exEnd] |
|
644 | 123 |
|
124 |
accessing the ok-Button component and changing its color: |
|
125 |
[exBegin] |
|
126 |
|aBox| |
|
127 |
||
128 |
aBox := WarningBox title:'Do you really want to do this ?'. |
|
129 |
aBox okText:'yes, go on'. |
|
130 |
aBox okButton foregroundColor:Color red. |
|
131 |
aBox showAtPointer. |
|
132 |
[exEnd] |
|
79 | 133 |
since warnboxes are much like infoBoxes, all of look can be changed |
134 |
like described there: |
|
593 | 135 |
[exBegin] |
644 | 136 |
|image aBox| |
79 | 137 |
|
593 | 138 |
aBox := WarningBox title:'Press ''OK'' to continue'. |
139 |
aBox okText:'yes, continue'. |
|
2362
f6ace7307e4d
examples fixed (bitmaps access)
Claus Gittinger <cg@exept.de>
parents:
2073
diff
changeset
|
140 |
image := Image fromFile:'bitmaps/SmalltalkX.xbm' inPackage:'stx:libtool'. |
644 | 141 |
aBox form:image. |
593 | 142 |
aBox showAtPointer. |
143 |
[exEnd] |
|
38 | 144 |
" |
59 | 145 |
! ! |
146 |
||
147 |
!WarningBox class methodsFor:'icon bitmap'! |
|
148 |
||
2474 | 149 |
errorIconBitmap |
150 |
"return the bitmap shown as icon in my instances. |
|
151 |
This is the default image; you can overwrite this in a concrete |
|
152 |
instance with the image: message" |
|
153 |
||
154 |
<resource: #style (#'errorBox.icon' #'errorBox.iconFile')> |
|
155 |
||
156 |
ErrorBitmap isNil ifTrue:[ |
|
2786 | 157 |
ErrorBitmap := self iconBitmapFromStyle:'errorBox.icon' orStyleFile:'errorBox.iconFile' orFilename:'bitmaps/Error.xbm'. |
158 |
ErrorBitmap isNil ifTrue:[ |
|
159 |
ErrorBitmap := self warnIconBitmap. |
|
2474 | 160 |
]. |
161 |
]. |
|
162 |
^ ErrorBitmap |
|
163 |
||
164 |
" |
|
165 |
|box| |
|
166 |
||
167 |
box := WarningBox title:'foo bar'. |
|
168 |
box image:(WarningBox errorIconBitmap). |
|
169 |
box showAtPointer. |
|
170 |
" |
|
171 |
||
172 |
"Created: / 17.11.1995 / 18:16:47 / cg" |
|
173 |
"Modified: / 16.11.2001 / 15:02:54 / cg" |
|
174 |
! |
|
175 |
||
59 | 176 |
iconBitmap |
184 | 177 |
"return the bitmap shown as icon in my instances. |
178 |
This is the default image; you can overwrite this in a concrete |
|
179 |
instance with the image: message" |
|
59 | 180 |
|
2474 | 181 |
^ self warnIconBitmap |
182 |
||
183 |
" |
|
184 |
self warn:'foo bar'. |
|
185 |
||
186 |
|box| |
|
187 |
box := WarningBox title:'foo bar'. |
|
188 |
box showAtPointer. |
|
189 |
||
190 |
|box| |
|
191 |
box := WarningBox title:'foo bar'. |
|
192 |
box image:(Image fromFile:'QUESTION.xpm' inPackage:'stx:goodies/bitmaps/xpmBitmaps'). |
|
193 |
box showAtPointer. |
|
194 |
" |
|
195 |
||
196 |
"Created: / 17.11.1995 / 18:16:47 / cg" |
|
197 |
"Modified: / 16.11.2001 / 15:02:38 / cg" |
|
198 |
! |
|
199 |
||
200 |
warnIconBitmap |
|
201 |
"return the bitmap shown as icon in my instances. |
|
202 |
This is the default image; you can overwrite this in a concrete |
|
203 |
instance with the image: message" |
|
204 |
||
1365 | 205 |
<resource: #style (#'warningBox.icon' #'warningBox.iconFile')> |
1173
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
206 |
|
0 | 207 |
WarnBitmap isNil ifTrue:[ |
2786 | 208 |
WarnBitmap := self iconBitmapFromStyle:'warningBox.icon' orStyleFile:'warningBox.iconFile' orFilename:'bitmaps/Warning.xbm'. |
0 | 209 |
]. |
59 | 210 |
^ WarnBitmap |
184 | 211 |
|
212 |
" |
|
213 |
self warn:'foo bar'. |
|
214 |
||
215 |
|box| |
|
216 |
box := WarningBox title:'foo bar'. |
|
217 |
box showAtPointer. |
|
218 |
||
219 |
|box| |
|
220 |
box := WarningBox title:'foo bar'. |
|
2362
f6ace7307e4d
examples fixed (bitmaps access)
Claus Gittinger <cg@exept.de>
parents:
2073
diff
changeset
|
221 |
box image:(Image fromFile:'QUESTION.xpm' inPackage:'stx:goodies/bitmaps/xpmBitmaps'). |
184 | 222 |
box showAtPointer. |
223 |
" |
|
224 |
||
1915 | 225 |
"Modified: / 25.5.1999 / 15:22:25 / cg" |
2474 | 226 |
"Created: / 16.11.2001 / 15:02:24 / cg" |
0 | 227 |
! ! |
228 |
||
197 | 229 |
!WarningBox class methodsFor:'styles'! |
230 |
||
231 |
updateStyleCache |
|
1173
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
232 |
"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
|
233 |
Here, the cached infoBitmap is simply flushed." |
443
555bb9c7e1be
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
355
diff
changeset
|
234 |
|
2474 | 235 |
WarnBitmap := nil. |
236 |
ErrorBitmap := nil. |
|
197 | 237 |
|
2474 | 238 |
"Modified: / 16.11.2001 / 15:00:43 / cg" |
197 | 239 |
! ! |
240 |
||
79 | 241 |
!WarningBox methodsFor:'initialization'! |
242 |
||
243 |
initialize |
|
244 |
super initialize. |
|
245 |
label := 'Warning' |
|
246 |
! ! |
|
247 |
||
0 | 248 |
!WarningBox methodsFor:'realization'! |
249 |
||
493 | 250 |
openModal |
0 | 251 |
"added bell to wake up user" |
252 |
||
693 | 253 |
self beep. |
493 | 254 |
super openModal |
26 | 255 |
|
493 | 256 |
" |
257 |
self warn:'hello' |
|
258 |
" |
|
26 | 259 |
|
693 | 260 |
"Modified: 28.5.1996 / 16:59:01 / cg" |
0 | 261 |
! ! |
197 | 262 |
|
243 | 263 |
!WarningBox class methodsFor:'documentation'! |
264 |
||
265 |
version |
|
2786 | 266 |
^ '$Header: /cvs/stx/stx/libwidg/WarningBox.st,v 1.33 2003-08-18 17:23:10 cg Exp $' |
243 | 267 |
! ! |