author | Claus Gittinger <cg@exept.de> |
Thu, 09 Nov 2017 20:09:30 +0100 | |
changeset 6225 | 0122e4e6c587 |
parent 5894 | 317a89cd0996 |
child 6290 | 9c06dcc35aaa |
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 |
||
148 |
!WarningBox class methodsFor:'icon bitmap'! |
|
149 |
||
2474 | 150 |
errorIconBitmap |
151 |
"return the bitmap shown as icon in my instances. |
|
152 |
This is the default image; you can overwrite this in a concrete |
|
153 |
instance with the image: message" |
|
154 |
||
155 |
<resource: #style (#'errorBox.icon' #'errorBox.iconFile')> |
|
156 |
||
157 |
ErrorBitmap isNil ifTrue:[ |
|
2786 | 158 |
ErrorBitmap := self iconBitmapFromStyle:'errorBox.icon' orStyleFile:'errorBox.iconFile' orFilename:'bitmaps/Error.xbm'. |
159 |
ErrorBitmap isNil ifTrue:[ |
|
3665
7ff70da31a25
care for non-existing bitmap files
Claus Gittinger <cg@exept.de>
parents:
3121
diff
changeset
|
160 |
ErrorBitmap := ToolbarIconLibrary errorIcon. |
2474 | 161 |
]. |
162 |
]. |
|
163 |
^ ErrorBitmap |
|
164 |
||
165 |
" |
|
166 |
|box| |
|
167 |
||
168 |
box := WarningBox title:'foo bar'. |
|
169 |
box image:(WarningBox errorIconBitmap). |
|
170 |
box showAtPointer. |
|
171 |
" |
|
172 |
||
173 |
"Created: / 17.11.1995 / 18:16:47 / cg" |
|
174 |
"Modified: / 16.11.2001 / 15:02:54 / cg" |
|
175 |
! |
|
176 |
||
59 | 177 |
iconBitmap |
184 | 178 |
"return the bitmap shown as icon in my instances. |
179 |
This is the default image; you can overwrite this in a concrete |
|
180 |
instance with the image: message" |
|
59 | 181 |
|
2474 | 182 |
^ self warnIconBitmap |
183 |
||
184 |
" |
|
185 |
self warn:'foo bar'. |
|
186 |
||
187 |
|box| |
|
188 |
box := WarningBox title:'foo bar'. |
|
189 |
box showAtPointer. |
|
190 |
||
191 |
|box| |
|
192 |
box := WarningBox title:'foo bar'. |
|
193 |
box image:(Image fromFile:'QUESTION.xpm' inPackage:'stx:goodies/bitmaps/xpmBitmaps'). |
|
194 |
box showAtPointer. |
|
195 |
" |
|
196 |
||
197 |
"Created: / 17.11.1995 / 18:16:47 / cg" |
|
198 |
"Modified: / 16.11.2001 / 15:02:38 / cg" |
|
199 |
! |
|
200 |
||
201 |
warnIconBitmap |
|
202 |
"return the bitmap shown as icon in my instances. |
|
203 |
This is the default image; you can overwrite this in a concrete |
|
204 |
instance with the image: message" |
|
205 |
||
1365 | 206 |
<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
|
207 |
|
0 | 208 |
WarnBitmap isNil ifTrue:[ |
2786 | 209 |
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
|
210 |
WarnBitmap isNil ifTrue:[ |
7ff70da31a25
care for non-existing bitmap files
Claus Gittinger <cg@exept.de>
parents:
3121
diff
changeset
|
211 |
WarnBitmap := ToolbarIconLibrary warnIcon. |
7ff70da31a25
care for non-existing bitmap files
Claus Gittinger <cg@exept.de>
parents:
3121
diff
changeset
|
212 |
]. |
0 | 213 |
]. |
59 | 214 |
^ WarnBitmap |
184 | 215 |
|
216 |
" |
|
217 |
self warn:'foo bar'. |
|
218 |
||
219 |
|box| |
|
220 |
box := WarningBox title:'foo bar'. |
|
221 |
box showAtPointer. |
|
222 |
||
223 |
|box| |
|
224 |
box := WarningBox title:'foo bar'. |
|
2362
f6ace7307e4d
examples fixed (bitmaps access)
Claus Gittinger <cg@exept.de>
parents:
2073
diff
changeset
|
225 |
box image:(Image fromFile:'QUESTION.xpm' inPackage:'stx:goodies/bitmaps/xpmBitmaps'). |
184 | 226 |
box showAtPointer. |
227 |
" |
|
228 |
||
1915 | 229 |
"Modified: / 25.5.1999 / 15:22:25 / cg" |
2474 | 230 |
"Created: / 16.11.2001 / 15:02:24 / cg" |
0 | 231 |
! ! |
232 |
||
197 | 233 |
!WarningBox class methodsFor:'styles'! |
234 |
||
235 |
updateStyleCache |
|
1173
86440dfaca06
allow either image or imageFileName to be specified
Claus Gittinger <cg@exept.de>
parents:
693
diff
changeset
|
236 |
"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
|
237 |
Here, the cached infoBitmap is simply flushed." |
443
555bb9c7e1be
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
355
diff
changeset
|
238 |
|
2474 | 239 |
WarnBitmap := nil. |
240 |
ErrorBitmap := nil. |
|
197 | 241 |
|
2474 | 242 |
"Modified: / 16.11.2001 / 15:00:43 / cg" |
197 | 243 |
! ! |
244 |
||
79 | 245 |
!WarningBox methodsFor:'initialization'! |
246 |
||
247 |
initialize |
|
248 |
super initialize. |
|
249 |
label := 'Warning' |
|
250 |
! ! |
|
251 |
||
3121 | 252 |
!WarningBox methodsFor:'queries'! |
0 | 253 |
|
3121 | 254 |
beepWhenOpening |
255 |
^ UserPreferences current beepForWarningDialog |
|
0 | 256 |
! ! |
197 | 257 |
|
243 | 258 |
!WarningBox class methodsFor:'documentation'! |
259 |
||
260 |
version |
|
5894 | 261 |
^ '$Header$' |
243 | 262 |
! ! |
5894 | 263 |