author | Claus Gittinger <cg@exept.de> |
Sat, 12 Jul 2008 15:54:02 +0200 | |
changeset 2519 | af89806c67e4 |
parent 2518 | fc1d2b481b6e |
child 2521 | 7e51aa294156 |
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 |
|
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 |
||
2392 | 61 |
!FlyByHelp methodsFor:'event handling'! |
1540 | 62 |
|
2474 | 63 |
buttonMotion:buttonAndModifierState x:x y:y view:aView |
2519 | 64 |
aView == currentHelpView ifTrue:[ |
65 |
"/ the help-bubble itself |
|
66 |
^ false |
|
67 |
]. |
|
68 |
||
2518 | 69 |
"/ don't start tooltip, if this view is not active |
70 |
"/ aView topView isActive ifFalse:[^ false]. |
|
2477
b009e0b51999
suppress tooltip for inactive (lower) windows
Claus Gittinger <cg@exept.de>
parents:
2474
diff
changeset
|
71 |
|
2474 | 72 |
^ super buttonMotion:buttonAndModifierState x:x y:y view:aView |
1540 | 73 |
! |
74 |
||
75 |
pointerLeave:state view:aView |
|
76 |
aView == currentHelpView ifTrue:[^ self]. |
|
77 |
super pointerLeave:state view:aView |
|
78 |
! ! |
|
79 |
||
2392 | 80 |
!FlyByHelp methodsFor:'help texts'! |
1536 | 81 |
|
82 |
helpTextFromModel:aModel view:aView at:aPointOrNil |
|
83 |
"helper: ask aModel for its helpText." |
|
84 |
||
85 |
|text| |
|
86 |
||
87 |
aPointOrNil notNil ifTrue:[ |
|
88 |
(aModel respondsTo:#flyByHelpTextFor:at:) ifTrue:[ |
|
89 |
text := aModel flyByHelpTextFor:aView at:aPointOrNil. |
|
90 |
]. |
|
91 |
]. |
|
92 |
text isNil ifTrue:[ |
|
93 |
(aModel respondsTo:#flyByHelpTextFor:) ifTrue:[ |
|
94 |
text := aModel flyByHelpTextFor:aView. |
|
95 |
]. |
|
96 |
]. |
|
97 |
^ text |
|
98 |
! |
|
99 |
||
100 |
helpTextFromView:aView at:aPointOrNil |
|
101 |
"helper: ask aView for its helpText." |
|
102 |
||
103 |
|text| |
|
104 |
||
105 |
aPointOrNil notNil ifTrue:[ |
|
106 |
(aView respondsTo:#flyByHelpTextAt:) ifTrue:[ |
|
107 |
text := aView flyByHelpTextAt:aPointOrNil. |
|
108 |
]. |
|
109 |
]. |
|
110 |
text isNil ifTrue:[ |
|
111 |
(aView respondsTo:#flyByHelpText) ifTrue:[ |
|
112 |
text := aView flyByHelpText. |
|
113 |
]. |
|
114 |
]. |
|
115 |
^ text. |
|
2392 | 116 |
! ! |
117 |
||
118 |
!FlyByHelp methodsFor:'private'! |
|
1536 | 119 |
|
120 |
hideIfPointerLeft:aView |
|
121 |
"hide help, if the pointer is not in aView" |
|
122 |
||
123 |
|whereOnScreen| |
|
124 |
||
125 |
currentFrame notNil ifTrue:[ |
|
126 |
whereOnScreen := aView graphicsDevice pointerPosition. |
|
127 |
||
128 |
(currentFrame notNil |
|
129 |
and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[ |
|
130 |
self hideHelp. |
|
131 |
]. |
|
132 |
]. |
|
133 |
||
134 |
"Modified: 28.5.1996 / 20:18:28 / cg" |
|
135 |
! |
|
136 |
||
137 |
initiateHelpFor:aView at:aPointOrNil now:showItNow |
|
138 |
"ask aView for helpText, passing x/y coordinates; |
|
139 |
start a timeout process to display this helpText after some delay; |
|
140 |
Normally used internally, but can also be used by widgets to force |
|
141 |
re-negotiation of the displayed helpText |
|
142 |
(for example in a menu, when the selection changes)" |
|
143 |
||
2392 | 144 |
|text delayTime| |
1536 | 145 |
|
146 |
(self interestedIn:aView) ifFalse:[ |
|
147 |
^ self |
|
148 |
]. |
|
149 |
||
150 |
text := self helpTextFor:aView at:aPointOrNil. |
|
151 |
lastHelpText = text ifTrue:[ |
|
2392 | 152 |
self toolTipFollowsMouse ifFalse:[ |
153 |
^ self |
|
154 |
] |
|
1536 | 155 |
]. |
156 |
||
157 |
text size > 0 ifTrue:[ |
|
2392 | 158 |
delayTime := self delayTime. |
159 |
(showItNow not and:[delayTime > 0]) ifTrue:[ |
|
1536 | 160 |
self stopHelpDisplayProcess. |
2392 | 161 |
showProcess := |
162 |
[ |
|
163 |
Delay waitForSeconds:delayTime. |
|
164 |
showProcess := nil. |
|
165 |
aView device anyButtonPressed ifFalse:[ |
|
166 |
self showHelp:text for:aView |
|
167 |
] |
|
168 |
] forkAt:(Processor userSchedulingPriority + 1). |
|
1536 | 169 |
] ifFalse:[ |
170 |
self showHelp:text for:aView |
|
171 |
] |
|
1542 | 172 |
] ifFalse:[ |
173 |
self hideHelp |
|
1536 | 174 |
]. |
175 |
! |
|
176 |
||
177 |
interestedIn:aView |
|
178 |
"return true, if I am interested in aView (either listeningForAll, |
|
179 |
or in my list of apps)" |
|
180 |
||
181 |
aView isNil ifTrue:[^ false]. |
|
2495
728d6935dc5b
also interestedIn: help, if a pointer moves
Claus Gittinger <cg@exept.de>
parents:
2478
diff
changeset
|
182 |
"/ aView topView == currentHelpView ifTrue:[^ false]. |
1536 | 183 |
|
184 |
^ super interestedIn:aView |
|
185 |
! ! |
|
186 |
||
2392 | 187 |
!FlyByHelp methodsFor:'queries'! |
188 |
||
189 |
toolTipFollowsMouse |
|
190 |
^ false |
|
191 |
! ! |
|
192 |
||
1768 | 193 |
!FlyByHelp methodsFor:'show & hide help'! |
1536 | 194 |
|
195 |
hideHelp |
|
196 |
"hide the help text" |
|
197 |
||
198 |
|p| |
|
199 |
||
1540 | 200 |
lastHelpText := nil. |
1536 | 201 |
self stopHelpDisplayProcess. |
202 |
||
203 |
currentHelpView notNil ifTrue:[ |
|
204 |
[ |
|
205 |
currentHelpView destroy. |
|
206 |
currentHelpView := nil. |
|
207 |
currentView := nil. |
|
208 |
] valueUninterruptably |
|
209 |
]. |
|
210 |
currentFrame := nil. |
|
211 |
closeProcess notNil ifTrue:[ |
|
212 |
p := closeProcess. closeProcess := nil. |
|
213 |
p terminate. |
|
214 |
] |
|
215 |
||
216 |
"Modified: 28.6.1997 / 14:03:50 / cg" |
|
217 |
! |
|
218 |
||
219 |
showHelp:aHelpText for:view |
|
220 |
"show the help text for aView" |
|
221 |
||
222 |
|org p v dev| |
|
223 |
||
224 |
view == currentView ifTrue:[ |
|
225 |
lastHelpText = aHelpText ifTrue:[ |
|
226 |
^ self |
|
227 |
] |
|
228 |
]. |
|
229 |
||
230 |
lastHelpText := aHelpText. |
|
231 |
||
232 |
closeProcess notNil ifTrue:[ |
|
233 |
p := closeProcess. closeProcess := nil. |
|
234 |
p terminate. |
|
235 |
]. |
|
236 |
currentHelpView notNil ifTrue:[ |
|
237 |
self hideHelp |
|
238 |
]. |
|
239 |
||
240 |
org := view originRelativeTo:nil. |
|
241 |
currentFrame := org extent:view extent. |
|
242 |
org :=org + (view extent // 2). |
|
243 |
||
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
244 |
dev := view graphicsDevice. |
1536 | 245 |
|
1963
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
246 |
v := ActiveHelpView for:aHelpText onDevice:dev. |
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
247 |
|
1536 | 248 |
org := dev pointerPosition. |
1657 | 249 |
org := org + (0@18"24"). |
1536 | 250 |
(org x + v width) > dev width ifTrue:[ |
251 |
org := (org x - v width) @ org y |
|
252 |
]. |
|
253 |
(org y + v height) > dev height ifTrue:[ |
|
254 |
org := org x @ (org y - v height). |
|
255 |
]. |
|
256 |
||
257 |
v origin:org. |
|
258 |
"/ currentHelpView open. |
|
259 |
v realize. |
|
260 |
v enableButtonMotionEvents. |
|
261 |
v enableMotionEvents. |
|
262 |
currentHelpView := v. |
|
2392 | 263 |
currentView := view. |
1536 | 264 |
|
2392 | 265 |
self showTime notNil ifTrue:[ |
266 |
closeProcess := [ |
|
1546 | 267 |
[ |
2392 | 268 |
(Delay forSeconds:self showTime) wait. |
269 |
[ |
|
270 |
currentHelpView notNil ifTrue:[ |
|
271 |
currentHelpView destroy. |
|
272 |
currentHelpView := nil. |
|
273 |
] |
|
274 |
] valueUninterruptably |
|
275 |
] ifCurtailed:[ |
|
276 |
closeProcess := nil. |
|
277 |
]. |
|
278 |
] newProcess. |
|
279 |
closeProcess priority:(Processor userSchedulingPriority + 1). |
|
280 |
closeProcess resume. |
|
281 |
]. |
|
1536 | 282 |
|
1963
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
283 |
"Modified: / 31-08-1995 / 19:20:45 / claus" |
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
284 |
"Modified: / 16-03-2004 / 15:27:50 / cg" |
1536 | 285 |
! |
286 |
||
287 |
stopHelpDisplayProcess |
|
288 |
|p| |
|
289 |
||
290 |
showProcess notNil ifTrue:[ |
|
291 |
p := showProcess. showProcess := nil. |
|
292 |
p terminate. |
|
293 |
]. |
|
294 |
||
295 |
"Created: 28.6.1997 / 14:03:17 / cg" |
|
296 |
! ! |
|
297 |
||
298 |
!FlyByHelp class methodsFor:'documentation'! |
|
299 |
||
300 |
version |
|
2519 | 301 |
^ '$Header: /cvs/stx/stx/libview2/FlyByHelp.st,v 1.22 2008-07-12 13:54:02 cg Exp $' |
1536 | 302 |
! ! |
1657 | 303 |
|
1536 | 304 |
FlyByHelp initialize! |