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