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