60
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
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 |
|
|
14 |
|
1485
|
15 |
"{ Package: 'stx:libview2' }"
|
|
16 |
|
60
|
17 |
View subclass:#ActiveHelpView
|
285
|
18 |
instanceVariableNames:'myView shapeStyle'
|
216
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Interface-Help'
|
60
|
22 |
!
|
|
23 |
|
380
|
24 |
!ActiveHelpView class methodsFor:'documentation'!
|
60
|
25 |
|
|
26 |
copyright
|
|
27 |
"
|
|
28 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
29 |
All Rights Reserved
|
|
30 |
|
|
31 |
This software is furnished under a license and may be used
|
|
32 |
only in accordance with the terms of that license and with the
|
|
33 |
inclusion of the above copyright notice. This software may not
|
|
34 |
be provided or otherwise made available to, or used by, any
|
|
35 |
other person. No title to or ownership of the software is
|
|
36 |
hereby transferred.
|
|
37 |
"
|
|
38 |
|
|
39 |
|
138
|
40 |
!
|
|
41 |
|
|
42 |
documentation
|
|
43 |
"
|
635
|
44 |
a bubbleHelp view.
|
233
|
45 |
|
138
|
46 |
Instances of myself show up either as a comics-like talking
|
|
47 |
view, or as a simple square popup. This is configured via the
|
233
|
48 |
styleSheet; the default is simple-square.
|
|
49 |
To get the fancy comics style, add a resource 'activeHelpStyle' with
|
|
50 |
a symbol-value of #cartoon.
|
138
|
51 |
However, be aware that some servers have performance problems with
|
|
52 |
these view-shapes (or do not support shapes at all).
|
635
|
53 |
Therefore, the default style is a rectangular popupView.
|
216
|
54 |
|
221
|
55 |
[author:]
|
|
56 |
Claus Gittinger
|
|
57 |
|
216
|
58 |
[See also:]
|
|
59 |
ActiveHelp
|
138
|
60 |
"
|
60
|
61 |
! !
|
|
62 |
|
380
|
63 |
!ActiveHelpView class methodsFor:'instance creation'!
|
60
|
64 |
|
|
65 |
for:someText
|
635
|
66 |
"create a bubble-view for some text"
|
233
|
67 |
|
60
|
68 |
|helpView textView|
|
|
69 |
|
|
70 |
helpView := self new.
|
285
|
71 |
|
|
72 |
textView := Label new.
|
1219
|
73 |
textView font:(helpView font onDevice:textView graphicsDevice).
|
60
|
74 |
^ (helpView withView:textView) contents:someText
|
|
75 |
|
|
76 |
"
|
635
|
77 |
|v|
|
285
|
78 |
|
635
|
79 |
v := (ActiveHelpView for:'hello world\this is an ActiveHelpView' withCRs) shapeStyle:nil.
|
|
80 |
v realize.
|
|
81 |
Delay waitForSeconds:2.
|
|
82 |
v destroy
|
60
|
83 |
"
|
233
|
84 |
|
635
|
85 |
"
|
|
86 |
|v|
|
|
87 |
|
|
88 |
v := (ActiveHelpView for:'hello world\this is an ActiveHelpView' withCRs) shapeStyle:#cartoon.
|
|
89 |
v realize.
|
|
90 |
Delay waitForSeconds:2.
|
|
91 |
v destroy
|
|
92 |
"
|
|
93 |
|
|
94 |
"Modified: 28.6.1997 / 14:24:23 / cg"
|
60
|
95 |
!
|
|
96 |
|
|
97 |
with:aView
|
233
|
98 |
"create a talking-view wrapping some other view"
|
|
99 |
|
60
|
100 |
^ self new withView:aView
|
|
101 |
|
|
102 |
"
|
|
103 |
(ActiveHelpView with:(TextView new)) realize
|
|
104 |
(ActiveHelpView with:(TextView new)) open
|
|
105 |
(ActiveHelpView with:(Button label:'ok')) open
|
|
106 |
"
|
233
|
107 |
|
|
108 |
"Modified: 27.4.1996 / 15:14:18 / cg"
|
60
|
109 |
! !
|
|
110 |
|
138
|
111 |
!ActiveHelpView methodsFor:'accessing'!
|
|
112 |
|
|
113 |
contents:someText
|
233
|
114 |
"set the text"
|
|
115 |
|
138
|
116 |
(myView isKindOf:Label) ifTrue:[
|
233
|
117 |
myView label:someText asString.
|
|
118 |
myView extent:(myView preferredExtent).
|
138
|
119 |
] ifFalse:[
|
233
|
120 |
myView contents:someText.
|
138
|
121 |
].
|
|
122 |
self resizeToFit
|
|
123 |
|
233
|
124 |
"Modified: 27.4.1996 / 15:14:56 / cg"
|
138
|
125 |
!
|
60
|
126 |
|
285
|
127 |
shapeStyle:aStyleSymbol
|
|
128 |
"set the shapeStyle
|
635
|
129 |
currently, only nil, #cartoon or #cartoon2 are supported"
|
285
|
130 |
|
|
131 |
shapeStyle := aStyleSymbol.
|
|
132 |
self resizeToFit.
|
|
133 |
self computeShape.
|
|
134 |
|
|
135 |
"Created: 29.5.1996 / 15:39:41 / cg"
|
635
|
136 |
"Modified: 28.6.1997 / 14:15:22 / cg"
|
285
|
137 |
!
|
|
138 |
|
138
|
139 |
withView:aView
|
233
|
140 |
"set the component view"
|
|
141 |
|
138
|
142 |
(aView isKindOf:Label) ifTrue:[
|
233
|
143 |
aView viewBackground:viewBackground.
|
|
144 |
aView backgroundColor:viewBackground.
|
138
|
145 |
].
|
|
146 |
self addSubView:aView.
|
|
147 |
myView := aView.
|
|
148 |
myView borderWidth:0
|
233
|
149 |
|
|
150 |
"Modified: 27.4.1996 / 15:16:46 / cg"
|
138
|
151 |
! !
|
|
152 |
|
|
153 |
!ActiveHelpView methodsFor:'initialization'!
|
|
154 |
|
92
|
155 |
initStyle
|
380
|
156 |
"setup viewStyle specifics"
|
|
157 |
|
725
|
158 |
<resource: #style (#'activeHelp.backgroundColor'
|
|
159 |
#'activeHelp.borderWidth'
|
1537
|
160 |
#'activeHelp.font'
|
725
|
161 |
#'activeHelp.style')>
|
285
|
162 |
|
1537
|
163 |
|bg font|
|
236
|
164 |
|
92
|
165 |
super initStyle.
|
|
166 |
|
725
|
167 |
shapeStyle := styleSheet at:'activeHelp.style' default:nil.
|
1537
|
168 |
font := styleSheet colorAt:'activeHelp.font' default:nil.
|
|
169 |
font notNil ifTrue:[
|
|
170 |
self font:font
|
|
171 |
].
|
|
172 |
|
725
|
173 |
bg := styleSheet colorAt:'activeHelp.backgroundColor' default:nil.
|
285
|
174 |
bg notNil ifTrue:[
|
|
175 |
viewBackground := bg
|
|
176 |
] ifFalse:[
|
|
177 |
shapeStyle == #cartoon ifTrue:[
|
|
178 |
viewBackground := White
|
|
179 |
]
|
|
180 |
].
|
|
181 |
|
725
|
182 |
borderWidth := styleSheet at:'activeHelp.borderWidth' default:1.
|
236
|
183 |
|
725
|
184 |
"Modified: / 26.10.1997 / 17:02:09 / cg"
|
92
|
185 |
!
|
|
186 |
|
138
|
187 |
realize
|
|
188 |
self create.
|
|
189 |
self computeShape.
|
|
190 |
self enableMotionEvents.
|
|
191 |
self enableButtonMotionEvents.
|
1485
|
192 |
super realize
|
60
|
193 |
! !
|
|
194 |
|
|
195 |
!ActiveHelpView methodsFor:'private'!
|
|
196 |
|
|
197 |
computeShape
|
233
|
198 |
"compute the shape, based upon the size of my component view"
|
|
199 |
|
60
|
200 |
|extent shapeForm borderForm y1 bw h w mirrorH mirrorV
|
1182
|
201 |
p1 p2 p3 pB1 pB2 pB3 offs hEll h2 w2 w8 w78|
|
60
|
202 |
|
1261
|
203 |
device supportsArbitraryShapedViews ifTrue:[
|
635
|
204 |
(shapeStyle == #cartoon) ifTrue:[
|
|
205 |
extent := self extent.
|
|
206 |
h := extent y.
|
|
207 |
w := extent x.
|
|
208 |
bw := 4.
|
|
209 |
offs := 0.
|
60
|
210 |
|
635
|
211 |
self corner x > device width ifTrue:[
|
|
212 |
mirrorH := true.
|
|
213 |
self origin:((self origin x - w) @ (self origin y)).
|
|
214 |
offs := bw * 2.
|
|
215 |
] ifFalse:[
|
|
216 |
mirrorH := false
|
|
217 |
].
|
|
218 |
self corner y > device height ifTrue:[
|
|
219 |
mirrorV := true.
|
|
220 |
self origin:(self origin x @ (self origin y - h)).
|
|
221 |
] ifFalse:[
|
|
222 |
mirrorV := false
|
|
223 |
].
|
285
|
224 |
|
635
|
225 |
borderForm := Form width:w height:h.
|
|
226 |
shapeForm := Form width:w height:h.
|
|
227 |
borderForm fill:(Color noColor).
|
|
228 |
shapeForm fill:(Color noColor).
|
|
229 |
|
|
230 |
hEll := (h // 3 * 2).
|
60
|
231 |
|
635
|
232 |
mirrorV ifTrue:[
|
|
233 |
y1 := 0.
|
|
234 |
] ifFalse:[
|
|
235 |
y1 := h // 4.
|
|
236 |
].
|
60
|
237 |
|
635
|
238 |
borderForm fillArcX:0 y:y1
|
|
239 |
width:w height:hEll
|
|
240 |
from:0 angle:360.
|
|
241 |
|
|
242 |
myView origin:(width - myView width // 2) @ (y1 + ((hEll - myView height) // 2)).
|
285
|
243 |
|
1182
|
244 |
h2 := h // 2.
|
|
245 |
w2 := w // 2.
|
|
246 |
w8 := w // 8.
|
|
247 |
w78 := w * 7 // 8.
|
|
248 |
|
635
|
249 |
mirrorH ifTrue:[
|
|
250 |
mirrorV ifTrue:[
|
|
251 |
p1 := w @ h.
|
1182
|
252 |
p2 := (w78 @ h2).
|
|
253 |
p3 := (w2 @ h2).
|
635
|
254 |
pB1 := (w-bw) @ (h-bw).
|
1182
|
255 |
pB2 := ((w78 - bw) @ (h2 - bw)).
|
|
256 |
pB3 := ((w2 + bw) @ (h2 - bw))
|
635
|
257 |
] ifFalse:[
|
|
258 |
p1 := w @ 0.
|
1182
|
259 |
p2 := (w78 @ h2).
|
|
260 |
p3 := (w2 @ h2).
|
635
|
261 |
pB1 := (w-bw) @ bw.
|
1182
|
262 |
pB2 := ((w78 - bw) @ (h2 + bw)).
|
|
263 |
pB3 := ((w2 + bw) @ (h2 + bw))
|
635
|
264 |
]
|
|
265 |
] ifFalse:[
|
|
266 |
mirrorV ifTrue:[
|
|
267 |
p1 := 0@h.
|
1182
|
268 |
p2 := (w8 @ h2).
|
|
269 |
p3 := (w2 @ h2).
|
635
|
270 |
pB1 := bw@(h-bw).
|
1182
|
271 |
pB2 := ((w8 + bw) @ (h2 - bw)).
|
|
272 |
pB3 := ((w2 - bw) @ (h2 - bw)).
|
635
|
273 |
] ifFalse:[
|
|
274 |
p1 := 0@0.
|
1182
|
275 |
p2 := (w8 @ h2).
|
|
276 |
p3 := (w2 @ h2).
|
635
|
277 |
pB1 := bw@bw.
|
1182
|
278 |
pB2 := ((w8 + bw) @ (h2 + bw)).
|
|
279 |
pB3 := ((w2 - bw) @ (h2 + bw)).
|
635
|
280 |
]
|
|
281 |
].
|
60
|
282 |
|
635
|
283 |
borderForm fillPolygon:(Array with:p1 with:p2 with:p3).
|
|
284 |
shapeForm fillPolygon:(Array with:pB1 with:pB2 with:pB3).
|
60
|
285 |
|
635
|
286 |
shapeForm lineWidth:bw.
|
|
287 |
shapeForm paint:(Color noColor).
|
|
288 |
shapeForm displayPolygon:(Array with:p3 with:p1 with:p2).
|
60
|
289 |
|
635
|
290 |
shapeForm paint:(Color colorId:1).
|
|
291 |
shapeForm fillArcX:bw y:y1 + bw
|
|
292 |
width:(w - (bw * 2)) height:(h // 3 * 2 - (bw * 2))
|
|
293 |
from:0 angle:360.
|
|
294 |
].
|
|
295 |
borderForm notNil ifTrue:[
|
|
296 |
self borderShape:borderForm.
|
|
297 |
self viewShape:shapeForm
|
|
298 |
].
|
|
299 |
]
|
60
|
300 |
|
1182
|
301 |
"Modified: / 5.6.1999 / 21:41:01 / cg"
|
1261
|
302 |
"Modified: / 27.10.1999 / 13:45:45 / stefan"
|
60
|
303 |
!
|
|
304 |
|
|
305 |
resizeToFit
|
233
|
306 |
"resize myself to make the component view fit"
|
|
307 |
|
285
|
308 |
|h w pref|
|
60
|
309 |
|
285
|
310 |
pref := myView preferredExtent.
|
|
311 |
shapeStyle == #cartoon ifTrue:[
|
|
312 |
h := pref y.
|
|
313 |
w := pref x.
|
|
314 |
self extent:((w / 0.85) rounded asInteger)
|
233
|
315 |
@
|
285
|
316 |
((h * 4) rounded asInteger)
|
92
|
317 |
] ifFalse:[
|
285
|
318 |
self extent:pref
|
92
|
319 |
]
|
233
|
320 |
|
635
|
321 |
"Modified: 28.6.1997 / 14:23:49 / cg"
|
233
|
322 |
! !
|
|
323 |
|
|
324 |
!ActiveHelpView methodsFor:'queries'!
|
|
325 |
|
|
326 |
isPopUpView
|
261
|
327 |
"return true - I am a popUp type of view (no decoration, pop-to-top)"
|
233
|
328 |
|
|
329 |
^ true
|
|
330 |
|
261
|
331 |
"Modified: 12.5.1996 / 21:58:12 / cg"
|
60
|
332 |
! !
|
|
333 |
|
380
|
334 |
!ActiveHelpView class methodsFor:'documentation'!
|
60
|
335 |
|
138
|
336 |
version
|
1537
|
337 |
^ '$Header: /cvs/stx/stx/libview2/ActiveHelpView.st,v 1.25 2001-12-08 00:36:32 cg Exp $'
|
60
|
338 |
! !
|