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