59
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
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 |
|
|
13 |
|
|
14 |
'From Smalltalk/X, Version:2.10.5 on 26-mar-1995 at 10:19:20 am'!
|
|
15 |
|
|
16 |
EventListener subclass:#ActiveHelp
|
|
17 |
instanceVariableNames:'currentView currentHelpView currentFrame closeProcess'
|
|
18 |
classVariableNames:'ShowTime TheOneAndOnlyHelpListener'
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Interface-Help'
|
|
21 |
!
|
|
22 |
|
|
23 |
!ActiveHelp class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
version
|
|
26 |
"
|
|
27 |
$Header: /cvs/stx/stx/libview2/ActiveHelp.st,v 1.1 1995-03-31 03:08:53 claus Exp $
|
|
28 |
"
|
|
29 |
!
|
|
30 |
|
|
31 |
documentation
|
|
32 |
"
|
|
33 |
The active help listener
|
|
34 |
"
|
|
35 |
!
|
|
36 |
|
|
37 |
copyright
|
|
38 |
"
|
|
39 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
40 |
All Rights Reserved
|
|
41 |
|
|
42 |
This software is furnished under a license and may be used
|
|
43 |
only in accordance with the terms of that license and with the
|
|
44 |
inclusion of the above copyright notice. This software may not
|
|
45 |
be provided or otherwise made available to, or used by, any
|
|
46 |
other person. No title to or ownership of the software is
|
|
47 |
hereby transferred.
|
|
48 |
"
|
|
49 |
|
|
50 |
! !
|
|
51 |
|
|
52 |
!ActiveHelp class methodsFor:'initialization'!
|
|
53 |
|
|
54 |
initialize
|
|
55 |
ShowTime := 15
|
|
56 |
! !
|
|
57 |
|
|
58 |
!ActiveHelp class methodsFor:'startup'!
|
|
59 |
|
|
60 |
start
|
|
61 |
TheOneAndOnlyHelpListener isNil ifTrue:[
|
|
62 |
TheOneAndOnlyHelpListener := self new.
|
|
63 |
].
|
|
64 |
TheOneAndOnlyHelpListener listen
|
|
65 |
|
|
66 |
"
|
|
67 |
ActiveHelp start
|
|
68 |
"
|
|
69 |
!
|
|
70 |
|
|
71 |
stop
|
|
72 |
TheOneAndOnlyHelpListener notNil ifTrue:[
|
|
73 |
TheOneAndOnlyHelpListener unlisten.
|
|
74 |
].
|
|
75 |
|
|
76 |
"
|
|
77 |
ActiveHelp stop
|
|
78 |
"
|
|
79 |
|
|
80 |
!
|
|
81 |
|
|
82 |
release
|
|
83 |
self stop.
|
|
84 |
TheOneAndOnlyHelpListener := nil
|
|
85 |
|
|
86 |
"
|
|
87 |
ActiveHelp release
|
|
88 |
"
|
|
89 |
! !
|
|
90 |
|
|
91 |
!ActiveHelp methodsFor:'private'!
|
|
92 |
|
|
93 |
helpTextFor:aView atX:x y:y
|
|
94 |
|model text view org found v sv|
|
|
95 |
|
|
96 |
view := aView.
|
|
97 |
|
|
98 |
(model := aView model) notNil ifTrue:[
|
|
99 |
"/ model printNL.
|
|
100 |
(model respondsTo:#helpTextFor:at:) ifTrue:[
|
|
101 |
text := model helpTextFor:aView at:x@y.
|
|
102 |
text notNil ifTrue:[^ text].
|
|
103 |
].
|
|
104 |
(model respondsTo:#helpTextFor:) ifTrue:[
|
|
105 |
text := model helpTextFor:aView.
|
|
106 |
text notNil ifTrue:[^ text].
|
|
107 |
]
|
|
108 |
].
|
|
109 |
|
|
110 |
(aView respondsTo:#helpText) ifTrue:[
|
|
111 |
text := aView helpText.
|
|
112 |
text notNil ifTrue:[^ text].
|
|
113 |
].
|
|
114 |
|
|
115 |
"walk up the chain - maybe someone knows about its subview ..."
|
|
116 |
v := aView.
|
|
117 |
|
|
118 |
[(sv := v superView) notNil] whileTrue:[
|
|
119 |
(model := sv model) notNil ifTrue:[
|
|
120 |
(model respondsTo:#helpTextFor:at:) ifTrue:[
|
|
121 |
text := model helpTextFor:aView at:x@y.
|
|
122 |
text notNil ifTrue:[^ text].
|
|
123 |
].
|
|
124 |
(model respondsTo:#helpTextFor:) ifTrue:[
|
|
125 |
text := model helpTextFor:aView.
|
|
126 |
text notNil ifTrue:[^ text].
|
|
127 |
]
|
|
128 |
].
|
|
129 |
|
|
130 |
(sv respondsTo:#helpTextFor:) ifTrue:[
|
|
131 |
text := sv helpTextFor:aView.
|
|
132 |
text notNil ifTrue:[^ text].
|
|
133 |
text := sv helpTextFor:v.
|
|
134 |
text notNil ifTrue:[^ text].
|
|
135 |
].
|
|
136 |
v := sv.
|
|
137 |
].
|
|
138 |
|
|
139 |
(view class respondsTo:#helpText) ifTrue:[
|
|
140 |
text := view class helpText.
|
|
141 |
text notNil ifTrue:[^ text].
|
|
142 |
].
|
|
143 |
|
|
144 |
^ nil
|
|
145 |
!
|
|
146 |
|
|
147 |
hideIfPointerLeft:aView
|
|
148 |
|whereOnScreen|
|
|
149 |
|
|
150 |
whereOnScreen := aView device pointerPosition.
|
|
151 |
|
|
152 |
(currentFrame notNil
|
|
153 |
and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[
|
|
154 |
self hideHelp.
|
|
155 |
currentView := nil
|
|
156 |
].
|
|
157 |
|
|
158 |
! !
|
|
159 |
|
|
160 |
!ActiveHelp methodsFor:'listening'!
|
|
161 |
|
|
162 |
buttonPress:state x:x y:y view:view
|
|
163 |
self hideHelp.
|
|
164 |
^ false
|
|
165 |
!
|
|
166 |
|
|
167 |
pointerEnter:state x:x y:y view:aView
|
|
168 |
|text|
|
|
169 |
|
|
170 |
self hideIfPointerLeft:aView.
|
|
171 |
aView topView == currentHelpView ifTrue:[
|
|
172 |
^ true
|
|
173 |
].
|
|
174 |
|
|
175 |
text := self helpTextFor:aView atX:x y:y.
|
|
176 |
|
|
177 |
text notNil ifTrue:[
|
|
178 |
self showHelp:text for:aView
|
|
179 |
].
|
|
180 |
|
|
181 |
^ false
|
|
182 |
!
|
|
183 |
|
|
184 |
pointerLeave:state view:view
|
|
185 |
self hideIfPointerLeft:view.
|
|
186 |
^ false
|
|
187 |
!
|
|
188 |
|
|
189 |
keyPress:state x:x y:y view:view
|
|
190 |
self hideHelp.
|
|
191 |
^ false
|
|
192 |
!
|
|
193 |
|
|
194 |
buttonMotion:state x:x y:y view:view
|
|
195 |
self hideIfPointerLeft:view.
|
|
196 |
^ false
|
|
197 |
! !
|
|
198 |
|
|
199 |
!ActiveHelp methodsFor:'show / hide help'!
|
|
200 |
|
|
201 |
hideHelp
|
|
202 |
currentHelpView notNil ifTrue:[
|
|
203 |
[
|
|
204 |
currentHelpView destroy.
|
|
205 |
currentHelpView := nil.
|
|
206 |
currentView := nil.
|
|
207 |
] valueUninterruptably
|
|
208 |
].
|
|
209 |
currentFrame := nil.
|
|
210 |
closeProcess notNil ifTrue:[
|
|
211 |
closeProcess terminate.
|
|
212 |
]
|
|
213 |
!
|
|
214 |
|
|
215 |
showHelp:aHelpText for:view
|
|
216 |
|org|
|
|
217 |
|
|
218 |
view == currentView ifTrue:[^ self].
|
|
219 |
|
|
220 |
currentHelpView notNil ifTrue:[
|
|
221 |
self hideHelp
|
|
222 |
].
|
|
223 |
|
|
224 |
org := view originRelativeTo:nil.
|
|
225 |
currentFrame := org extent:view extent.
|
|
226 |
org :=org + (view extent // 2).
|
|
227 |
|
|
228 |
org := view device pointerPosition.
|
|
229 |
|
|
230 |
currentHelpView := ActiveHelpView for:aHelpText withCRs.
|
|
231 |
currentHelpView origin:org.
|
|
232 |
"/ currentHelpView open.
|
|
233 |
currentHelpView realize.
|
|
234 |
currentHelpView enableButtonMotionEvents.
|
|
235 |
currentHelpView enableMotionEvents.
|
|
236 |
|
|
237 |
currentView := view.
|
|
238 |
closeProcess := [
|
|
239 |
Process terminateSignal handle:[:ex |
|
|
240 |
closeProcess := nil.
|
|
241 |
] do:[
|
|
242 |
(Delay forSeconds:ShowTime) wait.
|
|
243 |
[
|
|
244 |
currentHelpView notNil ifTrue:[
|
|
245 |
currentHelpView destroy.
|
|
246 |
currentHelpView := nil.
|
|
247 |
]
|
|
248 |
] valueUninterruptably
|
|
249 |
].
|
|
250 |
] forkAt:(Processor userSchedulingPriority + 1).
|
|
251 |
! !
|
|
252 |
|
|
253 |
ActiveHelp initialize!
|