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