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