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