author | Claus Gittinger <cg@exept.de> |
Thu, 06 Mar 1997 15:16:03 +0100 | |
changeset 494 | ce8c074d5e6b |
parent 380 | c553cc1bbfa7 |
child 635 | dfbc3a7b87c2 |
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 |
||
380 | 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 |
||
380 | 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 |
380 | 143 |
"setup viewStyle specifics" |
144 |
||
285 | 145 |
<resource: #style (#activeHelpBackgroundColor |
146 |
#activeHelpBorderWidth |
|
147 |
#activeHelpStyle)> |
|
148 |
||
149 |
|bg| |
|
236 | 150 |
|
92 | 151 |
super initStyle. |
152 |
||
285 | 153 |
shapeStyle := styleSheet at:'activeHelpStyle' default:nil. |
154 |
bg := styleSheet colorAt:'activeHelpBackgroundColor' default:nil. |
|
155 |
bg notNil ifTrue:[ |
|
156 |
viewBackground := bg |
|
157 |
] ifFalse:[ |
|
158 |
shapeStyle == #cartoon ifTrue:[ |
|
159 |
viewBackground := White |
|
160 |
] |
|
161 |
]. |
|
162 |
||
92 | 163 |
borderWidth := styleSheet at:'activeHelpBorderWidth' default:1. |
236 | 164 |
|
380 | 165 |
"Modified: 22.1.1997 / 11:56:56 / cg" |
92 | 166 |
! |
167 |
||
60 | 168 |
initialize |
169 |
super initialize. |
|
170 |
font := Font family:'helvetica' size:12. |
|
285 | 171 |
|
172 |
"Modified: 29.5.1996 / 15:37:40 / cg" |
|
60 | 173 |
! |
174 |
||
138 | 175 |
realize |
176 |
self create. |
|
177 |
self computeShape. |
|
178 |
self enableMotionEvents. |
|
179 |
self enableButtonMotionEvents. |
|
180 |
super realize |
|
60 | 181 |
! ! |
182 |
||
183 |
!ActiveHelpView methodsFor:'private'! |
|
184 |
||
185 |
computeShape |
|
233 | 186 |
"compute the shape, based upon the size of my component view" |
187 |
||
60 | 188 |
|extent shapeForm borderForm y1 bw h w mirrorH mirrorV |
285 | 189 |
p1 p2 p3 pB1 pB2 pB3 offs hEll| |
60 | 190 |
|
285 | 191 |
shapeStyle ~~ #cartoon ifTrue:[^ self]. |
92 | 192 |
|
60 | 193 |
extent := self extent. |
194 |
h := extent y. |
|
195 |
w := extent x. |
|
196 |
bw := 4. |
|
197 |
offs := 0. |
|
198 |
||
314
a239541adbc9
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
199 |
self corner x > device width ifTrue:[ |
233 | 200 |
mirrorH := true. |
201 |
self origin:((self origin x - w) @ (self origin y)). |
|
202 |
offs := bw * 2. |
|
60 | 203 |
] ifFalse:[ |
233 | 204 |
mirrorH := false |
60 | 205 |
]. |
314
a239541adbc9
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
206 |
self corner y > device height ifTrue:[ |
233 | 207 |
mirrorV := true. |
208 |
self origin:(self origin x @ (self origin y - h)). |
|
60 | 209 |
] ifFalse:[ |
233 | 210 |
mirrorV := false |
60 | 211 |
]. |
212 |
||
213 |
borderForm := Form width:w height:h. |
|
214 |
shapeForm := Form width:w height:h. |
|
237 | 215 |
borderForm fill:(Color noColor). |
216 |
shapeForm fill:(Color noColor). |
|
60 | 217 |
|
285 | 218 |
hEll := (h // 3 * 2). |
219 |
||
60 | 220 |
mirrorV ifTrue:[ |
233 | 221 |
y1 := 0. |
60 | 222 |
] ifFalse:[ |
233 | 223 |
y1 := h // 4. |
60 | 224 |
]. |
225 |
||
226 |
borderForm fillArcX:0 |
|
233 | 227 |
y:y1 |
241
30383e124f8c
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
237
diff
changeset
|
228 |
width:w |
285 | 229 |
height:hEll |
233 | 230 |
from:0 |
231 |
angle:360. |
|
60 | 232 |
|
285 | 233 |
myView origin:(width - myView width // 2) @ (y1 + ((hEll - myView height) // 2)). |
234 |
||
60 | 235 |
mirrorH ifTrue:[ |
233 | 236 |
mirrorV ifTrue:[ |
237 |
p1 := w @ h. |
|
238 |
p2 := ((w * 7 // 8) @ (h // 2)). |
|
239 |
p3 := ((w // 2) @ (h // 2)). |
|
240 |
pB1 := (w-bw) @ (h-bw). |
|
241 |
pB2 := ((w * 7 // 8 - bw) @ (h // 2 - bw)). |
|
242 |
pB3 := ((w // 2 + bw) @ (h // 2 - bw)) |
|
243 |
] ifFalse:[ |
|
244 |
p1 := w @ 0. |
|
245 |
p2 := ((w * 7 // 8) @ (h // 2)). |
|
246 |
p3 := ((w // 2) @ (h // 2)). |
|
247 |
pB1 := (w-bw) @ bw. |
|
248 |
pB2 := ((w * 7 // 8 - bw) @ (h // 2 + bw)). |
|
249 |
pB3 := ((w // 2 + bw) @ (h // 2 + bw)) |
|
250 |
] |
|
60 | 251 |
] ifFalse:[ |
233 | 252 |
mirrorV ifTrue:[ |
253 |
p1 := 0@h. |
|
254 |
p2 := ((w // 8) @ (h // 2)). |
|
255 |
p3 := ((w // 2) @ (h // 2)). |
|
256 |
pB1 := bw@(h-bw). |
|
257 |
pB2 := ((w // 8 + bw) @ (h // 2 - bw)). |
|
258 |
pB3 := ((w // 2 - bw) @ (h // 2 - bw)). |
|
259 |
] ifFalse:[ |
|
260 |
p1 := 0@0. |
|
261 |
p2 := ((w // 8) @ (h // 2)). |
|
262 |
p3 := ((w // 2) @ (h // 2)). |
|
263 |
pB1 := bw@bw. |
|
264 |
pB2 := ((w // 8 + bw) @ (h // 2 + bw)). |
|
265 |
pB3 := ((w // 2 - bw) @ (h // 2 + bw)). |
|
266 |
] |
|
60 | 267 |
]. |
268 |
||
269 |
borderForm fillPolygon:(Array with:p1 with:p2 with:p3). |
|
270 |
shapeForm fillPolygon:(Array with:pB1 with:pB2 with:pB3). |
|
271 |
||
272 |
shapeForm lineWidth:bw. |
|
237 | 273 |
shapeForm paint:(Color noColor). |
60 | 274 |
shapeForm displayPolygon:(Array with:p3 with:p1 with:p2). |
275 |
||
276 |
shapeForm paint:(Color colorId:1). |
|
277 |
shapeForm fillArcX:bw |
|
233 | 278 |
y:y1 + bw |
241
30383e124f8c
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
237
diff
changeset
|
279 |
width:(w - (bw * 2)) |
30383e124f8c
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
237
diff
changeset
|
280 |
height:(h // 3 * 2 - (bw * 2)) |
233 | 281 |
from:0 |
282 |
angle:360. |
|
60 | 283 |
|
284 |
self borderShape:borderForm. |
|
285 |
self viewShape:shapeForm |
|
233 | 286 |
|
314
a239541adbc9
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
287 |
"Modified: 5.7.1996 / 17:59:05 / cg" |
60 | 288 |
! |
289 |
||
290 |
resizeToFit |
|
233 | 291 |
"resize myself to make the component view fit" |
292 |
||
285 | 293 |
|h w pref| |
60 | 294 |
|
285 | 295 |
pref := myView preferredExtent. |
296 |
shapeStyle == #cartoon ifTrue:[ |
|
297 |
h := pref y. |
|
298 |
w := pref x. |
|
299 |
self extent:((w / 0.85) rounded asInteger) |
|
233 | 300 |
@ |
285 | 301 |
((h * 4) rounded asInteger) |
92 | 302 |
] ifFalse:[ |
285 | 303 |
self extent:pref |
92 | 304 |
] |
233 | 305 |
|
285 | 306 |
"Modified: 29.5.1996 / 15:54:23 / cg" |
233 | 307 |
! ! |
308 |
||
309 |
!ActiveHelpView methodsFor:'queries'! |
|
310 |
||
311 |
isPopUpView |
|
261 | 312 |
"return true - I am a popUp type of view (no decoration, pop-to-top)" |
233 | 313 |
|
314 |
^ true |
|
315 |
||
261 | 316 |
"Modified: 12.5.1996 / 21:58:12 / cg" |
60 | 317 |
! ! |
318 |
||
380 | 319 |
!ActiveHelpView class methodsFor:'documentation'! |
60 | 320 |
|
138 | 321 |
version |
380 | 322 |
^ '$Header: /cvs/stx/stx/libview2/ActiveHelpView.st,v 1.16 1997-01-22 17:17:33 cg Exp $' |
60 | 323 |
! ! |