author | Claus Gittinger <cg@exept.de> |
Thu, 09 Jul 2009 14:59:47 +0200 | |
changeset 2692 | 5fe75b7fb83a |
parent 2684 | de2d170a80ef |
child 2754 | 4c3b40eba71b |
permissions | -rw-r--r-- |
1802 | 1 |
" |
2 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
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 |
" |
|
1536 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
14 |
ActiveHelp subclass:#FlyByHelp |
|
2680 | 15 |
instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess' |
1892 | 16 |
classVariableNames:'' |
1536 | 17 |
poolDictionaries:'' |
18 |
category:'Interface-Help' |
|
19 |
! |
|
20 |
||
1802 | 21 |
!FlyByHelp class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
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 |
" |
|
1893 | 35 |
! |
36 |
||
37 |
examples |
|
38 |
" |
|
39 |
FlyByHelp isActive |
|
40 |
||
41 |
FlyByHelp stop |
|
42 |
FlyByHelp start |
|
43 |
" |
|
1802 | 44 |
! ! |
1536 | 45 |
|
46 |
!FlyByHelp class methodsFor:'initialization'! |
|
47 |
||
48 |
initialize |
|
49 |
"set default delay & help-display times" |
|
50 |
||
1657 | 51 |
ShowTime := 10. |
52 |
DelayTime := 0.4. |
|
1536 | 53 |
|
54 |
" |
|
55 |
FlyByHelp initialize |
|
56 |
" |
|
57 |
||
58 |
"Modified: 27.4.1996 / 15:07:27 / cg" |
|
59 |
! ! |
|
60 |
||
2692 | 61 |
!FlyByHelp class methodsFor:'accessing'! |
62 |
||
63 |
currentlyShownView |
|
64 |
^ TheOneAndOnlyHelpListener currentlyShownView |
|
65 |
! ! |
|
66 |
||
2684 | 67 |
!FlyByHelp methodsFor:'defaults'! |
68 |
||
69 |
flyByHelpTimeoutMillis |
|
70 |
"abort flyby help text generation, if no text can be generated within that |
|
71 |
time delta. This is used to abort long-lasting parsing/scanning/analysis in |
|
72 |
large methods when the mouse is moved over some syntactic constructs, and |
|
73 |
it takes too long to parse... |
|
74 |
The returned time is given in ms" |
|
75 |
||
76 |
^ 300 |
|
77 |
! ! |
|
78 |
||
2392 | 79 |
!FlyByHelp methodsFor:'event handling'! |
1540 | 80 |
|
2474 | 81 |
buttonMotion:buttonAndModifierState x:x y:y view:aView |
2519 | 82 |
aView == currentHelpView ifTrue:[ |
83 |
"/ the help-bubble itself |
|
84 |
^ false |
|
85 |
]. |
|
86 |
||
2518 | 87 |
"/ don't start tooltip, if this view is not active |
88 |
"/ aView topView isActive ifFalse:[^ false]. |
|
2477
b009e0b51999
suppress tooltip for inactive (lower) windows
Claus Gittinger <cg@exept.de>
parents:
2474
diff
changeset
|
89 |
|
2474 | 90 |
^ super buttonMotion:buttonAndModifierState x:x y:y view:aView |
1540 | 91 |
! |
92 |
||
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
93 |
buttonPress:button x:x y:y view:aView |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
94 |
aView == currentHelpView ifTrue:[ |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
95 |
self hideHelp. |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
96 |
^ true |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
97 |
]. |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
98 |
|
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
99 |
^ super buttonPress:button x:x y:y view:aView |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
100 |
! |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
101 |
|
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
102 |
keyPress:key x:x y:y view:aView |
2612 | 103 |
aView == currentHelpView ifTrue:[ |
104 |
key == #Escape ifTrue:[ |
|
105 |
self hideHelp. |
|
106 |
^ true |
|
107 |
]. |
|
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
108 |
]. |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
109 |
^ false |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
110 |
! |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
111 |
|
2521
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
112 |
mouseWheelMotion:state x:x y:y amount:amount deltaTime:dTime view:aView |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
113 |
currentHelpView notNil ifTrue:[ |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
114 |
self handleMouseIn:aView x:x y:y. |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
115 |
]. |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
116 |
^ false |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
117 |
! |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
118 |
|
1540 | 119 |
pointerLeave:state view:aView |
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
120 |
aView == currentHelpView ifTrue:[^ true]. |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
121 |
^ super pointerLeave:state view:aView |
1540 | 122 |
! ! |
123 |
||
2392 | 124 |
!FlyByHelp methodsFor:'help texts'! |
1536 | 125 |
|
126 |
helpTextFromModel:aModel view:aView at:aPointOrNil |
|
127 |
"helper: ask aModel for its helpText." |
|
128 |
||
129 |
|text| |
|
130 |
||
131 |
aPointOrNil notNil ifTrue:[ |
|
132 |
(aModel respondsTo:#flyByHelpTextFor:at:) ifTrue:[ |
|
133 |
text := aModel flyByHelpTextFor:aView at:aPointOrNil. |
|
134 |
]. |
|
135 |
]. |
|
136 |
text isNil ifTrue:[ |
|
137 |
(aModel respondsTo:#flyByHelpTextFor:) ifTrue:[ |
|
138 |
text := aModel flyByHelpTextFor:aView. |
|
139 |
]. |
|
140 |
]. |
|
141 |
^ text |
|
142 |
! |
|
143 |
||
144 |
helpTextFromView:aView at:aPointOrNil |
|
145 |
"helper: ask aView for its helpText." |
|
146 |
||
147 |
|text| |
|
148 |
||
149 |
aPointOrNil notNil ifTrue:[ |
|
150 |
(aView respondsTo:#flyByHelpTextAt:) ifTrue:[ |
|
151 |
text := aView flyByHelpTextAt:aPointOrNil. |
|
152 |
]. |
|
153 |
]. |
|
154 |
text isNil ifTrue:[ |
|
155 |
(aView respondsTo:#flyByHelpText) ifTrue:[ |
|
156 |
text := aView flyByHelpText. |
|
157 |
]. |
|
158 |
]. |
|
159 |
^ text. |
|
2392 | 160 |
! ! |
161 |
||
162 |
!FlyByHelp methodsFor:'private'! |
|
1536 | 163 |
|
164 |
hideIfPointerLeft:aView |
|
165 |
"hide help, if the pointer is not in aView" |
|
166 |
||
167 |
|whereOnScreen| |
|
168 |
||
169 |
currentFrame notNil ifTrue:[ |
|
170 |
whereOnScreen := aView graphicsDevice pointerPosition. |
|
171 |
||
172 |
(currentFrame notNil |
|
173 |
and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[ |
|
174 |
self hideHelp. |
|
175 |
]. |
|
176 |
]. |
|
177 |
||
178 |
"Modified: 28.5.1996 / 20:18:28 / cg" |
|
179 |
! |
|
180 |
||
181 |
initiateHelpFor:aView at:aPointOrNil now:showItNow |
|
182 |
"ask aView for helpText, passing x/y coordinates; |
|
183 |
start a timeout process to display this helpText after some delay; |
|
184 |
Normally used internally, but can also be used by widgets to force |
|
185 |
re-negotiation of the displayed helpText |
|
186 |
(for example in a menu, when the selection changes)" |
|
187 |
||
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
188 |
|text delayTime now| |
1536 | 189 |
|
190 |
(self interestedIn:aView) ifFalse:[ |
|
191 |
^ self |
|
192 |
]. |
|
193 |
||
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
194 |
now := Timestamp now. |
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
195 |
|
2680 | 196 |
"/ do not allow for more than 200 ms to be spent in the |
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
197 |
"/ helpText gatherer (the codeView parses the code for the variable under the cursor) |
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
198 |
[ |
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
199 |
text := self helpTextFor:aView at:aPointOrNil. |
2684 | 200 |
] valueWithWatchDog:[ ^ self ] afterMilliseconds:(self flyByHelpTimeoutMillis). |
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
201 |
|
1536 | 202 |
lastHelpText = text ifTrue:[ |
2392 | 203 |
self toolTipFollowsMouse ifFalse:[ |
204 |
^ self |
|
205 |
] |
|
1536 | 206 |
]. |
207 |
||
208 |
text size > 0 ifTrue:[ |
|
2392 | 209 |
delayTime := self delayTime. |
210 |
(showItNow not and:[delayTime > 0]) ifTrue:[ |
|
1536 | 211 |
self stopHelpDisplayProcess. |
2392 | 212 |
showProcess := |
213 |
[ |
|
2680 | 214 |
Delay waitForSeconds:delayTime. |
215 |
showProcess := nil. |
|
216 |
aView device anyButtonPressed ifFalse:[ |
|
217 |
self showHelp:text for:aView |
|
218 |
] |
|
2392 | 219 |
] forkAt:(Processor userSchedulingPriority + 1). |
1536 | 220 |
] ifFalse:[ |
221 |
self showHelp:text for:aView |
|
222 |
] |
|
1542 | 223 |
] ifFalse:[ |
224 |
self hideHelp |
|
1536 | 225 |
]. |
226 |
! |
|
227 |
||
228 |
interestedIn:aView |
|
229 |
"return true, if I am interested in aView (either listeningForAll, |
|
230 |
or in my list of apps)" |
|
231 |
||
232 |
aView isNil ifTrue:[^ false]. |
|
2495
728d6935dc5b
also interestedIn: help, if a pointer moves
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
233 |
"/ aView topView == currentHelpView ifTrue:[^ false]. |
1536 | 234 |
|
235 |
^ super interestedIn:aView |
|
236 |
! ! |
|
237 |
||
2392 | 238 |
!FlyByHelp methodsFor:'queries'! |
239 |
||
2692 | 240 |
currentlyShownView |
241 |
^ currentHelpView |
|
242 |
! |
|
243 |
||
2392 | 244 |
toolTipFollowsMouse |
245 |
^ false |
|
246 |
! ! |
|
247 |
||
1768 | 248 |
!FlyByHelp methodsFor:'show & hide help'! |
1536 | 249 |
|
250 |
hideHelp |
|
251 |
"hide the help text" |
|
252 |
||
253 |
|p| |
|
254 |
||
1540 | 255 |
lastHelpText := nil. |
1536 | 256 |
self stopHelpDisplayProcess. |
257 |
||
258 |
currentHelpView notNil ifTrue:[ |
|
259 |
[ |
|
260 |
currentHelpView destroy. |
|
261 |
currentHelpView := nil. |
|
262 |
currentView := nil. |
|
263 |
] valueUninterruptably |
|
264 |
]. |
|
265 |
currentFrame := nil. |
|
266 |
closeProcess notNil ifTrue:[ |
|
267 |
p := closeProcess. closeProcess := nil. |
|
268 |
p terminate. |
|
269 |
] |
|
270 |
||
271 |
"Modified: 28.6.1997 / 14:03:50 / cg" |
|
272 |
! |
|
273 |
||
274 |
showHelp:aHelpText for:view |
|
275 |
"show the help text for aView" |
|
276 |
||
2651 | 277 |
|wg org p v dev| |
1536 | 278 |
|
2651 | 279 |
(wg := view windowGroup) notNil ifTrue:[ |
280 |
wg isInModalLoop ifTrue:[ |
|
2628
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
281 |
"/ Transcript showCR:'1'. |
2651 | 282 |
wg isModal ifFalse:[ |
2628
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
283 |
"/ Transcript showCR:'2'. |
2651 | 284 |
^ self |
285 |
]. |
|
2628
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
286 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
287 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
288 |
|
1536 | 289 |
view == currentView ifTrue:[ |
290 |
lastHelpText = aHelpText ifTrue:[ |
|
291 |
^ self |
|
292 |
] |
|
293 |
]. |
|
294 |
||
295 |
lastHelpText := aHelpText. |
|
296 |
||
297 |
closeProcess notNil ifTrue:[ |
|
298 |
p := closeProcess. closeProcess := nil. |
|
299 |
p terminate. |
|
300 |
]. |
|
301 |
currentHelpView notNil ifTrue:[ |
|
302 |
self hideHelp |
|
303 |
]. |
|
304 |
||
305 |
org := view originRelativeTo:nil. |
|
306 |
currentFrame := org extent:view extent. |
|
307 |
org :=org + (view extent // 2). |
|
308 |
||
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
309 |
dev := view graphicsDevice. |
1536 | 310 |
|
1963
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
311 |
v := ActiveHelpView for:aHelpText onDevice:dev. |
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
312 |
|
1536 | 313 |
org := dev pointerPosition. |
1657 | 314 |
org := org + (0@18"24"). |
1536 | 315 |
(org x + v width) > dev width ifTrue:[ |
316 |
org := (org x - v width) @ org y |
|
317 |
]. |
|
318 |
(org y + v height) > dev height ifTrue:[ |
|
319 |
org := org x @ (org y - v height). |
|
320 |
]. |
|
321 |
||
322 |
v origin:org. |
|
323 |
v realize. |
|
324 |
v enableButtonMotionEvents. |
|
325 |
v enableMotionEvents. |
|
326 |
currentHelpView := v. |
|
2392 | 327 |
currentView := view. |
1536 | 328 |
|
2392 | 329 |
self showTime notNil ifTrue:[ |
330 |
closeProcess := [ |
|
1546 | 331 |
[ |
2392 | 332 |
(Delay forSeconds:self showTime) wait. |
333 |
[ |
|
334 |
currentHelpView notNil ifTrue:[ |
|
335 |
currentHelpView destroy. |
|
336 |
currentHelpView := nil. |
|
337 |
] |
|
338 |
] valueUninterruptably |
|
339 |
] ifCurtailed:[ |
|
340 |
closeProcess := nil. |
|
341 |
]. |
|
342 |
] newProcess. |
|
343 |
closeProcess priority:(Processor userSchedulingPriority + 1). |
|
344 |
closeProcess resume. |
|
345 |
]. |
|
1536 | 346 |
|
1963
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
347 |
"Modified: / 31-08-1995 / 19:20:45 / claus" |
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
348 |
"Modified: / 16-03-2004 / 15:27:50 / cg" |
1536 | 349 |
! |
350 |
||
351 |
stopHelpDisplayProcess |
|
352 |
|p| |
|
353 |
||
2680 | 354 |
(p := showProcess) notNil ifTrue:[ |
355 |
showProcess := nil. |
|
1536 | 356 |
p terminate. |
357 |
]. |
|
358 |
||
359 |
"Created: 28.6.1997 / 14:03:17 / cg" |
|
360 |
! ! |
|
361 |
||
362 |
!FlyByHelp class methodsFor:'documentation'! |
|
363 |
||
364 |
version |
|
2692 | 365 |
^ '$Header: /cvs/stx/stx/libview2/FlyByHelp.st,v 1.31 2009-07-09 12:59:47 cg Exp $' |
1536 | 366 |
! ! |
1657 | 367 |
|
1536 | 368 |
FlyByHelp initialize! |