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