author | Claus Gittinger <cg@exept.de> |
Mon, 20 Jan 2020 21:02:47 +0100 | |
changeset 19422 | c6ca1c3e0fd7 |
parent 19304 | 1304be6172f7 |
permissions | -rw-r--r-- |
12908 | 1 |
" |
2 |
COPYRIGHT (c) 2013 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 |
"{ Package: 'stx:libtool' }" |
|
13 |
||
18315 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
12908 | 16 |
View subclass:#CodeCompletionHelpView |
19182 | 17 |
instanceVariableNames:'myView editView delayedCloseAction checkAction |
18 |
closeOnPointerLeave pointerEntered' |
|
12908 | 19 |
classVariableNames:'' |
20 |
poolDictionaries:'' |
|
21 |
category:'Interface-Help' |
|
22 |
! |
|
23 |
||
24 |
!CodeCompletionHelpView class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 2013 by Claus Gittinger |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
13479 | 42 |
used with code completion suggestions |
12908 | 43 |
|
44 |
[author:] |
|
45 |
Claus Gittinger |
|
46 |
||
47 |
[See also:] |
|
13479 | 48 |
ActiveHelp Workspace::CodeCompletionService |
12908 | 49 |
" |
50 |
! ! |
|
51 |
||
52 |
!CodeCompletionHelpView class methodsFor:'instance creation'! |
|
53 |
||
54 |
with:aView |
|
55 |
"create a talking-view wrapping some other view" |
|
56 |
||
57 |
^ self new withView:aView |
|
58 |
||
59 |
" |
|
60 |
(ActiveHelpView with:(TextView new)) realize |
|
61 |
(ActiveHelpView with:(TextView new)) open |
|
62 |
(ActiveHelpView with:(Button label:'ok')) open |
|
63 |
" |
|
64 |
||
65 |
"Modified: 27.4.1996 / 15:14:18 / cg" |
|
66 |
! ! |
|
67 |
||
68 |
!CodeCompletionHelpView methodsFor:'accessing'! |
|
69 |
||
19182 | 70 |
closeOnPointerLeave:aBoolean |
71 |
closeOnPointerLeave := aBoolean. |
|
72 |
! |
|
73 |
||
14152
b13faf727c2c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13670
diff
changeset
|
74 |
editView:aView |
19181 | 75 |
"my code editor view" |
76 |
||
14152
b13faf727c2c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13670
diff
changeset
|
77 |
editView := aView |
b13faf727c2c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13670
diff
changeset
|
78 |
! |
b13faf727c2c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13670
diff
changeset
|
79 |
|
12908 | 80 |
withView:aView |
81 |
"set the component view" |
|
82 |
||
83 |
|fg| |
|
84 |
||
85 |
(aView isKindOf:Label) ifTrue:[ |
|
86 |
aView viewBackground:viewBackground. |
|
87 |
aView backgroundColor:viewBackground. |
|
88 |
(fg := styleSheet colorAt:#'activeHelp.foregroundColor' default:nil) notNil ifTrue:[ |
|
89 |
aView foregroundColor:fg. |
|
90 |
]. |
|
91 |
]. |
|
92 |
self addSubView:aView. |
|
93 |
myView := aView. |
|
94 |
myView borderWidth:0. |
|
95 |
myView origin:(0.0@0.0) corner:(1.0@1.0). |
|
96 |
||
19182 | 97 |
self enableDelegation. |
98 |
||
12908 | 99 |
"Modified: 27.4.1996 / 15:16:46 / cg" |
100 |
! ! |
|
101 |
||
18315 | 102 |
!CodeCompletionHelpView methodsFor:'event handling'! |
103 |
||
18320 | 104 |
delayedClose |
105 |
self delayedUnmap |
|
106 |
||
107 |
"Created: / 05-08-2018 / 03:16:26 / Claus Gittinger" |
|
108 |
! |
|
109 |
||
18319 | 110 |
delayedDestroy |
111 |
(subViews notEmptyOrNil) ifTrue:[ |
|
112 |
self topView destroy |
|
113 |
]. |
|
114 |
^ true |
|
115 |
||
116 |
"Created: / 04-08-2018 / 21:25:48 / Claus Gittinger" |
|
117 |
! |
|
118 |
||
18320 | 119 |
delayedUnmap |
120 |
(subViews notEmptyOrNil) ifTrue:[ |
|
121 |
self topView unmap |
|
122 |
]. |
|
123 |
^ true |
|
124 |
||
125 |
"Created: / 05-08-2018 / 03:12:39 / Claus Gittinger" |
|
126 |
! |
|
127 |
||
19181 | 128 |
focusIn |
129 |
self uninstallDelayedClose. |
|
130 |
||
131 |
"Created: / 04-08-2018 / 10:41:59 / Claus Gittinger" |
|
132 |
"Modified: / 05-08-2018 / 03:12:58 / Claus Gittinger" |
|
133 |
! |
|
134 |
||
18315 | 135 |
focusOut |
18320 | 136 |
self installDelayedClose. |
18315 | 137 |
|
138 |
"Created: / 04-08-2018 / 10:41:59 / Claus Gittinger" |
|
18320 | 139 |
"Modified: / 05-08-2018 / 03:12:58 / Claus Gittinger" |
18315 | 140 |
! |
141 |
||
18316 | 142 |
handlesButtonMotion:state inView:aView |
143 |
^ false |
|
144 |
||
145 |
"Created: / 04-08-2018 / 16:55:09 / Claus Gittinger" |
|
146 |
! |
|
147 |
||
148 |
handlesButtonPress:state inView:aView |
|
149 |
^ false |
|
150 |
||
151 |
"Created: / 04-08-2018 / 16:55:20 / Claus Gittinger" |
|
152 |
! |
|
153 |
||
154 |
handlesButtonRelease:state inView:aView |
|
155 |
^ false |
|
156 |
||
157 |
"Created: / 04-08-2018 / 16:55:24 / Claus Gittinger" |
|
158 |
! |
|
159 |
||
160 |
handlesKeyPress:key inView:aView |
|
19183 | 161 |
^ self realized |
18316 | 162 |
|
163 |
"Created: / 04-08-2018 / 16:54:44 / Claus Gittinger" |
|
164 |
! |
|
165 |
||
166 |
handlesKeyRelease:key inView:aView |
|
167 |
^ false |
|
168 |
||
169 |
"Created: / 04-08-2018 / 16:54:54 / Claus Gittinger" |
|
170 |
! |
|
171 |
||
172 |
handlesPointerEnter:state inView:aView |
|
19183 | 173 |
^ self realized |
174 |
"/ ^ true |
|
18316 | 175 |
|
176 |
"Created: / 04-08-2018 / 16:55:49 / Claus Gittinger" |
|
177 |
! |
|
178 |
||
179 |
handlesPointerLeave:state inView:aView |
|
19183 | 180 |
^ self realized |
181 |
"/ ^ true |
|
18316 | 182 |
|
183 |
"Created: / 04-08-2018 / 16:55:53 / Claus Gittinger" |
|
184 |
! |
|
185 |
||
18320 | 186 |
installDelayedClose |
19181 | 187 |
self uninstallDelayedClose. |
188 |
delayedCloseAction isNil ifTrue:[ |
|
189 |
delayedCloseAction := [ self delayedClose ]. |
|
190 |
]. |
|
191 |
Processor addTimedBlock:delayedCloseAction for:nil afterMilliseconds:750. |
|
18315 | 192 |
|
18320 | 193 |
"Created: / 05-08-2018 / 03:13:23 / Claus Gittinger" |
18588 | 194 |
"Modified: / 14-02-2019 / 02:16:10 / Claus Gittinger" |
18316 | 195 |
! |
196 |
||
197 |
keyPress:key x:x y:y view:aView |
|
18319 | 198 |
key == #Escape ifTrue:[ |
19181 | 199 |
"/ close now |
18449 | 200 |
self delayedClose. |
201 |
^ true. |
|
202 |
]. |
|
203 |
( #( CursorUp CursorDown Return ) includes:key) ifFalse:[ |
|
19181 | 204 |
"/ close soon |
18320 | 205 |
self installDelayedClose. |
19183 | 206 |
^ false. |
18449 | 207 |
]. |
19182 | 208 |
self uninstallDelayedClose. |
209 |
||
18319 | 210 |
"/ (subViews notNil and:[aView == (subViews firstIfEmpty:nil)]) ifTrue:[ |
211 |
"/ self topView destroy |
|
212 |
"/ ]. |
|
213 |
^ false |
|
18316 | 214 |
|
215 |
"Created: / 04-08-2018 / 17:00:33 / Claus Gittinger" |
|
18449 | 216 |
"Modified: / 08-10-2018 / 08:36:52 / Claus Gittinger" |
18316 | 217 |
! |
218 |
||
219 |
pointerEnter:state x:x y:y view:view |
|
19182 | 220 |
(view isComponentOf:myView) ifTrue:[ |
221 |
self uninstallDelayedClose. |
|
222 |
pointerEntered := true. |
|
223 |
]. |
|
18316 | 224 |
^ false |
225 |
||
226 |
"Created: / 04-08-2018 / 17:01:39 / Claus Gittinger" |
|
227 |
! |
|
228 |
||
229 |
pointerLeave:state view:view |
|
19182 | 230 |
(view isComponentOf:myView) ifTrue:[ |
231 |
closeOnPointerLeave ifTrue:[ |
|
232 |
pointerEntered == true ifTrue:[ |
|
233 |
pointerEntered := false. |
|
234 |
self installDelayedClose. |
|
235 |
^ false |
|
236 |
]. |
|
237 |
]. |
|
238 |
]. |
|
18316 | 239 |
^ false |
240 |
||
241 |
"Created: / 04-08-2018 / 16:57:18 / Claus Gittinger" |
|
18320 | 242 |
"Modified: / 05-08-2018 / 03:13:46 / Claus Gittinger" |
19181 | 243 |
! |
244 |
||
245 |
uninstallDelayedClose |
|
19182 | 246 |
closeOnPointerLeave := true. |
19181 | 247 |
delayedCloseAction notNil ifTrue:[ |
248 |
Processor removeTimedBlock:delayedCloseAction. |
|
249 |
]. |
|
250 |
||
251 |
"Created: / 05-08-2018 / 03:13:23 / Claus Gittinger" |
|
252 |
"Modified: / 14-02-2019 / 02:16:10 / Claus Gittinger" |
|
18315 | 253 |
! ! |
254 |
||
12908 | 255 |
!CodeCompletionHelpView methodsFor:'initialization'! |
256 |
||
19183 | 257 |
checkForClosedOrRaisedEditor |
19271 | 258 |
|a p wg| |
18590 | 259 |
|
260 |
(a := checkAction) notNil ifTrue:[ |
|
19271 | 261 |
"/ Transcript showCR:editView. |
262 |
"/ Transcript showCR:editView topView. |
|
18590 | 263 |
(editView isNil |
264 |
or:[editView realized not |
|
19254 | 265 |
or:[editView isReallyShown not |
19232 | 266 |
or:[editView topView shown not |
19271 | 267 |
or:[(wg := editView windowGroup) isNil |
268 |
or:[(p := wg process) isNil |
|
19232 | 269 |
or:[p isDead |
19271 | 270 |
or:[wg anyViewHasFocus not |
271 |
]]]]]]]) ifTrue:[ |
|
18590 | 272 |
self pushEvent:#closeRequest. |
273 |
checkAction := nil. |
|
19183 | 274 |
] ifFalse:[ |
19232 | 275 |
"/ Transcript showCR:'raising...'. |
19271 | 276 |
"/ self inspect. |
19183 | 277 |
self raise. |
18590 | 278 |
Processor addTimedBlock:a for:nil afterSeconds:5. |
279 |
] |
|
280 |
] |
|
281 |
||
282 |
"Created: / 14-02-2019 / 15:33:26 / Claus Gittinger" |
|
283 |
! |
|
284 |
||
19182 | 285 |
enableDelegation |
286 |
|helpMenuView| |
|
287 |
||
288 |
myView notNil ifTrue:[ |
|
289 |
myView isScrollWrapper ifTrue:[ |
|
290 |
helpMenuView := myView scrolledView |
|
291 |
] ifFalse:[ |
|
292 |
helpMenuView := myView |
|
293 |
]. |
|
19209 | 294 |
helpMenuView notNil ifTrue:[ |
295 |
helpMenuView delegate:self. |
|
296 |
helpMenuView enableEnterLeaveEvents. |
|
297 |
helpMenuView enableMotionEvents. |
|
298 |
helpMenuView enableButtonMotionEvents. |
|
299 |
helpMenuView enableFocusEvents. |
|
300 |
]. |
|
19182 | 301 |
]. |
302 |
! |
|
303 |
||
12908 | 304 |
initStyle |
305 |
"setup viewStyle specifics" |
|
306 |
||
13670
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
307 |
<resource: #style ( |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
308 |
"/ #'activeHelp.backgroundColor' |
12908 | 309 |
#'activeHelp.borderWidth' |
13670
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
310 |
"/ #'activeHelp.font' |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
311 |
)> |
12908 | 312 |
|
313 |
|defaultFont| |
|
314 |
||
315 |
super initStyle. |
|
316 |
||
13670
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
317 |
"/ defaultFont := styleSheet fontAt:#'activeHelp.font' default:nil. |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
318 |
"/ defaultFont notNil ifTrue:[ |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
319 |
"/ self font:defaultFont |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
320 |
"/ ]. |
12908 | 321 |
|
322 |
self borderWidth:(styleSheet at:#'activeHelp.borderWidth' default:1). |
|
323 |
||
324 |
"Modified: / 26.10.1997 / 17:02:09 / cg" |
|
325 |
! |
|
326 |
||
19182 | 327 |
initialize |
328 |
super initialize. |
|
329 |
closeOnPointerLeave := true. |
|
330 |
pointerEntered := false. |
|
331 |
! |
|
332 |
||
19183 | 333 |
mapped |
334 |
super mapped. |
|
18590 | 335 |
|
336 |
"/ install a watcher to check for the editView being still present |
|
337 |
"/ from time to time. |
|
338 |
"/ this prevents leftover completion views in case the editView is destroyed |
|
339 |
"/ and forgets to tell me... |
|
19183 | 340 |
checkAction := [self checkForClosedOrRaisedEditor]. |
341 |
Processor addTimedBlock:checkAction for:nil afterSeconds:2. |
|
342 |
! |
|
343 |
||
19232 | 344 |
raise |
345 |
super raise |
|
346 |
||
347 |
"Modified: / 14-02-2019 / 15:34:17 / Claus Gittinger" |
|
348 |
! |
|
349 |
||
19183 | 350 |
realize |
351 |
self create. |
|
352 |
"/ self computeShape. |
|
353 |
self enableDelegation. |
|
18590 | 354 |
|
12908 | 355 |
super realize |
18315 | 356 |
|
18590 | 357 |
"Modified: / 14-02-2019 / 15:34:17 / Claus Gittinger" |
358 |
! |
|
359 |
||
360 |
release |
|
361 |
|a| |
|
362 |
||
363 |
(a := checkAction) notNil ifTrue:[ |
|
364 |
checkAction := nil. |
|
365 |
Processor removeTimedBlock:a. |
|
366 |
]. |
|
367 |
super release. |
|
368 |
||
369 |
"Created: / 14-02-2019 / 15:35:32 / Claus Gittinger" |
|
19183 | 370 |
! |
371 |
||
372 |
unmapped |
|
373 |
Processor removeTimedBlock:checkAction. |
|
374 |
super unmapped. |
|
375 |
||
376 |
||
12908 | 377 |
! ! |
378 |
||
379 |
!CodeCompletionHelpView methodsFor:'private'! |
|
380 |
||
381 |
resizeToFit |
|
382 |
"resize myself to make the component view fit" |
|
383 |
||
13448
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
384 |
|pref bw| |
12908 | 385 |
|
386 |
pref := myView preferredExtent. |
|
13670
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
387 |
myView extent:pref. |
13448
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
388 |
bw := self borderWidth. |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
389 |
self extent:(pref + (bw * 2)). |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
390 |
myView origin:(bw asPoint). |
12908 | 391 |
|
392 |
"Modified: 28.6.1997 / 14:23:49 / cg" |
|
393 |
! ! |
|
394 |
||
395 |
!CodeCompletionHelpView methodsFor:'queries'! |
|
396 |
||
397 |
isPopUpView |
|
398 |
"return true - I am a popUp type of view (no decoration, pop-to-top)" |
|
399 |
||
400 |
^ true |
|
401 |
||
402 |
"Modified: 12.5.1996 / 21:58:12 / cg" |
|
13448
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
403 |
! |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
404 |
|
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
405 |
wantsFocusWithButtonPress |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
406 |
"DEFINITELY not, because if we do so, |
13476
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
407 |
the editView looses focus on click, and sends me to hell in its lost focus handling!! |
13448
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
408 |
So I will be terminated by a buttonPress, before I get a chance to handle the buttonRelease |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
409 |
(in which I fire my action)" |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
410 |
|
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
411 |
^ false |
13476
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
412 |
! |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
413 |
|
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
414 |
wantsFocusWithPointerEnter |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
415 |
"DEFINITELY not, because if we do so, |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
416 |
the editView looses focus on entry, and sends me to hell in its lost focus handling!! |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
417 |
So I will be terminated by a motion" |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
418 |
|
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
419 |
^ false |
12908 | 420 |
! ! |
421 |
||
422 |
!CodeCompletionHelpView class methodsFor:'documentation'! |
|
423 |
||
424 |
version |
|
18315 | 425 |
^ '$Header$' |
12908 | 426 |
! |
427 |
||
428 |
version_CVS |
|
18315 | 429 |
^ '$Header$' |
12908 | 430 |
! ! |
431 |