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