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