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