author | Claus Gittinger <cg@exept.de> |
Thu, 25 Apr 1996 19:26:41 +0200 | |
changeset 585 | 8f395aba0173 |
parent 493 | 64ac6d6270f6 |
child 593 | 86dd024ed773 |
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 |
" |
|
38 | 84 |
Examples: |
85 |
||
59 | 86 |
|aBox| |
38 | 87 |
|
59 | 88 |
aBox := WarningBox title:'Press ''OK'' to continue'. |
89 |
aBox okText:'OK'. |
|
90 |
aBox showAtPointer. |
|
38 | 91 |
|
79 | 92 |
since warnboxes are much like infoBoxes, all of look can be changed |
93 |
like described there: |
|
94 |
||
95 |
|aBox| |
|
96 |
||
97 |
aBox := WarningBox title:'Press ''OK'' to continue'. |
|
98 |
aBox okText:'yes, continue'. |
|
99 |
aBox form:(Image fromFile:'bitmaps/SmalltalkX.xbm'). |
|
100 |
aBox showAtPointer. |
|
38 | 101 |
" |
59 | 102 |
! ! |
103 |
||
104 |
!WarningBox class methodsFor:'icon bitmap'! |
|
105 |
||
106 |
iconBitmap |
|
184 | 107 |
"return the bitmap shown as icon in my instances. |
108 |
This is the default image; you can overwrite this in a concrete |
|
109 |
instance with the image: message" |
|
59 | 110 |
|
0 | 111 |
WarnBitmap isNil ifTrue:[ |
109 | 112 |
WarnBitmap := Image fromFile:'bitmaps/Warning.xbm'. |
107 | 113 |
WarnBitmap notNil ifTrue:[ |
114 |
WarnBitmap := WarnBitmap on:Display |
|
115 |
] |
|
0 | 116 |
]. |
59 | 117 |
^ WarnBitmap |
184 | 118 |
|
119 |
" |
|
120 |
WarnBitmap := Image fromFile:'bitmaps/WARNING.xpm'. |
|
121 |
self warn:'foo bar'. |
|
122 |
||
123 |
WarnBitmap := Image fromFile:'bitmaps/Warning.xbm'. |
|
124 |
self warn:'foo bar'. |
|
125 |
||
126 |
|box| |
|
127 |
box := WarningBox title:'foo bar'. |
|
128 |
box showAtPointer. |
|
129 |
||
130 |
|box| |
|
131 |
box := WarningBox title:'foo bar'. |
|
132 |
box image:(Image fromFile:'bitmaps/QUESTION.xpm'). |
|
133 |
box showAtPointer. |
|
134 |
" |
|
135 |
||
136 |
"Created: 17.11.1995 / 18:16:47 / cg" |
|
0 | 137 |
! ! |
138 |
||
197 | 139 |
!WarningBox class methodsFor:'styles'! |
140 |
||
141 |
updateStyleCache |
|
443
555bb9c7e1be
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
355
diff
changeset
|
142 |
"extract values from the styleSheet and cache them in class variables" |
555bb9c7e1be
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
355
diff
changeset
|
143 |
|
555bb9c7e1be
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
355
diff
changeset
|
144 |
<resource: #style (#warningBoxIcon)> |
555bb9c7e1be
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
355
diff
changeset
|
145 |
|
197 | 146 |
|img| |
147 |
||
148 |
img := StyleSheet at:'warningBoxIcon'. |
|
149 |
img notNil ifTrue:[WarnBitmap := img on:Display]. |
|
443
555bb9c7e1be
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
355
diff
changeset
|
150 |
|
555bb9c7e1be
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
355
diff
changeset
|
151 |
"Modified: 1.3.1996 / 13:51:43 / cg" |
197 | 152 |
! ! |
153 |
||
79 | 154 |
!WarningBox methodsFor:'initialization'! |
155 |
||
156 |
initialize |
|
157 |
super initialize. |
|
158 |
label := 'Warning' |
|
159 |
! ! |
|
160 |
||
0 | 161 |
!WarningBox methodsFor:'realization'! |
162 |
||
493 | 163 |
openModal |
0 | 164 |
"added bell to wake up user" |
165 |
||
166 |
device beep. |
|
493 | 167 |
super openModal |
26 | 168 |
|
493 | 169 |
" |
170 |
self warn:'hello' |
|
171 |
" |
|
26 | 172 |
|
493 | 173 |
"Modified: 7.3.1996 / 17:52:17 / cg" |
0 | 174 |
! ! |
197 | 175 |
|
243 | 176 |
!WarningBox class methodsFor:'documentation'! |
177 |
||
178 |
version |
|
585 | 179 |
^ '$Header: /cvs/stx/stx/libwidg/WarningBox.st,v 1.17 1996-04-25 17:20:41 cg Exp $' |
243 | 180 |
! ! |