author | Claus Gittinger <cg@exept.de> |
Tue, 14 Jan 1997 18:02:37 +0100 | |
changeset 365 | 47e0d48fd769 |
parent 314 | a239541adbc9 |
child 380 | c553cc1bbfa7 |
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 |
View subclass:#ActiveHelpView |
|
285 | 16 |
instanceVariableNames:'myView shapeStyle' |
216 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'Interface-Help' |
|
60 | 20 |
! |
21 |
||
314
a239541adbc9
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
22 |
!ActiveHelpView class methodsFor:'documentation'! |
60 | 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 |
||
314
a239541adbc9
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
60 |
!ActiveHelpView class methodsFor:'instance creation'! |
60 | 61 |
|
62 |
for:someText |
|
233 | 63 |
"create a talking-view for some text" |
64 |
||
60 | 65 |
|helpView textView| |
66 |
||
67 |
helpView := self new. |
|
285 | 68 |
|
69 |
textView := Label new. |
|
314
a239541adbc9
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
70 |
textView font:(helpView font on:textView graphicsDevice). |
60 | 71 |
^ (helpView withView:textView) contents:someText |
72 |
||
73 |
" |
|
285 | 74 |
(ActiveHelpView for:'hello world\this is an ActiveHelpView' withCRs) |
75 |
shapeStyle:nil; realize |
|
76 |
||
77 |
(ActiveHelpView for:'hello world\this is an ActiveHelpView' withCRs) |
|
78 |
shapeStyle:#cartoon; realize |
|
60 | 79 |
" |
233 | 80 |
|
314
a239541adbc9
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
81 |
"Modified: 5.7.1996 / 17:59:23 / cg" |
60 | 82 |
! |
83 |
||
84 |
with:aView |
|
233 | 85 |
"create a talking-view wrapping some other view" |
86 |
||
60 | 87 |
^ self new withView:aView |
88 |
||
89 |
" |
|
90 |
(ActiveHelpView with:(TextView new)) realize |
|
91 |
(ActiveHelpView with:(TextView new)) open |
|
92 |
(ActiveHelpView with:(Button label:'ok')) open |
|
93 |
" |
|
233 | 94 |
|
95 |
"Modified: 27.4.1996 / 15:14:18 / cg" |
|
60 | 96 |
! ! |
97 |
||
138 | 98 |
!ActiveHelpView methodsFor:'accessing'! |
99 |
||
100 |
contents:someText |
|
233 | 101 |
"set the text" |
102 |
||
138 | 103 |
(myView isKindOf:Label) ifTrue:[ |
233 | 104 |
myView label:someText asString. |
105 |
myView extent:(myView preferredExtent). |
|
138 | 106 |
] ifFalse:[ |
233 | 107 |
myView contents:someText. |
138 | 108 |
]. |
109 |
self resizeToFit |
|
110 |
||
233 | 111 |
"Modified: 27.4.1996 / 15:14:56 / cg" |
138 | 112 |
! |
60 | 113 |
|
285 | 114 |
shapeStyle:aStyleSymbol |
115 |
"set the shapeStyle |
|
116 |
currently, only nil or #cartoon are supported" |
|
117 |
||
118 |
shapeStyle := aStyleSymbol. |
|
119 |
self resizeToFit. |
|
120 |
self computeShape. |
|
121 |
||
122 |
"Created: 29.5.1996 / 15:39:41 / cg" |
|
123 |
"Modified: 29.5.1996 / 15:43:54 / cg" |
|
124 |
! |
|
125 |
||
138 | 126 |
withView:aView |
233 | 127 |
"set the component view" |
128 |
||
138 | 129 |
(aView isKindOf:Label) ifTrue:[ |
233 | 130 |
aView viewBackground:viewBackground. |
131 |
aView backgroundColor:viewBackground. |
|
138 | 132 |
]. |
133 |
self addSubView:aView. |
|
134 |
myView := aView. |
|
135 |
myView borderWidth:0 |
|
233 | 136 |
|
137 |
"Modified: 27.4.1996 / 15:16:46 / cg" |
|
138 | 138 |
! ! |
139 |
||
140 |
!ActiveHelpView methodsFor:'initialization'! |
|
141 |
||
92 | 142 |
initStyle |
285 | 143 |
<resource: #style (#activeHelpBackgroundColor |
144 |
#activeHelpBorderWidth |
|
145 |
#activeHelpStyle)> |
|
146 |
||
147 |
|bg| |
|
236 | 148 |
|
92 | 149 |
super initStyle. |
150 |
||
285 | 151 |
shapeStyle := styleSheet at:'activeHelpStyle' default:nil. |
152 |
bg := styleSheet colorAt:'activeHelpBackgroundColor' default:nil. |
|
153 |
bg notNil ifTrue:[ |
|
154 |
viewBackground := bg |
|
155 |
] ifFalse:[ |
|
156 |
shapeStyle == #cartoon ifTrue:[ |
|
157 |
viewBackground := White |
|
158 |
] |
|
159 |
]. |
|
160 |
||
92 | 161 |
borderWidth := styleSheet at:'activeHelpBorderWidth' default:1. |
236 | 162 |
|
285 | 163 |
"Modified: 29.5.1996 / 15:48:49 / cg" |
92 | 164 |
! |
165 |
||
60 | 166 |
initialize |
167 |
super initialize. |
|
168 |
font := Font family:'helvetica' size:12. |
|
285 | 169 |
|
170 |
"Modified: 29.5.1996 / 15:37:40 / cg" |
|
60 | 171 |
! |
172 |
||
138 | 173 |
realize |
174 |
self create. |
|
175 |
self computeShape. |
|
176 |
self enableMotionEvents. |
|
177 |
self enableButtonMotionEvents. |
|
178 |
super realize |
|
60 | 179 |
! ! |
180 |
||
181 |
!ActiveHelpView methodsFor:'private'! |
|
182 |
||
183 |
computeShape |
|
233 | 184 |
"compute the shape, based upon the size of my component view" |
185 |
||
60 | 186 |
|extent shapeForm borderForm y1 bw h w mirrorH mirrorV |
285 | 187 |
p1 p2 p3 pB1 pB2 pB3 offs hEll| |
60 | 188 |
|
285 | 189 |
shapeStyle ~~ #cartoon ifTrue:[^ self]. |
92 | 190 |
|
60 | 191 |
extent := self extent. |
192 |
h := extent y. |
|
193 |
w := extent x. |
|
194 |
bw := 4. |
|
195 |
offs := 0. |
|
196 |
||
314
a239541adbc9
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
197 |
self corner x > device width ifTrue:[ |
233 | 198 |
mirrorH := true. |
199 |
self origin:((self origin x - w) @ (self origin y)). |
|
200 |
offs := bw * 2. |
|
60 | 201 |
] ifFalse:[ |
233 | 202 |
mirrorH := false |
60 | 203 |
]. |
314
a239541adbc9
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
204 |
self corner y > device height ifTrue:[ |
233 | 205 |
mirrorV := true. |
206 |
self origin:(self origin x @ (self origin y - h)). |
|
60 | 207 |
] ifFalse:[ |
233 | 208 |
mirrorV := false |
60 | 209 |
]. |
210 |
||
211 |
borderForm := Form width:w height:h. |
|
212 |
shapeForm := Form width:w height:h. |
|
237 | 213 |
borderForm fill:(Color noColor). |
214 |
shapeForm fill:(Color noColor). |
|
60 | 215 |
|
285 | 216 |
hEll := (h // 3 * 2). |
217 |
||
60 | 218 |
mirrorV ifTrue:[ |
233 | 219 |
y1 := 0. |
60 | 220 |
] ifFalse:[ |
233 | 221 |
y1 := h // 4. |
60 | 222 |
]. |
223 |
||
224 |
borderForm fillArcX:0 |
|
233 | 225 |
y:y1 |
241
30383e124f8c
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
237
diff
changeset
|
226 |
width:w |
285 | 227 |
height:hEll |
233 | 228 |
from:0 |
229 |
angle:360. |
|
60 | 230 |
|
285 | 231 |
myView origin:(width - myView width // 2) @ (y1 + ((hEll - myView height) // 2)). |
232 |
||
60 | 233 |
mirrorH ifTrue:[ |
233 | 234 |
mirrorV ifTrue:[ |
235 |
p1 := w @ h. |
|
236 |
p2 := ((w * 7 // 8) @ (h // 2)). |
|
237 |
p3 := ((w // 2) @ (h // 2)). |
|
238 |
pB1 := (w-bw) @ (h-bw). |
|
239 |
pB2 := ((w * 7 // 8 - bw) @ (h // 2 - bw)). |
|
240 |
pB3 := ((w // 2 + bw) @ (h // 2 - bw)) |
|
241 |
] ifFalse:[ |
|
242 |
p1 := w @ 0. |
|
243 |
p2 := ((w * 7 // 8) @ (h // 2)). |
|
244 |
p3 := ((w // 2) @ (h // 2)). |
|
245 |
pB1 := (w-bw) @ bw. |
|
246 |
pB2 := ((w * 7 // 8 - bw) @ (h // 2 + bw)). |
|
247 |
pB3 := ((w // 2 + bw) @ (h // 2 + bw)) |
|
248 |
] |
|
60 | 249 |
] ifFalse:[ |
233 | 250 |
mirrorV ifTrue:[ |
251 |
p1 := 0@h. |
|
252 |
p2 := ((w // 8) @ (h // 2)). |
|
253 |
p3 := ((w // 2) @ (h // 2)). |
|
254 |
pB1 := bw@(h-bw). |
|
255 |
pB2 := ((w // 8 + bw) @ (h // 2 - bw)). |
|
256 |
pB3 := ((w // 2 - bw) @ (h // 2 - bw)). |
|
257 |
] ifFalse:[ |
|
258 |
p1 := 0@0. |
|
259 |
p2 := ((w // 8) @ (h // 2)). |
|
260 |
p3 := ((w // 2) @ (h // 2)). |
|
261 |
pB1 := bw@bw. |
|
262 |
pB2 := ((w // 8 + bw) @ (h // 2 + bw)). |
|
263 |
pB3 := ((w // 2 - bw) @ (h // 2 + bw)). |
|
264 |
] |
|
60 | 265 |
]. |
266 |
||
267 |
borderForm fillPolygon:(Array with:p1 with:p2 with:p3). |
|
268 |
shapeForm fillPolygon:(Array with:pB1 with:pB2 with:pB3). |
|
269 |
||
270 |
shapeForm lineWidth:bw. |
|
237 | 271 |
shapeForm paint:(Color noColor). |
60 | 272 |
shapeForm displayPolygon:(Array with:p3 with:p1 with:p2). |
273 |
||
274 |
shapeForm paint:(Color colorId:1). |
|
275 |
shapeForm fillArcX:bw |
|
233 | 276 |
y:y1 + bw |
241
30383e124f8c
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
237
diff
changeset
|
277 |
width:(w - (bw * 2)) |
30383e124f8c
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
237
diff
changeset
|
278 |
height:(h // 3 * 2 - (bw * 2)) |
233 | 279 |
from:0 |
280 |
angle:360. |
|
60 | 281 |
|
282 |
self borderShape:borderForm. |
|
283 |
self viewShape:shapeForm |
|
233 | 284 |
|
314
a239541adbc9
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
285 |
"Modified: 5.7.1996 / 17:59:05 / cg" |
60 | 286 |
! |
287 |
||
288 |
resizeToFit |
|
233 | 289 |
"resize myself to make the component view fit" |
290 |
||
285 | 291 |
|h w pref| |
60 | 292 |
|
285 | 293 |
pref := myView preferredExtent. |
294 |
shapeStyle == #cartoon ifTrue:[ |
|
295 |
h := pref y. |
|
296 |
w := pref x. |
|
297 |
self extent:((w / 0.85) rounded asInteger) |
|
233 | 298 |
@ |
285 | 299 |
((h * 4) rounded asInteger) |
92 | 300 |
] ifFalse:[ |
285 | 301 |
self extent:pref |
92 | 302 |
] |
233 | 303 |
|
285 | 304 |
"Modified: 29.5.1996 / 15:54:23 / cg" |
233 | 305 |
! ! |
306 |
||
307 |
!ActiveHelpView methodsFor:'queries'! |
|
308 |
||
309 |
isPopUpView |
|
261 | 310 |
"return true - I am a popUp type of view (no decoration, pop-to-top)" |
233 | 311 |
|
312 |
^ true |
|
313 |
||
261 | 314 |
"Modified: 12.5.1996 / 21:58:12 / cg" |
60 | 315 |
! ! |
316 |
||
314
a239541adbc9
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
317 |
!ActiveHelpView class methodsFor:'documentation'! |
60 | 318 |
|
138 | 319 |
version |
314
a239541adbc9
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
320 |
^ '$Header: /cvs/stx/stx/libview2/ActiveHelpView.st,v 1.15 1996-07-05 16:10:36 cg Exp $' |
60 | 321 |
! ! |