author | Claus Gittinger <cg@exept.de> |
Wed, 08 Oct 2003 16:10:08 +0200 | |
changeset 1831 | 766f0b3cd453 |
parent 1802 | ef3539bf86b7 |
child 1892 | 4c38a0c4369b |
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 |
" |
|
12 |
||
1536 | 13 |
"{ Package: 'stx:libview2' }" |
14 |
||
15 |
ActiveHelp subclass:#FlyByHelp |
|
16 |
instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess' |
|
17 |
classVariableNames:'DelayTime ShowTime TheOneAndOnlyHelpListener' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Interface-Help' |
|
20 |
! |
|
21 |
||
1802 | 22 |
!FlyByHelp class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! ! |
|
1536 | 37 |
|
38 |
!FlyByHelp class methodsFor:'initialization'! |
|
39 |
||
40 |
initialize |
|
41 |
"set default delay & help-display times" |
|
42 |
||
1657 | 43 |
ShowTime := 10. |
44 |
DelayTime := 0.4. |
|
1536 | 45 |
|
46 |
" |
|
47 |
FlyByHelp initialize |
|
48 |
" |
|
49 |
||
50 |
"Modified: 27.4.1996 / 15:07:27 / cg" |
|
51 |
! ! |
|
52 |
||
53 |
!FlyByHelp class methodsFor:'start & stop'! |
|
54 |
||
55 |
start |
|
56 |
"start activeHelp for all apps" |
|
57 |
||
58 |
TheOneAndOnlyHelpListener isNil ifTrue:[ |
|
59 |
TheOneAndOnlyHelpListener := self new. |
|
60 |
]. |
|
61 |
TheOneAndOnlyHelpListener listenForAll |
|
62 |
||
63 |
" |
|
1542 | 64 |
FlyByHelp start |
65 |
FlyByHelp stop |
|
66 |
" |
|
67 |
! |
|
68 |
||
69 |
stop |
|
70 |
"stop activeHelp for all (except for individual apps)" |
|
71 |
||
72 |
TheOneAndOnlyHelpListener notNil ifTrue:[ |
|
73 |
TheOneAndOnlyHelpListener unlistenAll. |
|
74 |
TheOneAndOnlyHelpListener := nil. |
|
75 |
]. |
|
76 |
||
77 |
" |
|
78 |
FlyByHelp start |
|
79 |
FlyByHelp stop |
|
1536 | 80 |
" |
81 |
! ! |
|
82 |
||
1540 | 83 |
!FlyByHelp methodsFor:'listening'! |
84 |
||
85 |
buttonMotion:state x:x y:y view:aView |
|
86 |
aView == currentHelpView ifTrue:[^ self]. |
|
87 |
super buttonMotion:state x:x y:y view:aView |
|
88 |
! |
|
89 |
||
90 |
pointerLeave:state view:aView |
|
91 |
aView == currentHelpView ifTrue:[^ self]. |
|
92 |
super pointerLeave:state view:aView |
|
93 |
! ! |
|
94 |
||
1536 | 95 |
!FlyByHelp methodsFor:'private'! |
96 |
||
97 |
helpTextFromModel:aModel view:aView at:aPointOrNil |
|
98 |
"helper: ask aModel for its helpText." |
|
99 |
||
100 |
|text| |
|
101 |
||
102 |
aPointOrNil notNil ifTrue:[ |
|
103 |
(aModel respondsTo:#flyByHelpTextFor:at:) ifTrue:[ |
|
104 |
text := aModel flyByHelpTextFor:aView at:aPointOrNil. |
|
105 |
]. |
|
106 |
]. |
|
107 |
text isNil ifTrue:[ |
|
108 |
(aModel respondsTo:#flyByHelpTextFor:) ifTrue:[ |
|
109 |
text := aModel flyByHelpTextFor:aView. |
|
110 |
]. |
|
111 |
]. |
|
112 |
^ text |
|
113 |
! |
|
114 |
||
115 |
helpTextFromView:aView at:aPointOrNil |
|
116 |
"helper: ask aView for its helpText." |
|
117 |
||
118 |
|text| |
|
119 |
||
120 |
aPointOrNil notNil ifTrue:[ |
|
121 |
(aView respondsTo:#flyByHelpTextAt:) ifTrue:[ |
|
122 |
text := aView flyByHelpTextAt:aPointOrNil. |
|
123 |
]. |
|
124 |
]. |
|
125 |
text isNil ifTrue:[ |
|
126 |
(aView respondsTo:#flyByHelpText) ifTrue:[ |
|
127 |
text := aView flyByHelpText. |
|
128 |
]. |
|
129 |
]. |
|
130 |
^ text. |
|
131 |
! |
|
132 |
||
133 |
hideIfPointerLeft:aView |
|
134 |
"hide help, if the pointer is not in aView" |
|
135 |
||
136 |
|whereOnScreen| |
|
137 |
||
138 |
currentFrame notNil ifTrue:[ |
|
139 |
whereOnScreen := aView graphicsDevice pointerPosition. |
|
140 |
||
141 |
(currentFrame notNil |
|
142 |
and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[ |
|
143 |
self hideHelp. |
|
144 |
]. |
|
145 |
]. |
|
146 |
||
147 |
"Modified: 28.5.1996 / 20:18:28 / cg" |
|
148 |
! |
|
149 |
||
150 |
initiateHelpFor:aView at:aPointOrNil now:showItNow |
|
151 |
"ask aView for helpText, passing x/y coordinates; |
|
152 |
start a timeout process to display this helpText after some delay; |
|
153 |
Normally used internally, but can also be used by widgets to force |
|
154 |
re-negotiation of the displayed helpText |
|
155 |
(for example in a menu, when the selection changes)" |
|
156 |
||
157 |
|text| |
|
158 |
||
159 |
(self interestedIn:aView) ifFalse:[ |
|
160 |
^ self |
|
161 |
]. |
|
162 |
||
163 |
text := self helpTextFor:aView at:aPointOrNil. |
|
164 |
lastHelpText = text ifTrue:[ |
|
165 |
^ self |
|
166 |
]. |
|
167 |
||
168 |
text size > 0 ifTrue:[ |
|
169 |
(showItNow not and:[DelayTime > 0]) ifTrue:[ |
|
170 |
self stopHelpDisplayProcess. |
|
171 |
showProcess := [ |
|
172 |
Delay waitForSeconds:DelayTime. |
|
173 |
showProcess := nil. |
|
174 |
self showHelp:text for:aView |
|
175 |
] forkAt:(Processor userSchedulingPriority + 1). |
|
176 |
] ifFalse:[ |
|
177 |
self showHelp:text for:aView |
|
178 |
] |
|
1542 | 179 |
] ifFalse:[ |
180 |
self hideHelp |
|
1536 | 181 |
]. |
182 |
! |
|
183 |
||
184 |
interestedIn:aView |
|
185 |
"return true, if I am interested in aView (either listeningForAll, |
|
186 |
or in my list of apps)" |
|
187 |
||
188 |
aView isNil ifTrue:[^ false]. |
|
189 |
aView topView == currentHelpView ifTrue:[^ false]. |
|
190 |
||
191 |
^ super interestedIn:aView |
|
192 |
! ! |
|
193 |
||
1768 | 194 |
!FlyByHelp methodsFor:'show & hide help'! |
1536 | 195 |
|
196 |
hideHelp |
|
197 |
"hide the help text" |
|
198 |
||
199 |
|p| |
|
200 |
||
1540 | 201 |
lastHelpText := nil. |
1536 | 202 |
self stopHelpDisplayProcess. |
203 |
||
204 |
currentHelpView notNil ifTrue:[ |
|
205 |
[ |
|
206 |
currentHelpView destroy. |
|
207 |
currentHelpView := nil. |
|
208 |
currentView := nil. |
|
209 |
] valueUninterruptably |
|
210 |
]. |
|
211 |
currentFrame := nil. |
|
212 |
closeProcess notNil ifTrue:[ |
|
213 |
p := closeProcess. closeProcess := nil. |
|
214 |
p terminate. |
|
215 |
] |
|
216 |
||
217 |
"Modified: 28.6.1997 / 14:03:50 / cg" |
|
218 |
! |
|
219 |
||
220 |
showHelp:aHelpText for:view |
|
221 |
"show the help text for aView" |
|
222 |
||
223 |
|org p v dev| |
|
224 |
||
225 |
view == currentView ifTrue:[ |
|
226 |
lastHelpText = aHelpText ifTrue:[ |
|
227 |
^ self |
|
228 |
] |
|
229 |
]. |
|
230 |
||
231 |
lastHelpText := aHelpText. |
|
232 |
||
233 |
closeProcess notNil ifTrue:[ |
|
234 |
p := closeProcess. closeProcess := nil. |
|
235 |
p terminate. |
|
236 |
]. |
|
237 |
currentHelpView notNil ifTrue:[ |
|
238 |
self hideHelp |
|
239 |
]. |
|
240 |
||
241 |
org := view originRelativeTo:nil. |
|
242 |
currentFrame := org extent:view extent. |
|
243 |
org :=org + (view extent // 2). |
|
244 |
||
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
245 |
dev := view graphicsDevice. |
1536 | 246 |
|
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
247 |
v := ActiveHelpView for:aHelpText withCRs onDevice:dev. |
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
248 |
|
1536 | 249 |
org := dev pointerPosition. |
1657 | 250 |
org := org + (0@18"24"). |
1536 | 251 |
(org x + v width) > dev width ifTrue:[ |
252 |
org := (org x - v width) @ org y |
|
253 |
]. |
|
254 |
(org y + v height) > dev height ifTrue:[ |
|
255 |
org := org x @ (org y - v height). |
|
256 |
]. |
|
257 |
||
258 |
v origin:org. |
|
259 |
"/ currentHelpView open. |
|
260 |
v realize. |
|
261 |
v enableButtonMotionEvents. |
|
262 |
v enableMotionEvents. |
|
263 |
currentHelpView := v. |
|
264 |
||
265 |
currentView := view. |
|
266 |
closeProcess := [ |
|
267 |
[ |
|
1546 | 268 |
(Delay forSeconds:ShowTime) wait. |
269 |
[ |
|
270 |
currentHelpView notNil ifTrue:[ |
|
271 |
currentHelpView destroy. |
|
272 |
currentHelpView := nil. |
|
273 |
] |
|
274 |
] valueUninterruptably |
|
1576
ff6cb0701733
Use #ifCurtailed: instead of #valueOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
1546
diff
changeset
|
275 |
] ifCurtailed:[ |
1546 | 276 |
closeProcess := nil. |
277 |
]. |
|
278 |
] newProcess. |
|
279 |
closeProcess priority:(Processor userSchedulingPriority + 1). |
|
280 |
closeProcess resume. |
|
1536 | 281 |
|
1546 | 282 |
"Modified: / 31.8.1995 / 19:20:45 / claus" |
283 |
"Modified: / 10.12.2001 / 21:28:26 / cg" |
|
1536 | 284 |
! |
285 |
||
286 |
stopHelpDisplayProcess |
|
287 |
|p| |
|
288 |
||
289 |
showProcess notNil ifTrue:[ |
|
290 |
p := showProcess. showProcess := nil. |
|
291 |
p terminate. |
|
292 |
]. |
|
293 |
||
294 |
"Created: 28.6.1997 / 14:03:17 / cg" |
|
295 |
! ! |
|
296 |
||
297 |
!FlyByHelp class methodsFor:'documentation'! |
|
298 |
||
299 |
version |
|
1802 | 300 |
^ '$Header: /cvs/stx/stx/libview2/FlyByHelp.st,v 1.10 2003-08-29 19:34:08 cg Exp $' |
1536 | 301 |
! ! |
1657 | 302 |
|
1536 | 303 |
FlyByHelp initialize! |