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