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