author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 17 Nov 2017 11:52:18 -0300 | |
branch | jv |
changeset 8223 | d0117698147d |
parent 7715 | 925b859e1758 |
child 8420 | 76e39223f5ab |
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 |
||
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
626
diff
changeset
|
14 |
DisplaySurface subclass:#DisplayRootView |
616 | 15 |
instanceVariableNames:'' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
626 | 18 |
category:'Views-Special' |
0 | 19 |
! |
20 |
||
1254 | 21 |
!DisplayRootView class methodsFor:'documentation'! |
45 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
71 | 26 |
All Rights Reserved |
45 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
2916 | 39 |
this class describes the rootWindow (which is the background window or |
6616
9dad6d1245cc
Merged ea4e1faf457a and 160cf8d7ea05 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
40 |
desktop and can be used for drawing outside of Views |
2916 | 41 |
i.e. for dragging between Views). |
89 | 42 |
|
6616
9dad6d1245cc
Merged ea4e1faf457a and 160cf8d7ea05 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
43 |
For historic and compatibility reasons, there is a global variable |
1254 | 44 |
called 'RootView', which is bound to the default displays ('Display') |
45 |
rootview. We recommend, not to access this variable, instead, get a |
|
46 |
displays rootView via the #rootView message (sent to the device). |
|
47 |
Otherwise, your application will not work in a multiScreen environment. |
|
180 | 48 |
|
6616
9dad6d1245cc
Merged ea4e1faf457a and 160cf8d7ea05 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
49 |
Instances of myself (i.e. these rootViews) are light-weight views; |
180 | 50 |
they do not support events, models etc. |
51 |
They are pure drawing canvases and should be only used for special |
|
6616
9dad6d1245cc
Merged ea4e1faf457a and 160cf8d7ea05 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
52 |
applications (i.e. dragging). |
1254 | 53 |
There may be display systems in which rootViews are not |
180 | 54 |
supported/allowed implemented. So be VERY careful when using them. |
134 | 55 |
|
1254 | 56 |
Be aware, that the rootView is not always visible - some |
57 |
windowManagers install another (pseudoRoot), into which icons and |
|
58 |
windowManager menus are drawn. If that is the case, your paining |
|
59 |
into the rootView may not be visible, unless you set the #noClipByChildren |
|
60 |
option (see below). |
|
2916 | 61 |
Also, it is not guaranteed, that all devices support drawing in the |
62 |
root window - especially if the device is a simulated one, such as |
|
63 |
a remote webBrowser ... |
|
1254 | 64 |
In general, you should never use the rootView for normal applications. |
65 |
||
134 | 66 |
To draw in the (Displays) root window: |
89 | 67 |
|
1254 | 68 |
|rootView| |
69 |
||
70 |
rootView := Screen current rootView. |
|
71 |
rootView paint:(Color red). |
|
72 |
rootView fillRectangleX:10 y:10 width:100 height:100. |
|
89 | 73 |
|
74 |
of course, all stuff from View and its superclasses can be used: |
|
75 |
||
1254 | 76 |
|rootView| |
89 | 77 |
|
1254 | 78 |
rootView := Screen current rootView. |
79 |
rootView paint:(Color red). |
|
80 |
rootView noClipByChildren. |
|
81 |
rootView fillRectangleX:10 y:10 width:100 height:100. |
|
82 |
||
616 | 83 |
|
84 |
[author:] |
|
85 |
Claus Gittinger |
|
45 | 86 |
" |
7317
cea144a15948
Backed out changeset ce64e30ecf54
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7287
diff
changeset
|
87 |
! |
45 | 88 |
|
1254 | 89 |
!DisplayRootView class methodsFor:'instance creation'! |
0 | 90 |
|
1256 | 91 |
onDevice:aDisplay |
89 | 92 |
"since there is only one RootView - catch new and return |
93 |
the one and only rootView." |
|
94 |
||
134 | 95 |
aDisplay == Display ifTrue:[ |
3337 | 96 |
RootView notNil ifTrue:[ |
97 |
RootView device == aDisplay ifTrue:[ |
|
98 |
^ RootView |
|
99 |
] |
|
100 |
]. |
|
1256 | 101 |
RootView := super onDevice:aDisplay. |
102 |
^ RootView |
|
0 | 103 |
]. |
1256 | 104 |
^ super onDevice:aDisplay |
105 |
||
3630
2b2f6649c014
Change Workstation initialization.
Stefan Vogel <sv@exept.de>
parents:
3337
diff
changeset
|
106 |
"Created: 18.1.1997 / 18:23:22 / cg" |
2b2f6649c014
Change Workstation initialization.
Stefan Vogel <sv@exept.de>
parents:
3337
diff
changeset
|
107 |
! ! |
0 | 108 |
|
109 |
!DisplayRootView methodsFor:'accessing'! |
|
110 |
||
4213 | 111 |
application |
112 |
^ nil |
|
113 |
! |
|
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 |
|
144 |
we destroy the rootWindow if its a virtual root window" |
|
145 |
||
146 |
^ self |
|
147 |
! ! |
|
148 |
||
3253 | 149 |
!DisplayRootView methodsFor:'dummy'! |
150 |
||
7627 | 151 |
keyboardZoom:larger |
152 |
"/ MUST be ignored here |
|
153 |
! |
|
154 |
||
3253 | 155 |
redrawX:x y:y width:width height:height |
156 |
"ignored" |
|
157 |
! ! |
|
158 |
||
6574 | 159 |
!DisplayRootView methodsFor:'hotkeys'! |
160 |
||
161 |
addHotKeyHandler:handler forKey:aKey modifierMask:optionalModifierMaskOrNil |
|
162 |
"install a handler (which should implement keyPress:x:y:view: |
|
163 |
and keyRelease:x:y:view: on aKey. |
|
164 |
aKey should be a symbolic key (like #F2). |
|
165 |
modifierMask may constraint the key to be only handled when a certain |
|
166 |
modifier is pressed (use a bitOr combination of device ctrlModifierMask, |
|
167 |
altModifierMask etc.) or nil, so the key is always treated as a hotkey" |
|
168 |
||
169 |
self sensor addEventListener:handler. |
|
6616
9dad6d1245cc
Merged ea4e1faf457a and 160cf8d7ea05 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
170 |
self device |
6574 | 171 |
grabKey:aKey |
172 |
modifier:optionalModifierMaskOrNil |
|
173 |
window:self. |
|
174 |
||
175 |
" |
|
176 |
Display rootView sensor removeAllEventListeners. |
|
177 |
||
178 |
Display rootView |
|
179 |
addHotKeyHandler:[:ev | |
|
180 |
Transcript showCR:ev. |
|
181 |
ev key = 'F3' ifTrue:[ |
|
182 |
Dialog information:'YES!!'. |
|
183 |
]. |
|
184 |
false. |
|
185 |
] |
|
186 |
forKey:'F3' |
|
187 |
modifierMask:nil |
|
188 |
" |
|
189 |
! |
|
190 |
||
191 |
removeHotKeyHandler:handler forKey:aKey modifierMask:optionalModifierMaskOrNil |
|
192 |
"install a handler (which should implement keyPress:x:y:view: |
|
193 |
and keyRelease:x:y:view: on aKey. |
|
194 |
aKey should be a symbolic key (like #F2). |
|
195 |
modifierMask may constraint the key to be only handled when a certain |
|
196 |
modifier is pressed (use a bitOr combination of device ctrlModifierMask, |
|
197 |
altModifierMask etc.) or nil, so the key is always treated as a hotkey" |
|
198 |
||
199 |
self sensor removeEventListener:handler. |
|
6616
9dad6d1245cc
Merged ea4e1faf457a and 160cf8d7ea05 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
200 |
self device |
6574 | 201 |
ungrabKey:aKey |
202 |
modifier:optionalModifierMaskOrNil |
|
203 |
window:self. |
|
204 |
||
205 |
" |
|
206 |
" |
|
207 |
! ! |
|
208 |
||
3883 | 209 |
!DisplayRootView methodsFor:'initialization & release'! |
269 | 210 |
|
211 |
initialize |
|
6233 | 212 |
|dev| |
213 |
||
269 | 214 |
super initialize. |
215 |
||
6233 | 216 |
dev := self device. |
217 |
width := dev width. |
|
218 |
height := dev height. |
|
6342
d2a4135ecf36
Access graphicsDevice via method send instead of instVar access
Stefan Vogel <sv@exept.de>
parents:
6282
diff
changeset
|
219 |
self createRootWindow. |
269 | 220 |
realized := true. |
221 |
! |
|
222 |
||
223 |
reinitialize |
|
224 |
"reinit after snapin" |
|
225 |
||
6349 | 226 |
self recreate. |
227 |
self createRootWindow. |
|
7266 | 228 |
width := device width. |
229 |
height := device height. |
|
269 | 230 |
realized := true. |
231 |
! ! |
|
232 |
||
0 | 233 |
!DisplayRootView methodsFor:'queries'! |
234 |
||
4650 | 235 |
canDropObjects:aCollectionOfDropObjects |
1584
03d62f063935
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
236 |
"return true, if aCollectionOfDropObjects can be |
6616
9dad6d1245cc
Merged ea4e1faf457a and 160cf8d7ea05 (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
237 |
dropped in the receiver. |
2916 | 238 |
False is returned here, since nothing can be dropped on the desktop. |
239 |
(for now - actually some systems do allow dropping things on the desktop |
|
240 |
and this query should be forwarded to my display device)" |
|
0 | 241 |
|
242 |
^ false |
|
1584
03d62f063935
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
243 |
|
4650 | 244 |
"Created: / 13-10-2006 / 15:55:54 / cg" |
269 | 245 |
! |
0 | 246 |
|
6764 | 247 |
isActive |
248 |
"for protocol compatibility with regular views" |
|
249 |
||
250 |
^ false. |
|
251 |
! |
|
252 |
||
6753 | 253 |
isComponentOf: aView |
254 |
^ false |
|
255 |
! |
|
256 |
||
919
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
257 |
isRootView |
2916 | 258 |
"return true, since yes, I am a rootview" |
919
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
259 |
|
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
260 |
^ true |
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 |
"Created: 5.7.1996 / 13:48:24 / cg" |
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
263 |
"Modified: 5.7.1996 / 14:57:44 / cg" |
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
264 |
! |
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
265 |
|
6986 | 266 |
isSameOrComponentOf:aView |
267 |
"return true, if I am aView or a (direct or indirect) component of aView" |
|
268 |
||
269 |
^ self == aView |
|
270 |
! |
|
271 |
||
0 | 272 |
isWindowManagerRunning |
2 | 273 |
"answer true, if a window manager is currently running. |
274 |
This is done by performing an action (enabling button events of |
|
23 | 275 |
root window), which will fail if a window manager is running." |
0 | 276 |
|
6373 | 277 |
device isWindowsPlatform ifTrue:[^ true]. |
278 |
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
|
279 |
^ false. |
2 | 280 |
] do:[ |
2916 | 281 |
self enableButtonEvents. |
6267 | 282 |
self flush. |
2 | 283 |
]. |
4221
666dea8f4aa7
Do not move messages to superclass (where they are sent)
Stefan Vogel <sv@exept.de>
parents:
4214
diff
changeset
|
284 |
^ true |
23 | 285 |
|
134 | 286 |
" |
287 |
DisplayRootView new |
|
288 |
RootView isWindowManagerRunning |
|
289 |
" |
|
0 | 290 |
! ! |
269 | 291 |
|
1254 | 292 |
!DisplayRootView class methodsFor:'documentation'! |
269 | 293 |
|
294 |
version |
|
6986 | 295 |
^ '$Header$' |
269 | 296 |
! ! |
6233 | 297 |