author | Claus Gittinger <cg@exept.de> |
Wed, 06 Jun 2018 16:50:40 +0200 | |
changeset 8376 | 7f9164ebccfa |
parent 7625 | 581604ff20a7 |
child 8776 | 7b28d7a6f3cb |
permissions | -rw-r--r-- |
1284 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
2840 | 3 |
All Rights Reserved |
1284 | 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 |
" |
|
3285 | 12 |
"{ Package: 'stx:libview' }" |
13 |
||
6884 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1284 | 16 |
GraphicsDevice subclass:#HostGraphicsDevice |
7443 | 17 |
instanceVariableNames:'graphicsContexts deviceColors deviceFonts deviceCursors' |
1284 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-Graphics' |
|
21 |
! |
|
22 |
||
23 |
!HostGraphicsDevice class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
2840 | 28 |
All Rights Reserved |
1284 | 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 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
this abstract class was inserted to provide a home for ST-80 classes |
|
44 |
(previously, DeviceWorkstation was directly under Object). |
|
2813
913aca399962
preps to keep the view & form lobbies on a per-display basis.
Claus Gittinger <cg@exept.de>
parents:
2809
diff
changeset
|
45 |
We will (over time) move common functionality from there into this class. |
1284 | 46 |
|
47 |
In ST/X, this is mostly dummy. |
|
48 |
||
49 |
[see also:] |
|
2840 | 50 |
DeviceWorkstation XWorkstation |
1284 | 51 |
|
52 |
[author:] |
|
2840 | 53 |
Claus Gittinger |
1284 | 54 |
" |
55 |
||
56 |
||
57 |
! ! |
|
58 |
||
3880 | 59 |
!HostGraphicsDevice methodsFor:'Compatibility-Squeak'! |
2961 | 60 |
|
61 |
deferUpdates: aBoolean |
|
62 |
"Set the deferUpdates flag in the virtual machine. |
|
63 |
When this flag is true, BitBlt operations on the Display are not |
|
64 |
automatically propagated to the screen. |
|
65 |
If this underlying platform does not support deferred updates, |
|
66 |
this primitive will fail. |
|
67 |
Answer the receiver if the primitive succeeds, nil if it fails." |
|
68 |
||
69 |
"/ <primitive: 126> |
|
70 |
^ nil "answer nil if primitive fails" |
|
71 |
||
72 |
! |
|
73 |
||
74 |
forceDisplayUpdate |
|
75 |
"On platforms that buffer screen updates, |
|
76 |
force the screen to be updated immediately. |
|
77 |
On other platforms, or if the primitive is not implemented, do nothing." |
|
78 |
||
79 |
"/ <primitive: 231> |
|
80 |
"do nothing if primitive fails" |
|
81 |
! ! |
|
82 |
||
1365
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
83 |
!HostGraphicsDevice methodsFor:'accessing'! |
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
84 |
|
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
85 |
deviceColors |
1371 | 86 |
"return the registry keeping track of colors which were allocated |
2813
913aca399962
preps to keep the view & form lobbies on a per-display basis.
Claus Gittinger <cg@exept.de>
parents:
2809
diff
changeset
|
87 |
on this device." |
1365
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
88 |
|
6212 | 89 |
^ deviceColors ? #() |
1365
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
90 |
|
6212 | 91 |
"Created: / 24-02-1997 / 18:01:41 / cg" |
1365
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
92 |
! |
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
93 |
|
2843
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
94 |
deviceCursors |
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
95 |
"return the registry keeping track of cursors which were allocated |
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
96 |
on this device." |
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
97 |
|
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
98 |
^ deviceCursors |
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
99 |
|
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
100 |
"Created: 24.2.1997 / 18:01:41 / cg" |
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
101 |
! |
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
102 |
|
1371 | 103 |
deviceFonts |
104 |
"return the registry keeping track of fonts which were allocated |
|
2813
913aca399962
preps to keep the view & form lobbies on a per-display basis.
Claus Gittinger <cg@exept.de>
parents:
2809
diff
changeset
|
105 |
on this device." |
1365
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
106 |
|
4541 | 107 |
^ deviceFonts ? #() |
108 |
||
109 |
"Modified: / 28-07-2006 / 19:48:23 / fm" |
|
2813
913aca399962
preps to keep the view & form lobbies on a per-display basis.
Claus Gittinger <cg@exept.de>
parents:
2809
diff
changeset
|
110 |
! |
913aca399962
preps to keep the view & form lobbies on a per-display basis.
Claus Gittinger <cg@exept.de>
parents:
2809
diff
changeset
|
111 |
|
7443 | 112 |
graphicsContexts |
113 |
"return the registry keeping track of graphics contexts which were allocated |
|
2839 | 114 |
on this device." |
115 |
||
7443 | 116 |
^ graphicsContexts |
1365
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
117 |
! ! |
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
118 |
|
3444 | 119 |
!HostGraphicsDevice methodsFor:'accessing & queries'! |
120 |
||
121 |
defaultExtentForTopViews |
|
3447 | 122 |
|w h| |
123 |
||
124 |
w := self width. |
|
125 |
h := self height. |
|
126 |
||
127 |
self isPDA ifTrue:[ |
|
128 |
^ (w - 16) @ (h - 20) |
|
129 |
]. |
|
130 |
^ (w // 3 * 2) @ (h // 3 * 2) |
|
3444 | 131 |
! ! |
132 |
||
3883 | 133 |
!HostGraphicsDevice methodsFor:'initialization & release'! |
1365
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
134 |
|
1367 | 135 |
initializeDeviceResourceTables |
7443 | 136 |
graphicsContexts := Registry new. |
1365
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
137 |
deviceColors := Registry new. |
2843
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
138 |
deviceCursors := Registry new. |
7625 | 139 |
deviceFonts := CachingRegistry new:50. |
1365
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
140 |
|
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
141 |
"Created: 24.2.1997 / 18:29:53 / cg" |
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
142 |
! |
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
143 |
|
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
144 |
releaseDeviceColors |
6884 | 145 |
deviceColors notNil ifTrue:[ |
146 |
deviceColors do:[:aColor | |
|
147 |
aColor releaseFromDevice |
|
148 |
]. |
|
149 |
deviceColors := Registry new. |
|
150 |
||
151 |
"TrueColors are not registered. |
|
7546 | 152 |
Release them the hard way" |
6884 | 153 |
Color flushDeviceColorsFor:self. |
2839 | 154 |
]. |
4222
4fee2e231633
Take care to relases the device of TrueColors.
Stefan Vogel <sv@exept.de>
parents:
3927
diff
changeset
|
155 |
|
1365
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
156 |
"Created: 24.2.1997 / 18:07:49 / cg" |
1371 | 157 |
! |
158 |
||
2843
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
159 |
releaseDeviceCursors |
6884 | 160 |
deviceCursors notNil ifTrue:[ |
161 |
deviceCursors do:[:aCursor | |
|
162 |
aCursor releaseFromDevice |
|
163 |
]. |
|
164 |
deviceCursors := Registry new. |
|
165 |
] |
|
2843
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
166 |
|
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
167 |
"Created: 24.2.1997 / 18:07:49 / cg" |
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
168 |
! |
e13e0c53924a
keep registry of cursors here - no longer use a Cursor Lobby
Claus Gittinger <cg@exept.de>
parents:
2840
diff
changeset
|
169 |
|
1371 | 170 |
releaseDeviceFonts |
6884 | 171 |
deviceFonts notNil ifTrue:[ |
172 |
deviceFonts do:[:aFont | |
|
173 |
aFont releaseFromDevice. |
|
174 |
]. |
|
7578 | 175 |
deviceFonts := CachingRegistry new:20. |
2846 | 176 |
]. |
7443 | 177 |
! |
178 |
||
179 |
releaseGraphicsContexts |
|
180 |
graphicsContexts notNil ifTrue:[ |
|
181 |
graphicsContexts unregisterAllForWhichHandle:[:eachHandle | |
|
182 |
eachHandle finalize. |
|
183 |
true |
|
184 |
]. |
|
185 |
] |
|
1365
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
186 |
! ! |
37a9e7ac4dbc
moved color registration from Color class to per-device lobby
Claus Gittinger <cg@exept.de>
parents:
1315
diff
changeset
|
187 |
|
3285 | 188 |
!HostGraphicsDevice methodsFor:'misc'! |
189 |
||
190 |
recolorCursorsToFgColor:fgColor defaultBgColor:bgColor |
|
191 |
"change the colors of all existing cursors" |
|
192 |
||
193 |
"/ recolor existing cursors |
|
194 |
deviceCursors do:[:eachCursor | eachCursor foreground:fgColor background:bgColor]. |
|
195 |
||
196 |
" |
|
197 |
Display recolorCursorsToFgColor:(Color red) defaultBgColor:(Color white) |
|
198 |
||
199 |
Display recolorCursorsToFgColor:(Color blue) defaultBgColor:(Color white) |
|
200 |
Display recolorCursorsToFgColor:(Color blue) defaultBgColor:(Color black) |
|
201 |
Display recolorCursorsToFgColor:(Color white) defaultBgColor:(Color black) |
|
202 |
Display recolorCursorsToFgColor:(Color white) defaultBgColor:(Color red) |
|
203 |
" |
|
204 |
! ! |
|
205 |
||
2846 | 206 |
!HostGraphicsDevice methodsFor:'registration'! |
207 |
||
7475 | 208 |
cleanupLobbyForChildrenOfViewWithId:anId |
209 |
"recursively clean all the subcomponents of the handle with id anId. |
|
210 |
This must be done on finalization, because descendent handles |
|
211 |
are destroyed implicitly when a parent handle is destroyed." |
|
212 |
||
213 |
|parents newChildren| |
|
214 |
||
215 |
parents := Array with:anId address. |
|
216 |
||
217 |
[ |
|
218 |
newChildren := Set new. |
|
219 |
graphicsContexts unregisterAllForWhichHandle:[:handle | |
|
220 |
|parentId| |
|
221 |
||
222 |
handle notNil |
|
223 |
and:[(parentId := handle parentId) notNil |
|
224 |
and:[(parents includes:parentId) |
|
225 |
and:[newChildren add:handle id. true]]]. |
|
226 |
]. |
|
227 |
parents := newChildren. |
|
228 |
] doWhile:[parents notEmpty]. |
|
229 |
! |
|
230 |
||
2846 | 231 |
registerColor:aColor |
232 |
deviceColors register:aColor. |
|
233 |
||
234 |
"Created: 24.2.1997 / 18:29:10 / cg" |
|
235 |
! |
|
236 |
||
237 |
registerCursor:aCursor |
|
238 |
deviceCursors register:aCursor. |
|
239 |
||
240 |
"Created: 24.2.1997 / 18:29:10 / cg" |
|
241 |
! |
|
242 |
||
243 |
registerFont:aFont |
|
244 |
deviceFonts register:aFont. |
|
245 |
||
246 |
"Created: 24.2.1997 / 18:29:10 / cg" |
|
247 |
! |
|
248 |
||
7443 | 249 |
registerGraphicsContext:aGC |
250 |
graphicsContexts register:aGC |
|
2846 | 251 |
! |
252 |
||
253 |
unregisterColor:aColor |
|
254 |
deviceColors unregister:aColor. |
|
255 |
||
256 |
"Created: 24.2.1997 / 18:29:14 / cg" |
|
257 |
! |
|
258 |
||
259 |
unregisterCursor:aCursor |
|
260 |
deviceCursors unregister:aCursor. |
|
261 |
||
262 |
"Created: 24.2.1997 / 18:29:14 / cg" |
|
263 |
! |
|
264 |
||
265 |
unregisterFont:aFont |
|
266 |
deviceFonts unregister:aFont. |
|
267 |
||
268 |
"Created: 24.2.1997 / 18:29:14 / cg" |
|
269 |
! |
|
270 |
||
7443 | 271 |
unregisterGraphicsContext:aGC |
272 |
graphicsContexts unregister:aGC |
|
2846 | 273 |
! ! |
274 |
||
1284 | 275 |
!HostGraphicsDevice class methodsFor:'documentation'! |
276 |
||
277 |
version |
|
6884 | 278 |
^ '$Header$' |
1284 | 279 |
! ! |
6212 | 280 |