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
|
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:'WarnBitmap'
|
|
16 |
poolDictionaries:''
|
38
|
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 |
version
|
184
|
37 |
^ '$Header: /cvs/stx/stx/libwidg/WarningBox.st,v 1.11 1995-11-17 17:23:19 cg Exp $'
|
38
|
38 |
!
|
0
|
39 |
|
38
|
40 |
documentation
|
|
41 |
"
|
|
42 |
this class implements a pop-up box to show an information message.
|
|
43 |
WarningBoxes are basically InfoBoxes with a different bitmap-image.
|
|
44 |
(also, they add a beep when popping up)
|
|
45 |
|
|
46 |
They are created with:
|
|
47 |
|
59
|
48 |
aBox := WarningBox title:'some title'.
|
38
|
49 |
|
|
50 |
and shown with:
|
|
51 |
|
59
|
52 |
aBox showAtPointer
|
38
|
53 |
|
|
54 |
The default box shows 'yes' in its button; this can be changed with:
|
|
55 |
|
59
|
56 |
aBox okText:'some string'.
|
38
|
57 |
|
79
|
58 |
Since showing warnings is a common action, a convenient method has been
|
|
59 |
added to Object; thus you can use:
|
|
60 |
|
|
61 |
self warn:'oops - headcrash'
|
|
62 |
|
|
63 |
everywhere in your code.
|
63
|
64 |
"
|
|
65 |
!
|
38
|
66 |
|
63
|
67 |
examples
|
|
68 |
"
|
38
|
69 |
Examples:
|
|
70 |
|
59
|
71 |
|aBox|
|
38
|
72 |
|
59
|
73 |
aBox := WarningBox title:'Press ''OK'' to continue'.
|
|
74 |
aBox okText:'OK'.
|
|
75 |
aBox showAtPointer.
|
38
|
76 |
|
79
|
77 |
since warnboxes are much like infoBoxes, all of look can be changed
|
|
78 |
like described there:
|
|
79 |
|
|
80 |
|aBox|
|
|
81 |
|
|
82 |
aBox := WarningBox title:'Press ''OK'' to continue'.
|
|
83 |
aBox okText:'yes, continue'.
|
|
84 |
aBox form:(Image fromFile:'bitmaps/SmalltalkX.xbm').
|
|
85 |
aBox showAtPointer.
|
38
|
86 |
"
|
|
87 |
! !
|
0
|
88 |
|
59
|
89 |
!WarningBox class methodsFor:'styles'!
|
|
90 |
|
|
91 |
updateStyleCache
|
|
92 |
|img|
|
0
|
93 |
|
59
|
94 |
img := StyleSheet at:'warningBoxIcon'.
|
79
|
95 |
img notNil ifTrue:[WarnBitmap := img on:Display].
|
59
|
96 |
! !
|
|
97 |
|
|
98 |
!WarningBox class methodsFor:'icon bitmap'!
|
|
99 |
|
|
100 |
iconBitmap
|
184
|
101 |
"return the bitmap shown as icon in my instances.
|
|
102 |
This is the default image; you can overwrite this in a concrete
|
|
103 |
instance with the image: message"
|
59
|
104 |
|
0
|
105 |
WarnBitmap isNil ifTrue:[
|
109
|
106 |
WarnBitmap := Image fromFile:'bitmaps/Warning.xbm'.
|
107
|
107 |
WarnBitmap notNil ifTrue:[
|
|
108 |
WarnBitmap := WarnBitmap on:Display
|
|
109 |
]
|
0
|
110 |
].
|
59
|
111 |
^ WarnBitmap
|
184
|
112 |
|
|
113 |
"
|
|
114 |
WarnBitmap := Image fromFile:'bitmaps/WARNING.xpm'.
|
|
115 |
self warn:'foo bar'.
|
|
116 |
|
|
117 |
WarnBitmap := Image fromFile:'bitmaps/Warning.xbm'.
|
|
118 |
self warn:'foo bar'.
|
|
119 |
|
|
120 |
|box|
|
|
121 |
box := WarningBox title:'foo bar'.
|
|
122 |
box showAtPointer.
|
|
123 |
|
|
124 |
|box|
|
|
125 |
box := WarningBox title:'foo bar'.
|
|
126 |
box image:(Image fromFile:'bitmaps/QUESTION.xpm').
|
|
127 |
box showAtPointer.
|
|
128 |
"
|
|
129 |
|
|
130 |
"Created: 17.11.1995 / 18:16:47 / cg"
|
0
|
131 |
! !
|
|
132 |
|
79
|
133 |
!WarningBox methodsFor:'initialization'!
|
|
134 |
|
|
135 |
initialize
|
|
136 |
super initialize.
|
|
137 |
label := 'Warning'
|
|
138 |
! !
|
|
139 |
|
0
|
140 |
!WarningBox methodsFor:'realization'!
|
|
141 |
|
|
142 |
show
|
|
143 |
"added bell to wake up user"
|
|
144 |
|
|
145 |
device beep.
|
|
146 |
super show
|
26
|
147 |
!
|
|
148 |
|
|
149 |
showAtPointer
|
|
150 |
"added bell to wake up user"
|
|
151 |
|
|
152 |
device beep.
|
|
153 |
super showAtPointer
|
0
|
154 |
! !
|