author | Claus Gittinger <cg@exept.de> |
Thu, 12 Sep 2013 15:17:56 +0200 | |
changeset 3246 | d167d433053c |
parent 3242 | f8d10ab0f301 |
child 3249 | 38845952e1d4 |
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. |
3242 | 96 |
textView font:(helpView font onDevice:aDevice). |
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 |
3218 | 151 |
"set the shapeStyle. |
152 |
Currently, only nil and #cartoon are supported" |
|
285 | 153 |
|
154 |
shapeStyle := aStyleSymbol. |
|
3246 | 155 |
Screen current supportsArbitraryShapedViews ifFalse:[ |
156 |
shapeStyle := nil |
|
157 |
]. |
|
285 | 158 |
self resizeToFit. |
159 |
self computeShape. |
|
160 |
||
161 |
"Created: 29.5.1996 / 15:39:41 / cg" |
|
635 | 162 |
"Modified: 28.6.1997 / 14:15:22 / cg" |
285 | 163 |
! |
164 |
||
138 | 165 |
withView:aView |
233 | 166 |
"set the component view" |
167 |
||
3118 | 168 |
|fg| |
169 |
||
138 | 170 |
(aView isKindOf:Label) ifTrue:[ |
233 | 171 |
aView viewBackground:viewBackground. |
172 |
aView backgroundColor:viewBackground. |
|
3118 | 173 |
(fg := styleSheet colorAt:#'activeHelp.foregroundColor' default:nil) notNil ifTrue:[ |
174 |
aView foregroundColor:fg. |
|
175 |
]. |
|
138 | 176 |
]. |
177 |
self addSubView:aView. |
|
178 |
myView := aView. |
|
179 |
myView borderWidth:0 |
|
233 | 180 |
|
181 |
"Modified: 27.4.1996 / 15:16:46 / cg" |
|
138 | 182 |
! ! |
183 |
||
184 |
!ActiveHelpView methodsFor:'initialization'! |
|
185 |
||
92 | 186 |
initStyle |
380 | 187 |
"setup viewStyle specifics" |
188 |
||
725 | 189 |
<resource: #style (#'activeHelp.backgroundColor' |
190 |
#'activeHelp.borderWidth' |
|
1537 | 191 |
#'activeHelp.font' |
725 | 192 |
#'activeHelp.style')> |
285 | 193 |
|
2776
7181bb9659ae
comment/format in: #withView:
Claus Gittinger <cg@exept.de>
parents:
2773
diff
changeset
|
194 |
|bg defaultFont| |
236 | 195 |
|
92 | 196 |
super initStyle. |
197 |
||
3218 | 198 |
(shapeStyle := UserPreferences current toolTipShapeStyle) isNil ifTrue:[ |
199 |
shapeStyle := styleSheet at:#'activeHelp.style' default:nil. |
|
200 |
]. |
|
201 |
||
2776
7181bb9659ae
comment/format in: #withView:
Claus Gittinger <cg@exept.de>
parents:
2773
diff
changeset
|
202 |
defaultFont := styleSheet fontAt:#'activeHelp.font' default:nil. |
7181bb9659ae
comment/format in: #withView:
Claus Gittinger <cg@exept.de>
parents:
2773
diff
changeset
|
203 |
defaultFont notNil ifTrue:[ |
7181bb9659ae
comment/format in: #withView:
Claus Gittinger <cg@exept.de>
parents:
2773
diff
changeset
|
204 |
self font:defaultFont |
1537 | 205 |
]. |
206 |
||
1583
36d82eed6873
Use #isWindowsStyle instead of comparing to style name.
Stefan Vogel <sv@exept.de>
parents:
1537
diff
changeset
|
207 |
bg := styleSheet colorAt:#'activeHelp.backgroundColor' default:nil. |
285 | 208 |
bg notNil ifTrue:[ |
209 |
viewBackground := bg |
|
210 |
] ifFalse:[ |
|
211 |
shapeStyle == #cartoon ifTrue:[ |
|
212 |
viewBackground := White |
|
213 |
] |
|
214 |
]. |
|
2773
eaec2e45bd8d
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
215 |
self borderWidth:(styleSheet at:#'activeHelp.borderWidth' default:1). |
2776
7181bb9659ae
comment/format in: #withView:
Claus Gittinger <cg@exept.de>
parents:
2773
diff
changeset
|
216 |
self borderColor:(styleSheet at:#'activeHelp.borderColor' default:Color black). |
236 | 217 |
|
725 | 218 |
"Modified: / 26.10.1997 / 17:02:09 / cg" |
92 | 219 |
! |
220 |
||
138 | 221 |
realize |
222 |
self create. |
|
223 |
self computeShape. |
|
224 |
self enableMotionEvents. |
|
225 |
self enableButtonMotionEvents. |
|
1485 | 226 |
super realize |
60 | 227 |
! ! |
228 |
||
229 |
!ActiveHelpView methodsFor:'private'! |
|
230 |
||
231 |
computeShape |
|
233 | 232 |
"compute the shape, based upon the size of my component view" |
233 |
||
3224 | 234 |
|extent oldOrigin shapeForm borderForm y1 bw h w mirrorH mirrorV |
3218 | 235 |
p1 p2 p3 pB1 pB2 pB3 offs hEll h2 w2 w8 w78 mousePosition| |
60 | 236 |
|
1261 | 237 |
device supportsArbitraryShapedViews ifTrue:[ |
635 | 238 |
(shapeStyle == #cartoon) ifTrue:[ |
239 |
extent := self extent. |
|
3224 | 240 |
oldOrigin := self origin. |
635 | 241 |
h := extent y. |
242 |
w := extent x. |
|
243 |
bw := 4. |
|
244 |
offs := 0. |
|
3218 | 245 |
mousePosition := device pointerPosition. |
60 | 246 |
|
3218 | 247 |
((mousePosition > (device width * (2/3))) |
248 |
or:[ self corner x > device usableWidth ]) ifTrue:[ |
|
635 | 249 |
mirrorH := true. |
3224 | 250 |
self origin:((oldOrigin x - w) @ (self origin y)). |
635 | 251 |
offs := bw * 2. |
252 |
] ifFalse:[ |
|
253 |
mirrorH := false |
|
254 |
]. |
|
3218 | 255 |
((mousePosition > (device height * (2/3))) |
256 |
or:[ self corner y > device usableHeight ]) ifTrue:[ |
|
635 | 257 |
mirrorV := true. |
3224 | 258 |
self origin:(oldOrigin x @ (self origin y - h)). |
635 | 259 |
] ifFalse:[ |
260 |
mirrorV := false |
|
261 |
]. |
|
285 | 262 |
|
635 | 263 |
borderForm := Form width:w height:h. |
264 |
shapeForm := Form width:w height:h. |
|
265 |
borderForm fill:(Color noColor). |
|
266 |
shapeForm fill:(Color noColor). |
|
267 |
||
268 |
hEll := (h // 3 * 2). |
|
60 | 269 |
|
635 | 270 |
mirrorV ifTrue:[ |
271 |
y1 := 0. |
|
272 |
] ifFalse:[ |
|
273 |
y1 := h // 4. |
|
274 |
]. |
|
60 | 275 |
|
635 | 276 |
borderForm fillArcX:0 y:y1 |
3224 | 277 |
width:w height:hEll |
278 |
from:0 angle:360. |
|
635 | 279 |
|
280 |
myView origin:(width - myView width // 2) @ (y1 + ((hEll - myView height) // 2)). |
|
285 | 281 |
|
1182 | 282 |
h2 := h // 2. |
283 |
w2 := w // 2. |
|
284 |
w8 := w // 8. |
|
285 |
w78 := w * 7 // 8. |
|
286 |
||
635 | 287 |
mirrorH ifTrue:[ |
288 |
mirrorV ifTrue:[ |
|
289 |
p1 := w @ h. |
|
1182 | 290 |
p2 := (w78 @ h2). |
291 |
p3 := (w2 @ h2). |
|
635 | 292 |
pB1 := (w-bw) @ (h-bw). |
1182 | 293 |
pB2 := ((w78 - bw) @ (h2 - bw)). |
294 |
pB3 := ((w2 + bw) @ (h2 - bw)) |
|
635 | 295 |
] ifFalse:[ |
296 |
p1 := w @ 0. |
|
1182 | 297 |
p2 := (w78 @ h2). |
298 |
p3 := (w2 @ h2). |
|
635 | 299 |
pB1 := (w-bw) @ bw. |
1182 | 300 |
pB2 := ((w78 - bw) @ (h2 + bw)). |
301 |
pB3 := ((w2 + bw) @ (h2 + bw)) |
|
635 | 302 |
] |
303 |
] ifFalse:[ |
|
304 |
mirrorV ifTrue:[ |
|
305 |
p1 := 0@h. |
|
1182 | 306 |
p2 := (w8 @ h2). |
307 |
p3 := (w2 @ h2). |
|
635 | 308 |
pB1 := bw@(h-bw). |
1182 | 309 |
pB2 := ((w8 + bw) @ (h2 - bw)). |
310 |
pB3 := ((w2 - bw) @ (h2 - bw)). |
|
635 | 311 |
] ifFalse:[ |
312 |
p1 := 0@0. |
|
1182 | 313 |
p2 := (w8 @ h2). |
314 |
p3 := (w2 @ h2). |
|
635 | 315 |
pB1 := bw@bw. |
1182 | 316 |
pB2 := ((w8 + bw) @ (h2 + bw)). |
317 |
pB3 := ((w2 - bw) @ (h2 + bw)). |
|
635 | 318 |
] |
319 |
]. |
|
60 | 320 |
|
635 | 321 |
borderForm fillPolygon:(Array with:p1 with:p2 with:p3). |
322 |
shapeForm fillPolygon:(Array with:pB1 with:pB2 with:pB3). |
|
60 | 323 |
|
635 | 324 |
shapeForm lineWidth:bw. |
325 |
shapeForm paint:(Color noColor). |
|
326 |
shapeForm displayPolygon:(Array with:p3 with:p1 with:p2). |
|
60 | 327 |
|
635 | 328 |
shapeForm paint:(Color colorId:1). |
329 |
shapeForm fillArcX:bw y:y1 + bw |
|
3224 | 330 |
width:(w - (bw * 2)) height:(h // 3 * 2 - (bw * 2)) |
331 |
from:0 angle:360. |
|
635 | 332 |
]. |
333 |
borderForm notNil ifTrue:[ |
|
334 |
self borderShape:borderForm. |
|
335 |
self viewShape:shapeForm |
|
336 |
]. |
|
337 |
] |
|
60 | 338 |
|
1182 | 339 |
"Modified: / 5.6.1999 / 21:41:01 / cg" |
1261 | 340 |
"Modified: / 27.10.1999 / 13:45:45 / stefan" |
60 | 341 |
! |
342 |
||
343 |
resizeToFit |
|
233 | 344 |
"resize myself to make the component view fit" |
345 |
||
3223 | 346 |
|h w pref bw| |
60 | 347 |
|
285 | 348 |
pref := myView preferredExtent. |
349 |
shapeStyle == #cartoon ifTrue:[ |
|
350 |
h := pref y. |
|
351 |
w := pref x. |
|
3223 | 352 |
self extent:((w / 0.85) @ (h * 4)) rounded. |
92 | 353 |
] ifFalse:[ |
3223 | 354 |
bw := self borderWidth. |
355 |
self extent:(pref + (bw * 2)). |
|
356 |
myView origin:(bw asPoint). |
|
92 | 357 |
] |
233 | 358 |
|
635 | 359 |
"Modified: 28.6.1997 / 14:23:49 / cg" |
233 | 360 |
! ! |
361 |
||
362 |
!ActiveHelpView methodsFor:'queries'! |
|
363 |
||
364 |
isPopUpView |
|
261 | 365 |
"return true - I am a popUp type of view (no decoration, pop-to-top)" |
233 | 366 |
|
367 |
^ true |
|
368 |
||
261 | 369 |
"Modified: 12.5.1996 / 21:58:12 / cg" |
60 | 370 |
! ! |
371 |
||
380 | 372 |
!ActiveHelpView class methodsFor:'documentation'! |
60 | 373 |
|
138 | 374 |
version |
3246 | 375 |
^ '$Header: /cvs/stx/stx/libview2/ActiveHelpView.st,v 1.38 2013-09-12 13:17:56 cg Exp $' |
2773
eaec2e45bd8d
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
376 |
! |
eaec2e45bd8d
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
377 |
|
eaec2e45bd8d
no more direct accesses to borderWidth and borderColor
Claus Gittinger <cg@exept.de>
parents:
2413
diff
changeset
|
378 |
version_CVS |
3246 | 379 |
^ '$Header: /cvs/stx/stx/libview2/ActiveHelpView.st,v 1.38 2013-09-12 13:17:56 cg Exp $' |
60 | 380 |
! ! |
3118 | 381 |