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