author | Claus Gittinger <cg@exept.de> |
Wed, 11 May 2016 01:30:12 +0200 | |
changeset 3675 | c7ba11759026 |
parent 3656 | de582c82fa70 |
child 3681 | c56b665d08a7 |
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 |
||
3656 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1536 | 16 |
ActiveHelp subclass:#FlyByHelp |
2680 | 17 |
instanceVariableNames:'currentFrame currentView currentHelpView showProcess closeProcess' |
3255 | 18 |
classVariableNames:'MaxNumberOfLines MaxNumberOfColumns' |
1536 | 19 |
poolDictionaries:'' |
20 |
category:'Interface-Help' |
|
21 |
! |
|
22 |
||
1802 | 23 |
!FlyByHelp class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2001 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
1893 | 37 |
! |
38 |
||
39 |
examples |
|
40 |
" |
|
3220 | 41 |
UserPreferences current toolTipShapeStyle:nil |
42 |
UserPreferences current toolTipShapeStyle:#cartoon |
|
43 |
||
1893 | 44 |
FlyByHelp isActive |
45 |
||
46 |
FlyByHelp stop |
|
47 |
FlyByHelp start |
|
48 |
" |
|
1802 | 49 |
! ! |
1536 | 50 |
|
2692 | 51 |
!FlyByHelp class methodsFor:'accessing'! |
52 |
||
53 |
currentlyShownView |
|
2846
e90ba00f9df1
changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents:
2826
diff
changeset
|
54 |
TheOneAndOnlyHelpListener isNil ifTrue:[^ nil]. |
2692 | 55 |
^ TheOneAndOnlyHelpListener currentlyShownView |
2846
e90ba00f9df1
changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents:
2826
diff
changeset
|
56 |
|
e90ba00f9df1
changed: #currentlyShownView
Claus Gittinger <cg@exept.de>
parents:
2826
diff
changeset
|
57 |
"Modified: / 09-06-2010 / 16:35:48 / cg" |
3255 | 58 |
! |
59 |
||
60 |
maxNumberOfColumns |
|
61 |
^ MaxNumberOfColumns ? 200 |
|
62 |
! |
|
63 |
||
64 |
maxNumberOfLines |
|
65 |
^ MaxNumberOfLines ? 40 |
|
2692 | 66 |
! ! |
67 |
||
2684 | 68 |
!FlyByHelp methodsFor:'defaults'! |
69 |
||
70 |
flyByHelpTimeoutMillis |
|
71 |
"abort flyby help text generation, if no text can be generated within that |
|
72 |
time delta. This is used to abort long-lasting parsing/scanning/analysis in |
|
73 |
large methods when the mouse is moved over some syntactic constructs, and |
|
74 |
it takes too long to parse... |
|
75 |
The returned time is given in ms" |
|
76 |
||
77 |
^ 300 |
|
78 |
! ! |
|
79 |
||
2392 | 80 |
!FlyByHelp methodsFor:'event handling'! |
1540 | 81 |
|
2474 | 82 |
buttonMotion:buttonAndModifierState x:x y:y view:aView |
2519 | 83 |
aView == currentHelpView ifTrue:[ |
84 |
"/ the help-bubble itself |
|
85 |
^ false |
|
86 |
]. |
|
87 |
||
2518 | 88 |
"/ don't start tooltip, if this view is not active |
3243 | 89 |
"/ does not work, because motion events are reported for the current focus-view, |
3321 | 90 |
"/ which is always active. Must check after we have determined the view under the pointer |
3675 | 91 |
"/ aView topView isActive ifFalse:[^ false]. |
2477
b009e0b51999
suppress tooltip for inactive (lower) windows
Claus Gittinger <cg@exept.de>
parents:
2474
diff
changeset
|
92 |
|
2474 | 93 |
^ super buttonMotion:buttonAndModifierState x:x y:y view:aView |
1540 | 94 |
! |
95 |
||
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
96 |
buttonPress:button x:x y:y view:aView |
3198 | 97 |
|prevView| |
98 |
||
99 |
"/ hideHelp nils the currentView |
|
100 |
"/ we restore it, so the tooltip is not shown again for this view |
|
101 |
"/ until the mouse really leaves the view |
|
102 |
"/ let's call this the "do-not-show-in-this-view mode" |
|
103 |
prevView := currentView. |
|
2978
4358a9302b95
changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
104 |
self hideHelp. |
3198 | 105 |
currentView := prevView. |
106 |
||
107 |
^ false |
|
2978
4358a9302b95
changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
108 |
|
4358a9302b95
changed: #buttonPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2925
diff
changeset
|
109 |
"Modified: / 23-12-2011 / 20:37:28 / cg" |
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
110 |
! |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
111 |
|
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
112 |
keyPress:key x:x y:y view:aView |
3216 | 113 |
<resource: #keyboard (#Escape)> |
114 |
||
3198 | 115 |
|prevView| |
116 |
||
2885
a70144d85a81
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2884
diff
changeset
|
117 |
currentHelpView notNil ifTrue:[ |
2925
352825e1163c
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2920
diff
changeset
|
118 |
key == $§ ifTrue:[ |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
119 |
"/ generate a line suitable for the resources file (a null translation) |
3216 | 120 |
"/ into the clipboard; makes it easy to add missing translations to a .rs file, |
121 |
"/ by pressing paragrapj whenever you see an untranslated helptext |
|
2885
a70144d85a81
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2884
diff
changeset
|
122 |
aView setClipboardText:(lastHelpText storeString , ' ' , lastHelpText storeString). |
2612 | 123 |
self hideHelp. |
124 |
^ true |
|
125 |
]. |
|
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
126 |
key == #Escape ifTrue:[ |
3198 | 127 |
prevView := currentView. |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
128 |
self hideHelp. |
3198 | 129 |
currentView := prevView. |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
130 |
^ true |
2885
a70144d85a81
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2884
diff
changeset
|
131 |
]. |
3216 | 132 |
(#('Shift' #'Shift_L' #'Shift_R') includes:key) ifTrue:[ |
133 |
"/ do not close on those... |
|
134 |
^ false |
|
135 |
]. |
|
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
136 |
]. |
3198 | 137 |
|
138 |
"/ hideHelp nils the currentView |
|
139 |
"/ we restore it, so the tooltip is not shown again for this view |
|
140 |
"/ until the mouse really leaves the view |
|
141 |
"/ let's call this the "do-not-show-in-this-view mode" |
|
142 |
prevView := currentView. |
|
143 |
self hideHelpIgnoringErrors. |
|
144 |
currentView := prevView. |
|
145 |
||
146 |
^ false |
|
147 |
"/ ^ super keyPress:key x:x y:y view:aView |
|
2884
7d37f5a0719e
changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2878
diff
changeset
|
148 |
|
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
149 |
"Modified (format): / 25-12-2011 / 10:25:23 / cg" |
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
150 |
! |
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
151 |
|
2521
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
152 |
mouseWheelMotion:state x:x y:y amount:amount deltaTime:dTime view:aView |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
153 |
currentHelpView notNil ifTrue:[ |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
154 |
self handleMouseIn:aView x:x y:y. |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
155 |
]. |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
156 |
^ false |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
157 |
! |
7e51aa294156
care for mousewheel while showing help
Claus Gittinger <cg@exept.de>
parents:
2519
diff
changeset
|
158 |
|
1540 | 159 |
pointerLeave:state view:aView |
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
160 |
aView == currentHelpView ifTrue:[^ true]. |
3198 | 161 |
|
162 |
"/ clear the do-not-show-in-this-view mode (see keyPress) |
|
163 |
"/ (currentHelpView isNil and:[currentView notNil]) ifTrue:[currentView := nil]. |
|
164 |
||
2611
f578b9c43a6f
handle escape key to close flyByHelp
Claus Gittinger <cg@exept.de>
parents:
2521
diff
changeset
|
165 |
^ super pointerLeave:state view:aView |
1540 | 166 |
! ! |
167 |
||
2392 | 168 |
!FlyByHelp methodsFor:'help texts'! |
1536 | 169 |
|
170 |
helpTextFromModel:aModel view:aView at:aPointOrNil |
|
171 |
"helper: ask aModel for its helpText." |
|
172 |
||
173 |
|text| |
|
174 |
||
175 |
aPointOrNil notNil ifTrue:[ |
|
176 |
(aModel respondsTo:#flyByHelpTextFor:at:) ifTrue:[ |
|
177 |
text := aModel flyByHelpTextFor:aView at:aPointOrNil. |
|
2754 | 178 |
text notNil ifTrue:[^ text]. |
1536 | 179 |
]. |
180 |
]. |
|
2754 | 181 |
(aModel respondsTo:#flyByHelpTextFor:) ifTrue:[ |
182 |
text := aModel flyByHelpTextFor:aView. |
|
183 |
text notNil ifTrue:[^ text]. |
|
1536 | 184 |
]. |
2754 | 185 |
^ nil |
1536 | 186 |
! |
187 |
||
188 |
helpTextFromView:aView at:aPointOrNil |
|
189 |
"helper: ask aView for its helpText." |
|
190 |
||
2754 | 191 |
|text key app| |
1536 | 192 |
|
193 |
aPointOrNil notNil ifTrue:[ |
|
194 |
(aView respondsTo:#flyByHelpTextAt:) ifTrue:[ |
|
195 |
text := aView flyByHelpTextAt:aPointOrNil. |
|
2754 | 196 |
text notNil ifTrue:[^ text]. |
1536 | 197 |
]. |
198 |
]. |
|
2754 | 199 |
(aView respondsTo:#flyByHelpText) ifTrue:[ |
200 |
text := aView flyByHelpText. |
|
201 |
text notNil ifTrue:[^ text]. |
|
202 |
]. |
|
203 |
(aView respondsTo:#helpKey) ifTrue:[ |
|
204 |
key := aView helpKey. |
|
205 |
key notNil ifTrue:[ |
|
206 |
app := aView application. |
|
207 |
app isNil ifTrue:[ |
|
208 |
app := Error handle:[:ex | nil] do:[ aView windowGroup mainGroup application ]. |
|
209 |
]. |
|
210 |
app notNil ifTrue:[ |
|
211 |
^ app flyByHelpTextForKey:key |
|
212 |
]. |
|
213 |
^ aView resources string:key |
|
1536 | 214 |
]. |
215 |
]. |
|
2754 | 216 |
^ nil. |
2392 | 217 |
! ! |
218 |
||
219 |
!FlyByHelp methodsFor:'private'! |
|
1536 | 220 |
|
221 |
hideIfPointerLeft:aView |
|
222 |
"hide help, if the pointer is not in aView" |
|
223 |
||
224 |
|whereOnScreen| |
|
225 |
||
226 |
currentFrame notNil ifTrue:[ |
|
227 |
whereOnScreen := aView graphicsDevice pointerPosition. |
|
228 |
||
229 |
(currentFrame notNil |
|
230 |
and:[(currentFrame insetBy:1@1) containsPoint:whereOnScreen]) ifFalse:[ |
|
231 |
self hideHelp. |
|
232 |
]. |
|
233 |
]. |
|
234 |
||
235 |
"Modified: 28.5.1996 / 20:18:28 / cg" |
|
236 |
! |
|
237 |
||
238 |
initiateHelpFor:aView at:aPointOrNil now:showItNow |
|
239 |
"ask aView for helpText, passing x/y coordinates; |
|
240 |
start a timeout process to display this helpText after some delay; |
|
241 |
Normally used internally, but can also be used by widgets to force |
|
242 |
re-negotiation of the displayed helpText |
|
243 |
(for example in a menu, when the selection changes)" |
|
244 |
||
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
245 |
|text delayTime now| |
1536 | 246 |
|
247 |
(self interestedIn:aView) ifFalse:[ |
|
248 |
^ self |
|
249 |
]. |
|
250 |
||
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
251 |
now := Timestamp now. |
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
252 |
|
2680 | 253 |
"/ do not allow for more than 200 ms to be spent in the |
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
254 |
"/ helpText gatherer (the codeView parses the code for the variable under the cursor) |
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
255 |
[ |
2826
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
256 |
Error handle:[:ex | |
3394 | 257 |
('FlyByhelp [warning]: error while asking for helpText: ',ex description) errorPrintCR. |
3675 | 258 |
Transcript showCR:'-------------------------'. |
3394 | 259 |
ex suspendedContext fullPrintAllOn:Transcript. |
2872
ea7e6fe01727
comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
260 |
"/ self halt. |
2826
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
261 |
] do:[ |
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
262 |
text := self helpTextFor:aView at:aPointOrNil. |
74bd82edee5a
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2799
diff
changeset
|
263 |
]. |
3656 | 264 |
] valueWithWatchDog:[ |
265 |
'FlyByhelp [info]: flyBy text generation took too long' infoPrintCR. |
|
266 |
^ self |
|
267 |
] afterMilliseconds:(self flyByHelpTimeoutMillis). |
|
2679
552847065fb3
car not to hog the cpu by flyByHelp processing
Claus Gittinger <cg@exept.de>
parents:
2651
diff
changeset
|
268 |
|
1536 | 269 |
lastHelpText = text ifTrue:[ |
3228 | 270 |
lastHelpWidget == aView ifTrue:[ |
271 |
self toolTipFollowsMouse ifFalse:[ |
|
272 |
^ self |
|
273 |
] |
|
2392 | 274 |
] |
1536 | 275 |
]. |
276 |
||
277 |
text size > 0 ifTrue:[ |
|
2778 | 278 |
(showItNow not and:[(delayTime := self delayTime) > 0]) ifTrue:[ |
1536 | 279 |
self stopHelpDisplayProcess. |
2392 | 280 |
showProcess := |
281 |
[ |
|
2680 | 282 |
Delay waitForSeconds:delayTime. |
2774
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
283 |
[ |
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
284 |
aView device anyButtonPressed ifFalse:[ |
2777
4cdef981fdb3
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2774
diff
changeset
|
285 |
showProcess := nil. |
2774
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
286 |
self showHelp:text for:aView |
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
287 |
] |
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
288 |
] ensure:[ |
7894ba397774
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2754
diff
changeset
|
289 |
showProcess := nil. |
2680 | 290 |
] |
2392 | 291 |
] forkAt:(Processor userSchedulingPriority + 1). |
1536 | 292 |
] ifFalse:[ |
293 |
self showHelp:text for:aView |
|
294 |
] |
|
1542 | 295 |
] ifFalse:[ |
296 |
self hideHelp |
|
1536 | 297 |
]. |
2872
ea7e6fe01727
comment/format in: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2848
diff
changeset
|
298 |
|
2901
fed697afcef8
changed: #initiateHelpFor:at:now:
Claus Gittinger <cg@exept.de>
parents:
2900
diff
changeset
|
299 |
"Modified: / 22-03-2011 / 19:10:28 / cg" |
1536 | 300 |
! ! |
301 |
||
2392 | 302 |
!FlyByHelp methodsFor:'queries'! |
303 |
||
2692 | 304 |
currentlyShownView |
305 |
^ currentHelpView |
|
306 |
! |
|
307 |
||
2392 | 308 |
toolTipFollowsMouse |
3675 | 309 |
"if true, the tooltip-window moves with the pointer |
310 |
so that it stays away from (does not cover) the mouse pointer" |
|
311 |
||
2392 | 312 |
^ false |
313 |
! ! |
|
314 |
||
1768 | 315 |
!FlyByHelp methodsFor:'show & hide help'! |
1536 | 316 |
|
3248
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
317 |
activeHelpViewForApplication:applicationOrNil text:helpText onDevice:aDevice |
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
318 |
applicationOrNil notNil ifTrue:[ |
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
319 |
^ applicationOrNil activeHelpViewFor:helpText onDevice:aDevice |
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
320 |
]. |
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
321 |
^ ActiveHelpView for:helpText onDevice:aDevice. |
3656 | 322 |
|
323 |
" |
|
324 |
(ActiveHelpView for:'Hello' onDevice:Display) open |
|
325 |
" |
|
3248
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
326 |
! |
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
327 |
|
1536 | 328 |
hideHelp |
329 |
"hide the help text" |
|
330 |
||
331 |
|p| |
|
332 |
||
3198 | 333 |
"/ lastHelpText := nil. |
1536 | 334 |
self stopHelpDisplayProcess. |
3258 | 335 |
lastHelpText := nil. |
1536 | 336 |
|
337 |
currentHelpView notNil ifTrue:[ |
|
338 |
[ |
|
2780 | 339 |
currentHelpView notNil ifTrue:[ |
340 |
currentHelpView unmap. |
|
341 |
currentHelpView destroy. |
|
342 |
currentHelpView := nil. |
|
343 |
currentView := nil. |
|
344 |
] |
|
1536 | 345 |
] valueUninterruptably |
346 |
]. |
|
347 |
currentFrame := nil. |
|
3198 | 348 |
(p := closeProcess) notNil ifTrue:[ |
349 |
closeProcess := nil. |
|
1536 | 350 |
p terminate. |
351 |
] |
|
352 |
||
353 |
"Modified: 28.6.1997 / 14:03:50 / cg" |
|
354 |
! |
|
355 |
||
356 |
showHelp:aHelpText for:view |
|
357 |
"show the help text for aView" |
|
358 |
||
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
359 |
|wg applicationOrNil org p v dev helpTextShown textLines |
3334 | 360 |
helpViewWidth helpViewHeight usableWidth monitorBounds usableHeight |
3418 | 361 |
showTime cursorView| |
1536 | 362 |
|
2781 | 363 |
"/ thisContext fullPrintAllOn:Transcript. |
2651 | 364 |
(wg := view windowGroup) notNil ifTrue:[ |
365 |
wg isInModalLoop ifTrue:[ |
|
366 |
wg isModal ifFalse:[ |
|
367 |
^ self |
|
368 |
]. |
|
2628
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
369 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
370 |
]. |
03a41945fb37
do not show flyBy help for a view,
Claus Gittinger <cg@exept.de>
parents:
2612
diff
changeset
|
371 |
|
3418 | 372 |
"/ mouse still over that view? |
373 |
cursorView := view graphicsDevice viewFromPoint:(view graphicsDevice cursorPoint). |
|
374 |
cursorView ~~ view ifTrue:[ |
|
375 |
Debugging ifTrue:[ 'mouse no longer in view' infoPrintCR ]. |
|
376 |
^ self |
|
377 |
]. |
|
378 |
||
1536 | 379 |
view == currentView ifTrue:[ |
380 |
lastHelpText = aHelpText ifTrue:[ |
|
381 |
^ self |
|
382 |
] |
|
383 |
]. |
|
3228 | 384 |
lastHelpWidget := view. |
1536 | 385 |
|
386 |
lastHelpText := aHelpText. |
|
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
387 |
helpTextShown := aHelpText. |
3257 | 388 |
"/ the text originator must already have generated CRs; |
389 |
"/ no longer done here (otherwise, we could not generate tooltips with windows filenames in it) |
|
390 |
textLines := helpTextShown "withCRs" asCollectionOfLines asStringCollection. |
|
3255 | 391 |
textLines size > (self class maxNumberOfLines) ifTrue:[ |
392 |
textLines := (textLines copyTo:(self class maxNumberOfLines)) copyWith:'...' |
|
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
393 |
]. |
3255 | 394 |
textLines := textLines collect:[:l | l contractAtEndTo:(self class maxNumberOfColumns)]. |
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
395 |
helpTextShown := textLines asString. |
1536 | 396 |
|
2780 | 397 |
(p := closeProcess) notNil ifTrue:[ |
398 |
closeProcess := nil. |
|
1536 | 399 |
p terminate. |
400 |
]. |
|
401 |
currentHelpView notNil ifTrue:[ |
|
402 |
self hideHelp |
|
403 |
]. |
|
404 |
||
405 |
org := view originRelativeTo:nil. |
|
406 |
currentFrame := org extent:view extent. |
|
2848 | 407 |
org := org + (view extent // 2). |
1536 | 408 |
|
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
409 |
dev := view graphicsDevice. |
3248
d72c8e4f7684
more control over the shape style
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
410 |
wg notNil ifTrue:[ applicationOrNil := wg application ]. |
3251
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
411 |
v := self activeHelpViewForApplication:applicationOrNil text:helpTextShown onDevice:dev. |
afc7d588b25b
handle key press and close help.
Claus Gittinger <cg@exept.de>
parents:
3248
diff
changeset
|
412 |
v perform:#controllingHelpListener: with:self ifNotUnderstood:[]. |
1536 | 413 |
|
2848 | 414 |
helpViewWidth := v width. |
415 |
helpViewHeight := v height. |
|
1677
dc49ab70b762
open helpView on the correcdt device
Claus Gittinger <cg@exept.de>
parents:
1657
diff
changeset
|
416 |
|
3114 | 417 |
org := dev pointerPosition + (0@18"24"). |
418 |
monitorBounds := dev monitorBoundsAt:org. |
|
419 |
usableWidth := monitorBounds width - 2. |
|
420 |
usableHeight := dev usableHeightAt:org. |
|
421 |
||
422 |
helpViewWidth > usableWidth ifTrue:[v width:(helpViewWidth := usableWidth)]. |
|
3247 | 423 |
helpViewHeight > usableHeight ifTrue:[v height:(helpViewHeight := usableHeight)]. |
3114 | 424 |
|
425 |
(org x + helpViewWidth) > (monitorBounds left + usableWidth) ifTrue:[ |
|
426 |
org := ((monitorBounds left + usableWidth - helpViewWidth) @ org y). |
|
1536 | 427 |
]. |
3114 | 428 |
(org y + helpViewHeight) > (monitorBounds top + usableHeight) ifTrue:[ |
429 |
org := org x @ (monitorBounds top + usableHeight - helpViewHeight). |
|
1536 | 430 |
]. |
431 |
||
432 |
v origin:org. |
|
433 |
v realize. |
|
434 |
v enableButtonMotionEvents. |
|
435 |
v enableMotionEvents. |
|
436 |
currentHelpView := v. |
|
2392 | 437 |
currentView := view. |
1536 | 438 |
|
3334 | 439 |
showTime := self showTime. |
440 |
(showTime notNil and:[showTime > 0]) ifTrue:[ |
|
2392 | 441 |
closeProcess := [ |
1546 | 442 |
[ |
3334 | 443 |
(Delay forSeconds:showTime) wait. |
2392 | 444 |
[ |
2780 | 445 |
|v| |
446 |
(v := currentHelpView) notNil ifTrue:[ |
|
2392 | 447 |
currentHelpView := nil. |
2780 | 448 |
v unmap. |
449 |
v destroy. |
|
2392 | 450 |
] |
451 |
] valueUninterruptably |
|
452 |
] ifCurtailed:[ |
|
453 |
closeProcess := nil. |
|
454 |
]. |
|
455 |
] newProcess. |
|
456 |
closeProcess priority:(Processor userSchedulingPriority + 1). |
|
457 |
closeProcess resume. |
|
458 |
]. |
|
1536 | 459 |
|
1963
fb6663696d20
removed withCRs in showHelp:
Claus Gittinger <cg@exept.de>
parents:
1893
diff
changeset
|
460 |
"Modified: / 31-08-1995 / 19:20:45 / claus" |
2848 | 461 |
"Modified: / 16-07-2010 / 14:33:13 / cg" |
1536 | 462 |
! |
463 |
||
464 |
stopHelpDisplayProcess |
|
465 |
|p| |
|
466 |
||
2680 | 467 |
(p := showProcess) notNil ifTrue:[ |
468 |
showProcess := nil. |
|
1536 | 469 |
p terminate. |
470 |
]. |
|
471 |
||
472 |
"Created: 28.6.1997 / 14:03:17 / cg" |
|
473 |
! ! |
|
474 |
||
475 |
!FlyByHelp class methodsFor:'documentation'! |
|
476 |
||
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
477 |
version |
3656 | 478 |
^ '$Header$' |
2979
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
479 |
! |
306456bdfb61
comment in: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents:
2978
diff
changeset
|
480 |
|
2754 | 481 |
version_CVS |
3656 | 482 |
^ '$Header$' |
1536 | 483 |
! ! |
3114 | 484 |