author | Claus Gittinger <cg@exept.de> |
Thu, 28 Apr 2016 14:18:50 +0200 | |
changeset 7319 | a7aeb15d709f |
parent 7266 | 6b9ccc0ad0c8 |
child 7286 | c3b4c3c664d4 |
child 7627 | 86ebf06e43a1 |
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 |
||
4213 | 113 |
application |
114 |
^ nil |
|
115 |
! |
|
116 |
||
4214 | 117 |
model |
118 |
^ nil |
|
119 |
! |
|
120 |
||
269 | 121 |
name |
2916 | 122 |
"return my name - always 'RootWindow'" |
123 |
||
269 | 124 |
^ 'RootWindow' |
125 |
! |
|
126 |
||
3253 | 127 |
subViews |
128 |
"return the collection of subviews - none here" |
|
129 |
||
130 |
^ #() |
|
131 |
||
132 |
||
4981 | 133 |
! |
134 |
||
135 |
uuid |
|
4989 | 136 |
"return my uuid - always the same here. |
137 |
TODO: think what happens with multiple screens..." |
|
4981 | 138 |
|
139 |
^ UUID readFrom:'31be9300-41fc-11dd-b99f-001558137da0' "/ do not change - ask cg if you dont know why |
|
0 | 140 |
! ! |
141 |
||
71 | 142 |
!DisplayRootView methodsFor:'destroying'! |
143 |
||
144 |
destroy |
|
145 |
"catch destroy - some windowmanagers get confused if |
|
146 |
we destroy the rootWindow if its a virtual root window" |
|
147 |
||
148 |
^ self |
|
149 |
! ! |
|
150 |
||
3253 | 151 |
!DisplayRootView methodsFor:'dummy'! |
152 |
||
153 |
redrawX:x y:y width:width height:height |
|
154 |
"ignored" |
|
155 |
! ! |
|
156 |
||
6574 | 157 |
!DisplayRootView methodsFor:'hotkeys'! |
158 |
||
159 |
addHotKeyHandler:handler forKey:aKey modifierMask:optionalModifierMaskOrNil |
|
160 |
"install a handler (which should implement keyPress:x:y:view: |
|
161 |
and keyRelease:x:y:view: on aKey. |
|
162 |
aKey should be a symbolic key (like #F2). |
|
163 |
modifierMask may constraint the key to be only handled when a certain |
|
164 |
modifier is pressed (use a bitOr combination of device ctrlModifierMask, |
|
165 |
altModifierMask etc.) or nil, so the key is always treated as a hotkey" |
|
166 |
||
167 |
self sensor addEventListener:handler. |
|
168 |
device |
|
169 |
grabKey:aKey |
|
170 |
modifier:optionalModifierMaskOrNil |
|
171 |
window:self. |
|
172 |
||
173 |
" |
|
174 |
Display rootView sensor removeAllEventListeners. |
|
175 |
||
176 |
Display rootView |
|
177 |
addHotKeyHandler:[:ev | |
|
178 |
Transcript showCR:ev. |
|
179 |
ev key = 'F3' ifTrue:[ |
|
180 |
Dialog information:'YES!!'. |
|
181 |
]. |
|
182 |
false. |
|
183 |
] |
|
184 |
forKey:'F3' |
|
185 |
modifierMask:nil |
|
186 |
" |
|
187 |
! |
|
188 |
||
189 |
removeHotKeyHandler:handler forKey:aKey modifierMask:optionalModifierMaskOrNil |
|
190 |
"install a handler (which should implement keyPress:x:y:view: |
|
191 |
and keyRelease:x:y:view: on aKey. |
|
192 |
aKey should be a symbolic key (like #F2). |
|
193 |
modifierMask may constraint the key to be only handled when a certain |
|
194 |
modifier is pressed (use a bitOr combination of device ctrlModifierMask, |
|
195 |
altModifierMask etc.) or nil, so the key is always treated as a hotkey" |
|
196 |
||
197 |
self sensor removeEventListener:handler. |
|
198 |
device |
|
199 |
ungrabKey:aKey |
|
200 |
modifier:optionalModifierMaskOrNil |
|
201 |
window:self. |
|
202 |
||
203 |
" |
|
204 |
" |
|
205 |
! ! |
|
206 |
||
3883 | 207 |
!DisplayRootView methodsFor:'initialization & release'! |
269 | 208 |
|
209 |
initialize |
|
6233 | 210 |
|dev| |
211 |
||
269 | 212 |
super initialize. |
213 |
||
6233 | 214 |
dev := self device. |
215 |
width := dev width. |
|
216 |
height := dev height. |
|
6342
d2a4135ecf36
Access graphicsDevice via method send instead of instVar access
Stefan Vogel <sv@exept.de>
parents:
6282
diff
changeset
|
217 |
self createRootWindow. |
269 | 218 |
realized := true. |
219 |
! |
|
220 |
||
221 |
reinitialize |
|
222 |
"reinit after snapin" |
|
223 |
||
6349 | 224 |
self recreate. |
225 |
self createRootWindow. |
|
7266 | 226 |
width := device width. |
227 |
height := device height. |
|
269 | 228 |
realized := true. |
229 |
! ! |
|
230 |
||
0 | 231 |
!DisplayRootView methodsFor:'queries'! |
232 |
||
4650 | 233 |
canDropObjects:aCollectionOfDropObjects |
1584
03d62f063935
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
234 |
"return true, if aCollectionOfDropObjects can be |
2916 | 235 |
dropped in the receiver. |
236 |
False is returned here, since nothing can be dropped on the desktop. |
|
237 |
(for now - actually some systems do allow dropping things on the desktop |
|
238 |
and this query should be forwarded to my display device)" |
|
0 | 239 |
|
240 |
^ false |
|
1584
03d62f063935
drop argument is always a collection
Claus Gittinger <cg@exept.de>
parents:
1256
diff
changeset
|
241 |
|
4650 | 242 |
"Created: / 13-10-2006 / 15:55:54 / cg" |
269 | 243 |
! |
0 | 244 |
|
6764 | 245 |
isActive |
246 |
"for protocol compatibility with regular views" |
|
247 |
||
248 |
^ false. |
|
249 |
! |
|
250 |
||
6753 | 251 |
isComponentOf: aView |
252 |
^ false |
|
253 |
! |
|
254 |
||
919
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
255 |
isRootView |
2916 | 256 |
"return true, since yes, I am a rootview" |
919
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
257 |
|
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
258 |
^ true |
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 |
"Created: 5.7.1996 / 13:48:24 / cg" |
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
261 |
"Modified: 5.7.1996 / 14:57:44 / cg" |
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
262 |
! |
47b7aff0f1e4
added #isRootView & #shown queries
Claus Gittinger <cg@exept.de>
parents:
727
diff
changeset
|
263 |
|
6986 | 264 |
isSameOrComponentOf:aView |
265 |
"return true, if I am aView or a (direct or indirect) component of aView" |
|
266 |
||
267 |
^ self == aView |
|
268 |
! |
|
269 |
||
0 | 270 |
isWindowManagerRunning |
2 | 271 |
"answer true, if a window manager is currently running. |
272 |
This is done by performing an action (enabling button events of |
|
23 | 273 |
root window), which will fail if a window manager is running." |
0 | 274 |
|
6373 | 275 |
device isWindowsPlatform ifTrue:[^ true]. |
276 |
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
|
277 |
^ false. |
2 | 278 |
] do:[ |
2916 | 279 |
self enableButtonEvents. |
6267 | 280 |
self flush. |
2 | 281 |
]. |
4221
666dea8f4aa7
Do not move messages to superclass (where they are sent)
Stefan Vogel <sv@exept.de>
parents:
4214
diff
changeset
|
282 |
^ true |
23 | 283 |
|
134 | 284 |
" |
285 |
DisplayRootView new |
|
286 |
RootView isWindowManagerRunning |
|
287 |
" |
|
0 | 288 |
! ! |
269 | 289 |
|
1254 | 290 |
!DisplayRootView class methodsFor:'documentation'! |
269 | 291 |
|
292 |
version |
|
6986 | 293 |
^ '$Header$' |
269 | 294 |
! ! |
6233 | 295 |