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