author | Claus Gittinger <cg@exept.de> |
Wed, 22 Jan 2020 16:46:49 +0100 | |
changeset 8973 | cd7c23c4029e |
parent 8935 | bb3677b7a7bb |
child 9009 | 1b4dfccafd87 |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
71 | 3 |
All Rights Reserved |
0 | 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 |
" |
|
3253 | 12 |
"{ Package: 'stx:libview' }" |
13 |
||
6753 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
16 |
DisplaySurface subclass:#DisplayRootView |
616 | 17 |
instanceVariableNames:'' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
626 | 20 |
category:'Views-Special' |
0 | 21 |
! |
22 |
||
1254 | 23 |
!DisplayRootView class methodsFor:'documentation'! |
45 | 24 |
|
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
71 | 28 |
All Rights Reserved |
45 | 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 |
" |
|
2916 | 41 |
this class describes the rootWindow (which is the background window or |
42 |
desktop and can be used for drawing outside of Views |
|
43 |
i.e. for dragging between Views). |
|
89 | 44 |
|
1254 | 45 |
For historic and compatibility reasons, there is a global variable |
46 |
called 'RootView', which is bound to the default displays ('Display') |
|
47 |
rootview. We recommend, not to access this variable, instead, get a |
|
48 |
displays rootView via the #rootView message (sent to the device). |
|
49 |
Otherwise, your application will not work in a multiScreen environment. |
|
180 | 50 |
|
51 |
Instances of myself (i.e. these rootViews) are light-weight views; |
|
52 |
they do not support events, models etc. |
|
53 |
They are pure drawing canvases and should be only used for special |
|
1254 | 54 |
applications (i.e. dragging). |
55 |
There may be display systems in which rootViews are not |
|
180 | 56 |
supported/allowed implemented. So be VERY careful when using them. |
134 | 57 |
|
1254 | 58 |
Be aware, that the rootView is not always visible - some |
59 |
windowManagers install another (pseudoRoot), into which icons and |
|
60 |
windowManager menus are drawn. If that is the case, your paining |
|
61 |
into the rootView may not be visible, unless you set the #noClipByChildren |
|
62 |
option (see below). |
|
2916 | 63 |
Also, it is not guaranteed, that all devices support drawing in the |
64 |
root window - especially if the device is a simulated one, such as |
|
65 |
a remote webBrowser ... |
|
1254 | 66 |
In general, you should never use the rootView for normal applications. |
67 |
||
134 | 68 |
To draw in the (Displays) root window: |
89 | 69 |
|
1254 | 70 |
|rootView| |
71 |
||
72 |
rootView := Screen current rootView. |
|
73 |
rootView paint:(Color red). |
|
74 |
rootView fillRectangleX:10 y:10 width:100 height:100. |
|
89 | 75 |
|
76 |
of course, all stuff from View and its superclasses can be used: |
|
77 |
||
1254 | 78 |
|rootView| |
89 | 79 |
|
1254 | 80 |
rootView := Screen current rootView. |
81 |
rootView paint:(Color red). |
|
82 |
rootView noClipByChildren. |
|
83 |
rootView fillRectangleX:10 y:10 width:100 height:100. |
|
84 |
||
616 | 85 |
|
86 |
[author:] |
|
87 |
Claus Gittinger |
|
45 | 88 |
" |
89 |
! ! |
|
90 |
||
1254 | 91 |
!DisplayRootView class methodsFor:'instance creation'! |
0 | 92 |
|
1256 | 93 |
onDevice:aDisplay |
89 | 94 |
"since there is only one RootView - catch new and return |
95 |
the one and only rootView." |
|
96 |
||
134 | 97 |
aDisplay == Display ifTrue:[ |
3337 | 98 |
RootView notNil ifTrue:[ |
99 |
RootView device == aDisplay ifTrue:[ |
|
100 |
^ RootView |
|
101 |
] |
|
102 |
]. |
|
1256 | 103 |
RootView := super onDevice:aDisplay. |
104 |
^ RootView |
|
0 | 105 |
]. |
1256 | 106 |
^ super onDevice:aDisplay |
107 |
||
3630
2b2f6649c014
Change Workstation initialization.
Stefan Vogel <sv@exept.de>
parents:
3337
diff
changeset
|
108 |
"Created: 18.1.1997 / 18:23:22 / cg" |
2b2f6649c014
Change Workstation initialization.
Stefan Vogel <sv@exept.de>
parents:
3337
diff
changeset
|
109 |
! ! |
0 | 110 |
|
111 |
!DisplayRootView methodsFor:'accessing'! |
|
112 |
||
4214 | 113 |
model |
114 |
^ nil |
|
115 |
! |
|
116 |
||
269 | 117 |
name |
2916 | 118 |
"return my name - always 'RootWindow'" |
119 |
||
269 | 120 |
^ 'RootWindow' |
121 |
! |
|
122 |
||
3253 | 123 |
subViews |
124 |
"return the collection of subviews - none here" |
|
125 |
||
126 |
^ #() |
|
127 |
||
128 |
||
4981 | 129 |
! |
130 |
||
131 |
uuid |
|
4989 | 132 |
"return my uuid - always the same here. |
133 |
TODO: think what happens with multiple screens..." |
|
4981 | 134 |
|
7654 | 135 |
^ UUID readFrom:'31be9300-41fc-11dd-b99f-001558137da0' "/ do not change - ask cg if you don't know why |
0 | 136 |
! ! |
137 |
||
71 | 138 |
!DisplayRootView methodsFor:'destroying'! |
139 |
||
140 |
destroy |
|
141 |
"catch destroy - some windowmanagers get confused if |
|
7880 | 142 |
we destroy the rootWindow if it's a virtual root window" |
71 | 143 |
|
144 |
^ self |
|
7880 | 145 |
|
146 |
"Modified (comment): / 13-02-2017 / 20:01:04 / cg" |
|
71 | 147 |
! ! |
148 |
||
3253 | 149 |
!DisplayRootView methodsFor:'dummy'! |
150 |
||
8249 | 151 |
keyboardZoom:largerBoolean |
8251 | 152 |
"CTRL+/- zoom action" |
153 |
||
7627 | 154 |
"/ MUST be ignored here |
155 |
! |
|
156 |
||
3253 | 157 |
redrawX:x y:y width:width height:height |
158 |
"ignored" |
|
159 |
! ! |
|
160 |
||
6574 | 161 |
!DisplayRootView methodsFor:'hotkeys'! |
162 |
||
163 |
addHotKeyHandler:handler forKey:aKey modifierMask:optionalModifierMaskOrNil |
|
164 |
"install a handler (which should implement keyPress:x:y:view: |
|
165 |
and keyRelease:x:y:view: on aKey. |
|
166 |
aKey should be a symbolic key (like #F2). |
|
167 |
modifierMask may constraint the key to be only handled when a certain |
|
168 |
modifier is pressed (use a bitOr combination of device ctrlModifierMask, |
|
169 |
altModifierMask etc.) or nil, so the key is always treated as a hotkey" |
|
170 |
||
171 |
self sensor addEventListener:handler. |
|
172 |
device |
|
173 |
grabKey:aKey |
|
174 |
modifier:optionalModifierMaskOrNil |
|
175 |
window:self. |
|
176 |
||
177 |
" |
|
178 |
Display rootView sensor removeAllEventListeners. |
|
179 |
||
180 |
Display rootView |
|
181 |
addHotKeyHandler:[:ev | |
|
182 |
Transcript showCR:ev. |
|
183 |
ev key = 'F3' ifTrue:[ |
|
184 |
Dialog information:'YES!!'. |
|
185 |
]. |
|
186 |
false. |
|
187 |
] |
|
188 |
forKey:'F3' |
|
189 |
modifierMask:nil |
|
190 |
" |
|
191 |
! |
|
192 |
||
193 |
removeHotKeyHandler:handler forKey:aKey modifierMask:optionalModifierMaskOrNil |
|
194 |
"install a handler (which should implement keyPress:x:y:view: |
|
195 |
and keyRelease:x:y:view: on aKey. |
|
196 |
aKey should be a symbolic key (like #F2). |
|
197 |
modifierMask may constraint the key to be only handled when a certain |
|
198 |
modifier is pressed (use a bitOr combination of device ctrlModifierMask, |
|
199 |
altModifierMask etc.) or nil, so the key is always treated as a hotkey" |
|
200 |
||
201 |
self sensor removeEventListener:handler. |
|
202 |
device |
|
203 |
ungrabKey:aKey |
|
204 |
modifier:optionalModifierMaskOrNil |
|
205 |
window:self. |
|
206 |
||
207 |
" |
|
208 |
" |
|
209 |
! ! |
|
210 |
||
3883 | 211 |
!DisplayRootView methodsFor:'initialization & release'! |
269 | 212 |
|
213 |
initialize |
|
6233 | 214 |
|dev| |
215 |
||
269 | 216 |
super initialize. |
217 |
||
6233 | 218 |
dev := self device. |
219 |
width := dev width. |
|
220 |
height := dev height. |
|
6342
d2a4135ecf36
Access graphicsDevice via method send instead of instVar access
Stefan Vogel <sv@exept.de>
parents:
6282
diff
changeset
|
221 |
self createRootWindow. |
269 | 222 |
realized := true. |
223 |
! |
|
224 |
||
225 |
reinitialize |
|
226 |
"reinit after snapin" |
|
227 |
||
6349 | 228 |
self recreate. |
229 |
self createRootWindow. |
|
7266 | 230 |
width := device width. |
231 |
height := device height. |
|
269 | 232 |
realized := true. |
233 |
! ! |
|
234 |
||
0 | 235 |
!DisplayRootView methodsFor:'queries'! |
236 |
||
4650 | 237 |
canDropObjects:aCollectionOfDropObjects |
1584
03d62f063935
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
238 |
"return true, if aCollectionOfDropObjects can be |
2916 | 239 |
dropped in the receiver. |
240 |
False is returned here, since nothing can be dropped on the desktop. |
|
241 |
(for now - actually some systems do allow dropping things on the desktop |
|
242 |
and this query should be forwarded to my display device)" |
|
0 | 243 |
|
244 |
^ false |
|
1584
03d62f063935
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
245 |
|
4650 | 246 |
"Created: / 13-10-2006 / 15:55:54 / cg" |
269 | 247 |
! |
0 | 248 |
|
6764 | 249 |
isActive |
250 |
"for protocol compatibility with regular views" |
|
251 |
||
252 |
^ false. |
|
253 |
! |
|
254 |
||
6753 | 255 |
isComponentOf: aView |
256 |
^ false |
|
257 |
! |
|
258 |
||
919
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
259 |
isRootView |
2916 | 260 |
"return true, since yes, I am a rootview" |
919
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
261 |
|
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
262 |
^ true |
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
263 |
|
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
264 |
"Created: 5.7.1996 / 13:48:24 / cg" |
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
265 |
"Modified: 5.7.1996 / 14:57:44 / cg" |
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
266 |
! |
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
267 |
|
6986 | 268 |
isSameOrComponentOf:aView |
269 |
"return true, if I am aView or a (direct or indirect) component of aView" |
|
270 |
||
271 |
^ self == aView |
|
272 |
! |
|
273 |
||
0 | 274 |
isWindowManagerRunning |
2 | 275 |
"answer true, if a window manager is currently running. |
276 |
This is done by performing an action (enabling button events of |
|
23 | 277 |
root window), which will fail if a window manager is running." |
0 | 278 |
|
6373 | 279 |
device isWindowsPlatform ifTrue:[^ true]. |
280 |
device class deviceErrorSignal handle:[:ex | |
|
4221
666dea8f4aa7
Do not move messages to superclass (where they are sent)
Stefan Vogel <sv@exept.de>
parents:
4214
diff
changeset
|
281 |
^ false. |
2 | 282 |
] do:[ |
2916 | 283 |
self enableButtonEvents. |
6267 | 284 |
self flush. |
2 | 285 |
]. |
4221
666dea8f4aa7
Do not move messages to superclass (where they are sent)
Stefan Vogel <sv@exept.de>
parents:
4214
diff
changeset
|
286 |
^ true |
23 | 287 |
|
134 | 288 |
" |
289 |
DisplayRootView new |
|
290 |
RootView isWindowManagerRunning |
|
291 |
" |
|
0 | 292 |
! ! |
269 | 293 |
|
1254 | 294 |
!DisplayRootView class methodsFor:'documentation'! |
269 | 295 |
|
296 |
version |
|
6986 | 297 |
^ '$Header$' |
8251 | 298 |
! |
299 |
||
300 |
version_CVS |
|
301 |
^ '$Header$' |
|
269 | 302 |
! ! |
6233 | 303 |