author | Claus Gittinger <cg@exept.de> |
Wed, 13 May 2009 13:23:32 +0200 | |
changeset 2675 | a68038b7c4c3 |
parent 2413 | ceba27b5a30f |
child 2773 | eaec2e45bd8d |
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 |
" |
|
1485 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
60 | 14 |
View subclass:#ActiveHelpView |
285 | 15 |
instanceVariableNames:'myView shapeStyle' |
216 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'Interface-Help' |
|
60 | 19 |
! |
20 |
||
380 | 21 |
!ActiveHelpView class methodsFor:'documentation'! |
60 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
||
36 |
||
138 | 37 |
! |
38 |
||
39 |
documentation |
|
40 |
" |
|
635 | 41 |
a bubbleHelp view. |
233 | 42 |
|
138 | 43 |
Instances of myself show up either as a comics-like talking |
44 |
view, or as a simple square popup. This is configured via the |
|
233 | 45 |
styleSheet; the default is simple-square. |
46 |
To get the fancy comics style, add a resource 'activeHelpStyle' with |
|
47 |
a symbol-value of #cartoon. |
|
138 | 48 |
However, be aware that some servers have performance problems with |
49 |
these view-shapes (or do not support shapes at all). |
|
635 | 50 |
Therefore, the default style is a rectangular popupView. |
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 |
|
635 | 63 |
"create a bubble-view for some text" |
233 | 64 |
|
1676 | 65 |
^ self for:someText onDevice:Screen current. |
66 |
||
67 |
" |
|
68 |
|v| |
|
69 |
||
70 |
v := (ActiveHelpView for:'hello world\this is an ActiveHelpView' withCRs) shapeStyle:nil. |
|
71 |
v realize. |
|
72 |
Delay waitForSeconds:2. |
|
73 |
v destroy |
|
74 |
" |
|
75 |
||
76 |
" |
|
77 |
|v| |
|
78 |
||
79 |
v := (ActiveHelpView for:'hello world\this is an ActiveHelpView' withCRs) shapeStyle:#cartoon. |
|
80 |
v realize. |
|
81 |
Delay waitForSeconds:2. |
|
82 |
v destroy |
|
83 |
" |
|
84 |
||
85 |
"Modified: 28.6.1997 / 14:24:23 / cg" |
|
86 |
! |
|
87 |
||
88 |
for:someText onDevice:aDevice |
|
89 |
"create a bubble-view for some text" |
|
90 |
||
60 | 91 |
|helpView textView| |
92 |
||
1714
85cd314f0916
Fix ActiveHelp for foreign displays
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
93 |
helpView := self onDevice:aDevice. |
285 | 94 |
|
1714
85cd314f0916
Fix ActiveHelp for foreign displays
Stefan Vogel <sv@exept.de>
parents:
1676
diff
changeset
|
95 |
textView := Label onDevice:aDevice. |
1219 | 96 |
textView font:(helpView font onDevice:textView graphicsDevice). |
60 | 97 |
^ (helpView withView:textView) contents:someText |
98 |
||
99 |
" |
|
635 | 100 |
|v| |
285 | 101 |
|
635 | 102 |
v := (ActiveHelpView for:'hello world\this is an ActiveHelpView' withCRs) shapeStyle:nil. |
103 |
v realize. |
|
104 |
Delay waitForSeconds:2. |
|
105 |
v destroy |
|
60 | 106 |
" |
233 | 107 |
|
635 | 108 |
" |
109 |
|v| |
|
110 |
||
111 |
v := (ActiveHelpView for:'hello world\this is an ActiveHelpView' withCRs) shapeStyle:#cartoon. |
|
112 |
v realize. |
|
113 |
Delay waitForSeconds:2. |
|
114 |
v destroy |
|
115 |
" |
|
116 |
||
117 |
"Modified: 28.6.1997 / 14:24:23 / cg" |
|
60 | 118 |
! |
119 |
||
120 |
with:aView |
|
233 | 121 |
"create a talking-view wrapping some other view" |
122 |
||
60 | 123 |
^ self new withView:aView |
124 |
||
125 |
" |
|
126 |
(ActiveHelpView with:(TextView new)) realize |
|
127 |
(ActiveHelpView with:(TextView new)) open |
|
128 |
(ActiveHelpView with:(Button label:'ok')) open |
|
129 |
" |
|
233 | 130 |
|
131 |
"Modified: 27.4.1996 / 15:14:18 / cg" |
|
60 | 132 |
! ! |
133 |
||
138 | 134 |
!ActiveHelpView methodsFor:'accessing'! |
135 |
||
136 |
contents:someText |
|
233 | 137 |
"set the text" |
138 |
||
138 | 139 |
(myView isKindOf:Label) ifTrue:[ |
233 | 140 |
myView label:someText asString. |
141 |
myView extent:(myView preferredExtent). |
|
138 | 142 |
] ifFalse:[ |
233 | 143 |
myView contents:someText. |
138 | 144 |
]. |
145 |
self resizeToFit |
|
146 |
||
233 | 147 |
"Modified: 27.4.1996 / 15:14:56 / cg" |
138 | 148 |
! |
60 | 149 |
|
285 | 150 |
shapeStyle:aStyleSymbol |
151 |
"set the shapeStyle |
|
635 | 152 |
currently, only nil, #cartoon or #cartoon2 are supported" |
285 | 153 |
|
154 |
shapeStyle := aStyleSymbol. |
|
155 |
self resizeToFit. |
|
156 |
self computeShape. |
|
157 |
||
158 |
"Created: 29.5.1996 / 15:39:41 / cg" |
|
635 | 159 |
"Modified: 28.6.1997 / 14:15:22 / cg" |
285 | 160 |
! |
161 |
||
138 | 162 |
withView:aView |
233 | 163 |
"set the component view" |
164 |
||
138 | 165 |
(aView isKindOf:Label) ifTrue:[ |
233 | 166 |
aView viewBackground:viewBackground. |
167 |
aView backgroundColor:viewBackground. |
|
138 | 168 |
]. |
169 |
self addSubView:aView. |
|
170 |
myView := aView. |
|
171 |
myView borderWidth:0 |
|
233 | 172 |
|
173 |
"Modified: 27.4.1996 / 15:16:46 / cg" |
|
138 | 174 |
! ! |
175 |
||
176 |
!ActiveHelpView methodsFor:'initialization'! |
|
177 |
||
92 | 178 |
initStyle |
380 | 179 |
"setup viewStyle specifics" |
180 |
||
725 | 181 |
<resource: #style (#'activeHelp.backgroundColor' |
182 |
#'activeHelp.borderWidth' |
|
1537 | 183 |
#'activeHelp.font' |
725 | 184 |
#'activeHelp.style')> |
285 | 185 |
|
1537 | 186 |
|bg font| |
236 | 187 |
|
92 | 188 |
super initStyle. |
189 |
||
1583
36d82eed6873
Use #isWindowsStyle instead of comparing to style name.
Stefan Vogel <sv@exept.de>
parents:
1537
diff
changeset
|
190 |
shapeStyle := styleSheet at:#'activeHelp.style' default:nil. |
36d82eed6873
Use #isWindowsStyle instead of comparing to style name.
Stefan Vogel <sv@exept.de>
parents:
1537
diff
changeset
|
191 |
font := styleSheet fontAt:#'activeHelp.font' default:nil. |
1537 | 192 |
font notNil ifTrue:[ |
193 |
self font:font |
|
194 |
]. |
|
195 |
||
1583
36d82eed6873
Use #isWindowsStyle instead of comparing to style name.
Stefan Vogel <sv@exept.de>
parents:
1537
diff
changeset
|
196 |
bg := styleSheet colorAt:#'activeHelp.backgroundColor' default:nil. |
285 | 197 |
bg notNil ifTrue:[ |
198 |
viewBackground := bg |
|
199 |
] ifFalse:[ |
|
200 |
shapeStyle == #cartoon ifTrue:[ |
|
201 |
viewBackground := White |
|
202 |
] |
|
203 |
]. |
|
204 |
||
1583
36d82eed6873
Use #isWindowsStyle instead of comparing to style name.
Stefan Vogel <sv@exept.de>
parents:
1537
diff
changeset
|
205 |
borderWidth := styleSheet at:#'activeHelp.borderWidth' default:1. |
236 | 206 |
|
725 | 207 |
"Modified: / 26.10.1997 / 17:02:09 / cg" |
92 | 208 |
! |
209 |
||
138 | 210 |
realize |
211 |
self create. |
|
212 |
self computeShape. |
|
213 |
self enableMotionEvents. |
|
214 |
self enableButtonMotionEvents. |
|
1485 | 215 |
super realize |
60 | 216 |
! ! |
217 |
||
218 |
!ActiveHelpView methodsFor:'private'! |
|
219 |
||
220 |
computeShape |
|
233 | 221 |
"compute the shape, based upon the size of my component view" |
222 |
||
60 | 223 |
|extent shapeForm borderForm y1 bw h w mirrorH mirrorV |
1182 | 224 |
p1 p2 p3 pB1 pB2 pB3 offs hEll h2 w2 w8 w78| |
60 | 225 |
|
1261 | 226 |
device supportsArbitraryShapedViews ifTrue:[ |
635 | 227 |
(shapeStyle == #cartoon) ifTrue:[ |
228 |
extent := self extent. |
|
229 |
h := extent y. |
|
230 |
w := extent x. |
|
231 |
bw := 4. |
|
232 |
offs := 0. |
|
60 | 233 |
|
2413
ceba27b5a30f
usableExtent vs. width/height of a display
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
234 |
self corner x > device usableExtent x ifTrue:[ |
635 | 235 |
mirrorH := true. |
236 |
self origin:((self origin x - w) @ (self origin y)). |
|
237 |
offs := bw * 2. |
|
238 |
] ifFalse:[ |
|
239 |
mirrorH := false |
|
240 |
]. |
|
2413
ceba27b5a30f
usableExtent vs. width/height of a display
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
241 |
self corner y > device usableExtent y ifTrue:[ |
635 | 242 |
mirrorV := true. |
243 |
self origin:(self origin x @ (self origin y - h)). |
|
244 |
] ifFalse:[ |
|
245 |
mirrorV := false |
|
246 |
]. |
|
285 | 247 |
|
635 | 248 |
borderForm := Form width:w height:h. |
249 |
shapeForm := Form width:w height:h. |
|
250 |
borderForm fill:(Color noColor). |
|
251 |
shapeForm fill:(Color noColor). |
|
252 |
||
253 |
hEll := (h // 3 * 2). |
|
60 | 254 |
|
635 | 255 |
mirrorV ifTrue:[ |
256 |
y1 := 0. |
|
257 |
] ifFalse:[ |
|
258 |
y1 := h // 4. |
|
259 |
]. |
|
60 | 260 |
|
635 | 261 |
borderForm fillArcX:0 y:y1 |
262 |
width:w height:hEll |
|
263 |
from:0 angle:360. |
|
264 |
||
265 |
myView origin:(width - myView width // 2) @ (y1 + ((hEll - myView height) // 2)). |
|
285 | 266 |
|
1182 | 267 |
h2 := h // 2. |
268 |
w2 := w // 2. |
|
269 |
w8 := w // 8. |
|
270 |
w78 := w * 7 // 8. |
|
271 |
||
635 | 272 |
mirrorH ifTrue:[ |
273 |
mirrorV ifTrue:[ |
|
274 |
p1 := w @ h. |
|
1182 | 275 |
p2 := (w78 @ h2). |
276 |
p3 := (w2 @ h2). |
|
635 | 277 |
pB1 := (w-bw) @ (h-bw). |
1182 | 278 |
pB2 := ((w78 - bw) @ (h2 - bw)). |
279 |
pB3 := ((w2 + bw) @ (h2 - bw)) |
|
635 | 280 |
] ifFalse:[ |
281 |
p1 := w @ 0. |
|
1182 | 282 |
p2 := (w78 @ h2). |
283 |
p3 := (w2 @ h2). |
|
635 | 284 |
pB1 := (w-bw) @ bw. |
1182 | 285 |
pB2 := ((w78 - bw) @ (h2 + bw)). |
286 |
pB3 := ((w2 + bw) @ (h2 + bw)) |
|
635 | 287 |
] |
288 |
] ifFalse:[ |
|
289 |
mirrorV ifTrue:[ |
|
290 |
p1 := 0@h. |
|
1182 | 291 |
p2 := (w8 @ h2). |
292 |
p3 := (w2 @ h2). |
|
635 | 293 |
pB1 := bw@(h-bw). |
1182 | 294 |
pB2 := ((w8 + bw) @ (h2 - bw)). |
295 |
pB3 := ((w2 - bw) @ (h2 - bw)). |
|
635 | 296 |
] ifFalse:[ |
297 |
p1 := 0@0. |
|
1182 | 298 |
p2 := (w8 @ h2). |
299 |
p3 := (w2 @ h2). |
|
635 | 300 |
pB1 := bw@bw. |
1182 | 301 |
pB2 := ((w8 + bw) @ (h2 + bw)). |
302 |
pB3 := ((w2 - bw) @ (h2 + bw)). |
|
635 | 303 |
] |
304 |
]. |
|
60 | 305 |
|
635 | 306 |
borderForm fillPolygon:(Array with:p1 with:p2 with:p3). |
307 |
shapeForm fillPolygon:(Array with:pB1 with:pB2 with:pB3). |
|
60 | 308 |
|
635 | 309 |
shapeForm lineWidth:bw. |
310 |
shapeForm paint:(Color noColor). |
|
311 |
shapeForm displayPolygon:(Array with:p3 with:p1 with:p2). |
|
60 | 312 |
|
635 | 313 |
shapeForm paint:(Color colorId:1). |
314 |
shapeForm fillArcX:bw y:y1 + bw |
|
315 |
width:(w - (bw * 2)) height:(h // 3 * 2 - (bw * 2)) |
|
316 |
from:0 angle:360. |
|
317 |
]. |
|
318 |
borderForm notNil ifTrue:[ |
|
319 |
self borderShape:borderForm. |
|
320 |
self viewShape:shapeForm |
|
321 |
]. |
|
322 |
] |
|
60 | 323 |
|
1182 | 324 |
"Modified: / 5.6.1999 / 21:41:01 / cg" |
1261 | 325 |
"Modified: / 27.10.1999 / 13:45:45 / stefan" |
60 | 326 |
! |
327 |
||
328 |
resizeToFit |
|
233 | 329 |
"resize myself to make the component view fit" |
330 |
||
285 | 331 |
|h w pref| |
60 | 332 |
|
285 | 333 |
pref := myView preferredExtent. |
334 |
shapeStyle == #cartoon ifTrue:[ |
|
335 |
h := pref y. |
|
336 |
w := pref x. |
|
337 |
self extent:((w / 0.85) rounded asInteger) |
|
233 | 338 |
@ |
285 | 339 |
((h * 4) rounded asInteger) |
92 | 340 |
] ifFalse:[ |
285 | 341 |
self extent:pref |
92 | 342 |
] |
233 | 343 |
|
635 | 344 |
"Modified: 28.6.1997 / 14:23:49 / cg" |
233 | 345 |
! ! |
346 |
||
347 |
!ActiveHelpView methodsFor:'queries'! |
|
348 |
||
349 |
isPopUpView |
|
261 | 350 |
"return true - I am a popUp type of view (no decoration, pop-to-top)" |
233 | 351 |
|
352 |
^ true |
|
353 |
||
261 | 354 |
"Modified: 12.5.1996 / 21:58:12 / cg" |
60 | 355 |
! ! |
356 |
||
380 | 357 |
!ActiveHelpView class methodsFor:'documentation'! |
60 | 358 |
|
138 | 359 |
version |
2413
ceba27b5a30f
usableExtent vs. width/height of a display
Claus Gittinger <cg@exept.de>
parents:
1714
diff
changeset
|
360 |
^ '$Header: /cvs/stx/stx/libview2/ActiveHelpView.st,v 1.29 2008-04-11 13:16:33 cg Exp $' |
60 | 361 |
! ! |