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