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