author | Claus Gittinger <cg@exept.de> |
Thu, 14 Feb 2019 02:20:13 +0100 | |
changeset 18588 | 9790ae89ebee |
parent 18587 | dc3e84f464fc |
child 18590 | b6158d4015f0 |
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 |
18320 | 17 |
instanceVariableNames:'myView editView delayedCloseAction' |
12908 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-Help' |
|
21 |
! |
|
22 |
||
23 |
!CodeCompletionHelpView class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2013 by Claus Gittinger |
|
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 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
13479 | 41 |
used with code completion suggestions |
12908 | 42 |
|
43 |
[author:] |
|
44 |
Claus Gittinger |
|
45 |
||
46 |
[See also:] |
|
13479 | 47 |
ActiveHelp Workspace::CodeCompletionService |
12908 | 48 |
" |
49 |
! ! |
|
50 |
||
51 |
!CodeCompletionHelpView class methodsFor:'instance creation'! |
|
52 |
||
53 |
with:aView |
|
54 |
"create a talking-view wrapping some other view" |
|
55 |
||
56 |
^ self new withView:aView |
|
57 |
||
58 |
" |
|
59 |
(ActiveHelpView with:(TextView new)) realize |
|
60 |
(ActiveHelpView with:(TextView new)) open |
|
61 |
(ActiveHelpView with:(Button label:'ok')) open |
|
62 |
" |
|
63 |
||
64 |
"Modified: 27.4.1996 / 15:14:18 / cg" |
|
65 |
! ! |
|
66 |
||
67 |
!CodeCompletionHelpView methodsFor:'accessing'! |
|
68 |
||
14152
b13faf727c2c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13670
diff
changeset
|
69 |
editView:aView |
b13faf727c2c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13670
diff
changeset
|
70 |
editView := aView |
b13faf727c2c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13670
diff
changeset
|
71 |
! |
b13faf727c2c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13670
diff
changeset
|
72 |
|
12908 | 73 |
withView:aView |
74 |
"set the component view" |
|
75 |
||
76 |
|fg| |
|
77 |
||
78 |
(aView isKindOf:Label) ifTrue:[ |
|
79 |
aView viewBackground:viewBackground. |
|
80 |
aView backgroundColor:viewBackground. |
|
81 |
(fg := styleSheet colorAt:#'activeHelp.foregroundColor' default:nil) notNil ifTrue:[ |
|
82 |
aView foregroundColor:fg. |
|
83 |
]. |
|
84 |
]. |
|
85 |
self addSubView:aView. |
|
86 |
myView := aView. |
|
87 |
myView borderWidth:0. |
|
88 |
myView origin:(0.0@0.0) corner:(1.0@1.0). |
|
89 |
||
90 |
"Modified: 27.4.1996 / 15:16:46 / cg" |
|
91 |
! ! |
|
92 |
||
18315 | 93 |
!CodeCompletionHelpView methodsFor:'event handling'! |
94 |
||
18320 | 95 |
delayedClose |
96 |
self delayedUnmap |
|
97 |
||
98 |
"Created: / 05-08-2018 / 03:16:26 / Claus Gittinger" |
|
99 |
! |
|
100 |
||
18319 | 101 |
delayedDestroy |
102 |
(subViews notEmptyOrNil) ifTrue:[ |
|
103 |
self topView destroy |
|
104 |
]. |
|
105 |
^ true |
|
106 |
||
107 |
"Created: / 04-08-2018 / 21:25:48 / Claus Gittinger" |
|
108 |
! |
|
109 |
||
18320 | 110 |
delayedUnmap |
111 |
(subViews notEmptyOrNil) ifTrue:[ |
|
112 |
self topView unmap |
|
113 |
]. |
|
114 |
^ true |
|
115 |
||
116 |
"Created: / 05-08-2018 / 03:12:39 / Claus Gittinger" |
|
117 |
! |
|
118 |
||
18315 | 119 |
focusOut |
18320 | 120 |
self installDelayedClose. |
18315 | 121 |
|
122 |
"Created: / 04-08-2018 / 10:41:59 / Claus Gittinger" |
|
18320 | 123 |
"Modified: / 05-08-2018 / 03:12:58 / Claus Gittinger" |
18315 | 124 |
! |
125 |
||
18316 | 126 |
handlesButtonMotion:state inView:aView |
127 |
^ false |
|
128 |
||
129 |
"Created: / 04-08-2018 / 16:55:09 / Claus Gittinger" |
|
130 |
! |
|
131 |
||
132 |
handlesButtonPress:state inView:aView |
|
133 |
^ false |
|
134 |
||
135 |
"Created: / 04-08-2018 / 16:55:20 / Claus Gittinger" |
|
136 |
! |
|
137 |
||
138 |
handlesButtonRelease:state inView:aView |
|
139 |
^ false |
|
140 |
||
141 |
"Created: / 04-08-2018 / 16:55:24 / Claus Gittinger" |
|
142 |
! |
|
143 |
||
144 |
handlesKeyPress:key inView:aView |
|
145 |
^ true |
|
146 |
||
147 |
"Created: / 04-08-2018 / 16:54:44 / Claus Gittinger" |
|
148 |
! |
|
149 |
||
150 |
handlesKeyRelease:key inView:aView |
|
151 |
^ false |
|
152 |
||
153 |
"Created: / 04-08-2018 / 16:54:54 / Claus Gittinger" |
|
154 |
! |
|
155 |
||
156 |
handlesPointerEnter:state inView:aView |
|
157 |
^ true |
|
158 |
||
159 |
"Created: / 04-08-2018 / 16:55:49 / Claus Gittinger" |
|
160 |
! |
|
161 |
||
162 |
handlesPointerLeave:state inView:aView |
|
163 |
^ true |
|
164 |
||
165 |
"Created: / 04-08-2018 / 16:55:53 / Claus Gittinger" |
|
166 |
! |
|
167 |
||
18320 | 168 |
installDelayedClose |
169 |
delayedCloseAction notNil ifTrue:[ |
|
170 |
Processor removeTimedBlock:delayedCloseAction. |
|
18319 | 171 |
]. |
18320 | 172 |
delayedCloseAction := [ self delayedClose ]. |
18588 | 173 |
Processor addTimedBlock:delayedCloseAction for:nil afterMilliseconds:500. |
18315 | 174 |
|
18320 | 175 |
"Created: / 05-08-2018 / 03:13:23 / Claus Gittinger" |
18588 | 176 |
"Modified: / 14-02-2019 / 02:16:10 / Claus Gittinger" |
18316 | 177 |
! |
178 |
||
179 |
keyPress:key x:x y:y view:aView |
|
18319 | 180 |
key == #Escape ifTrue:[ |
18449 | 181 |
self delayedClose. |
182 |
^ true. |
|
183 |
]. |
|
184 |
( #( CursorUp CursorDown Return ) includes:key) ifFalse:[ |
|
18320 | 185 |
self installDelayedClose. |
18319 | 186 |
^ true. |
18449 | 187 |
]. |
188 |
||
18319 | 189 |
"/ (subViews notNil and:[aView == (subViews firstIfEmpty:nil)]) ifTrue:[ |
190 |
"/ self topView destroy |
|
191 |
"/ ]. |
|
192 |
^ false |
|
18316 | 193 |
|
194 |
"Created: / 04-08-2018 / 17:00:33 / Claus Gittinger" |
|
18449 | 195 |
"Modified: / 08-10-2018 / 08:36:52 / Claus Gittinger" |
18316 | 196 |
! |
197 |
||
198 |
pointerEnter:state x:x y:y view:view |
|
18320 | 199 |
delayedCloseAction notNil ifTrue:[ |
200 |
Processor removeTimedBlock:delayedCloseAction. |
|
18316 | 201 |
]. |
202 |
^ false |
|
203 |
||
204 |
"Created: / 04-08-2018 / 17:01:39 / Claus Gittinger" |
|
205 |
! |
|
206 |
||
207 |
pointerLeave:state view:view |
|
18320 | 208 |
self installDelayedClose. |
18316 | 209 |
^ false |
210 |
||
211 |
"Created: / 04-08-2018 / 16:57:18 / Claus Gittinger" |
|
18320 | 212 |
"Modified: / 05-08-2018 / 03:13:46 / Claus Gittinger" |
18315 | 213 |
! ! |
214 |
||
12908 | 215 |
!CodeCompletionHelpView methodsFor:'initialization'! |
216 |
||
217 |
initStyle |
|
218 |
"setup viewStyle specifics" |
|
219 |
||
13670
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
220 |
<resource: #style ( |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
221 |
"/ #'activeHelp.backgroundColor' |
12908 | 222 |
#'activeHelp.borderWidth' |
13670
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
223 |
"/ #'activeHelp.font' |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
224 |
)> |
12908 | 225 |
|
226 |
|defaultFont| |
|
227 |
||
228 |
super initStyle. |
|
229 |
||
13670
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
230 |
"/ defaultFont := styleSheet fontAt:#'activeHelp.font' default:nil. |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
231 |
"/ defaultFont notNil ifTrue:[ |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
232 |
"/ self font:defaultFont |
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
233 |
"/ ]. |
12908 | 234 |
|
235 |
self borderWidth:(styleSheet at:#'activeHelp.borderWidth' default:1). |
|
236 |
||
237 |
"Modified: / 26.10.1997 / 17:02:09 / cg" |
|
238 |
! |
|
239 |
||
240 |
realize |
|
241 |
self create. |
|
242 |
"/ self computeShape. |
|
243 |
self enableMotionEvents. |
|
244 |
self enableButtonMotionEvents. |
|
18315 | 245 |
self enableFocusEvents. |
18316 | 246 |
self subViews do:[:eachView | |
247 |
eachView delegate:self. |
|
248 |
]. |
|
12908 | 249 |
super realize |
18315 | 250 |
|
18316 | 251 |
"Modified: / 04-08-2018 / 16:53:13 / Claus Gittinger" |
12908 | 252 |
! ! |
253 |
||
254 |
!CodeCompletionHelpView methodsFor:'private'! |
|
255 |
||
256 |
resizeToFit |
|
257 |
"resize myself to make the component view fit" |
|
258 |
||
13448
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
259 |
|pref bw| |
12908 | 260 |
|
261 |
pref := myView preferredExtent. |
|
13670
43d2d7c37e61
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13479
diff
changeset
|
262 |
myView extent:pref. |
13448
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
263 |
bw := self borderWidth. |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
264 |
self extent:(pref + (bw * 2)). |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
265 |
myView origin:(bw asPoint). |
12908 | 266 |
|
267 |
"Modified: 28.6.1997 / 14:23:49 / cg" |
|
268 |
! ! |
|
269 |
||
270 |
!CodeCompletionHelpView methodsFor:'queries'! |
|
271 |
||
272 |
isPopUpView |
|
273 |
"return true - I am a popUp type of view (no decoration, pop-to-top)" |
|
274 |
||
275 |
^ true |
|
276 |
||
277 |
"Modified: 12.5.1996 / 21:58:12 / cg" |
|
13448
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
278 |
! |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
279 |
|
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
280 |
wantsFocusWithButtonPress |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
281 |
"DEFINITELY not, because if we do so, |
13476
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
282 |
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
|
283 |
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
|
284 |
(in which I fire my action)" |
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
285 |
|
8f3c88862f5a
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
12908
diff
changeset
|
286 |
^ false |
13476
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
287 |
! |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
288 |
|
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
289 |
wantsFocusWithPointerEnter |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
290 |
"DEFINITELY not, because if we do so, |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
291 |
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
|
292 |
So I will be terminated by a motion" |
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
293 |
|
9e09d2a0bf7c
class: CodeCompletionHelpView
Claus Gittinger <cg@exept.de>
parents:
13448
diff
changeset
|
294 |
^ false |
12908 | 295 |
! ! |
296 |
||
297 |
!CodeCompletionHelpView class methodsFor:'documentation'! |
|
298 |
||
299 |
version |
|
18315 | 300 |
^ '$Header$' |
12908 | 301 |
! |
302 |
||
303 |
version_CVS |
|
18315 | 304 |
^ '$Header$' |
12908 | 305 |
! ! |
306 |