author | Stefan Vogel <sv@exept.de> |
Fri, 17 May 2019 17:09:44 +0200 | |
changeset 18766 | e0a9a93a8edc |
parent 18590 | b6158d4015f0 |
child 19181 | e82136e9fd16 |
permissions | -rw-r--r-- |
18590 | 1 |
"{ Encoding: utf8 }" |
2 |
||
12908 | 3 |
" |
4 |
COPYRIGHT (c) 2013 by Claus Gittinger |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
14 |
"{ Package: 'stx:libtool' }" |
|
15 |
||
18315 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
12908 | 18 |
View subclass:#CodeCompletionHelpView |
18590 | 19 |
instanceVariableNames:'myView editView delayedCloseAction checkAction' |
12908 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
22 |
category:'Interface-Help' |
|
23 |
! |
|
24 |
||
25 |
!CodeCompletionHelpView class methodsFor:'documentation'! |
|
26 |
||
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 2013 by Claus Gittinger |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
13479 | 43 |
used with code completion suggestions |
12908 | 44 |
|
45 |
[author:] |
|
46 |
Claus Gittinger |
|
47 |
||
48 |
[See also:] |
|
13479 | 49 |
ActiveHelp Workspace::CodeCompletionService |
12908 | 50 |
" |
51 |
! ! |
|
52 |
||
53 |
!CodeCompletionHelpView class methodsFor:'instance creation'! |
|
54 |
||
55 |
with:aView |
|
56 |
"create a talking-view wrapping some other view" |
|
57 |
||
58 |
^ self new withView:aView |
|
59 |
||
60 |
" |
|
61 |
(ActiveHelpView with:(TextView new)) realize |
|
62 |
(ActiveHelpView with:(TextView new)) open |
|
63 |
(ActiveHelpView with:(Button label:'ok')) open |
|
64 |
" |
|
65 |
||
66 |
"Modified: 27.4.1996 / 15:14:18 / cg" |
|
67 |
! ! |
|
68 |
||
69 |
!CodeCompletionHelpView methodsFor:'accessing'! |
|
70 |
||
14152
b13faf727c2c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13670
diff
changeset
|
71 |
editView:aView |
b13faf727c2c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13670
diff
changeset
|
72 |
editView := aView |
b13faf727c2c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13670
diff
changeset
|
73 |
! |
b13faf727c2c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13670
diff
changeset
|
74 |
|
12908 | 75 |
withView:aView |
76 |
"set the component view" |
|
77 |
||
78 |
|fg| |
|
79 |
||
80 |
(aView isKindOf:Label) ifTrue:[ |
|
81 |
aView viewBackground:viewBackground. |
|
82 |
aView backgroundColor:viewBackground. |
|
83 |
(fg := styleSheet colorAt:#'activeHelp.foregroundColor' default:nil) notNil ifTrue:[ |
|
84 |
aView foregroundColor:fg. |
|
85 |
]. |
|
86 |
]. |
|
87 |
self addSubView:aView. |
|
88 |
myView := aView. |
|
89 |
myView borderWidth:0. |
|
90 |
myView origin:(0.0@0.0) corner:(1.0@1.0). |
|
91 |
||
92 |
"Modified: 27.4.1996 / 15:16:46 / cg" |
|
93 |
! ! |
|
94 |
||
18315 | 95 |
!CodeCompletionHelpView methodsFor:'event handling'! |
96 |
||
18320 | 97 |
delayedClose |
98 |
self delayedUnmap |
|
99 |
||
100 |
"Created: / 05-08-2018 / 03:16:26 / Claus Gittinger" |
|
101 |
! |
|
102 |
||
18319 | 103 |
delayedDestroy |
104 |
(subViews notEmptyOrNil) ifTrue:[ |
|
105 |
self topView destroy |
|
106 |
]. |
|
107 |
^ true |
|
108 |
||
109 |
"Created: / 04-08-2018 / 21:25:48 / Claus Gittinger" |
|
110 |
! |
|
111 |
||
18320 | 112 |
delayedUnmap |
113 |
(subViews notEmptyOrNil) ifTrue:[ |
|
114 |
self topView unmap |
|
115 |
]. |
|
116 |
^ true |
|
117 |
||
118 |
"Created: / 05-08-2018 / 03:12:39 / Claus Gittinger" |
|
119 |
! |
|
120 |
||
18315 | 121 |
focusOut |
18320 | 122 |
self installDelayedClose. |
18315 | 123 |
|
124 |
"Created: / 04-08-2018 / 10:41:59 / Claus Gittinger" |
|
18320 | 125 |
"Modified: / 05-08-2018 / 03:12:58 / Claus Gittinger" |
18315 | 126 |
! |
127 |
||
18316 | 128 |
handlesButtonMotion:state inView:aView |
129 |
^ false |
|
130 |
||
131 |
"Created: / 04-08-2018 / 16:55:09 / Claus Gittinger" |
|
132 |
! |
|
133 |
||
134 |
handlesButtonPress:state inView:aView |
|
135 |
^ false |
|
136 |
||
137 |
"Created: / 04-08-2018 / 16:55:20 / Claus Gittinger" |
|
138 |
! |
|
139 |
||
140 |
handlesButtonRelease:state inView:aView |
|
141 |
^ false |
|
142 |
||
143 |
"Created: / 04-08-2018 / 16:55:24 / Claus Gittinger" |
|
144 |
! |
|
145 |
||
146 |
handlesKeyPress:key inView:aView |
|
147 |
^ true |
|
148 |
||
149 |
"Created: / 04-08-2018 / 16:54:44 / Claus Gittinger" |
|
150 |
! |
|
151 |
||
152 |
handlesKeyRelease:key inView:aView |
|
153 |
^ false |
|
154 |
||
155 |
"Created: / 04-08-2018 / 16:54:54 / Claus Gittinger" |
|
156 |
! |
|
157 |
||
158 |
handlesPointerEnter:state inView:aView |
|
159 |
^ true |
|
160 |
||
161 |
"Created: / 04-08-2018 / 16:55:49 / Claus Gittinger" |
|
162 |
! |
|
163 |
||
164 |
handlesPointerLeave:state inView:aView |
|
165 |
^ true |
|
166 |
||
167 |
"Created: / 04-08-2018 / 16:55:53 / Claus Gittinger" |
|
168 |
! |
|
169 |
||
18320 | 170 |
installDelayedClose |
171 |
delayedCloseAction notNil ifTrue:[ |
|
172 |
Processor removeTimedBlock:delayedCloseAction. |
|
18319 | 173 |
]. |
18320 | 174 |
delayedCloseAction := [ self delayedClose ]. |
18588 | 175 |
Processor addTimedBlock:delayedCloseAction for:nil afterMilliseconds:500. |
18315 | 176 |
|
18320 | 177 |
"Created: / 05-08-2018 / 03:13:23 / Claus Gittinger" |
18588 | 178 |
"Modified: / 14-02-2019 / 02:16:10 / Claus Gittinger" |
18316 | 179 |
! |
180 |
||
181 |
keyPress:key x:x y:y view:aView |
|
18319 | 182 |
key == #Escape ifTrue:[ |
18449 | 183 |
self delayedClose. |
184 |
^ true. |
|
185 |
]. |
|
186 |
( #( CursorUp CursorDown Return ) includes:key) ifFalse:[ |
|
18320 | 187 |
self installDelayedClose. |
18319 | 188 |
^ true. |
18449 | 189 |
]. |
190 |
||
18319 | 191 |
"/ (subViews notNil and:[aView == (subViews firstIfEmpty:nil)]) ifTrue:[ |
192 |
"/ self topView destroy |
|
193 |
"/ ]. |
|
194 |
^ false |
|
18316 | 195 |
|
196 |
"Created: / 04-08-2018 / 17:00:33 / Claus Gittinger" |
|
18449 | 197 |
"Modified: / 08-10-2018 / 08:36:52 / Claus Gittinger" |
18316 | 198 |
! |
199 |
||
200 |
pointerEnter:state x:x y:y view:view |
|
18320 | 201 |
delayedCloseAction notNil ifTrue:[ |
202 |
Processor removeTimedBlock:delayedCloseAction. |
|
18316 | 203 |
]. |
204 |
^ false |
|
205 |
||
206 |
"Created: / 04-08-2018 / 17:01:39 / Claus Gittinger" |
|
207 |
! |
|
208 |
||
209 |
pointerLeave:state view:view |
|
18320 | 210 |
self installDelayedClose. |
18316 | 211 |
^ false |
212 |
||
213 |
"Created: / 04-08-2018 / 16:57:18 / Claus Gittinger" |
|
18320 | 214 |
"Modified: / 05-08-2018 / 03:13:46 / Claus Gittinger" |
18315 | 215 |
! ! |
216 |
||
12908 | 217 |
!CodeCompletionHelpView methodsFor:'initialization'! |
218 |
||
18590 | 219 |
checkForClosedEditor |
220 |
|a| |
|
221 |
||
222 |
(a := checkAction) notNil ifTrue:[ |
|
223 |
(editView isNil |
|
224 |
or:[editView realized not |
|
225 |
or:[editView topView shown not]] |
|
226 |
) ifTrue:[ |
|
227 |
self pushEvent:#closeRequest. |
|
228 |
checkAction := nil. |
|
229 |
] ifFalse:[ |
|
230 |
Processor addTimedBlock:a for:nil afterSeconds:5. |
|
231 |
] |
|
232 |
] |
|
233 |
||
234 |
"Created: / 14-02-2019 / 15:33:26 / Claus Gittinger" |
|
235 |
! |
|
236 |
||
12908 | 237 |
initStyle |
238 |
"setup viewStyle specifics" |
|
239 |
||
13670
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
240 |
<resource: #style ( |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
241 |
"/ #'activeHelp.backgroundColor' |
12908 | 242 |
#'activeHelp.borderWidth' |
13670
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
243 |
"/ #'activeHelp.font' |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
244 |
)> |
12908 | 245 |
|
246 |
|defaultFont| |
|
247 |
||
248 |
super initStyle. |
|
249 |
||
13670
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
250 |
"/ defaultFont := styleSheet fontAt:#'activeHelp.font' default:nil. |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
251 |
"/ defaultFont notNil ifTrue:[ |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
252 |
"/ self font:defaultFont |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
253 |
"/ ]. |
12908 | 254 |
|
255 |
self borderWidth:(styleSheet at:#'activeHelp.borderWidth' default:1). |
|
256 |
||
257 |
"Modified: / 26.10.1997 / 17:02:09 / cg" |
|
258 |
! |
|
259 |
||
260 |
realize |
|
261 |
self create. |
|
262 |
"/ self computeShape. |
|
263 |
self enableMotionEvents. |
|
264 |
self enableButtonMotionEvents. |
|
18315 | 265 |
self enableFocusEvents. |
18316 | 266 |
self subViews do:[:eachView | |
267 |
eachView delegate:self. |
|
268 |
]. |
|
18590 | 269 |
|
270 |
"/ install a watcher to check for the editView being still present |
|
271 |
"/ from time to time. |
|
272 |
"/ this prevents leftover completion views in case the editView is destroyed |
|
273 |
"/ and forgets to tell me... |
|
274 |
checkAction := [self checkForClosedEditor]. |
|
275 |
Processor addTimedBlock:checkAction for:nil afterSeconds:5. |
|
276 |
||
12908 | 277 |
super realize |
18315 | 278 |
|
18590 | 279 |
"Modified: / 14-02-2019 / 15:34:17 / Claus Gittinger" |
280 |
! |
|
281 |
||
282 |
release |
|
283 |
|a| |
|
284 |
||
285 |
(a := checkAction) notNil ifTrue:[ |
|
286 |
checkAction := nil. |
|
287 |
Processor removeTimedBlock:a. |
|
288 |
]. |
|
289 |
super release. |
|
290 |
||
291 |
"Created: / 14-02-2019 / 15:35:32 / Claus Gittinger" |
|
12908 | 292 |
! ! |
293 |
||
294 |
!CodeCompletionHelpView methodsFor:'private'! |
|
295 |
||
296 |
resizeToFit |
|
297 |
"resize myself to make the component view fit" |
|
298 |
||
13448
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
299 |
|pref bw| |
12908 | 300 |
|
301 |
pref := myView preferredExtent. |
|
13670
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
302 |
myView extent:pref. |
13448
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
303 |
bw := self borderWidth. |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
304 |
self extent:(pref + (bw * 2)). |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
305 |
myView origin:(bw asPoint). |
12908 | 306 |
|
307 |
"Modified: 28.6.1997 / 14:23:49 / cg" |
|
308 |
! ! |
|
309 |
||
310 |
!CodeCompletionHelpView methodsFor:'queries'! |
|
311 |
||
312 |
isPopUpView |
|
313 |
"return true - I am a popUp type of view (no decoration, pop-to-top)" |
|
314 |
||
315 |
^ true |
|
316 |
||
317 |
"Modified: 12.5.1996 / 21:58:12 / cg" |
|
13448
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
318 |
! |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
319 |
|
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
320 |
wantsFocusWithButtonPress |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
321 |
"DEFINITELY not, because if we do so, |
13476
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
322 |
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
|
323 |
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
|
324 |
(in which I fire my action)" |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
325 |
|
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
326 |
^ false |
13476
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
327 |
! |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
328 |
|
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
329 |
wantsFocusWithPointerEnter |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
330 |
"DEFINITELY not, because if we do so, |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
331 |
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
|
332 |
So I will be terminated by a motion" |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
333 |
|
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
334 |
^ false |
12908 | 335 |
! ! |
336 |
||
337 |
!CodeCompletionHelpView class methodsFor:'documentation'! |
|
338 |
||
339 |
version |
|
18315 | 340 |
^ '$Header$' |
12908 | 341 |
! |
342 |
||
343 |
version_CVS |
|
18315 | 344 |
^ '$Header$' |
12908 | 345 |
! ! |
346 |