author | Stefan Vogel <sv@exept.de> |
Thu, 04 Jul 1996 12:47:08 +0200 | |
changeset 914 | 6cf4cc647095 |
parent 911 | c934a49174e8 |
child 918 | 8f00b091552b |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
70 | 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 |
" |
|
12 |
||
13 |
DeviceWorkstation subclass:#XWorkstation |
|
341 | 14 |
instanceVariableNames:'screen hasShapeExtension hasFaxExtension hasShmExtension |
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
15 |
hasDPSExtension hasMbufExtension hasXVideoExtension hasSaveUnder |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
16 |
hasPEXExtension hasImageExtension hasInputExtension |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
17 |
ignoreBackingStore blackpixel whitepixel protocolsAtom |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
18 |
deleteWindowAtom saveYourselfAtom quitAppAtom primaryAtom |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
19 |
secondaryAtom cutBuffer0Atom stringAtom lengthAtom listOfXFonts |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
20 |
buttonsPressed eventRootX eventRootY displayName eventTrace |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
21 |
dispatchingExpose rgbVisual virtualRootId rootId eventBuffer |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
22 |
altModifierMask metaModifierMask' |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
23 |
classVariableNames:'RawKeysymTranslation ConservativeSync' |
341 | 24 |
poolDictionaries:'' |
25 |
category:'Interface-Graphics' |
|
295 | 26 |
! |
0 | 27 |
|
78 | 28 |
!XWorkstation primitiveDefinitions! |
0 | 29 |
%{ |
46 | 30 |
/* |
31 |
* x does a typedef Time - I need Object Time ... |
|
32 |
*/ |
|
0 | 33 |
#define Time XTime |
34 |
||
391
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
35 |
/* |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
36 |
* x does a #define True / False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
37 |
* we are lucky - the ST/X True/False are not needed |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
38 |
*/ |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
39 |
#undef True |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
40 |
#undef False |
d3cad7c15ae2
well well well - do a sync in eventPending
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
41 |
|
37 | 42 |
#ifdef memset |
43 |
# undef memset |
|
44 |
#endif |
|
45 |
||
0 | 46 |
#include <stdio.h> |
47 |
#include <X11/Xlib.h> |
|
48 |
#include <X11/Xutil.h> |
|
49 |
#include <X11/Xatom.h> |
|
50 |
||
150 | 51 |
#define XK_MISCELLANY |
52 |
#include <X11/keysymdef.h> |
|
53 |
||
277
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
54 |
#include <X11/cursorfont.h> |
eb67c44da084
testing new inline-expression feature of stc - no real change
Claus Gittinger <cg@exept.de>
parents:
268
diff
changeset
|
55 |
|
90 | 56 |
/* |
57 |
* this define adds support for two-byte-strings. |
|
58 |
* leaving it undefined does not really save you much |
|
59 |
* (the define will vanish) |
|
60 |
*/ |
|
36 | 61 |
#define TWOBYTESTRINGS |
62 |
||
0 | 63 |
/* |
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
64 |
* this define suppresses XAllocColor/XFreeColor on |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
65 |
* TrueColor systems - I am not certain, if this is |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
66 |
* always legal to do (it works with XFree servers). |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
67 |
*/ |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
68 |
#define QUICK_TRUE_COLORS |
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
69 |
|
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
70 |
/* |
0 | 71 |
* shape support works; enabled by -DSHAPE in makefile |
72 |
* see RoundClock and RoundGlobe examples |
|
73 |
*/ |
|
74 |
#ifdef SHAPE |
|
75 |
# include <X11/extensions/shape.h> |
|
76 |
#endif |
|
77 |
||
78 |
/* |
|
150 | 79 |
* shared memory extension access is currently not supported |
0 | 80 |
* (only query is implemented) |
81 |
*/ |
|
82 |
#ifdef SHM |
|
83 |
# include <X11/extensions/XShm.h> |
|
84 |
#endif |
|
85 |
||
86 |
/* |
|
150 | 87 |
* multiBuffer extension access is currently not supported |
88 |
* (only query is implemented) |
|
89 |
*/ |
|
90 |
#ifdef MBUF |
|
91 |
# include <X11/extensions/multibuf.h> |
|
92 |
#endif |
|
93 |
||
94 |
/* |
|
95 |
* XVideo extension access is currently not supported |
|
96 |
* (only query is implemented) |
|
97 |
*/ |
|
98 |
#ifdef XVIDEO |
|
99 |
# include <X11/extensions/Xv.h> |
|
100 |
#endif |
|
101 |
||
102 |
/* |
|
0 | 103 |
* this is a non-standard fax-image decompression extension |
104 |
* (only found in megascan servers ported by myself) |
|
105 |
*/ |
|
106 |
#ifdef FAX |
|
107 |
# include <X11/extensions/XFAXImage.h> |
|
108 |
#endif |
|
109 |
||
110 |
/* |
|
186 | 111 |
* PEX extension - if available |
112 |
*/ |
|
113 |
#ifdef PEX5 |
|
114 |
# include <PEX5/PEX.h> |
|
115 |
#endif |
|
116 |
||
117 |
/* |
|
118 |
* XImage extension - if available |
|
119 |
*/ |
|
120 |
#ifdef XIE |
|
121 |
# include <X11/extensions/XIE.h> |
|
122 |
#endif |
|
123 |
||
124 |
/* |
|
90 | 125 |
* when I have more time to check it out, I will support display-PS |
0 | 126 |
*/ |
127 |
#ifdef DPS |
|
128 |
# ifdef sgi |
|
129 |
# include <X11/extensions/XDPS.h> |
|
130 |
# include <X11/extensions/XDPSlib.h> |
|
131 |
# include <X11/extensions/dpsXclient.h> |
|
132 |
# else |
|
133 |
# include <DPS/XDPS.h> |
|
134 |
# include <DPS/XDPSlib.h> |
|
135 |
# include <DPS/dpsXclient.h> |
|
136 |
# endif |
|
137 |
#endif |
|
138 |
||
90 | 139 |
#if defined(IRIX5) || (XlibSpecificationRelease == 6) |
140 |
/* |
|
141 |
* accessing private data in Display ... sorry |
|
142 |
*/ |
|
143 |
# define DISPLAYACCESS(d) ((_XPrivDisplay)d) |
|
144 |
#else |
|
145 |
# define DISPLAYACCESS(d) d |
|
146 |
#endif |
|
147 |
||
78 | 148 |
/* |
149 |
* some defines - tired of typing ... |
|
150 |
*/ |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
151 |
#define _DisplayVal(o) (Display *)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
152 |
#define _WindowVal(o) (Window)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
153 |
#define _PixmapVal(o) (Pixmap)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
154 |
#define _GCVal(o) (GC)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
155 |
#define _CursorVal(o) (Cursor)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
156 |
#define _FontVal(o) (XFontStruct *)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
157 |
#define _DPSContextVal(o) (DPSContext)(__MKCP(o)) |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
158 |
|
211 | 159 |
#define __MKATOMOBJ(a) __MKSMALLINT(a) |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
160 |
#define _AtomVal(o) __intVal(o) |
211 | 161 |
#define __isAtomID(o) __isSmallInteger(o) |
162 |
||
555 | 163 |
#define myDpy _DisplayVal(__INST(displayId)) |
164 |
#define ISCONNECTED (__INST(displayId) != nil) |
|
78 | 165 |
|
166 |
#ifndef THISCONTEXT_IN_REGISTER |
|
167 |
# define BEGIN_INTERRUPTSBLOCKED /* */ |
|
168 |
# define END_INTERRUPTSBLOCKED /* */ |
|
169 |
#else |
|
170 |
extern int __interruptsBlocked; |
|
171 |
# define BEGIN_INTERRUPTSBLOCKED \ |
|
172 |
{ \ |
|
850 | 173 |
int needUnblock = 0; \ |
174 |
extern OBJ __thisContext__; \ |
|
175 |
\ |
|
176 |
__thisContext__ = __thisContext;\ |
|
177 |
if (!__interruptsBlocked) { \ |
|
178 |
__BLOCKINTERRUPTS(); \ |
|
179 |
needUnblock = 1; \ |
|
180 |
} |
|
78 | 181 |
|
182 |
# define END_INTERRUPTSBLOCKED \ |
|
850 | 183 |
__thisContext = __thisContext; \ |
184 |
__thisContext__ = 0; \ |
|
185 |
if (needUnblock) { \ |
|
186 |
__UNBLOCKINTERRUPTS(); \ |
|
187 |
} \ |
|
78 | 188 |
} |
189 |
||
190 |
#endif |
|
191 |
%} |
|
192 |
! ! |
|
193 |
||
194 |
!XWorkstation primitiveVariables! |
|
195 |
%{ |
|
0 | 196 |
/* |
146 | 197 |
* remembered info from private error handler |
0 | 198 |
*/ |
2 | 199 |
static char lastErrorMsg[80] = ""; |
200 |
static unsigned lastRequestCode = 0; |
|
201 |
static unsigned lastMinorCode = 0; |
|
202 |
static unsigned lastResource = 0; |
|
129 | 203 |
|
204 |
static int __debug__ = 0; |
|
205 |
#define DPRINTF(x) if (__debug__) { printf x; } |
|
78 | 206 |
%} |
207 |
! ! |
|
208 |
||
209 |
!XWorkstation primitiveFunctions! |
|
210 |
%{ |
|
18 | 211 |
/* |
144 | 212 |
* catch X-errors and forward as errorInterrupt:#DisplayError, |
213 |
* (which itself invokes my handler and optionally raises an exceptionSignal) |
|
90 | 214 |
* the implementation below is somewhat wrong: it will |
78 | 215 |
* report all errors for Display, even though there could be |
162 | 216 |
* more than one display connection. (being fixed, new errorInterrupt mechanism |
217 |
* allows passing an additional argument, which is the displayID ...) |
|
18 | 218 |
*/ |
168 | 219 |
static |
12 | 220 |
__XErrorHandler__(dpy, event) |
0 | 221 |
Display *dpy; |
222 |
XErrorEvent *event; |
|
223 |
{ |
|
224 |
XGetErrorText(dpy, event->error_code, lastErrorMsg, 80); |
|
225 |
if (lastErrorMsg[0] == '\0') { |
|
70 | 226 |
sprintf(lastErrorMsg, "code: %d", event->error_code); |
0 | 227 |
} |
2 | 228 |
lastRequestCode = event->request_code; |
229 |
lastMinorCode = event->minor_code; |
|
230 |
lastResource = event->resourceid; |
|
911 | 231 |
if ((event->error_code == BadWindow) && (lastRequestCode == 4) && (lastMinorCode == 0)) { |
232 |
/* |
|
233 |
* this is a BadWindow error for X_DestroyWindow. |
|
234 |
* ignore it here, since it results from the GC freeing windows |
|
235 |
* in non bottom-up window order. |
|
236 |
*/ |
|
237 |
return 0; |
|
238 |
} |
|
2 | 239 |
|
254
d6f12ecd7767
ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
240 |
if (@global(ErrorPrinting) == true) { |
219
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
241 |
fprintf(stderr, "XWORKSTAT: x-error cought maj=%d (0x%x) min=%d (0x%x) resource=%x\n", |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
242 |
event->request_code, event->request_code, |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
243 |
event->minor_code, event->minor_code, event->resourceid); |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
244 |
fprintf(stderr, "XWORKSTAT: x-error message is '%s'\n", lastErrorMsg); |
218
10072d9beba5
can now turn off Xlib error messages from the errorHandler
Claus Gittinger <cg@exept.de>
parents:
217
diff
changeset
|
245 |
} |
43 | 246 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
247 |
__errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy)); |
0 | 248 |
return 0; |
249 |
} |
|
250 |
||
90 | 251 |
#ifdef VIRTUAL_ROOT |
0 | 252 |
/* |
18 | 253 |
* added since RootWindow-macro is not suficient |
254 |
* when virtual root-windows are involved (i.e. tvtwm) |
|
255 |
*/ |
|
256 |
static Window |
|
257 |
getRootWindow(dpy, screen) |
|
258 |
Display *dpy; |
|
259 |
{ |
|
260 |
Window root; |
|
261 |
Atom vRootAtom = None; |
|
262 |
int i; |
|
263 |
Window rootReturn, parentReturn; |
|
264 |
Window* children; |
|
265 |
unsigned int numChildren; |
|
266 |
||
267 |
root = RootWindow(dpy, screen); |
|
268 |
/* |
|
269 |
* on IRIS, this creates a badwindow error - why ? |
|
270 |
* children contains a funny window (000034) |
|
271 |
*/ |
|
90 | 272 |
# if !defined(IRIS) || defined(IRIX5) |
18 | 273 |
if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) { |
70 | 274 |
vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True ); |
275 |
if (vRootAtom != None) { |
|
276 |
for (i=0; i < numChildren; i++) { |
|
277 |
Atom actual_type; |
|
278 |
int actual_format; |
|
279 |
unsigned long nitems, bytesafter; |
|
280 |
Window* newRoot = (Window*) 0; |
|
281 |
||
282 |
if (children[i]) { |
|
283 |
if (XGetWindowProperty(dpy, children[i], vRootAtom, |
|
284 |
0L, 1L, False, XA_WINDOW, |
|
285 |
&actual_type, &actual_format, &nitems, &bytesafter, |
|
286 |
(unsigned char**) &newRoot) == Success && newRoot) { |
|
287 |
root = *newRoot; |
|
288 |
break; |
|
289 |
} |
|
290 |
} |
|
291 |
} |
|
292 |
if (children) XFree( children ); |
|
293 |
} |
|
18 | 294 |
} |
90 | 295 |
# endif |
18 | 296 |
return root; |
297 |
} |
|
90 | 298 |
#endif |
0 | 299 |
%} |
78 | 300 |
! ! |
0 | 301 |
|
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
302 |
!XWorkstation class methodsFor:'documentation'! |
295 | 303 |
|
304 |
copyright |
|
305 |
" |
|
306 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
307 |
All Rights Reserved |
|
308 |
||
309 |
This software is furnished under a license and may be used |
|
310 |
only in accordance with the terms of that license and with the |
|
311 |
inclusion of the above copyright notice. This software may not |
|
312 |
be provided or otherwise made available to, or used by, any |
|
313 |
other person. No title to or ownership of the software is |
|
314 |
hereby transferred. |
|
315 |
" |
|
316 |
! |
|
317 |
||
318 |
documentation |
|
319 |
" |
|
320 |
this class provides the interface to X11. It redefines all required methods |
|
321 |
from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically |
|
322 |
limited to one display - in theory, you can create Views on many displays |
|
323 |
simultanously. However, the default setup is for one display only. |
|
324 |
To support multiple displays, you will have to start another event dispatcher |
|
325 |
process for the other display(s) and create the other views with a slightly |
|
326 |
different protocol. However, 'normal' applications do not have to care for |
|
327 |
all of this ... |
|
328 |
||
329 |
See more documentation in my superclass, DeviceWorkstation. |
|
613 | 330 |
|
331 |
[author:] |
|
850 | 332 |
Claus Gittinger |
295 | 333 |
" |
334 |
! ! |
|
335 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
336 |
!XWorkstation class methodsFor:'initialization'! |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
337 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
338 |
initialize |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
339 |
|d| |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
340 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
341 |
super initialize. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
342 |
|
386 | 343 |
RawKeysymTranslation isNil ifTrue:[ |
344 |
"/ the following table maps X-keyevents to ST/X |
|
345 |
"/ device independed events. |
|
346 |
"/ It is NOT meant as a keyboardMap replacement. |
|
347 |
||
348 |
RawKeysymTranslation := d := Dictionary new. |
|
349 |
d at:'Delete_line' put:#DeleteLine. |
|
350 |
d at:'Delete_word' put:#DeleteWord. |
|
351 |
d at:'Down' put:#CursorDown. |
|
352 |
d at:'Up' put:#CursorUp. |
|
353 |
d at:'Left' put:#CursorLeft. |
|
354 |
d at:'Right' put:#CursorRight. |
|
355 |
] |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
356 |
! ! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
357 |
|
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
358 |
!XWorkstation class methodsFor:'error handling'! |
2 | 359 |
|
129 | 360 |
debug:aBoolean |
361 |
%{ /* NOCONTEXT */ |
|
362 |
||
363 |
__debug__ = (aBoolean == true) ? 1 : 0; |
|
364 |
%} |
|
365 |
! |
|
366 |
||
78 | 367 |
errorStringOfLastError |
368 |
%{ |
|
216 | 369 |
RETURN ( __MKSTRING(lastErrorMsg COMMA_CON) ); |
78 | 370 |
%} |
371 |
! |
|
372 |
||
135 | 373 |
lastErrorString |
2 | 374 |
"return the last X-error string - |
375 |
when buffering is on, this may be |
|
376 |
an error for a long-ago operation" |
|
78 | 377 |
|
378 |
|string requestCode s match line| |
|
379 |
||
380 |
string := self errorStringOfLastError. |
|
381 |
requestCode := self requestCodeOfLastError. |
|
382 |
" |
|
383 |
X specific: search the requestCode in '/usr/lib/X11/XErrorDB', |
|
384 |
and append the name of the corresponding X-request |
|
385 |
" |
|
386 |
s := '/usr/lib/X11/XErrorDB' asFilename readStream. |
|
387 |
s notNil ifTrue:[ |
|
388 |
match := 'XRequest.' , requestCode printString. |
|
389 |
line := s peekForLineStartingWith:match. |
|
390 |
line notNil ifTrue:[ |
|
391 |
string := string , ' in ' , (line copyFrom:(line indexOf:$:)+1) |
|
392 |
]. |
|
393 |
s close. |
|
394 |
]. |
|
395 |
^ string |
|
295 | 396 |
! |
397 |
||
398 |
minorCodeOfLastError |
|
399 |
%{ /* NOCONTEXT */ |
|
400 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
401 |
RETURN ( __MKSMALLINT(lastMinorCode) ); |
295 | 402 |
%} |
403 |
! |
|
404 |
||
405 |
requestCodeOfLastError |
|
152 | 406 |
%{ /* NOCONTEXT */ |
407 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
408 |
RETURN ( __MKSMALLINT(lastRequestCode) ); |
0 | 409 |
%} |
135 | 410 |
! |
411 |
||
295 | 412 |
resourceIdOfLastError |
0 | 413 |
%{ /* NOCONTEXT */ |
295 | 414 |
|
415 |
RETURN ( __MKOBJ(lastResource) ); |
|
0 | 416 |
%} |
417 |
! ! |
|
418 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
419 |
!XWorkstation class methodsFor:'queries'! |
104 | 420 |
|
421 |
platformName |
|
133 | 422 |
"ST-80 compatibility. |
423 |
Return a string describing the display systems platform." |
|
424 |
||
715 | 425 |
^ 'X11' "I don't know what ST-80 returns for X ..." |
426 |
||
427 |
"Modified: 26.5.1996 / 15:32:46 / cg" |
|
104 | 428 |
! ! |
429 |
||
0 | 430 |
!XWorkstation methodsFor:'accessing & queries'! |
431 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
432 |
anyButtonMotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
433 |
"return the state-mask for any button in motion events' state-field. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
434 |
This is the devices mask." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
435 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
436 |
%{ /* NOCONTEXT */ |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
437 |
RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask)); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
438 |
%}. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
439 |
^ nil |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
440 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
441 |
|
295 | 442 |
blackpixel |
443 |
"return the colornumber of black" |
|
444 |
||
445 |
^ blackpixel |
|
446 |
! |
|
447 |
||
448 |
button1MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
449 |
"return the state-mask for button1 in motion events' state-field. |
295 | 450 |
For backward compatibility." |
451 |
||
452 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
453 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
295 | 454 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
455 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
456 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
457 |
Display button1MotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
458 |
" |
295 | 459 |
! |
460 |
||
461 |
button2MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
462 |
"return the state-mask for button2 in motion events' state-field |
295 | 463 |
For backward compatibility." |
464 |
||
465 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
466 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
295 | 467 |
%} |
468 |
! |
|
469 |
||
470 |
button3MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
471 |
"return the state-mask for button3 in motion events' state-field |
295 | 472 |
For backward compatibility." |
473 |
||
474 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
475 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 476 |
%} |
477 |
! |
|
478 |
||
479 |
buttonMotionMask:aButton |
|
480 |
"return the state-mask for button1 in motion events state-field. |
|
481 |
This is the devices mask." |
|
482 |
||
483 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
484 |
if (aButton == __MKSMALLINT(1)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
485 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
486 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
487 |
if (aButton == __MKSMALLINT(2)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
488 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
489 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
490 |
if (aButton == __MKSMALLINT(3)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
491 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 492 |
} |
493 |
%}. |
|
494 |
^ nil |
|
495 |
! |
|
496 |
||
382 | 497 |
controlMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
498 |
"return the state-mask for the CTRL modified in motion events' state-field." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
499 |
|
382 | 500 |
%{ /* NOCONTEXT */ |
501 |
RETURN (__MKSMALLINT(ControlMask)); |
|
502 |
%} |
|
503 |
! |
|
504 |
||
295 | 505 |
defaultEventMask |
506 |
"return a mask to enable some events by default." |
|
507 |
||
508 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
509 |
RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask | |
295 | 510 |
KeyPressMask | KeyReleaseMask | |
511 |
EnterWindowMask | LeaveWindowMask | |
|
512 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask )); |
|
513 |
%} |
|
514 |
! |
|
515 |
||
0 | 516 |
displayFileDescriptor |
517 |
"return the displays fileNumber - for select" |
|
518 |
||
519 |
%{ /* NOCONTEXT */ |
|
520 |
||
150 | 521 |
if (ISCONNECTED) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
522 |
RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) ); |
150 | 523 |
} |
524 |
RETURN (nil); |
|
0 | 525 |
%} |
526 |
! |
|
527 |
||
133 | 528 |
displayName |
529 |
"return the X-connections display name. |
|
530 |
This is (currently) nil for the default display, |
|
531 |
something like foo:0 for any other remote display. |
|
532 |
Future versions may return non-nil strings for the default display as well." |
|
533 |
||
534 |
^ displayName |
|
535 |
! |
|
536 |
||
341 | 537 |
protocolVersion |
538 |
"return the X-servers protocol version - should normally not be of |
|
539 |
any interest" |
|
540 |
||
541 |
%{ /* NOCONTEXT */ |
|
542 |
if (ISCONNECTED) { |
|
543 |
RETURN ( __MKSMALLINT(XProtocolVersion(myDpy)) ); |
|
544 |
} |
|
545 |
RETURN (nil); |
|
546 |
%} |
|
547 |
||
548 |
" |
|
549 |
Display protocolVersion |
|
550 |
" |
|
551 |
! |
|
552 |
||
553 |
serverVendor |
|
554 |
"return the X-server vendor string - this should normally not be of |
|
555 |
any interest, but can be for special cases |
|
556 |
(to avoid bugs in certain implementations)" |
|
557 |
%{ |
|
558 |
if (ISCONNECTED) { |
|
559 |
RETURN ( __MKSTRING(XServerVendor(myDpy) COMMA_CON) ); |
|
560 |
} |
|
561 |
RETURN (nil); |
|
562 |
%} |
|
563 |
||
564 |
" |
|
565 |
Display serverVendor |
|
566 |
" |
|
567 |
! |
|
568 |
||
382 | 569 |
shiftMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
570 |
"return the state-mask for the SHIFT modified in motion events' state-field." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
571 |
|
382 | 572 |
%{ /* NOCONTEXT */ |
573 |
RETURN (__MKSMALLINT(ShiftMask)); |
|
574 |
%} |
|
575 |
! |
|
576 |
||
341 | 577 |
translatePoint:aPoint from:windowId1 to:windowId2 |
578 |
"given a point in window1, return the coordinate in window2. |
|
579 |
This expects a device coordinate (relative to the first views origin) |
|
580 |
in aPoint and returns a device coordinate relative to the 2nd views origin. |
|
581 |
- use to xlate points from a window to rootwindow" |
|
582 |
||
583 |
|x1 y1 x2 y2| |
|
584 |
||
585 |
x1 := x2 := aPoint x truncated. |
|
586 |
y1 := y2 := aPoint y truncated. |
|
587 |
%{ |
|
588 |
int xpos, ypos; |
|
589 |
Window w1, w2, child_return; |
|
555 | 590 |
int screen = __intVal(__INST(screen)); |
341 | 591 |
Display *dpy = myDpy; |
592 |
||
593 |
if (__isExternalAddress(windowId1) |
|
594 |
&& __isExternalAddress(windowId2) |
|
595 |
&& __bothSmallInteger(x1, y1)) { |
|
596 |
w1 = _WindowVal(windowId1); |
|
597 |
w2 = _WindowVal(windowId2); |
|
598 |
#ifdef VIRTUAL_ROOT |
|
599 |
if ((w1 == RootWindow(dpy, screen)) |
|
600 |
|| (w2 == RootWindow(dpy, screen))) { |
|
601 |
if (w1 == RootWindow(dpy, screen)) { |
|
602 |
w1 = getRootWindow(dpy, screen); |
|
603 |
} |
|
604 |
if (w2 == RootWindow(dpy, screen)) { |
|
605 |
w2 = getRootWindow(dpy, screen); |
|
606 |
} |
|
607 |
} |
|
608 |
#endif |
|
609 |
BEGIN_INTERRUPTSBLOCKED |
|
610 |
XTranslateCoordinates(dpy, w1, w2, |
|
555 | 611 |
__intVal(x1), __intVal(y1), |
341 | 612 |
&xpos, &ypos, &child_return); |
613 |
END_INTERRUPTSBLOCKED |
|
614 |
x2 = __MKSMALLINT(xpos); |
|
615 |
y2 = __MKSMALLINT(ypos); |
|
616 |
} |
|
617 |
%}. |
|
618 |
||
619 |
^ (x2 @ y2) |
|
620 |
! |
|
621 |
||
622 |
vendorRelease |
|
623 |
"return the X-servers vendor release - should normally not be of |
|
624 |
any interest, but can be for special cases. |
|
625 |
(to avoid bugs in certain implementations)" |
|
626 |
||
627 |
%{ /* NOCONTEXT */ |
|
628 |
if (ISCONNECTED) { |
|
629 |
RETURN ( __MKSMALLINT(XVendorRelease(myDpy)) ); |
|
630 |
} |
|
631 |
RETURN (nil); |
|
632 |
%} |
|
633 |
||
634 |
" |
|
635 |
Display vendorRelease |
|
636 |
" |
|
637 |
! |
|
638 |
||
639 |
viewIdFromPoint:aPoint in:windowId |
|
640 |
"given a point in rootWindow, return the viewId of the subview of windowId |
|
641 |
hit by this coordinate. Return nil if no view was hit. |
|
642 |
The returned id may be the id of a non ST view. |
|
643 |
- used to find the window to drop objects after a cross-view drag." |
|
644 |
||
645 |
%{ /* NOCONTEXT */ |
|
646 |
||
647 |
Display *dpy = myDpy; |
|
555 | 648 |
int screen = __intVal(__INST(screen)); |
341 | 649 |
OBJ xp, yp; |
650 |
int xpos, ypos; |
|
651 |
Window child_return; |
|
652 |
||
653 |
if (__isExternalAddress(windowId) |
|
654 |
&& __isPoint(aPoint)) { |
|
655 |
xp = _point_X(aPoint); |
|
656 |
yp = _point_Y(aPoint); |
|
657 |
if (__bothSmallInteger(xp, yp)) { |
|
658 |
BEGIN_INTERRUPTSBLOCKED |
|
659 |
XTranslateCoordinates(dpy, |
|
660 |
RootWindow(dpy, screen), |
|
661 |
_WindowVal(windowId), |
|
555 | 662 |
__intVal(xp), __intVal(yp), |
341 | 663 |
&xpos, &ypos, &child_return); |
664 |
END_INTERRUPTSBLOCKED |
|
665 |
if (child_return) { |
|
666 |
RETURN ( __MKOBJ(child_return) ); |
|
667 |
} |
|
668 |
RETURN ( nil ); |
|
669 |
} |
|
670 |
} |
|
671 |
%}. |
|
672 |
windowId notNil ifTrue:[ |
|
673 |
aPoint isPoint ifTrue:[ |
|
674 |
^ self viewIdFromPoint:aPoint asPoint truncated in:windowId |
|
675 |
] |
|
676 |
]. |
|
677 |
||
678 |
^ nil |
|
679 |
! |
|
680 |
||
681 |
virtualExtent |
|
682 |
"return the virtual extent of the display (in pixels). |
|
683 |
On most systems, this is the same as the physical width; |
|
684 |
except, if a window manager with a virtual desktop like olvwm |
|
685 |
(simulating a bigger screen) is running." |
|
686 |
||
687 |
%{ |
|
555 | 688 |
if ((__INST(rootId) != __INST(virtualRootId)) |
689 |
&& __isExternalAddress(__INST(virtualRootId))) { |
|
341 | 690 |
Window vRootWin; |
691 |
Window root; |
|
692 |
int x, y; |
|
693 |
unsigned int width, height; |
|
694 |
unsigned int dummy; |
|
695 |
||
555 | 696 |
vRootWin = _WindowVal(__INST(virtualRootId)); |
341 | 697 |
if (XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height, |
698 |
&dummy, &dummy)) { |
|
699 |
RETURN ( __MKPOINT_INT(width, height) ); |
|
700 |
} |
|
701 |
} |
|
702 |
%}. |
|
703 |
^ width @ height |
|
704 |
! |
|
705 |
||
706 |
whitepixel |
|
707 |
"return the colornumber of white" |
|
708 |
||
709 |
^ whitepixel |
|
710 |
! ! |
|
711 |
||
712 |
!XWorkstation methodsFor:'accessing display capabilities'! |
|
713 |
||
0 | 714 |
hasDPS |
186 | 715 |
"return true, if this workstation supports display postscript. |
716 |
Both the server must support it, and the feature must have been |
|
717 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 718 |
|
719 |
^ hasDPSExtension |
|
186 | 720 |
|
721 |
" |
|
722 |
Display hasDPS |
|
723 |
" |
|
724 |
! |
|
725 |
||
150 | 726 |
hasExtension:extensionString |
727 |
"query for an X extension. The argument, extensionString |
|
728 |
should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc). |
|
186 | 729 |
Return true, if that extension is available in the server. |
730 |
(which does not imply, that there is support in smalltalk for it." |
|
150 | 731 |
|
732 |
%{ |
|
733 |
int dummy; |
|
734 |
||
735 |
if (__isString(extensionString) && ISCONNECTED) { |
|
736 |
if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) { |
|
737 |
RETURN ( true ); |
|
738 |
} |
|
739 |
} |
|
740 |
%}. |
|
741 |
^ false |
|
186 | 742 |
|
743 |
" |
|
744 |
Display hasExtension:'XVideo' |
|
745 |
Display hasExtension:'Input' |
|
746 |
Display hasExtension:'GLX' |
|
747 |
Display hasExtension:'X3D-PEX' |
|
748 |
Display hasExtension:'XInputExtension' |
|
749 |
Display hasExtension:'SHAPE' |
|
750 |
Display hasExtension:'MIT-SHM' |
|
751 |
Display hasExtension:'SGIFullScreenStereo' |
|
752 |
" |
|
150 | 753 |
! |
754 |
||
295 | 755 |
hasFax |
756 |
"return true, if this workstation supports decompression of fax images. |
|
757 |
Both the server must support it, and the feature must have been |
|
758 |
enabled in the smalltalk system, for true to be returned." |
|
759 |
||
760 |
^ hasFaxExtension |
|
761 |
||
762 |
" |
|
763 |
Display hasFaxExtension |
|
764 |
" |
|
765 |
! |
|
766 |
||
767 |
hasImageExtension |
|
768 |
"return true, if this workstation supports the X image extension. |
|
769 |
Both the server must support it, and the feature must have been |
|
770 |
enabled in the smalltalk system, for true to be returned." |
|
771 |
||
772 |
^ hasImageExtension |
|
773 |
||
774 |
" |
|
775 |
Display hasImageExtension |
|
776 |
" |
|
777 |
! |
|
778 |
||
779 |
hasInputExtension |
|
780 |
"return true, if this workstation supports the X input extension. |
|
781 |
Both the server must support it, and the feature must have been |
|
782 |
enabled in the smalltalk system, for true to be returned." |
|
783 |
||
784 |
^ hasInputExtension |
|
785 |
||
786 |
" |
|
787 |
Display hasInputExtension |
|
788 |
" |
|
789 |
! |
|
790 |
||
791 |
hasMultibuffer |
|
792 |
"return true, if this workstation supports the multibuffer extension. |
|
793 |
Both the server must support it, and the feature must have been |
|
794 |
enabled in the smalltalk system, for true to be returned." |
|
795 |
||
796 |
^ hasMbufExtension |
|
797 |
||
798 |
" |
|
799 |
Display hasMultibuffer |
|
800 |
" |
|
801 |
! |
|
802 |
||
803 |
hasPEX |
|
804 |
"return true, if this workstation supports PEX 3D graphics. |
|
805 |
Both the server must support it, and the feature must have been |
|
806 |
enabled in the smalltalk system, for true to be returned." |
|
807 |
||
808 |
^ hasPEXExtension |
|
809 |
||
810 |
" |
|
811 |
Display hasPEX |
|
812 |
" |
|
813 |
! |
|
814 |
||
815 |
hasShape |
|
816 |
"return true, if this workstation supports non-rectangular windows. |
|
817 |
Both the server must support it, and the feature must have been |
|
818 |
enabled in the smalltalk system, for true to be returned." |
|
819 |
||
820 |
^ hasShapeExtension |
|
821 |
||
822 |
" |
|
823 |
Display hasShape |
|
824 |
" |
|
825 |
! |
|
826 |
||
827 |
hasShm |
|
828 |
"return true, if this workstation supports the shared pixmap extension. |
|
829 |
Both the server must support it, and the feature must have been |
|
830 |
enabled in the smalltalk system, for true to be returned." |
|
831 |
||
832 |
^ hasShmExtension |
|
833 |
||
834 |
" |
|
835 |
Display hasShm |
|
836 |
" |
|
837 |
! |
|
838 |
||
839 |
hasXVideo |
|
840 |
"return true, if this workstation supports the XVideo extension. |
|
841 |
Both the server must support it, and the feature must have been |
|
842 |
enabled in the smalltalk system, for true to be returned." |
|
843 |
||
844 |
^ hasXVideoExtension |
|
845 |
||
846 |
" |
|
847 |
Display hasXVideo |
|
848 |
" |
|
849 |
! |
|
850 |
||
851 |
iconSizes |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
852 |
"Get the preferred/supported icon sizes. These are set by the window manager. |
819 | 853 |
We return nil (if not set) or an OrderedCollection of iconSize specs." |
295 | 854 |
|
855 |
|xIconSizes count ret| |
|
856 |
||
857 |
%{ |
|
858 |
Display *dpy = myDpy; |
|
555 | 859 |
int screen = __intVal(__INST(screen)); |
295 | 860 |
XIconSize *sizeList; |
861 |
int cnt; |
|
862 |
||
863 |
if (ISCONNECTED) { |
|
850 | 864 |
if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) { |
865 |
xIconSizes = __MKEXTERNALBYTES(sizeList); |
|
866 |
count = __MKSMALLINT(cnt); |
|
867 |
} |
|
295 | 868 |
} |
869 |
%}. |
|
870 |
xIconSizes isNil ifTrue:[^ nil]. |
|
871 |
||
872 |
ret := OrderedCollection new:count. |
|
873 |
1 to:count do:[ :i | |
|
850 | 874 |
|minWidth minHeight maxWidth maxHeight widthStep heightStep d| |
295 | 875 |
|
876 |
%{ |
|
850 | 877 |
XIconSize *slp; |
878 |
||
879 |
slp = &((XIconSize *)__externalBytesAddress(xIconSizes))[__intVal(i)-1]; |
|
880 |
minWidth = __MKSMALLINT(slp->min_width); |
|
881 |
minHeight = __MKSMALLINT(slp->min_height); |
|
882 |
maxWidth = __MKSMALLINT(slp->max_width); |
|
883 |
maxHeight = __MKSMALLINT(slp->max_height); |
|
884 |
widthStep = __MKSMALLINT(slp->width_inc); |
|
885 |
heightStep = __MKSMALLINT(slp->height_inc); |
|
295 | 886 |
%}. |
850 | 887 |
d := IdentityDictionary new. |
888 |
d at:#minWidth put:minWidth. |
|
889 |
d at:#maxWidth put:maxWidth. |
|
890 |
d at:#widthStep put:widthStep. |
|
891 |
d at:#minHeight put:minHeight. |
|
892 |
d at:#maxHeight put:maxHeight. |
|
893 |
d at:#heightStep put:heightStep. |
|
894 |
||
895 |
ret add:d |
|
295 | 896 |
]. |
897 |
||
898 |
xIconSizes free. |
|
899 |
^ ret |
|
900 |
||
901 |
" |
|
819 | 902 |
Display iconSizes |
295 | 903 |
" |
904 |
! |
|
905 |
||
341 | 906 |
ignoreBackingStore:aBoolean |
907 |
"if the argument is true, the views backingStore setting will be ignored, and |
|
908 |
no backing store used - this can be used on servers where backing store is |
|
909 |
very slow or is broken (can be put into display-rc-file)" |
|
910 |
||
911 |
ignoreBackingStore := aBoolean |
|
295 | 912 |
! |
913 |
||
823 | 914 |
preferredIconSize |
915 |
"return the displays preferred size for icons. |
|
916 |
Redefined to return a special value on SGI servers." |
|
917 |
||
918 |
self serverVendor = 'Silicon Graphics' ifTrue:[ |
|
850 | 919 |
^ 86@68 |
823 | 920 |
]. |
921 |
^ super preferredIconSize |
|
922 |
||
923 |
"Created: 10.6.1996 / 21:06:48 / cg" |
|
924 |
! |
|
925 |
||
43 | 926 |
supportedImageFormats |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
927 |
"return an array with supported image formats; |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
928 |
each array entry is an attribute dictionary, consisting of |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
929 |
depth, bitsPerPixel and padding values." |
43 | 930 |
|
150 | 931 |
|nFormats "{ Class: SmallInteger }" |
932 |
formatArray| |
|
43 | 933 |
%{ |
934 |
Display *dpy = myDpy; |
|
150 | 935 |
|
936 |
if (! ISCONNECTED) { |
|
937 |
RETURN (nil); |
|
938 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
939 |
nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats); |
43 | 940 |
%}. |
941 |
formatArray := Array new:nFormats. |
|
150 | 942 |
1 to:nFormats do:[:index | |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
943 |
|info bitsPerPixelInfo depthInfo paddingInfo i| |
150 | 944 |
|
945 |
i := index. |
|
43 | 946 |
%{ |
70 | 947 |
ScreenFormat *format; |
948 |
Display *dpy = myDpy; |
|
949 |
||
90 | 950 |
format = DISPLAYACCESS(dpy)->pixmap_format; |
555 | 951 |
format += (__intVal(i)-1); |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
952 |
bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
953 |
depthInfo = __MKSMALLINT(format->depth); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
954 |
paddingInfo = __MKSMALLINT(format->scanline_pad); |
43 | 955 |
%}. |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
956 |
info := IdentityDictionary new. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
957 |
info at:#depth put:depthInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
958 |
info at:#bitsPerPixel put:bitsPerPixelInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
959 |
info at:#padding put:paddingInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
960 |
formatArray at:index put:info. |
43 | 961 |
]. |
962 |
^ formatArray |
|
963 |
||
964 |
" |
|
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
965 |
Display supportedImageFormats |
43 | 966 |
" |
967 |
! |
|
968 |
||
823 | 969 |
supportsIconViews |
970 |
"return true, if this device supports views as icons. |
|
971 |
Only Xservers (currently) support this." |
|
972 |
||
973 |
^ true |
|
974 |
||
975 |
" |
|
976 |
Display supportsIconViews |
|
977 |
" |
|
978 |
||
979 |
"Modified: 10.6.1996 / 20:11:48 / cg" |
|
980 |
"Created: 10.6.1996 / 21:08:18 / cg" |
|
981 |
! |
|
982 |
||
81 | 983 |
supportsViewGravity |
984 |
"return true, if this device supports gravity attributes. |
|
82 | 985 |
We do not depend on it being implemented, but some resizing operations |
81 | 986 |
are faster, it is is." |
987 |
||
988 |
^ true |
|
0 | 989 |
! ! |
990 |
||
991 |
!XWorkstation methodsFor:'bitmap/window creation'! |
|
992 |
||
295 | 993 |
createBitmapFromArray:anArray width:w height:h |
994 |
|bitmapId| |
|
995 |
||
996 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
|
997 |
bitmapId isNil ifTrue:[ |
|
998 |
self primitiveFailed |
|
999 |
]. |
|
1000 |
^ bitmapId |
|
1001 |
! |
|
1002 |
||
1003 |
createBitmapFromFile:aString for:aForm |
|
1004 |
|id w h| |
|
1005 |
||
1006 |
%{ |
|
1007 |
Display *dpy = myDpy; |
|
555 | 1008 |
int screen = __intVal(__INST(screen)); |
295 | 1009 |
Pixmap newBitmap; |
1010 |
char *filename; |
|
1011 |
unsigned b_width, b_height; |
|
1012 |
int b_x_hot, b_y_hot; |
|
1013 |
int status; |
|
1014 |
||
1015 |
if (ISCONNECTED) { |
|
1016 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1017 |
filename = (char *)_stringVal(aString); |
|
1018 |
||
1019 |
BEGIN_INTERRUPTSBLOCKED |
|
1020 |
status = XReadBitmapFile(dpy, RootWindow(dpy, screen), |
|
1021 |
filename, &b_width, &b_height, &newBitmap, |
|
1022 |
&b_x_hot, &b_y_hot); |
|
1023 |
END_INTERRUPTSBLOCKED |
|
1024 |
||
892 | 1025 |
if ((status == BitmapSuccess) && newBitmap) { |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1026 |
w = __MKSMALLINT(b_width); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1027 |
h = __MKSMALLINT(b_height); |
295 | 1028 |
id = __MKOBJ(newBitmap); |
1029 |
} |
|
1030 |
} |
|
1031 |
} |
|
1032 |
%}. |
|
1033 |
id notNil ifTrue:[ |
|
1034 |
aForm setWidth:w height:h |
|
1035 |
]. |
|
1036 |
^ id |
|
1037 |
! |
|
1038 |
||
1039 |
createBitmapWidth:w height:h |
|
1040 |
"allocate a bitmap on the Xserver, the contents is undefined |
|
1041 |
(i.e. random). Return a bitmap id or nil" |
|
1042 |
||
1043 |
%{ /* NOCONTEXT */ |
|
1044 |
||
1045 |
Display *dpy = myDpy; |
|
555 | 1046 |
int screen = __intVal(__INST(screen)); |
295 | 1047 |
Pixmap newBitmap; |
1048 |
||
1049 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
|
1050 |
BEGIN_INTERRUPTSBLOCKED |
|
1051 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
555 | 1052 |
__intVal(w), __intVal(h), 1); |
295 | 1053 |
END_INTERRUPTSBLOCKED |
1054 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
|
1055 |
} |
|
1056 |
%} |
|
1057 |
. |
|
1058 |
self primitiveFailed. |
|
1059 |
^ nil |
|
1060 |
! |
|
1061 |
||
0 | 1062 |
createFaxImageFromArray:data width:w height:h type:type k:k msbFirst:msbFirst |
1063 |
"create a new faxImage in the workstation |
|
1064 |
type: 0 -> uncompressed |
|
70 | 1065 |
1 -> group3 1D (k is void) |
1066 |
2 -> group3 2D |
|
1067 |
3 -> group4 2D (k is void)" |
|
0 | 1068 |
|
1069 |
|nBytes| |
|
1070 |
||
1071 |
hasFaxExtension ifFalse:[^ nil]. |
|
1072 |
nBytes := data size. |
|
1073 |
%{ |
|
1074 |
#ifdef FAX |
|
1075 |
Display *dpy = myDpy; |
|
555 | 1076 |
int screen = __intVal(__INST(screen)); |
0 | 1077 |
FAXImage newImage; |
1078 |
int _type, _msb, _k = 0; |
|
1079 |
unsigned char *bits; |
|
1080 |
||
97 | 1081 |
if (__bothSmallInteger(w, h) |
1082 |
&& __bothSmallInteger(type, k) |
|
1083 |
&& __isSmallInteger(nBytes) |
|
44 | 1084 |
&& __isByteArray(data)) { |
70 | 1085 |
if (msbFirst == true) |
1086 |
_msb = 1; |
|
1087 |
else |
|
1088 |
_msb = 0; |
|
555 | 1089 |
_type = __intVal(type); |
70 | 1090 |
if ((_type < 0) || (_type > 3)) { |
1091 |
RETURN ( nil ); |
|
1092 |
} |
|
1093 |
if (_type == 2) { |
|
97 | 1094 |
if (! __isSmallInteger(k)) { |
70 | 1095 |
RETURN ( nil ); |
1096 |
} |
|
555 | 1097 |
_k = __intVal(k); |
70 | 1098 |
} |
555 | 1099 |
bits = __ByteArrayInstPtr(data)->ba_element; |
70 | 1100 |
BEGIN_INTERRUPTSBLOCKED |
555 | 1101 |
newImage = XFAXImageCreateImage(dpy, __intVal(w), __intVal(h), |
70 | 1102 |
_type, _k, _msb, |
555 | 1103 |
__intVal(nBytes), bits); |
70 | 1104 |
END_INTERRUPTSBLOCKED |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1105 |
RETURN ( (newImage != (FAXImage)0) ? __MKOBJ(newImage) : nil ); |
0 | 1106 |
} |
1107 |
#else |
|
1108 |
RETURN ( nil ); |
|
1109 |
#endif |
|
1110 |
%} |
|
1111 |
. |
|
43 | 1112 |
self primitiveFailed. |
1113 |
^ nil |
|
0 | 1114 |
! |
1115 |
||
1116 |
createPixmapWidth:w height:h depth:d |
|
1117 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
1118 |
(i.e. random). Return a bitmap id or nil" |
|
1119 |
||
1120 |
%{ /* NOCONTEXT */ |
|
1121 |
||
1122 |
Display *dpy = myDpy; |
|
555 | 1123 |
int screen = __intVal(__INST(screen)); |
0 | 1124 |
Pixmap newBitmap; |
1125 |
||
150 | 1126 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
70 | 1127 |
BEGIN_INTERRUPTSBLOCKED |
1128 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
555 | 1129 |
__intVal(w), __intVal(h), __intVal(d)); |
70 | 1130 |
END_INTERRUPTSBLOCKED |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1131 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
0 | 1132 |
} |
1133 |
%} |
|
1134 |
. |
|
43 | 1135 |
self primitiveFailed. |
1136 |
^ nil |
|
0 | 1137 |
! |
1138 |
||
1139 |
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight |
|
46 | 1140 |
"will vanish - for compatibility with previous versions" |
1141 |
||
1142 |
^ self |
|
850 | 1143 |
createWindowFor:aView |
1144 |
origin:(xpos @ ypos) |
|
1145 |
extent:(wwidth @ wheight) |
|
1146 |
minExtent:(aView minExtent) |
|
1147 |
maxExtent:(aView maxExtent) |
|
1148 |
borderWidth:(aView borderWidth) |
|
1149 |
subViewOf:(aView superView) |
|
1150 |
onTop:(aView isPopUpView) |
|
1151 |
inputOnly:(aView isInputOnly) |
|
1152 |
label:(aView label) |
|
1153 |
cursor:(aView cursor) |
|
1154 |
icon:(aView icon) |
|
1155 |
iconView:(aView iconView) |
|
780
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1156 |
|
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1157 |
"Modified: 1.6.1996 / 13:22:48 / cg" |
46 | 1158 |
! |
1159 |
||
1160 |
createWindowFor:aView |
|
70 | 1161 |
origin:origin |
1162 |
extent:extent |
|
1163 |
minExtent:minExt |
|
1164 |
maxExtent:maxExt |
|
1165 |
borderWidth:bWidth |
|
1166 |
subViewOf:wsuperView |
|
157 | 1167 |
onTop:wisPopUpView |
70 | 1168 |
inputOnly:winputOnly |
1169 |
label:wlabel |
|
1170 |
cursor:wcursor |
|
1171 |
icon:wicon |
|
1172 |
iconView:wiconView |
|
46 | 1173 |
|
1174 |
|xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight |
|
1175 |
bColorId wsuperViewId wcursorId wiconId windowId |
|
1176 |
weventMask wiconViewId bitGravity viewGravity vBgColor |
|
150 | 1177 |
vBgForm deepForm preferredVisual preferredDepth| |
1178 |
||
1179 |
displayId isNil ifTrue:[ |
|
1180 |
self primitiveFailed. |
|
1181 |
^ nil |
|
1182 |
]. |
|
0 | 1183 |
|
46 | 1184 |
origin notNil ifTrue:[ |
70 | 1185 |
xpos := origin x. |
1186 |
ypos := origin y. |
|
46 | 1187 |
] ifFalse:[ |
70 | 1188 |
xpos := ypos := 0. |
0 | 1189 |
]. |
46 | 1190 |
extent notNil ifTrue:[ |
70 | 1191 |
wwidth := extent x. |
1192 |
wheight := extent y. |
|
46 | 1193 |
] ifFalse:[ |
70 | 1194 |
wwidth := wheight := 100. |
46 | 1195 |
]. |
1196 |
minExt notNil ifTrue:[ |
|
70 | 1197 |
minWidth := minExt x. |
1198 |
minHeight := minExt y |
|
0 | 1199 |
]. |
46 | 1200 |
maxExt notNil ifTrue:[ |
70 | 1201 |
maxWidth := maxExt x. |
1202 |
maxHeight := maxExt y |
|
46 | 1203 |
]. |
1204 |
||
0 | 1205 |
wsuperView notNil ifTrue:[ |
70 | 1206 |
wsuperViewId := wsuperView id |
0 | 1207 |
]. |
1208 |
wcursor isNil ifTrue:[ |
|
145 | 1209 |
'XWORKSTATION: cursor nil - defaulted' errorPrintNL |
0 | 1210 |
] ifFalse:[ |
70 | 1211 |
wcursorId := wcursor id |
0 | 1212 |
]. |
1213 |
||
1214 |
wicon notNil ifTrue:[ |
|
70 | 1215 |
wiconId := wicon id |
0 | 1216 |
]. |
1217 |
wiconView notNil ifTrue:[ |
|
70 | 1218 |
wiconViewId := wiconView id |
0 | 1219 |
]. |
1220 |
weventMask := aView eventMask. |
|
1221 |
||
150 | 1222 |
preferredVisual := aView preferredVisual. |
1223 |
preferredDepth := aView preferredDepth. |
|
23 | 1224 |
|
72 | 1225 |
%{ /* STACK:16000 */ |
0 | 1226 |
Display *dpy = myDpy; |
555 | 1227 |
int screen = __intVal(__INST(screen)); |
0 | 1228 |
Visual visual; |
1229 |
XGCValues xgcv; |
|
1230 |
XSetWindowAttributes xswa; |
|
1231 |
XSizeHints sizehints; |
|
1232 |
XWMHints wmhints; |
|
46 | 1233 |
int bw, bd, bg; |
0 | 1234 |
Window newWindow, parentWindow; |
1235 |
char *windowName; |
|
1236 |
XFontStruct *f; |
|
1237 |
Pixmap backPixmap = (Pixmap)0, iconBitmap = (Pixmap)0; |
|
1238 |
int flags = 0, depth, ioClass; |
|
1239 |
Window iconWindow; |
|
1240 |
Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom; |
|
1241 |
Atom WmQuitAppAtom; |
|
1242 |
Atom atoms[3]; |
|
1243 |
int atomCount = 0, isTopWindow = 0; |
|
1244 |
||
1245 |
sizehints.flags = 0; |
|
1246 |
sizehints.width = 100; |
|
1247 |
sizehints.height = 100; |
|
1248 |
sizehints.x = 0; |
|
1249 |
sizehints.y = 0; |
|
1250 |
||
97 | 1251 |
if (__bothSmallInteger(wwidth, wheight)) { |
70 | 1252 |
sizehints.flags |= PSize; |
555 | 1253 |
sizehints.width = __intVal(wwidth); |
1254 |
sizehints.height = __intVal(wheight); |
|
0 | 1255 |
} |
97 | 1256 |
if (__bothSmallInteger(xpos, ypos)) { |
70 | 1257 |
sizehints.flags |= PPosition; |
555 | 1258 |
sizehints.x = __intVal(xpos); |
1259 |
sizehints.y = __intVal(ypos); |
|
0 | 1260 |
} |
97 | 1261 |
if (__bothSmallInteger(minWidth, minHeight)) { |
70 | 1262 |
sizehints.flags |= PMinSize; |
555 | 1263 |
sizehints.min_width = __intVal(minWidth); |
1264 |
sizehints.min_height = __intVal(minHeight); |
|
0 | 1265 |
} |
97 | 1266 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
70 | 1267 |
sizehints.flags |= PMaxSize; |
555 | 1268 |
sizehints.max_width = __intVal(maxWidth); |
1269 |
sizehints.max_height = __intVal(maxHeight); |
|
0 | 1270 |
} |
1271 |
||
37 | 1272 |
bg = WhitePixel(dpy, screen); |
0 | 1273 |
|
97 | 1274 |
if (__isSmallInteger(bWidth)) { |
555 | 1275 |
bw = __intVal(bWidth); |
46 | 1276 |
} else { |
70 | 1277 |
bw = 0; |
0 | 1278 |
} |
1279 |
||
72 | 1280 |
bd = BlackPixel(dpy, screen); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1281 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1282 |
if (__isExternalAddress(wsuperViewId)) { |
70 | 1283 |
parentWindow = _WindowVal(wsuperViewId); |
0 | 1284 |
} else { |
70 | 1285 |
parentWindow = RootWindow(dpy, screen); |
1286 |
isTopWindow = 1; |
|
0 | 1287 |
} |
1288 |
||
157 | 1289 |
if (wisPopUpView == true) |
70 | 1290 |
xswa.override_redirect = 1; |
0 | 1291 |
else |
70 | 1292 |
xswa.override_redirect = 0; |
0 | 1293 |
|
1294 |
if (winputOnly == true) |
|
70 | 1295 |
ioClass = InputOnly; |
0 | 1296 |
else |
70 | 1297 |
ioClass = InputOutput; |
0 | 1298 |
|
97 | 1299 |
if (__isSmallInteger(weventMask)) { |
555 | 1300 |
xswa.event_mask = __intVal(weventMask); |
0 | 1301 |
} else { |
70 | 1302 |
xswa.event_mask = 0; |
0 | 1303 |
} |
1304 |
||
1305 |
if (ioClass == InputOnly) { |
|
70 | 1306 |
bw = 0; |
1307 |
depth = 0; |
|
1308 |
flags |= CWEventMask; |
|
0 | 1309 |
} else { |
70 | 1310 |
depth = DefaultDepth(dpy,screen); |
1311 |
flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect; |
|
1312 |
||
1313 |
if (backPixmap != (Pixmap)0) { |
|
1314 |
xswa.background_pixmap = backPixmap; |
|
1315 |
flags |= CWBackPixmap; |
|
1316 |
} else { |
|
1317 |
xswa.background_pixel = bg; |
|
1318 |
flags |= CWBackPixel; |
|
1319 |
} |
|
1320 |
xswa.border_pixel = bd; |
|
0 | 1321 |
} |
23 | 1322 |
|
0 | 1323 |
visual.visualid = CopyFromParent; |
150 | 1324 |
if (__isSmallInteger(preferredDepth)) { |
555 | 1325 |
depth = __intVal(preferredDepth); |
23 | 1326 |
} |
54 | 1327 |
|
1328 |
BEGIN_INTERRUPTSBLOCKED |
|
150 | 1329 |
if (preferredVisual != nil) { |
70 | 1330 |
XVisualInfo vi; |
1331 |
int cls; |
|
1332 |
||
150 | 1333 |
if (preferredVisual == @symbol(StaticGray)) |
70 | 1334 |
cls = StaticGray; |
150 | 1335 |
else if (preferredVisual == @symbol(GrayScale)) |
857
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
1336 |
cls = GrayScale; |
150 | 1337 |
else if (preferredVisual == @symbol(StaticColor)) |
70 | 1338 |
cls = StaticColor; |
150 | 1339 |
else if (preferredVisual == @symbol(PseudoColor)) |
70 | 1340 |
cls = PseudoColor; |
150 | 1341 |
else if (preferredVisual == @symbol(TrueColor)) |
70 | 1342 |
cls = TrueColor; |
150 | 1343 |
else if (preferredVisual == @symbol(DirectColor)) |
70 | 1344 |
cls = DirectColor; |
1345 |
else |
|
1346 |
cls = PseudoColor; |
|
200 | 1347 |
|
70 | 1348 |
if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) { |
1349 |
visual.visualid = vi.visualid; |
|
163 | 1350 |
/* |
1351 |
printf("visualId=%x\n", vi.visualid); |
|
1352 |
*/ |
|
70 | 1353 |
} |
23 | 1354 |
} |
0 | 1355 |
|
1356 |
newWindow = XCreateWindow(dpy, parentWindow, |
|
70 | 1357 |
sizehints.x, sizehints.y, |
1358 |
sizehints.width, sizehints.height, |
|
1359 |
bw, depth, ioClass, &visual, |
|
1360 |
flags, &xswa); |
|
54 | 1361 |
END_INTERRUPTSBLOCKED |
0 | 1362 |
|
1363 |
if (! newWindow) { |
|
70 | 1364 |
RETURN ( nil ); |
0 | 1365 |
} |
1366 |
||
54 | 1367 |
BEGIN_INTERRUPTSBLOCKED |
0 | 1368 |
/* |
1369 |
* define its cursor |
|
1370 |
*/ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1371 |
if (__isExternalAddress(wcursorId)) { |
70 | 1372 |
XDefineCursor(dpy, newWindow, _CursorVal(wcursorId)); |
0 | 1373 |
} |
1374 |
||
1375 |
/* |
|
1376 |
* define its icon and name |
|
1377 |
* (only makes sense for topWindows) |
|
1378 |
*/ |
|
1379 |
if (isTopWindow) { |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1380 |
if (__isExternalAddress(wiconId)) |
70 | 1381 |
iconBitmap = _PixmapVal(wiconId); |
1382 |
else |
|
1383 |
iconBitmap = (Pixmap)0; |
|
1384 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1385 |
if (__isExternalAddress(wiconViewId)) |
70 | 1386 |
iconWindow = _WindowVal(wiconViewId); |
1387 |
else |
|
1388 |
iconWindow = (Window)0; |
|
1389 |
||
1390 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
1391 |
windowName = (char *)_stringVal(wlabel); |
|
1392 |
else |
|
1393 |
windowName = ""; |
|
1394 |
||
1395 |
if (iconBitmap || windowName) { |
|
1396 |
XSetStandardProperties(dpy, newWindow, |
|
1397 |
windowName, windowName, |
|
1398 |
iconBitmap, |
|
1399 |
0, 0, &sizehints); |
|
1400 |
||
1401 |
} |
|
1402 |
||
1403 |
wmhints.flags = 0; |
|
1404 |
if (iconBitmap) { |
|
1405 |
wmhints.flags |= IconPixmapHint; |
|
1406 |
wmhints.icon_pixmap = iconBitmap; |
|
1407 |
} |
|
1408 |
if (iconWindow) { |
|
1409 |
wmhints.flags |= IconWindowHint; |
|
1410 |
wmhints.icon_window = iconWindow; |
|
1411 |
} |
|
0 | 1412 |
/* |
70 | 1413 |
wmhints.flags |= InputHint; |
1414 |
wmhints.input = True; |
|
0 | 1415 |
*/ |
70 | 1416 |
XSetWMHints(dpy, newWindow, &wmhints); |
1417 |
||
1418 |
/* |
|
1419 |
* tell window manager to not kill us but send an event instead |
|
1420 |
*/ |
|
1421 |
/* |
|
1422 |
* get atoms first (if not already known) |
|
1423 |
*/ |
|
555 | 1424 |
if (__INST(protocolsAtom) == nil) { |
70 | 1425 |
WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False); |
555 | 1426 |
__INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom); |
0 | 1427 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 1428 |
WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False); |
555 | 1429 |
__INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom); |
0 | 1430 |
#endif |
1431 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 1432 |
WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False); |
555 | 1433 |
__INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom); |
0 | 1434 |
#endif |
70 | 1435 |
WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
555 | 1436 |
__INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom); |
70 | 1437 |
} else { |
0 | 1438 |
#ifdef USE_QUIT_APP_ATOM |
555 | 1439 |
WmQuitAppAtom = _AtomVal(__INST(quitAppAtom)); |
0 | 1440 |
#else |
70 | 1441 |
WmQuitAppAtom = 0; |
0 | 1442 |
#endif |
555 | 1443 |
WmProtocolsAtom = _AtomVal(__INST(protocolsAtom)); |
1444 |
WmDeleteWindowAtom = _AtomVal(__INST(deleteWindowAtom)); |
|
0 | 1445 |
#ifdef USE_SAVEYOURSELF_ATOM |
555 | 1446 |
WmSaveYourselfAtom = _AtomVal(__INST(saveYourselfAtom)); |
0 | 1447 |
#else |
70 | 1448 |
WmSaveYourselfAtom = 0; |
0 | 1449 |
#endif |
70 | 1450 |
} |
1451 |
||
1452 |
atoms[0] = WmDeleteWindowAtom; atomCount++; |
|
0 | 1453 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 1454 |
atoms[atomCount] = WmSaveYourselfAtom; atomCount++; |
0 | 1455 |
#endif |
1456 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 1457 |
atoms[atomCount] = WmQuitAppAtom; atomCount++; |
0 | 1458 |
#endif |
70 | 1459 |
XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM, |
1460 |
32, PropModeReplace, (unsigned char *)atoms, atomCount); |
|
0 | 1461 |
} |
1462 |
||
54 | 1463 |
END_INTERRUPTSBLOCKED |
1464 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1465 |
windowId = __MKOBJ(newWindow); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1466 |
%}. |
0 | 1467 |
self addKnownView:aView withId:windowId. |
1468 |
^ windowId |
|
1469 |
! |
|
1470 |
||
295 | 1471 |
destroyFaxImage:aFaxImageId |
1472 |
||
1473 |
%{ /* NOCONTEXT */ |
|
1474 |
||
1475 |
#ifdef FAX |
|
1476 |
if (__isExternalAddress(aFaxImageId)) { |
|
70 | 1477 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1478 |
XFAXImageFreeImage(myDpy, (FAXImage)_WindowVal(aFaxImageId)); |
70 | 1479 |
END_INTERRUPTSBLOCKED |
295 | 1480 |
RETURN ( self ); |
1481 |
} |
|
1482 |
#endif |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1483 |
%}. |
295 | 1484 |
self primitiveFailed |
0 | 1485 |
! |
1486 |
||
1487 |
destroyGC:aGCId |
|
1488 |
||
1489 |
%{ /* NOCONTEXT */ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1490 |
if (__isExternalAddress(aGCId) && ISCONNECTED) { |
366 | 1491 |
GC gc = _GCVal(aGCId); |
1492 |
||
1493 |
if (gc) { |
|
1494 |
BEGIN_INTERRUPTSBLOCKED |
|
1495 |
XFreeGC(myDpy, gc); |
|
1496 |
END_INTERRUPTSBLOCKED |
|
1497 |
} |
|
70 | 1498 |
RETURN ( self ); |
0 | 1499 |
} |
118 | 1500 |
%}. |
0 | 1501 |
self primitiveFailed |
1502 |
! |
|
1503 |
||
295 | 1504 |
destroyPixmap:aDrawableId |
0 | 1505 |
|
1506 |
%{ /* NOCONTEXT */ |
|
1507 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1508 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
70 | 1509 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1510 |
XFreePixmap(myDpy, _PixmapVal(aDrawableId)); |
70 | 1511 |
END_INTERRUPTSBLOCKED |
295 | 1512 |
RETURN ( self ); |
0 | 1513 |
} |
118 | 1514 |
%}. |
295 | 1515 |
self primitiveFailed |
1516 |
! |
|
1517 |
||
1518 |
destroyView:aView withId:aWindowId |
|
1519 |
%{ |
|
1520 |
if (__isExternalAddress(aWindowId) && ISCONNECTED) { |
|
1521 |
BEGIN_INTERRUPTSBLOCKED |
|
1522 |
XDestroyWindow(myDpy, _WindowVal(aWindowId)); |
|
1523 |
END_INTERRUPTSBLOCKED |
|
1524 |
} |
|
1525 |
%}. |
|
1526 |
self removeKnownView:aView |
|
0 | 1527 |
! |
1528 |
||
1529 |
dpsContextFor:aDrawableId and:aGCId |
|
1530 |
||
1531 |
%{ /* NOCONTEXT */ |
|
1532 |
#ifdef XXDPS |
|
555 | 1533 |
int screen = __intVal(__INST(screen)); |
0 | 1534 |
DPSContext dps; |
1535 |
int height; |
|
1536 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1537 |
if (__isExternalAddress(aDrawableId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1538 |
&& __isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1539 |
&& ISCONNECTED) { |
70 | 1540 |
BEGIN_INTERRUPTSBLOCKED |
1541 |
dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1542 |
_GCVal(aGCId), |
|
1543 |
0, height, 0, colormap, NULL, 0, |
|
1544 |
XDPSDefaultTextBackstop, |
|
1545 |
XDPSDefaultErrorProc, |
|
1546 |
NULL); |
|
1547 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1548 |
RETURN ( dps ? __MKOBJ(dps) : nil ); |
0 | 1549 |
} |
1550 |
#endif |
|
1551 |
%} |
|
1552 |
. |
|
43 | 1553 |
self primitiveFailed. |
1554 |
^ nil |
|
295 | 1555 |
! |
1556 |
||
1557 |
gcFor:aDrawableId |
|
132 | 1558 |
|
1559 |
%{ /* NOCONTEXT */ |
|
555 | 1560 |
int screen = __intVal(__INST(screen)); |
295 | 1561 |
GC gc; |
1562 |
||
1563 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
|
1564 |
BEGIN_INTERRUPTSBLOCKED |
|
1565 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1566 |
0L, (XGCValues *)0); |
|
1567 |
END_INTERRUPTSBLOCKED |
|
1568 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
200 | 1569 |
} |
1570 |
%}. |
|
1571 |
self primitiveFailed. |
|
1572 |
^ nil |
|
295 | 1573 |
! |
1574 |
||
1575 |
primCreateBitmapFromArray:anArray width:w height:h |
|
154 | 1576 |
|
1577 |
%{ /* UNLIMITEDSTACK */ |
|
1578 |
||
295 | 1579 |
Display *dpy = myDpy; |
555 | 1580 |
int screen = __intVal(__INST(screen)); |
295 | 1581 |
Pixmap newBitmap; |
1582 |
unsigned int b_width, b_height; |
|
1583 |
REGISTER unsigned char *cp; |
|
1584 |
REGISTER unsigned char *pBits; |
|
1585 |
unsigned char *b_bits, *allocatedBits; |
|
1586 |
int index, row; |
|
1587 |
REGISTER int col; |
|
1588 |
unsigned bits; |
|
1589 |
static char reverseBitTable[256]; |
|
1590 |
static firstCall = 1; |
|
1591 |
int nBytes; |
|
1592 |
unsigned char fastBits[10000]; |
|
1593 |
OBJ num, *op; |
|
1594 |
int bytesPerRow; |
|
1595 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1596 |
if (! ISCONNECTED) { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1597 |
RETURN (nil); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1598 |
} |
295 | 1599 |
if (firstCall) { |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1600 |
for (index=0; index < 256; index++) { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1601 |
reverseBitTable[index] = 0; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1602 |
if (index & 128) reverseBitTable[index] |= 1; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1603 |
if (index & 64) reverseBitTable[index] |= 2; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1604 |
if (index & 32) reverseBitTable[index] |= 4; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1605 |
if (index & 16) reverseBitTable[index] |= 8; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1606 |
if (index & 8) reverseBitTable[index] |= 16; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1607 |
if (index & 4) reverseBitTable[index] |= 32; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1608 |
if (index & 2) reverseBitTable[index] |= 64; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1609 |
if (index & 1) reverseBitTable[index] |= 128; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1610 |
} |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1611 |
firstCall = 0; |
295 | 1612 |
} |
1613 |
||
1614 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
|
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1615 |
newBitmap = (Pixmap)0; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1616 |
b_width = __intVal(w); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1617 |
b_height = __intVal(h); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1618 |
bytesPerRow = (b_width + 7) / 8; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1619 |
nBytes = b_height * bytesPerRow; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1620 |
if (nBytes < sizeof(fastBits)) { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1621 |
cp = b_bits = fastBits; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1622 |
allocatedBits = 0; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1623 |
} else { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1624 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1625 |
if (! cp) goto fail; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1626 |
} |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1627 |
|
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1628 |
if (__qClass(anArray) == @global(Array)) { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1629 |
index = 1; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1630 |
op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1631 |
for (row = b_height; row; row--) { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1632 |
for (col = bytesPerRow; col; col--) { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1633 |
num = *op++; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1634 |
if (! __isSmallInteger(num)) goto fail; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1635 |
bits = __intVal(num); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1636 |
*cp++ = reverseBitTable[bits]; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1637 |
} |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1638 |
} |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1639 |
} else { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1640 |
if (__qClass(anArray) == @global(ByteArray)) { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1641 |
pBits = __ByteArrayInstPtr(anArray)->ba_element; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1642 |
for (col = b_height*bytesPerRow; col; col--) { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1643 |
*cp++ = reverseBitTable[*pBits++]; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1644 |
} |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1645 |
} else { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1646 |
goto fail; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1647 |
} |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1648 |
} |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1649 |
|
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1650 |
BEGIN_INTERRUPTSBLOCKED |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1651 |
newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1652 |
(char *)b_bits, |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1653 |
b_width, b_height); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1654 |
END_INTERRUPTSBLOCKED |
295 | 1655 |
fail: ; |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1656 |
if (allocatedBits) |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1657 |
free(allocatedBits); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1658 |
RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil ); |
0 | 1659 |
} |
1660 |
%} |
|
295 | 1661 |
! |
1662 |
||
1663 |
realRootWindowFor:aView |
|
1664 |
"the name of this method is historic; |
|
1665 |
- it will vanish" |
|
1666 |
||
1667 |
|id| |
|
1668 |
||
1669 |
id := self realRootWindowId. |
|
1670 |
self addKnownView:aView withId:id. |
|
1671 |
^ id |
|
1672 |
! |
|
1673 |
||
1674 |
realRootWindowId |
|
1675 |
"return the id of the real root window. |
|
1676 |
This may not be the window you see as background, |
|
1677 |
since some window managers install a virtual root window on top |
|
1678 |
of it. Except for very special cases, use #rootWindowId, which takes |
|
1679 |
care of any virtual root." |
|
0 | 1680 |
|
1681 |
%{ /* NOCONTEXT */ |
|
1682 |
||
555 | 1683 |
int screen = __intVal(__INST(screen)); |
295 | 1684 |
Window root; |
1685 |
OBJ id; |
|
1686 |
||
555 | 1687 |
if (__INST(rootId) != nil) { |
1688 |
RETURN (__INST(rootId)); |
|
295 | 1689 |
} |
0 | 1690 |
|
150 | 1691 |
if (ISCONNECTED) { |
295 | 1692 |
root = RootWindow(myDpy, screen); |
1693 |
if (! root) { |
|
1694 |
id = nil; |
|
1695 |
} else { |
|
555 | 1696 |
__INST(rootId) = id = __MKOBJ(root); __STORE(self, id); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1697 |
} |
295 | 1698 |
RETURN (id); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1699 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1700 |
%}. |
295 | 1701 |
self primitiveFailed |
1702 |
! |
|
1703 |
||
1704 |
rootWindowFor:aView |
|
1705 |
|id| |
|
1706 |
||
1707 |
id := self rootWindowId. |
|
1708 |
self addKnownView:aView withId:id. |
|
0 | 1709 |
^ id |
1710 |
! |
|
1711 |
||
295 | 1712 |
rootWindowId |
1713 |
"return the id of the root window. |
|
1714 |
This is the window you see as background, |
|
1715 |
however, it may or may not be the real physical root window, |
|
1716 |
since some window managers install a virtual root window on top |
|
1717 |
of the real one. If this is the case, that views id is returned here." |
|
23 | 1718 |
|
0 | 1719 |
%{ /* NOCONTEXT */ |
555 | 1720 |
int screen = __intVal(__INST(screen)); |
295 | 1721 |
Window rootWin, vRootWin; |
1722 |
OBJ id; |
|
1723 |
||
555 | 1724 |
if (__INST(virtualRootId) != nil) { |
1725 |
RETURN (__INST(virtualRootId)); |
|
295 | 1726 |
} |
0 | 1727 |
|
169 | 1728 |
if (ISCONNECTED) { |
295 | 1729 |
vRootWin = rootWin = RootWindow(myDpy, screen); |
1730 |
#ifndef IRIS |
|
180 | 1731 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1732 |
/* |
1733 |
* on IRIS, this creates a badwindow error - why ? |
|
1734 |
* children contains a funny window (000034) |
|
1735 |
*/ |
|
1736 |
||
1737 |
/* |
|
1738 |
* care for virtual root windows (tvtwm & friends) |
|
1739 |
*/ |
|
1740 |
{ |
|
1741 |
Atom vRootAtom = None; |
|
1742 |
int i; |
|
1743 |
Window rootReturn, parentReturn; |
|
1744 |
Window* children; |
|
1745 |
unsigned int numChildren; |
|
1746 |
||
1747 |
if (XQueryTree(myDpy, rootWin, |
|
1748 |
&rootReturn, &parentReturn, |
|
1749 |
&children, &numChildren)) { |
|
1750 |
vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True ); |
|
1751 |
if (vRootAtom != None) { |
|
1752 |
for (i=0; i < numChildren; i++) { |
|
1753 |
Atom actual_type; |
|
1754 |
int actual_format; |
|
1755 |
unsigned long nitems, bytesafter; |
|
1756 |
Window* newRoot = (Window*) 0; |
|
1757 |
||
1758 |
if (children[i]) { |
|
1759 |
if (XGetWindowProperty(myDpy, children[i], vRootAtom, |
|
1760 |
0L, 1L, False, XA_WINDOW, |
|
1761 |
&actual_type, &actual_format, |
|
1762 |
&nitems, &bytesafter, |
|
1763 |
(unsigned char**) &newRoot |
|
1764 |
) == Success && newRoot) { |
|
1765 |
vRootWin = *newRoot; |
|
1766 |
break; |
|
1767 |
} |
|
1768 |
} |
|
1769 |
} |
|
1770 |
if (children) XFree( children ); |
|
1771 |
} |
|
1772 |
} |
|
1773 |
} |
|
180 | 1774 |
END_INTERRUPTSBLOCKED |
295 | 1775 |
#endif |
1776 |
} |
|
1777 |
||
1778 |
/* cannot happen */ |
|
1779 |
if (! vRootWin) { |
|
1780 |
vRootWin = rootWin; |
|
1781 |
if (! rootWin) { |
|
1782 |
RETURN ( nil ); |
|
1783 |
} |
|
1784 |
} |
|
555 | 1785 |
__INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id); |
1786 |
__INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id); |
|
295 | 1787 |
RETURN ( id ); |
63 | 1788 |
%} |
0 | 1789 |
! ! |
1790 |
||
1791 |
!XWorkstation methodsFor:'color stuff'! |
|
1792 |
||
295 | 1793 |
colorCell |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1794 |
"allocate a color cell - return the color index (i.e. colorID). |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1795 |
This method will return nil for StaticGrey, StaticGrey and TrueColor displays." |
0 | 1796 |
|
1797 |
%{ /* NOCONTEXT */ |
|
1798 |
||
1799 |
Display *dpy = myDpy; |
|
555 | 1800 |
int screen = __intVal(__INST(screen)); |
295 | 1801 |
XColor color; |
1802 |
unsigned long dummy; |
|
1803 |
Status ok; |
|
1804 |
||
1805 |
BEGIN_INTERRUPTSBLOCKED |
|
1806 |
ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0, |
|
1807 |
&dummy, 0, &color.pixel, 1); |
|
1808 |
END_INTERRUPTSBLOCKED |
|
1809 |
if (ok) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1810 |
RETURN ( __MKSMALLINT(color.pixel) ); |
0 | 1811 |
} |
1812 |
%} |
|
1813 |
. |
|
43 | 1814 |
^ nil |
0 | 1815 |
! |
1816 |
||
1817 |
colorNamed:aString |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1818 |
"allocate a color with color name - return the color index (i.e. colorID). |
0 | 1819 |
Dont use this method, colornames are mostly X specific" |
1820 |
||
1821 |
%{ /* NOCONTEXT */ |
|
1822 |
||
1823 |
char *colorname; |
|
1824 |
Display *dpy = myDpy; |
|
1825 |
XColor scolor, ecolor; |
|
555 | 1826 |
int screen = __intVal(__INST(screen)); |
850 | 1827 |
int id; |
54 | 1828 |
Status ok; |
0 | 1829 |
|
150 | 1830 |
if (ISCONNECTED) { |
850 | 1831 |
if (__isString(aString) || __isSymbol(aString)) { |
1832 |
colorname = (char *)_stringVal(aString); |
|
1833 |
||
1834 |
BEGIN_INTERRUPTSBLOCKED |
|
1835 |
ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor); |
|
1836 |
if (ok) { |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1837 |
#ifdef QUICK_TRUE_COLORS |
850 | 1838 |
if (__INST(visualType) == @symbol(TrueColor)) { |
1839 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
|
1840 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
|
1841 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
|
1842 |
RETURN ( __MKSMALLINT(id) ); |
|
1843 |
} |
|
847
f7c402bc5983
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
846
diff
changeset
|
1844 |
#endif |
850 | 1845 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
1846 |
} |
|
1847 |
END_INTERRUPTSBLOCKED |
|
1848 |
if (! ok) { |
|
1849 |
RETURN ( nil ); |
|
1850 |
} |
|
1851 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
|
1852 |
} |
|
0 | 1853 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1854 |
%}. |
43 | 1855 |
self primitiveFailed. |
1856 |
^ nil |
|
0 | 1857 |
! |
1858 |
||
295 | 1859 |
colorRed:redVal green:greenVal blue:blueVal |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1860 |
"allocate a color with rgb values (0..100) - return the color index (i.e. colorID). |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1861 |
This method is obsoleted by #colorScaledRed:scaledGreen:scaledBlue:" |
295 | 1862 |
|
1863 |
|r g b| |
|
1864 |
||
1865 |
r := self percentToXColorValue:redVal. |
|
1866 |
g := self percentToXColorValue:greenVal. |
|
1867 |
b := self percentToXColorValue:blueVal. |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1868 |
^ self colorScaledRed:r scaledGreen:g scaledBlue:b |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1869 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1870 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1871 |
colorScaledRed:r scaledGreen:g scaledBlue:b |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1872 |
"allocate a color with rgb values (0..16rFFFF) - return the color index (i.e. colorID)" |
295 | 1873 |
%{ |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1874 |
Display *dpy; |
295 | 1875 |
XColor ecolor; |
555 | 1876 |
int screen = __intVal(__INST(screen)); |
295 | 1877 |
Status ok; |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1878 |
int id; |
295 | 1879 |
|
1880 |
if (__bothSmallInteger(r, g) |
|
1881 |
&& __isSmallInteger(b) |
|
1882 |
&& ISCONNECTED) { |
|
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1883 |
ecolor.red = __intVal(r); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1884 |
ecolor.green= __intVal(g); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1885 |
ecolor.blue = __intVal(b); |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1886 |
#ifdef QUICK_TRUE_COLORS |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1887 |
if (__INST(visualType) == @symbol(TrueColor)) { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1888 |
id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask)); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1889 |
id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask)); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1890 |
id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask)); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1891 |
RETURN ( __MKSMALLINT(id) ); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1892 |
} |
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1893 |
#endif |
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1894 |
dpy = myDpy; |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1895 |
BEGIN_INTERRUPTSBLOCKED |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1896 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1897 |
END_INTERRUPTSBLOCKED |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1898 |
if (! ok) { |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1899 |
RETURN ( nil ); |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1900 |
} |
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1901 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
295 | 1902 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1903 |
%}. |
295 | 1904 |
self primitiveFailed. |
1905 |
^ nil |
|
1906 |
! |
|
1907 |
||
1908 |
freeColor:colorIndex |
|
1909 |
"free a display color when its no longer needed" |
|
0 | 1910 |
|
1911 |
%{ /* NOCONTEXT */ |
|
1912 |
||
1913 |
Display *dpy = myDpy; |
|
295 | 1914 |
unsigned long color; |
555 | 1915 |
int screen = __intVal(__INST(screen)); |
295 | 1916 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1917 |
#ifdef QUICK_TRUE_COLORS |
555 | 1918 |
if (__INST(visualType) == @symbol(TrueColor)) { |
850 | 1919 |
/* no need to do anything on TrueColor displays ... */ |
1920 |
RETURN (self); |
|
295 | 1921 |
} |
1922 |
#endif |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1923 |
|
295 | 1924 |
if (__isSmallInteger(colorIndex) && ISCONNECTED) { |
850 | 1925 |
color = (long) __intVal(colorIndex); |
1926 |
BEGIN_INTERRUPTSBLOCKED |
|
1927 |
XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L); |
|
1928 |
END_INTERRUPTSBLOCKED |
|
1929 |
RETURN ( self ); |
|
0 | 1930 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1931 |
%}. |
295 | 1932 |
self primitiveFailed |
1933 |
! |
|
1934 |
||
1935 |
getRGBFrom:index into:aBlock |
|
1936 |
"get rgb components (0..100) of color in map at:index, |
|
1937 |
and evaluate the 3-arg block, aBlock with them" |
|
1938 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1939 |
|val| |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1940 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1941 |
self getScaledRGBFrom:index into:[:r :g :b | |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1942 |
val := aBlock |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1943 |
value:(r * 100.0 / 16rFFFF) |
850 | 1944 |
value:(g * 100.0 / 16rFFFF) |
1945 |
value:(b * 100.0 / 16rFFFF) |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1946 |
]. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1947 |
^ val |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1948 |
! |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1949 |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1950 |
getRGBFromName:colorName into:aBlock |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1951 |
"get rgb components (0..100) of color named colorName, |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1952 |
and evaluate the 3-arg block, aBlock with them" |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1953 |
|val| |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1954 |
|
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1955 |
self getScaledRGBFromName:colorName into:[:r :g :b | |
850 | 1956 |
val := aBlock |
1957 |
value:(r * 100.0 / 16rFFFF) |
|
1958 |
value:(g * 100.0 / 16rFFFF) |
|
1959 |
value:(b * 100.0 / 16rFFFF) |
|
846
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1960 |
]. |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1961 |
^ val |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1962 |
! |
49a4732dec95
dont XAlloc/XFree colors on TrueColor systems
Claus Gittinger <cg@exept.de>
parents:
834
diff
changeset
|
1963 |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1964 |
getScaledRGBFrom:index into:aBlock |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1965 |
"get rgb components (0 .. 16rFFFF) of color in map at:index, |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1966 |
and evaluate the 3-arg block, aBlock with them" |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1967 |
|
295 | 1968 |
|r g b| |
1969 |
%{ |
|
1970 |
Display *dpy = myDpy; |
|
555 | 1971 |
int screen = __intVal(__INST(screen)); |
295 | 1972 |
XColor color; |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1973 |
int sr, sg, sb; |
295 | 1974 |
int bits, scale, shift; |
1975 |
||
1976 |
if (__isSmallInteger(index)) { |
|
555 | 1977 |
color.pixel = __intVal(index); |
295 | 1978 |
BEGIN_INTERRUPTSBLOCKED |
1979 |
XQueryColor(dpy, DefaultColormap(dpy, screen), &color); |
|
1980 |
END_INTERRUPTSBLOCKED |
|
1981 |
||
1982 |
/* |
|
1983 |
* have to compensate for an error in X ?, which does not scale |
|
1984 |
* colors correctly if lesser than 16bits are valid in a color, |
|
1985 |
* (for example, color white on a 4bitsPerRGB server will return |
|
1986 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
1987 |
*/ |
|
555 | 1988 |
bits = __intVal(__INST(bitsPerRGB)); |
295 | 1989 |
scale = (1<<bits) - 1; |
1990 |
shift = 16 - bits; |
|
1991 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1992 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1993 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1994 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1995 |
r = __MKSMALLINT(sr); |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1996 |
g = __MKSMALLINT(sg); |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
1997 |
b = __MKSMALLINT(sb); |
295 | 1998 |
} |
1999 |
%}. |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2000 |
^ aBlock value:r value:g value:b |
295 | 2001 |
! |
2002 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2003 |
getScaledRGBFromName:colorName into:aBlock |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2004 |
"get rgb components (0..16rFFFF) of color named colorName, |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2005 |
and evaluate the 3-arg block, aBlock with them" |
295 | 2006 |
|
2007 |
|r g b| |
|
2008 |
||
2009 |
displayId isNil ifTrue:[ |
|
2010 |
self pimitiveFailed. |
|
2011 |
^ nil |
|
2012 |
]. |
|
2013 |
%{ |
|
2014 |
Display *dpy = myDpy; |
|
555 | 2015 |
int screen = __intVal(__INST(screen)); |
295 | 2016 |
XColor color; |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2017 |
int sr, sg, sb; |
295 | 2018 |
double floor(); |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2019 |
int bits, scale, shift; |
295 | 2020 |
|
2021 |
if (__isString(colorName) || __isSymbol(colorName)) { |
|
2022 |
BEGIN_INTERRUPTSBLOCKED |
|
2023 |
if (XParseColor(dpy, DefaultColormap(dpy, screen), |
|
2024 |
(char *)_stringVal(colorName), &color)) { |
|
2025 |
/* |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2026 |
* have to compensate for an error in X ?, which does not scale |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2027 |
* colors correctly if lesser than 16bits are valid in a color, |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2028 |
* (for example, color white on a 4bitsPerRGB server will return |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2029 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
295 | 2030 |
*/ |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2031 |
bits = __intVal(__INST(bitsPerRGB)); |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2032 |
scale = (1<<bits) - 1; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2033 |
shift = 16 - bits; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2034 |
|
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2035 |
sr = ((double)(color.red>>shift) / scale) * 0xFFFF; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2036 |
sg = ((double)(color.green>>shift) / scale) * 0xFFFF; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2037 |
sb = ((double)(color.blue>>shift) / scale) * 0xFFFF; |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2038 |
r = __MKSMALLINT(sr); |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2039 |
g = __MKSMALLINT(sg); |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2040 |
b = __MKSMALLINT(sb); |
295 | 2041 |
} |
2042 |
END_INTERRUPTSBLOCKED |
|
2043 |
} |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2044 |
%}. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2045 |
^ aBlock value:r value:g value:b |
295 | 2046 |
! |
2047 |
||
2048 |
listOfAvailableColors |
|
2049 |
"return a list of all available colornames. |
|
2050 |
This should not be used, since colornames are very |
|
2051 |
display-specific (here X-specific)." |
|
2052 |
||
2053 |
|aStream list line index colorName| |
|
2054 |
||
2055 |
aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'. |
|
2056 |
aStream isNil ifTrue:[^ nil]. |
|
2057 |
list := OrderedCollection new. |
|
2058 |
[aStream atEnd] whileFalse:[ |
|
2059 |
line := aStream nextLine. |
|
2060 |
line notNil ifTrue:[ |
|
2061 |
"skip the r/g/b numbers" |
|
2062 |
index := 1. |
|
2063 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2064 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2065 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2066 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2067 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
2068 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
2069 |
colorName := line copyFrom:index. |
|
2070 |
((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ |
|
2071 |
list add:colorName |
|
2072 |
] |
|
2073 |
] |
|
2074 |
]. |
|
2075 |
aStream close. |
|
2076 |
^ list sort |
|
2077 |
! |
|
2078 |
||
2079 |
percentToXColorValue:aPercentage |
|
2080 |
"given a color-component value in percent (0..100), return the corresponding |
|
2081 |
x-component value (0..65k) as an integer" |
|
2082 |
||
2083 |
%{ /* NOCONTEXT */ |
|
2084 |
||
2085 |
if (__isSmallInteger(aPercentage)) { |
|
555 | 2086 |
RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) ); |
295 | 2087 |
} |
2088 |
if (__isFloat(aPercentage)) { |
|
555 | 2089 |
RETURN ( __MKSMALLINT(0xFFFF * (int)(__floatVal(aPercentage)) / 100) ); |
295 | 2090 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2091 |
%}. |
295 | 2092 |
^ (16rFFFF * aPercentage / 100) rounded |
0 | 2093 |
! |
2094 |
||
892 | 2095 |
setColor:index scaledRed:sred scaledGreen:sgreen scaledBlue:sblue |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2096 |
"change color in map at:index to rgb (0..16rFFFF). |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2097 |
This method is a noop for StaticGrey, StaticGrey and TrueColor displays." |
0 | 2098 |
|
2099 |
%{ /* NOCONTEXT */ |
|
2100 |
||
2101 |
char *colorname; |
|
2102 |
Display *dpy = myDpy; |
|
2103 |
XColor color; |
|
555 | 2104 |
int screen = __intVal(__INST(screen)); |
0 | 2105 |
int r, g, b; |
2106 |
int ok = 1; |
|
2107 |
||
892 | 2108 |
if (__isSmallInteger(sred)) |
2109 |
r = __intVal(sred); |
|
0 | 2110 |
else ok = 0; |
2111 |
||
892 | 2112 |
if (__isSmallInteger(sgreen)) |
2113 |
g = __intVal(sgreen); |
|
0 | 2114 |
else ok = 0; |
2115 |
||
892 | 2116 |
if (__isSmallInteger(sblue)) |
2117 |
b = __intVal(sblue); |
|
0 | 2118 |
else ok = 0; |
2119 |
||
97 | 2120 |
if (__isSmallInteger(index) && ok) { |
555 | 2121 |
color.pixel = __intVal(index); |
70 | 2122 |
color.red = r; |
2123 |
color.green = g; |
|
2124 |
color.blue = b; |
|
2125 |
color.flags = DoRed | DoGreen | DoBlue; |
|
2126 |
||
2127 |
BEGIN_INTERRUPTSBLOCKED |
|
2128 |
XStoreColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2129 |
END_INTERRUPTSBLOCKED |
|
2130 |
RETURN ( self ); |
|
0 | 2131 |
} |
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2132 |
%}. |
0 | 2133 |
self primitiveFailed |
295 | 2134 |
! ! |
2135 |
||
2136 |
!XWorkstation methodsFor:'cursor stuff'! |
|
2137 |
||
2138 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
|
2139 |
"change a cursors colors" |
|
2140 |
||
2141 |
|fgR fgG fgB bgR bgG bgB| |
|
2142 |
||
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2143 |
fgR := fgColor scaledRed. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2144 |
fgG := fgColor scaledGreen. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2145 |
fgB := fgColor scaledBlue. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2146 |
bgR := bgColor scaledRed. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2147 |
bgG := bgColor scaledGreen. |
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2148 |
bgB := bgColor scaledBlue. |
0 | 2149 |
%{ |
295 | 2150 |
XColor fgcolor, bgcolor; |
2151 |
||
2152 |
if (__isExternalAddress(aCursorId) |
|
2153 |
&& __bothSmallInteger(fgG, fgB) |
|
2154 |
&& __bothSmallInteger(bgR, bgG) |
|
2155 |
&& __bothSmallInteger(bgB, fgR)) { |
|
2156 |
||
555 | 2157 |
fgcolor.red = __intVal(fgR); |
2158 |
fgcolor.green= __intVal(fgG); |
|
2159 |
fgcolor.blue = __intVal(fgB); |
|
2160 |
bgcolor.red = __intVal(bgR); |
|
2161 |
bgcolor.green= __intVal(bgG); |
|
2162 |
bgcolor.blue = __intVal(bgB); |
|
70 | 2163 |
BEGIN_INTERRUPTSBLOCKED |
295 | 2164 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
72 | 2165 |
END_INTERRUPTSBLOCKED |
2166 |
RETURN ( self ); |
|
2167 |
} |
|
834
f71ba674da2a
Color changed to use integer r/g/b components internally (0..16rFFFF)
Claus Gittinger <cg@exept.de>
parents:
830
diff
changeset
|
2168 |
%}. |
0 | 2169 |
self primitiveFailed |
70 | 2170 |
! |
2171 |
||
295 | 2172 |
createCursorShape:aShape |
2173 |
"create a cursor given a shape-symbol" |
|
2174 |
||
2175 |
|number id| |
|
2176 |
||
2177 |
displayId isNil ifTrue:[ |
|
2178 |
self primitiveFailed. |
|
2179 |
^ nil |
|
2180 |
]. |
|
2181 |
number := self shapeNumberFromSymbol:aShape. |
|
2182 |
%{ |
|
2183 |
Cursor newCursor; |
|
2184 |
||
2185 |
if (__isSmallInteger(number)) { |
|
2186 |
BEGIN_INTERRUPTSBLOCKED |
|
555 | 2187 |
newCursor = XCreateFontCursor(myDpy, __intVal(number)); |
295 | 2188 |
END_INTERRUPTSBLOCKED |
2189 |
if (newCursor != (Cursor)0) { |
|
2190 |
id = __MKOBJ(newCursor); |
|
70 | 2191 |
} |
0 | 2192 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2193 |
%}. |
295 | 2194 |
^ id |
2195 |
! |
|
2196 |
||
2197 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy |
|
2198 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
|
2199 |
||
2200 |
|id sourceId maskId| |
|
2201 |
||
2202 |
displayId isNil ifTrue:[ |
|
2203 |
self primitiveFailed. |
|
2204 |
^ nil |
|
2205 |
]. |
|
2206 |
sourceId := sourceForm id. |
|
2207 |
maskId := maskForm id. |
|
2208 |
%{ |
|
2209 |
Cursor newCursor; |
|
2210 |
XColor fgColor, bgColor; |
|
2211 |
||
2212 |
if (__isExternalAddress(sourceId) |
|
2213 |
&& __isExternalAddress(maskId) |
|
2214 |
&& __bothSmallInteger(hx, hy)) { |
|
2215 |
fgColor.red = 0; /* fg is black */ |
|
2216 |
fgColor.green = 0; |
|
2217 |
fgColor.blue = 0; |
|
2218 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
2219 |
bgColor.green = 0xFFFF; |
|
2220 |
bgColor.blue = 0xFFFF; |
|
2221 |
||
2222 |
BEGIN_INTERRUPTSBLOCKED |
|
2223 |
newCursor = XCreatePixmapCursor(myDpy, |
|
2224 |
_PixmapVal(sourceId), |
|
2225 |
_PixmapVal(maskId), |
|
555 | 2226 |
&fgColor, &bgColor, __intVal(hx), __intVal(hy)); |
295 | 2227 |
END_INTERRUPTSBLOCKED |
2228 |
if (newCursor != (Cursor)0) { |
|
2229 |
id = __MKOBJ(newCursor); |
|
70 | 2230 |
} |
0 | 2231 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2232 |
%}. |
295 | 2233 |
^ id |
2234 |
! |
|
2235 |
||
2236 |
destroyCursor:aCursorId |
|
0 | 2237 |
|
2238 |
%{ /* NOCONTEXT */ |
|
2239 |
||
295 | 2240 |
if (ISCONNECTED) { |
2241 |
if (__isExternalAddress(aCursorId)) { |
|
2242 |
BEGIN_INTERRUPTSBLOCKED |
|
2243 |
XFreeCursor(myDpy, _CursorVal(aCursorId)); |
|
2244 |
END_INTERRUPTSBLOCKED |
|
70 | 2245 |
RETURN ( self ); |
2246 |
} |
|
0 | 2247 |
} |
2248 |
%} |
|
2249 |
. |
|
2250 |
self primitiveFailed |
|
295 | 2251 |
! |
2252 |
||
2253 |
shapeNumberFromSymbol:shape |
|
2254 |
"given a shape-symbol, return the corresponding cursor-number" |
|
2255 |
||
2256 |
"this is pure X-knowlegde - but you may easily add more" |
|
2257 |
||
2258 |
(shape == #upLeftArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow) %} "132" ]. |
|
2259 |
(shape == #upRightHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1) %} "58" ]. |
|
2260 |
(shape == #upDownArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ]. |
|
2261 |
(shape == #leftRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ]. |
|
2262 |
(shape == #upLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side) %} "138" ]. |
|
2263 |
(shape == #downLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side) %} "16" ]. |
|
2264 |
(shape == #leftLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side) %} "70" ]. |
|
2265 |
(shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side) %} "96" ]. |
|
2266 |
(shape == #text) ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm) %} "152" ]. |
|
2267 |
(shape == #upRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large) %} "44" ]. |
|
2268 |
(shape == #leftHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2) %} "60" ]. |
|
2269 |
(shape == #questionMark) ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow) %} "92" ]. |
|
2270 |
(shape == #cross) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2271 |
(shape == #wait) ifTrue:[ ^ %{ __MKSMALLINT(XC_watch) %} "150" ]. |
|
2272 |
(shape == #crossHair) ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross) %} "130" ]. |
|
2273 |
((shape == #origin) |
|
2274 |
or:[shape == #topLeft]) ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle) %} "144" ]. |
|
2275 |
((shape == #corner) |
|
2276 |
or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle) %} "78" ]. |
|
2277 |
(shape == #topRight) ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle) %} "148" ]. |
|
2278 |
(shape == #bottomLeft) ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle) %} "76" ]. |
|
2279 |
(shape == #square) ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox) %} "40" ]. |
|
2280 |
(shape == #fourWay) ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur) %} "52" ]. |
|
2281 |
(shape == #crossCursor) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2282 |
('XWORKSTATION: invalid cursorShape:' , shape printString) errorPrintNL. |
|
2283 |
^ 0 |
|
0 | 2284 |
! ! |
2285 |
||
2286 |
!XWorkstation methodsFor:'drawing'! |
|
2287 |
||
2288 |
copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2289 |
width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY |
12 | 2290 |
|
2291 |
"do a bit-blt of a compressed FAX image |
|
2292 |
- this needs my private FAX extension" |
|
132 | 2293 |
|
2294 |
%{ /* NOCONTEXT */ |
|
0 | 2295 |
#ifdef FAX |
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2296 |
GC gc; |
0 | 2297 |
FAXImage source; |
2298 |
Drawable dest; |
|
2299 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2300 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2301 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2302 |
&& __isExternalAddress(destId) |
97 | 2303 |
&& __bothSmallInteger(scaleX, scaleY) |
2304 |
&& __bothSmallInteger(w, h) |
|
2305 |
&& __bothSmallInteger(srcX, srcY) |
|
2306 |
&& __bothSmallInteger(dstX, dstY)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2307 |
gc = _GCVal(aGCId); |
70 | 2308 |
source = (FAXImage) _WindowVal(sourceId); |
2309 |
dest = (Drawable) _WindowVal(destId); |
|
2310 |
XFAXImageCopyImage(myDpy, source, dest, gc, |
|
555 | 2311 |
__intVal(srcX), __intVal(srcY), |
2312 |
__intVal(w), __intVal(h), |
|
2313 |
__intVal(dstX), __intVal(dstY), |
|
2314 |
__intVal(scaleX), __intVal(scaleY)); |
|
70 | 2315 |
RETURN ( self ); |
0 | 2316 |
} |
2317 |
#endif |
|
118 | 2318 |
%}. |
0 | 2319 |
self primitiveFailed |
2320 |
! |
|
2321 |
||
2322 |
copyFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2323 |
width:w height:h with:aGCId |
118 | 2324 |
"do a bit-blt; copy bits from the rectangle defined by |
2325 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2326 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2327 |
argument is not integer." |
|
0 | 2328 |
|
2329 |
%{ /* NOCONTEXT */ |
|
2330 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2331 |
GC gc; |
0 | 2332 |
Drawable source, dest; |
2333 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2334 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2335 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2336 |
&& __isExternalAddress(destId) |
97 | 2337 |
&& __bothSmallInteger(w, h) |
2338 |
&& __bothSmallInteger(srcX, srcY) |
|
2339 |
&& __bothSmallInteger(dstX, dstY)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2340 |
gc = _GCVal(aGCId); |
70 | 2341 |
source = (Drawable) _WindowVal(sourceId); |
2342 |
dest = (Drawable) _WindowVal(destId); |
|
2343 |
XCopyArea(myDpy, source, dest, gc, |
|
555 | 2344 |
__intVal(srcX), __intVal(srcY), |
2345 |
__intVal(w), __intVal(h), |
|
2346 |
__intVal(dstX), __intVal(dstY)); |
|
70 | 2347 |
RETURN ( self ); |
0 | 2348 |
} |
118 | 2349 |
%}. |
2350 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2351 |
or any non integer coordinate" |
|
2352 |
||
0 | 2353 |
self primitiveFailed |
2354 |
! |
|
2355 |
||
2356 |
copyPlaneFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2357 |
width:w height:h with:aGCId |
118 | 2358 |
"do a bit-blt, but only copy the low-bit plane; |
2359 |
copy bits from the rectangle defined by |
|
2360 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2361 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2362 |
argument is not integer." |
|
0 | 2363 |
|
2364 |
%{ /* NOCONTEXT */ |
|
2365 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2366 |
GC gc; |
0 | 2367 |
Drawable source, dest; |
2368 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2369 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2370 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2371 |
&& __isExternalAddress(destId) |
97 | 2372 |
&& __bothSmallInteger(w, h) |
2373 |
&& __bothSmallInteger(srcX, srcY) |
|
2374 |
&& __bothSmallInteger(dstX, dstY)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2375 |
gc = _GCVal(aGCId); |
70 | 2376 |
source = (Drawable) _WindowVal(sourceId); |
2377 |
dest = (Drawable) _WindowVal(destId); |
|
2378 |
XCopyPlane(myDpy, source, dest, gc, |
|
555 | 2379 |
__intVal(srcX), __intVal(srcY), |
2380 |
__intVal(w), __intVal(h), |
|
2381 |
__intVal(dstX), __intVal(dstY), 1); |
|
70 | 2382 |
RETURN ( self ); |
0 | 2383 |
} |
118 | 2384 |
%}. |
2385 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2386 |
or any non integer coordinate" |
|
2387 |
||
0 | 2388 |
self primitiveFailed |
2389 |
! |
|
2390 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2391 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 2392 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
2393 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2394 |
|
2395 |
%{ /* NOCONTEXT */ |
|
2396 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2397 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2398 |
Window win; |
0 | 2399 |
int w, h, angle1, angle2; |
2400 |
double f; |
|
2401 |
||
97 | 2402 |
if (__isSmallInteger(startAngle)) |
850 | 2403 |
angle1 = __intVal(startAngle) * 64; |
36 | 2404 |
else if (__isFloat(startAngle)) { |
850 | 2405 |
f = __floatVal(startAngle); |
2406 |
angle1 = f * 64; |
|
0 | 2407 |
} |
97 | 2408 |
if (__isSmallInteger(angle)) |
850 | 2409 |
angle2 = __intVal(angle) * 64; |
36 | 2410 |
else if (__isFloat(angle)) { |
850 | 2411 |
f = __floatVal(angle); |
2412 |
angle2 = f * 64; |
|
0 | 2413 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2414 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2415 |
&& __isExternalAddress(aDrawableId) |
97 | 2416 |
&& __bothSmallInteger(x, y) |
2417 |
&& __bothSmallInteger(width, height)) { |
|
850 | 2418 |
win = _WindowVal(aDrawableId); |
2419 |
gc = _GCVal(aGCId); |
|
2420 |
w = __intVal(width); |
|
2421 |
h = __intVal(height); |
|
2422 |
/* |
|
2423 |
* need this check here: some servers simply dump core with bad args |
|
2424 |
*/ |
|
2425 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2426 |
XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
2427 |
w, h, angle1, angle2); |
|
2428 |
} |
|
2429 |
RETURN ( self ); |
|
0 | 2430 |
} |
73 | 2431 |
%}. |
2432 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2433 |
self primitiveFailed |
2434 |
! |
|
2435 |
||
295 | 2436 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
2437 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
2438 |
||
2439 |
%{ /* NOCONTEXT */ |
|
2440 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2441 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2442 |
Window win; |
295 | 2443 |
|
2444 |
if (__isExternalAddress(aGCId) |
|
2445 |
&& __isExternalAddress(aDrawableId) |
|
2446 |
&& __bothSmallInteger(x0, y0) |
|
2447 |
&& __bothSmallInteger(x1, y1)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2448 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2449 |
win = _WindowVal(aDrawableId); |
555 | 2450 |
XDrawLine(myDpy, win, gc, __intVal(x0), __intVal(y0), |
2451 |
__intVal(x1), __intVal(y1)); |
|
295 | 2452 |
RETURN ( self ); |
2453 |
} |
|
2454 |
%}. |
|
2455 |
"badGC, badDrawable or coordinates not integer" |
|
2456 |
self primitiveFailed |
|
2457 |
! |
|
2458 |
||
2459 |
displayPointX:x y:y in:aDrawableId with:aGCId |
|
2460 |
"draw a point. If x/y are not integers, an error is triggered." |
|
2461 |
||
2462 |
%{ /* NOCONTEXT */ |
|
2463 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2464 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2465 |
Window win; |
295 | 2466 |
|
2467 |
if (__isExternalAddress(aGCId) |
|
2468 |
&& __isExternalAddress(aDrawableId) |
|
2469 |
&& __bothSmallInteger(x, y)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2470 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2471 |
win = _WindowVal(aDrawableId); |
555 | 2472 |
XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y)); |
295 | 2473 |
RETURN ( self ); |
2474 |
} |
|
2475 |
%}. |
|
2476 |
"badGC, badDrawable or x/y not integer" |
|
2477 |
self primitiveFailed |
|
2478 |
! |
|
2479 |
||
2480 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
2481 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
2482 |
define the polygon. |
|
2483 |
If any coordinate is not integer, an error is triggered." |
|
2484 |
||
2485 |
|numberOfPoints newPoints| |
|
2486 |
||
2487 |
numberOfPoints := aPolygon size. |
|
2488 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2489 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2490 |
Window win; |
295 | 2491 |
OBJ point, x, y; |
2492 |
int i, num; |
|
2493 |
XPoint *points; |
|
2494 |
XPoint qPoints[100]; |
|
377 | 2495 |
int mustFree = 0; |
295 | 2496 |
|
2497 |
if (__isExternalAddress(aGCId) |
|
2498 |
&& __isExternalAddress(aDrawableId) |
|
2499 |
&& __isSmallInteger(numberOfPoints)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2500 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2501 |
win = _WindowVal(aDrawableId); |
555 | 2502 |
num = __intVal(numberOfPoints); |
295 | 2503 |
/* |
2504 |
* avoid a (slow) malloc, if the number of points is small |
|
2505 |
*/ |
|
2506 |
if (num > 100) { |
|
2507 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
|
2508 |
if (! points) goto fail; |
|
377 | 2509 |
mustFree = 1; |
295 | 2510 |
} else |
2511 |
points = qPoints; |
|
2512 |
||
2513 |
for (i=0; i<num; i++) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
2514 |
point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1)); |
295 | 2515 |
if (! __isPoint(point)) goto fail; |
2516 |
x = _point_X(point); |
|
2517 |
y = _point_Y(point); |
|
2518 |
if (! __bothSmallInteger(x, y)) |
|
2519 |
goto fail; |
|
555 | 2520 |
points[i].x = __intVal(x); |
2521 |
points[i].y = __intVal(y); |
|
295 | 2522 |
} |
2523 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
|
377 | 2524 |
if (mustFree) |
295 | 2525 |
free(points); |
2526 |
RETURN ( self ); |
|
2527 |
} |
|
2528 |
fail: ; |
|
377 | 2529 |
if (mustFree) |
382 | 2530 |
free(points); |
295 | 2531 |
%}. |
2532 |
"badGC, badDrawable or coordinates not integer" |
|
2533 |
self primitiveFailed |
|
2534 |
! |
|
2535 |
||
2536 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2537 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2538 |
||
2539 |
%{ /* NOCONTEXT */ |
|
2540 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2541 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2542 |
Window win; |
295 | 2543 |
int w, h; |
2544 |
||
2545 |
if (__isExternalAddress(aGCId) |
|
2546 |
&& __isExternalAddress(aDrawableId) |
|
2547 |
&& __bothSmallInteger(x, y) |
|
2548 |
&& __bothSmallInteger(width, height)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2549 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2550 |
win = _WindowVal(aDrawableId); |
555 | 2551 |
w = __intVal(width); |
2552 |
h = __intVal(height); |
|
295 | 2553 |
/* |
2554 |
* need this check here: some servers simply dump core with bad args |
|
2555 |
*/ |
|
2556 |
if ((w >= 0) && (h >= 0)) { |
|
555 | 2557 |
XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h); |
295 | 2558 |
} |
2559 |
RETURN ( self ); |
|
2560 |
} |
|
2561 |
%}. |
|
2562 |
"badGC, badDrawable or coordinates not integer" |
|
2563 |
self primitiveFailed |
|
2564 |
! |
|
2565 |
||
2566 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2567 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2568 |
foreground and background characters. |
|
2569 |
If the coordinates are not integers, an error is triggered." |
|
2570 |
||
2571 |
%{ /* NOCONTEXT */ |
|
2572 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2573 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2574 |
Window win; |
295 | 2575 |
unsigned char *cp; |
2576 |
OBJ cls; |
|
2577 |
int i1, i2, l, n; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2578 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2579 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2580 |
int nInstBytes; |
295 | 2581 |
|
2582 |
if (__isExternalAddress(aGCId) |
|
2583 |
&& __isExternalAddress(aDrawableId) |
|
2584 |
&& __isNonNilObject(aString) |
|
2585 |
&& __bothSmallInteger(index1, index2) |
|
2586 |
&& __bothSmallInteger(x, y)) { |
|
850 | 2587 |
gc = _GCVal(aGCId); |
2588 |
win = _WindowVal(aDrawableId); |
|
2589 |
cls = __qClass(aString); |
|
2590 |
||
2591 |
i1 = __intVal(index1) - 1; |
|
2592 |
if (i1 >= 0) { |
|
2593 |
i2 = __intVal(index2) - 1; |
|
2594 |
if (i2 < i1) { |
|
2595 |
RETURN (self); |
|
2596 |
} |
|
2597 |
||
2598 |
cp = _stringVal(aString); |
|
2599 |
l = i2 - i1 + 1; |
|
2600 |
||
2601 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2602 |
n = _stringSize(aString); |
|
2603 |
if (i2 < n) { |
|
2604 |
cp += i1; |
|
2605 |
if (l > 1000) l = 1000; |
|
2606 |
if (opaque == true) |
|
2607 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2608 |
else |
|
2609 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2610 |
RETURN ( self ); |
|
2611 |
} |
|
2612 |
} |
|
2613 |
||
2614 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2615 |
cp += nInstBytes; |
|
2616 |
||
2617 |
if (__isBytes(aString)) { |
|
2618 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2619 |
||
2620 |
if (i2 < n) { |
|
2621 |
cp += i1; |
|
2622 |
if (l > 1000) l = 1000; |
|
2623 |
if (opaque == true) |
|
2624 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2625 |
else |
|
2626 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
|
2627 |
RETURN ( self ); |
|
2628 |
} |
|
2629 |
} |
|
2630 |
||
2631 |
/* TWOBYTESTRINGS */ |
|
2632 |
if (__isWords(aString)) { |
|
2633 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2634 |
||
2635 |
if (i2 < n) { |
|
2636 |
union { |
|
2637 |
char b[2]; |
|
2638 |
unsigned short s; |
|
2639 |
} u; |
|
2640 |
int i; |
|
2641 |
XChar2b *cp2 = (XChar2b *)0; |
|
2642 |
int mustFree = 0; |
|
2643 |
||
2644 |
cp += (i1 * 2); |
|
2645 |
if (l > 1000) l = 1000; |
|
2646 |
||
2647 |
/* |
|
2648 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
2649 |
* X expects them MSB first |
|
2650 |
* convert as required |
|
2651 |
*/ |
|
2652 |
||
2653 |
u.s = 0x1234; |
|
2654 |
if (u.b[0] != 0x12) { |
|
2655 |
if (l <= NLOCALBUFFER) { |
|
2656 |
cp2 = xlatebuffer; |
|
2657 |
} else { |
|
2658 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
2659 |
mustFree = 1; |
|
2660 |
} |
|
2661 |
for (i=0; i<l; i++) { |
|
2662 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
2663 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
2664 |
} |
|
2665 |
cp = (char *) cp2; |
|
2666 |
} |
|
2667 |
||
2668 |
if (opaque == true) |
|
2669 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
2670 |
else |
|
2671 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
|
2672 |
||
2673 |
if (mustFree) { |
|
2674 |
free(cp2); |
|
2675 |
} |
|
2676 |
||
2677 |
RETURN ( self ); |
|
2678 |
} |
|
2679 |
} |
|
2680 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2681 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2682 |
#undef NLOCALBUFFER |
295 | 2683 |
%}. |
2684 |
"x/y not integer, badGC or drawable, or not a string" |
|
2685 |
self primitiveFailed |
|
2686 |
! |
|
2687 |
||
2688 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2689 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
2690 |
foreground and background characters. |
|
2691 |
If the coordinates are not integers, an error is triggered." |
|
2692 |
||
2693 |
%{ /* NOCONTEXT */ |
|
2694 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2695 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2696 |
Window win; |
295 | 2697 |
unsigned char *cp; |
2698 |
int n; |
|
2699 |
OBJ cls; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2700 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2701 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2702 |
int nInstBytes; |
295 | 2703 |
|
2704 |
if (__isExternalAddress(aGCId) |
|
2705 |
&& __isExternalAddress(aDrawableId) |
|
2706 |
&& __isNonNilObject(aString) |
|
2707 |
&& __bothSmallInteger(x, y)) { |
|
850 | 2708 |
gc = _GCVal(aGCId); |
2709 |
win = _WindowVal(aDrawableId); |
|
2710 |
cls = __qClass(aString); |
|
2711 |
||
2712 |
cp = _stringVal(aString); |
|
2713 |
||
2714 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2715 |
n = _stringSize(aString); |
|
2716 |
if (n > 1000) n = 1000; |
|
2717 |
if (opaque == true) |
|
2718 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2719 |
else |
|
2720 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2721 |
RETURN ( self ); |
|
2722 |
} |
|
2723 |
||
2724 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2725 |
cp += nInstBytes; |
|
2726 |
||
2727 |
if (__isBytes(aString)) { |
|
2728 |
n = __byteArraySize(aString) - nInstBytes - 1; |
|
2729 |
||
2730 |
if (n > 1000) n = 1000; |
|
2731 |
if (opaque == true) |
|
2732 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2733 |
else |
|
2734 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
|
2735 |
RETURN ( self ); |
|
2736 |
} |
|
2737 |
||
2738 |
/* TWOBYTESTRINGS */ |
|
2739 |
if (__isWords(aString)) { |
|
2740 |
union { |
|
2741 |
char b[2]; |
|
2742 |
unsigned short s; |
|
2743 |
} u; |
|
2744 |
int i; |
|
2745 |
XChar2b *cp2; |
|
2746 |
int mustFree = 0; |
|
2747 |
||
2748 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
2749 |
if (n > 1000) n = 1000; |
|
2750 |
||
2751 |
/* |
|
2752 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
2753 |
* X expects them MSB first |
|
2754 |
* convert as required |
|
2755 |
*/ |
|
2756 |
||
2757 |
u.s = 0x1234; |
|
2758 |
if (u.b[0] != 0x12) { |
|
2759 |
if (n <= NLOCALBUFFER) { |
|
2760 |
cp2 = xlatebuffer; |
|
2761 |
} else { |
|
2762 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
2763 |
mustFree = 1; |
|
2764 |
} |
|
2765 |
||
2766 |
for (i=0; i<n; i++) { |
|
2767 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
2768 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
2769 |
} |
|
2770 |
cp = (char *) cp2; |
|
2771 |
} |
|
2772 |
||
2773 |
if (opaque == true) |
|
2774 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
2775 |
else |
|
2776 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
|
2777 |
||
2778 |
||
2779 |
if (mustFree) { |
|
2780 |
free(cp2); |
|
2781 |
} |
|
2782 |
||
2783 |
RETURN ( self ); |
|
2784 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2785 |
} |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2786 |
#undef NLOCALBUFFER |
295 | 2787 |
%}. |
2788 |
"x/y not integer, badGC or drawable, or not a string" |
|
2789 |
self primitiveFailed |
|
2790 |
! |
|
2791 |
||
2792 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2793 |
width:imageWidth height:imageHeight |
|
2794 |
x:srcx y:srcy |
|
2795 |
into:aDrawableId |
|
2796 |
x:dstx y:dsty |
|
2797 |
width:w height:h |
|
2798 |
with:aGCId |
|
2799 |
||
2800 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2801 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2802 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
2803 |
depth and pixel-units to be different. |
|
2804 |
It has to be checked elsewhere, that the server can do it with the given |
|
2805 |
depth - otherwise, primitive failure will be signalled. |
|
2806 |
Also it is assumed, that the colormap is setup correctly and the |
|
2807 |
colors are allocated - otherwise the colors may be wrong." |
|
2808 |
||
2809 |
" |
|
2810 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
2811 |
an unlimited stack, and thus cannot send primitiveFailed |
|
2812 |
" |
|
2813 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2814 |
width:imageWidth height:imageHeight |
|
2815 |
x:srcx y:srcy |
|
2816 |
into:aDrawableId |
|
2817 |
x:dstx y:dsty |
|
2818 |
width:w height:h |
|
2819 |
with:aGCId) |
|
2820 |
ifFalse:[ |
|
2821 |
" |
|
2822 |
also happens, if a segmentation violation occurs in the |
|
2823 |
XPutImage ... |
|
2824 |
" |
|
2825 |
self primitiveFailed |
|
2826 |
]. |
|
2827 |
! |
|
2828 |
||
2829 |
drawBits:imageBits depth:imageDepth |
|
2830 |
width:imageWidth height:imageHeight |
|
2831 |
x:srcx y:srcy |
|
2832 |
into:aDrawableId |
|
2833 |
x:dstx y:dsty |
|
2834 |
width:w height:h |
|
2835 |
with:aGCId |
|
2836 |
||
2837 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2838 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2839 |
Individual source pixels must have imageDepth bits. |
|
2840 |
It has to be checked elsewhere, that the server can do it with the given |
|
2841 |
depth - otherwise, primitive failure will be signalled. |
|
2842 |
Also it is assumed, that the colormap is setup correctly and the |
|
2843 |
colors are allocated - otherwise the colors may be wrong." |
|
2844 |
||
2845 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
2846 |
width:imageWidth height:imageHeight |
|
2847 |
x:srcx y:srcy |
|
2848 |
into:aDrawableId |
|
2849 |
x:dstx y:dsty |
|
2850 |
width:w height:h |
|
2851 |
with:aGCId |
|
2852 |
||
2853 |
! |
|
2854 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2855 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
850 | 2856 |
in:aDrawableId with:aGCId |
90 | 2857 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
2858 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2859 |
|
2860 |
%{ /* NOCONTEXT */ |
|
2861 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2862 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2863 |
Window win; |
0 | 2864 |
int w, h, angle1, angle2; |
2865 |
double f; |
|
2866 |
||
97 | 2867 |
if (__isSmallInteger(startAngle)) |
850 | 2868 |
angle1 = __intVal(startAngle) * 64; |
36 | 2869 |
else if (__isFloat(startAngle)) { |
850 | 2870 |
f = __floatVal(startAngle); |
2871 |
angle1 = f * 64; |
|
0 | 2872 |
} |
97 | 2873 |
if (__isSmallInteger(angle)) |
850 | 2874 |
angle2 = __intVal(angle) * 64; |
36 | 2875 |
else if (__isFloat(angle)) { |
850 | 2876 |
f = __floatVal(angle); |
2877 |
angle2 = f * 64; |
|
0 | 2878 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2879 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2880 |
&& __isExternalAddress(aDrawableId) |
97 | 2881 |
&& __bothSmallInteger(x, y) |
2882 |
&& __bothSmallInteger(width, height)) { |
|
850 | 2883 |
gc = _GCVal(aGCId); |
2884 |
win = _WindowVal(aDrawableId); |
|
2885 |
w = __intVal(width); |
|
2886 |
h = __intVal(height); |
|
2887 |
/* |
|
2888 |
* need this check here: some servers simply dump core with bad args |
|
2889 |
*/ |
|
2890 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
|
2891 |
XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
|
2892 |
w, h, angle1, angle2); |
|
2893 |
} |
|
2894 |
RETURN ( self ); |
|
0 | 2895 |
} |
73 | 2896 |
%}. |
2897 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2898 |
self primitiveFailed |
2899 |
! |
|
2900 |
||
2901 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 2902 |
"fill a polygon given by its points. |
2903 |
If any coordinate is not integer, an error is triggered." |
|
73 | 2904 |
|
2905 |
|numberOfPoints| |
|
0 | 2906 |
|
2907 |
numberOfPoints := aPolygon size. |
|
2908 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2909 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2910 |
Window win; |
73 | 2911 |
OBJ point, x, y; |
2912 |
int i, num; |
|
2913 |
XPoint *points; |
|
2914 |
XPoint qPoints[100]; |
|
377 | 2915 |
int mustFree = 0; |
73 | 2916 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2917 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2918 |
&& __isExternalAddress(aDrawableId) |
97 | 2919 |
&& __isSmallInteger(numberOfPoints)) { |
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2920 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2921 |
win = _WindowVal(aDrawableId); |
555 | 2922 |
num = __intVal(numberOfPoints); |
73 | 2923 |
if (num < 3) { |
70 | 2924 |
RETURN ( self ); |
2925 |
} |
|
73 | 2926 |
/* |
2927 |
* avoid (slow) malloc, if not many points |
|
2928 |
*/ |
|
96 | 2929 |
if (num > 100) { |
73 | 2930 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
96 | 2931 |
if (! points) goto fail; |
377 | 2932 |
mustFree = 1; |
96 | 2933 |
} else |
73 | 2934 |
points = qPoints; |
2935 |
for (i=0; i<num; i++) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
2936 |
point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1)); |
73 | 2937 |
if (! __isPoint(point)) goto fail; |
2938 |
x = _point_X(point); |
|
2939 |
y = _point_Y(point); |
|
97 | 2940 |
if (! __bothSmallInteger(x, y)) |
73 | 2941 |
goto fail; |
555 | 2942 |
points[i].x = __intVal(x); |
2943 |
points[i].y = __intVal(y); |
|
73 | 2944 |
} |
2945 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
|
377 | 2946 |
if (mustFree) |
73 | 2947 |
free(points); |
2948 |
RETURN ( self ); |
|
377 | 2949 |
|
0 | 2950 |
fail: ; |
382 | 2951 |
if (mustFree) |
2952 |
free(points); |
|
0 | 2953 |
} |
73 | 2954 |
%}. |
2955 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2956 |
self primitiveFailed |
2957 |
! |
|
2958 |
||
295 | 2959 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
2960 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
2961 |
||
2962 |
%{ /* NOCONTEXT */ |
|
2963 |
||
2964 |
int w, h; |
|
2965 |
||
2966 |
if (__isExternalAddress(aGCId) |
|
2967 |
&& __isExternalAddress(aDrawableId) |
|
2968 |
&& __bothSmallInteger(x, y) |
|
2969 |
&& __bothSmallInteger(width, height)) { |
|
555 | 2970 |
w = __intVal(width); |
2971 |
h = __intVal(height); |
|
295 | 2972 |
/* |
2973 |
* need this check here: some servers simply dump core with bad args |
|
2974 |
*/ |
|
2975 |
if ((w >= 0) && (h >= 0)) { |
|
2976 |
XFillRectangle(myDpy, |
|
2977 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
555 | 2978 |
__intVal(x), __intVal(y), w, h); |
295 | 2979 |
} |
2980 |
RETURN ( self ); |
|
2981 |
} |
|
2982 |
%}. |
|
2983 |
"badGC, badDrawable or coordinates not integer" |
|
2984 |
self primitiveFailed |
|
43 | 2985 |
! |
2986 |
||
2987 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
70 | 2988 |
width:imageWidth height:imageHeight |
2989 |
x:srcx y:srcy |
|
2990 |
into:aDrawableId |
|
2991 |
x:dstx y:dsty |
|
2992 |
width:w height:h |
|
2993 |
with:aGCId |
|
0 | 2994 |
|
132 | 2995 |
"since XPutImage may allocate huge amount of stack space |
2996 |
(some implementations use alloca), this must run with unlimited stack." |
|
2997 |
||
12 | 2998 |
%{ /* UNLIMITEDSTACK */ |
0 | 2999 |
|
43 | 3000 |
/* |
3001 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
3002 |
* XPutImage |
|
3003 |
*/ |
|
3004 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3005 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3006 |
Window win; |
43 | 3007 |
XImage image; |
377 | 3008 |
int imgWdth; |
43 | 3009 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3010 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3011 |
&& __isExternalAddress(aDrawableId) |
97 | 3012 |
&& __bothSmallInteger(srcx, srcy) |
3013 |
&& __bothSmallInteger(dstx, dsty) |
|
3014 |
&& __bothSmallInteger(w, h) |
|
3015 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
3016 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 3017 |
&& __isByteArray(imageBits)) { |
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3018 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
3019 |
win = _WindowVal(aDrawableId); |
811 | 3020 |
if (! gc || !win) |
3021 |
goto fail; |
|
46 | 3022 |
#ifdef ARGDEBUG |
70 | 3023 |
printf("args ok\n"); |
46 | 3024 |
#endif |
555 | 3025 |
image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element; |
3026 |
image.width = imgWdth = __intVal(imageWidth); |
|
3027 |
image.height = __intVal(imageHeight); |
|
70 | 3028 |
image.xoffset = 0; |
3029 |
image.format = ZPixmap; |
|
3030 |
image.byte_order = MSBFirst; |
|
3031 |
image.bitmap_unit = 8; |
|
3032 |
image.bitmap_bit_order = MSBFirst; |
|
3033 |
image.bitmap_pad = 8; |
|
555 | 3034 |
image.depth = __intVal(imageDepth); |
3035 |
image.bits_per_pixel = __intVal(bitsPerPixel); |
|
70 | 3036 |
switch (image.bits_per_pixel) { |
3037 |
case 1: |
|
377 | 3038 |
image.bytes_per_line = (imgWdth + 7) / 8; |
70 | 3039 |
break; |
3040 |
case 2: |
|
377 | 3041 |
image.bytes_per_line = (imgWdth*2 + 7) / 8; |
70 | 3042 |
break; |
3043 |
case 4: |
|
377 | 3044 |
image.bytes_per_line = (imgWdth*4 + 7) / 8; |
70 | 3045 |
break; |
3046 |
case 8: |
|
377 | 3047 |
image.bytes_per_line = imgWdth; |
70 | 3048 |
break; |
3049 |
case 16: |
|
377 | 3050 |
image.bytes_per_line = imgWdth*2; |
70 | 3051 |
break; |
3052 |
case 24: |
|
377 | 3053 |
image.bytes_per_line = imgWdth*3; |
70 | 3054 |
break; |
193 | 3055 |
case 32: |
377 | 3056 |
image.bytes_per_line = imgWdth*4; |
193 | 3057 |
break; |
70 | 3058 |
default: |
46 | 3059 |
#ifdef ARGDEBUG |
70 | 3060 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 3061 |
#endif |
70 | 3062 |
goto fail; |
3063 |
} |
|
3064 |
image.red_mask = 0xFFFF; |
|
3065 |
image.green_mask = 0xFFFF; |
|
3066 |
image.blue_mask = 0xFFFF; |
|
555 | 3067 |
XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy), |
3068 |
__intVal(dstx), __intVal(dsty), |
|
3069 |
__intVal(w), __intVal(h)); |
|
70 | 3070 |
RETURN ( true ); |
43 | 3071 |
} |
46 | 3072 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3073 |
if (!! __isExternalAddress(aGCId)) printf("GC\n"); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3074 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 3075 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
3076 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
3077 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
3078 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
3079 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
3080 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
3081 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
3082 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
3083 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
3084 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
3085 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 3086 |
#endif |
3087 |
||
0 | 3088 |
fail: ; |
3089 |
%} |
|
3090 |
. |
|
12 | 3091 |
^ false |
0 | 3092 |
! ! |
3093 |
||
86 | 3094 |
!XWorkstation methodsFor:'event handling'! |
0 | 3095 |
|
3096 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
3097 |
"central event handling method: |
|
54 | 3098 |
get next event and send appropriate message to the sensor or view. |
0 | 3099 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 3100 |
otherwise only events for the view with given id are processed. |
3101 |
If the argument aMask is nonNil, only events for this eventMask are |
|
3102 |
handled." |
|
3103 |
||
54 | 3104 |
(self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[ |
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
3105 |
AbortSignal catch:[ |
83 | 3106 |
self dispatchLastEvent. |
3107 |
] |
|
54 | 3108 |
]. |
12 | 3109 |
! |
3110 |
||
295 | 3111 |
dispatchExposeEventFor:aViewIdOrNil |
3112 |
"get next expose event and send appropriate message to the sensor or view. |
|
3113 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
3114 |
otherwise only events for the view with given id are processed." |
|
3115 |
||
3116 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
12 | 3117 |
! |
3118 |
||
3119 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3120 |
|theView symS arg butt sibling windowID siblingID propertyID selectionID targetID requestorID |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3121 |
eventType| |
12 | 3122 |
|
3123 |
%{ /* STACK: 8000 */ |
|
3124 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 3125 |
|
3126 |
Display *dpy = myDpy; |
|
135 | 3127 |
OBJ eB; |
3128 |
XEvent *ev; |
|
3129 |
||
3130 |
# define ae ((XAnyEvent *)ev) |
|
3131 |
# define ee ((XExposeEvent *)ev) |
|
3132 |
# define ke ((XKeyPressedEvent *)ev) |
|
3133 |
# define be ((XButtonPressedEvent *)ev) |
|
3134 |
# define ce ((XConfigureEvent *)ev) |
|
3135 |
# define me ((XMotionEvent *)ev) |
|
3136 |
# define ewe ((XEnterWindowEvent *)ev) |
|
3137 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
3138 |
# define de ((XDestroyWindowEvent *)ev) |
|
3139 |
# define ve ((XVisibilityEvent *)ev) |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3140 |
# define mape ((XMappingEvent *)ev) |
135 | 3141 |
|
0 | 3142 |
KeySym keySym; |
3143 |
unsigned char buffer[10]; |
|
3144 |
int i, nchars; |
|
3145 |
char *keySymString; |
|
3146 |
char keySymStringBuffer[32]; |
|
3147 |
static unsigned multiClickTime = 0; |
|
3148 |
unsigned nextMultiClickTime; |
|
150 | 3149 |
OBJ upDown; |
115 | 3150 |
|
3151 |
struct inlineCache *ipS; |
|
0 | 3152 |
static struct inlineCache vid = _ILC1; |
12 | 3153 |
|
3154 |
static struct inlineCache expS = _ILC5; |
|
3155 |
static struct inlineCache gexpS = _ILC5; |
|
3156 |
static struct inlineCache nexpS = _ILC1; |
|
3157 |
static struct inlineCache motS = _ILC4; |
|
3158 |
static struct inlineCache bpS = _ILC4; |
|
3159 |
static struct inlineCache bmpS = _ILC4; |
|
3160 |
static struct inlineCache bspS = _ILC4; |
|
3161 |
static struct inlineCache brS = _ILC4; |
|
3162 |
static struct inlineCache focInS = _ILC1; |
|
3163 |
static struct inlineCache focOutS = _ILC1; |
|
3164 |
static struct inlineCache peS = _ILC4; |
|
3165 |
static struct inlineCache plS = _ILC2; |
|
54 | 3166 |
static struct inlineCache termS = _ILC1; |
3167 |
static struct inlineCache savtermS = _ILC1; |
|
3168 |
static struct inlineCache destrS = _ILC1; |
|
3169 |
static struct inlineCache unmapS = _ILC1; |
|
3170 |
static struct inlineCache mapS = _ILC1; |
|
3171 |
static struct inlineCache confS = _ILC5; |
|
70 | 3172 |
static struct inlineCache coveredS = _ILC2; |
12 | 3173 |
|
3174 |
static struct inlineCache keymap = _ILC0; |
|
3175 |
static struct inlineCache created = _ILC0; |
|
3176 |
static struct inlineCache mapReq = _ILC0; |
|
3177 |
static struct inlineCache repar = _ILC0; |
|
3178 |
static struct inlineCache confReq = _ILC0; |
|
3179 |
static struct inlineCache resReq = _ILC0; |
|
3180 |
static struct inlineCache prop = _ILC0; |
|
129 | 3181 |
static struct inlineCache selClear = _ILC1; |
90 | 3182 |
static struct inlineCache selReq = _ILC4; |
3183 |
static struct inlineCache selNotify = _ILC4; |
|
12 | 3184 |
static struct inlineCache colormap = _ILC0; |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3185 |
static struct inlineCache mapping = _ILC2; |
70 | 3186 |
static struct inlineCache vis = _ILC1; |
12 | 3187 |
|
3188 |
static struct inlineCache skpS = _ILC4; |
|
63 | 3189 |
static struct inlineCache skrS = _ILC4; |
12 | 3190 |
|
555 | 3191 |
eB = __INST(eventBuffer); |
135 | 3192 |
if (__isByteArray(eB)) { |
555 | 3193 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
135 | 3194 |
} else { |
3195 |
printf("DISPLAY: no eventBuffer\n"); |
|
3196 |
RETURN (false); |
|
3197 |
} |
|
3198 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3199 |
windowID = __MKOBJ(ae->window); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3200 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:) COMMA_CON, nil, &vid, windowID); |
12 | 3201 |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3202 |
if ((theView == nil) && (ev->type != MappingNotify)) { |
70 | 3203 |
RETURN (nil); |
12 | 3204 |
} |
3205 |
||
3206 |
/* |
|
3207 |
* key, button and pointer events are sent to the sensor, |
|
3208 |
* or (if there is none) to the delegate. |
|
3209 |
* or (if there is none) to the view. |
|
26 | 3210 |
* |
3211 |
* expose events are sent to the sensor, |
|
3212 |
* or (if there is none) to the view |
|
3213 |
* |
|
12 | 3214 |
* sensor and delegate get view as additional argument |
115 | 3215 |
* all of this has been taken out of here to corresponding methods |
3216 |
* in DeviceWorkstation. |
|
12 | 3217 |
*/ |
90 | 3218 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3219 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3220 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3221 |
#endif |
135 | 3222 |
switch (ev->type) { |
70 | 3223 |
case KeyRelease: |
115 | 3224 |
symS = @symbol(keyRelease:x:y:view:); |
70 | 3225 |
ipS = &skrS; |
150 | 3226 |
upDown = false; |
70 | 3227 |
goto keyPressAndRelease; |
3228 |
||
3229 |
case KeyPress: |
|
115 | 3230 |
symS = @symbol(keyPress:x:y:view:); |
70 | 3231 |
ipS = &skpS; |
150 | 3232 |
upDown = true; |
3233 |
/* FALL INTO */ |
|
70 | 3234 |
|
3235 |
keyPressAndRelease: |
|
555 | 3236 |
__INST(eventRootX) = __MKSMALLINT(ke->x_root); |
3237 |
__INST(eventRootY) = __MKSMALLINT(ke->y_root); |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3238 |
#ifdef OLD |
555 | 3239 |
__INST(altDown) = (ke->state & Mod2Mask) ? true : false; |
3240 |
__INST(metaDown) = (ke->state & Mod1Mask) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3241 |
#else |
555 | 3242 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3243 |
__INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3244 |
#endif |
555 | 3245 |
__INST(shiftDown) = (ke->state & ShiftMask) ? true : false; |
3246 |
__INST(ctrlDown) = (ke->state & ControlMask) ? true : false; |
|
70 | 3247 |
|
3248 |
arg = nil; |
|
3249 |
nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); |
|
3250 |
if (nchars |
|
3251 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
|
3252 |
|| (buffer[0] >= 0x80))) { |
|
3253 |
arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; |
|
3254 |
keySymString = NULL; |
|
3255 |
} else { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3256 |
#ifdef OLD |
150 | 3257 |
switch (keySym) { |
3258 |
case XK_Control_L: |
|
3259 |
case XK_Control_R: |
|
555 | 3260 |
__INST(ctrlDown) = upDown; |
150 | 3261 |
break; |
3262 |
case XK_Shift_L: |
|
3263 |
case XK_Shift_R: |
|
555 | 3264 |
__INST(shiftDown) = upDown; |
150 | 3265 |
break; |
3266 |
case XK_Meta_L: |
|
3267 |
case XK_Meta_R: |
|
555 | 3268 |
__INST(metaDown) = upDown; |
150 | 3269 |
break; |
3270 |
case XK_Alt_L: |
|
3271 |
case XK_Alt_R: |
|
555 | 3272 |
__INST(altDown) = upDown; |
150 | 3273 |
break; |
3274 |
} |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3275 |
#endif |
150 | 3276 |
|
70 | 3277 |
keySymString = XKeysymToString(keySym); |
3278 |
if (keySymString) { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3279 |
#ifdef OLD |
70 | 3280 |
if (keySymString[0] == 'D') { |
3281 |
/* |
|
3282 |
* remove underscore, dont want it in symbols |
|
3283 |
*/ |
|
3284 |
if (strcmp(keySymString, "Delete_line") == 0) { |
|
3285 |
keySymString = "DeleteLine"; |
|
3286 |
} else if (strcmp(keySymString, "Delete_word") == 0) { |
|
3287 |
keySymString = "DeleteWord"; |
|
3288 |
} |
|
3289 |
} |
|
3290 |
/* |
|
3291 |
* make names compatible |
|
3292 |
*/ |
|
3293 |
if (strcmp(keySymString, "Down") == 0) { |
|
3294 |
keySymString = "CursorDown"; |
|
3295 |
} else if (strcmp(keySymString, "Up") == 0) { |
|
3296 |
keySymString = "CursorUp"; |
|
3297 |
} else if (strcmp(keySymString, "Left") == 0) { |
|
3298 |
keySymString = "CursorLeft"; |
|
3299 |
} else if (strcmp(keySymString, "Right") == 0) { |
|
3300 |
keySymString = "CursorRight"; |
|
3301 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3302 |
arg = __MKSYMBOL(keySymString, (OBJ *)0, __context); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3303 |
#else |
350 | 3304 |
__PROTECT__(theView); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3305 |
arg = __MKSTRING(keySymString COMMA_CON); |
350 | 3306 |
__UNPROTECT__(theView); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3307 |
#endif |
70 | 3308 |
} |
3309 |
} |
|
3310 |
||
3311 |
if (arg == nil) { |
|
3312 |
/* happens sometimes (alt-graph on sun has no keysym) */ |
|
3313 |
break; |
|
3314 |
} |
|
3315 |
||
115 | 3316 |
(*(*ipS).ilc_func)(self, symS COMMA_CON, nil, ipS, |
3317 |
arg, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3318 |
__MKSMALLINT(ke->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3319 |
__MKSMALLINT(ke->y), |
115 | 3320 |
theView); |
70 | 3321 |
break; |
3322 |
||
3323 |
case ButtonPress: |
|
555 | 3324 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) | (1 << be->button)); |
3325 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
|
3326 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
|
3327 |
||
3328 |
if (__isSmallInteger(__INST(multiClickTimeDelta))) |
|
3329 |
nextMultiClickTime = be->time + __intVal(__INST(multiClickTimeDelta)); |
|
70 | 3330 |
else |
3331 |
nextMultiClickTime = 0; |
|
3332 |
||
3333 |
if (multiClickTime) { |
|
3334 |
if (be->time < multiClickTime) { |
|
3335 |
multiClickTime = nextMultiClickTime; |
|
3336 |
ipS = &bmpS; |
|
3337 |
symS = @symbol(buttonMultiPress:x:y:view:); |
|
3338 |
goto sendButtonEvent; |
|
3339 |
break; |
|
3340 |
} |
|
3341 |
} |
|
3342 |
multiClickTime = nextMultiClickTime; |
|
3343 |
if (be->state & ShiftMask) { |
|
3344 |
ipS = &bspS; |
|
3345 |
symS = @symbol(buttonShiftPress:x:y:view:); |
|
3346 |
goto sendButtonEvent; |
|
3347 |
} |
|
3348 |
ipS = &bpS; |
|
3349 |
symS = @symbol(buttonPress:x:y:view:); |
|
3350 |
goto sendButtonEvent; |
|
200 | 3351 |
|
70 | 3352 |
/* NOT REACHED */ |
3353 |
||
3354 |
case ButtonRelease: |
|
555 | 3355 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) & ~(1 << be->button)); |
3356 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
|
3357 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
|
70 | 3358 |
ipS = &brS; |
3359 |
symS = @symbol(buttonRelease:x:y:view:); |
|
3360 |
/* fall into */ |
|
3361 |
||
3362 |
sendButtonEvent: |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3363 |
butt = __MKSMALLINT(be->button); |
12 | 3364 |
#ifdef NOTDEF |
70 | 3365 |
/* |
3366 |
* this allows operation with single button mouses: meta-click is always Button 2 |
|
3367 |
*/ |
|
555 | 3368 |
if (__INST(metaDown) == true) |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3369 |
butt = __MKSMALLINT(2); |
70 | 3370 |
else |
0 | 3371 |
#endif |
555 | 3372 |
butt = __AT_(__INST(buttonTranslation), butt); |
200 | 3373 |
|
12 | 3374 |
|
115 | 3375 |
(*(*ipS).ilc_func)(self, |
3376 |
symS |
|
3377 |
COMMA_CON, nil, ipS, |
|
3378 |
butt, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3379 |
__MKSMALLINT(ke->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3380 |
__MKSMALLINT(ke->y), |
115 | 3381 |
theView); |
70 | 3382 |
break; |
3383 |
||
3384 |
case MotionNotify: |
|
555 | 3385 |
if (__INST(motionEventCompression) != false) { |
135 | 3386 |
while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; |
70 | 3387 |
} |
3388 |
||
555 | 3389 |
__INST(eventRootX) = __MKSMALLINT(me->x_root); |
3390 |
__INST(eventRootY) = __MKSMALLINT(me->y_root); |
|
70 | 3391 |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3392 |
#ifdef OLD |
555 | 3393 |
__INST(altDown) = (me->state & Mod2Mask) ? true : false; |
3394 |
__INST(metaDown) = (me->state & Mod1Mask) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3395 |
#else |
555 | 3396 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3397 |
__INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3398 |
#endif |
555 | 3399 |
__INST(shiftDown) = (me->state & ShiftMask) ? true : false; |
3400 |
__INST(ctrlDown) = (me->state & ControlMask) ? true : false; |
|
150 | 3401 |
|
115 | 3402 |
(*motS.ilc_func)(self, |
3403 |
@symbol(buttonMotion:x:y:view:) |
|
3404 |
COMMA_CON, nil, &motS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3405 |
__MKSMALLINT(me->state), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3406 |
__MKSMALLINT(me->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3407 |
__MKSMALLINT(me->y), |
115 | 3408 |
theView); |
70 | 3409 |
break; |
3410 |
||
3411 |
case FocusIn: |
|
115 | 3412 |
(*focInS.ilc_func)(self, |
3413 |
@symbol(focusInView:) |
|
3414 |
COMMA_CON, nil, &focInS, |
|
3415 |
theView); |
|
70 | 3416 |
break; |
3417 |
||
3418 |
case FocusOut: |
|
115 | 3419 |
(*focOutS.ilc_func)(self, |
3420 |
@symbol(focusOutView:) |
|
3421 |
COMMA_CON, nil, &focOutS, |
|
3422 |
theView); |
|
70 | 3423 |
break; |
3424 |
||
3425 |
case EnterNotify: |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3426 |
#ifdef OLD |
555 | 3427 |
__INST(altDown) = (ewe->state & Mod2Mask) ? true : false; |
3428 |
__INST(metaDown) = (ewe->state & Mod1Mask) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3429 |
#else |
555 | 3430 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3431 |
__INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3432 |
#endif |
555 | 3433 |
__INST(shiftDown) = (ewe->state & ShiftMask) ? true : false; |
3434 |
__INST(ctrlDown) = (ewe->state & ControlMask) ? true : false; |
|
150 | 3435 |
|
115 | 3436 |
(*peS.ilc_func)(self, |
3437 |
@symbol(pointerEnter:x:y:view:) |
|
3438 |
COMMA_CON, nil, &peS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3439 |
__MKSMALLINT(ewe->state), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3440 |
__MKSMALLINT(ewe->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3441 |
__MKSMALLINT(ewe->y), |
115 | 3442 |
theView); |
70 | 3443 |
break; |
3444 |
||
3445 |
case LeaveNotify: |
|
115 | 3446 |
(*plS.ilc_func)(self, |
3447 |
@symbol(pointerLeave:view:) |
|
3448 |
COMMA_CON, nil, &plS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3449 |
__MKSMALLINT(lwe->state), |
115 | 3450 |
theView); |
70 | 3451 |
break; |
3452 |
||
3453 |
case GraphicsExpose: |
|
115 | 3454 |
(*gexpS.ilc_func)(self, |
3455 |
@symbol(graphicExposeX:y:width:height:view:) |
|
3456 |
COMMA_CON, nil, &gexpS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3457 |
__MKSMALLINT(ee->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3458 |
__MKSMALLINT(ee->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3459 |
__MKSMALLINT(ee->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3460 |
__MKSMALLINT(ee->height), |
115 | 3461 |
theView); |
3462 |
||
3463 |
if (ee->count != 0) { |
|
70 | 3464 |
break; |
3465 |
} |
|
115 | 3466 |
/* fall into */ |
3467 |
||
3468 |
case NoExpose: |
|
3469 |
(*nexpS.ilc_func)(self, |
|
3470 |
@symbol(noExposeView:) |
|
3471 |
COMMA_CON, nil, &nexpS, |
|
3472 |
theView); |
|
3473 |
break; |
|
3474 |
||
3475 |
case Expose: |
|
3476 |
(*expS.ilc_func)(self, |
|
3477 |
@symbol(exposeX:y:width:height:view:) |
|
3478 |
COMMA_CON, nil, &expS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3479 |
__MKSMALLINT(ee->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3480 |
__MKSMALLINT(ee->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3481 |
__MKSMALLINT(ee->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3482 |
__MKSMALLINT(ee->height), |
115 | 3483 |
theView); |
70 | 3484 |
break; |
3485 |
||
3486 |
case ConfigureNotify: |
|
3487 |
if (ce->above != None) { |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3488 |
siblingID = __MKOBJ(ce->above); |
70 | 3489 |
sibling = (*vid.ilc_func)(self, @symbol(viewFromId:) |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3490 |
COMMA_CON, nil, &vid, siblingID); |
70 | 3491 |
} |
3492 |
||
115 | 3493 |
(*confS.ilc_func)(self, |
3494 |
@symbol(configureX:y:width:height:view:) |
|
3495 |
COMMA_CON, nil, &confS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3496 |
__MKSMALLINT(ce->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3497 |
__MKSMALLINT(ce->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3498 |
__MKSMALLINT(ce->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3499 |
__MKSMALLINT(ce->height), |
115 | 3500 |
theView); |
70 | 3501 |
if (sibling != nil) { |
115 | 3502 |
(*coveredS.ilc_func)(self, |
3503 |
@symbol(coveredBy:view:) |
|
3504 |
COMMA_CON, nil, &coveredS, |
|
3505 |
theView, |
|
3506 |
sibling); |
|
70 | 3507 |
} |
3508 |
break; |
|
3509 |
||
3510 |
case ClientMessage: |
|
555 | 3511 |
if (ev->xclient.message_type == (int) _AtomVal(__INST(protocolsAtom))) { |
3512 |
if ((ev->xclient.data.l[0] == (int) _AtomVal(__INST(quitAppAtom))) |
|
3513 |
|| (ev->xclient.data.l[0] == (int) _AtomVal(__INST(deleteWindowAtom)))) { |
|
115 | 3514 |
(*termS.ilc_func)(self, |
3515 |
@symbol(terminateView:) |
|
3516 |
COMMA_CON, nil, &termS, theView); |
|
70 | 3517 |
break; |
3518 |
} |
|
555 | 3519 |
if (ev->xclient.data.l[0] == (int) _AtomVal(__INST(saveYourselfAtom))) { |
115 | 3520 |
(*savtermS.ilc_func)(self, |
3521 |
@symbol(saveAndTerminateView:) |
|
3522 |
COMMA_CON, nil, &savtermS, theView); |
|
70 | 3523 |
break; |
3524 |
} |
|
3525 |
} |
|
3526 |
break; |
|
3527 |
||
3528 |
case DestroyNotify: |
|
115 | 3529 |
(*destrS.ilc_func)(self, @symbol(destroyedView:) |
3530 |
COMMA_CON, nil, &destrS, theView); |
|
70 | 3531 |
break; |
3532 |
||
3533 |
case UnmapNotify: |
|
115 | 3534 |
(*unmapS.ilc_func)(self, @symbol(unmappedView:) |
3535 |
COMMA_CON, nil, &unmapS, theView); |
|
70 | 3536 |
break; |
3537 |
||
3538 |
case MapNotify: |
|
115 | 3539 |
(*mapS.ilc_func)(self, |
3540 |
@symbol(mappedView:) |
|
3541 |
COMMA_CON, nil, &mapS, theView); |
|
70 | 3542 |
break; |
3543 |
||
3544 |
case KeymapNotify: |
|
115 | 3545 |
(*keymap.ilc_func)(theView, |
3546 |
@symbol(keyMapChange) |
|
3547 |
COMMA_CON, nil, &keymap); |
|
70 | 3548 |
break; |
3549 |
||
3550 |
case VisibilityNotify: |
|
3551 |
switch (ve->state) { |
|
3552 |
case VisibilityUnobscured: |
|
3553 |
arg = @symbol(unobscured); |
|
3554 |
break; |
|
3555 |
case VisibilityPartiallyObscured: |
|
3556 |
arg = @symbol(partiallyObscured); |
|
3557 |
break; |
|
3558 |
case VisibilityFullyObscured: |
|
3559 |
arg = @symbol(fullyObscured); |
|
3560 |
break; |
|
3561 |
} |
|
3562 |
(*vis.ilc_func)(theView, @symbol(visibilityChange:) COMMA_CON, nil, &vis, arg); |
|
3563 |
break; |
|
3564 |
||
3565 |
case CreateNotify: |
|
3566 |
(*created.ilc_func)(theView, @symbol(created) COMMA_CON, nil, &created); |
|
3567 |
break; |
|
3568 |
||
3569 |
case MapRequest: |
|
3570 |
(*mapReq.ilc_func)(theView, @symbol(mapRequest) COMMA_CON, nil, &mapReq); |
|
3571 |
break; |
|
3572 |
||
3573 |
case ReparentNotify: |
|
3574 |
(*repar.ilc_func)(theView, @symbol(reparented) COMMA_CON, nil, &repar); |
|
3575 |
break; |
|
3576 |
||
3577 |
case ConfigureRequest: |
|
3578 |
(*confReq.ilc_func)(theView, @symbol(configRequest) COMMA_CON, nil, &confReq); |
|
3579 |
break; |
|
3580 |
||
3581 |
case GravityNotify: |
|
3582 |
case ResizeRequest: |
|
3583 |
(*resReq.ilc_func)(theView, @symbol(resizeRequest) COMMA_CON, nil, &resReq); |
|
3584 |
break; |
|
3585 |
||
3586 |
case CirculateNotify: |
|
3587 |
case CirculateRequest: |
|
3588 |
break; |
|
3589 |
||
3590 |
case PropertyNotify: |
|
115 | 3591 |
(*prop.ilc_func)(theView, |
3592 |
@symbol(propertyChange) |
|
3593 |
COMMA_CON, nil, &prop); |
|
70 | 3594 |
break; |
3595 |
||
3596 |
case SelectionClear: |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3597 |
selectionID = __MKATOMOBJ(ev->xselectionclear.selection); |
115 | 3598 |
(*selClear.ilc_func)(theView, |
129 | 3599 |
@symbol(selectionClear:) |
3600 |
COMMA_CON, nil, &selClear, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3601 |
selectionID); |
70 | 3602 |
break; |
3603 |
||
90 | 3604 |
case SelectionNotify: |
3605 |
/* |
|
3606 |
* returned selection value (answer from SelectionRequest) |
|
3607 |
*/ |
|
129 | 3608 |
DPRINTF(("SelectionNotify prop=%x target=%x selection= %x requestor=%x\n", |
135 | 3609 |
ev->xselection.property, ev->xselection.target, |
3610 |
ev->xselection.selection, ev->xselection.requestor)); |
|
129 | 3611 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3612 |
propertyID = __MKATOMOBJ(ev->xselection.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3613 |
targetID = __MKATOMOBJ(ev->xselection.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3614 |
selectionID = __MKATOMOBJ(ev->xselection.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3615 |
requestorID = __MKOBJ(ev->xselection.requestor); |
115 | 3616 |
(*selNotify.ilc_func)(theView, |
3617 |
@symbol(selectionNotify:target:selection:from:) |
|
3618 |
COMMA_CON, nil, &selNotify, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3619 |
propertyID, targetID, selectionID, requestorID); |
70 | 3620 |
break; |
3621 |
||
90 | 3622 |
case SelectionRequest: |
129 | 3623 |
/* |
3624 |
* someone wants the selection |
|
3625 |
*/ |
|
3626 |
DPRINTF(("SelectionRequest prop=%x target=%x selection=%x requestor=%x\n", |
|
135 | 3627 |
ev->xselectionrequest.property, |
3628 |
ev->xselectionrequest.target, |
|
3629 |
ev->xselectionrequest.selection, |
|
3630 |
ev->xselectionrequest.requestor)); |
|
129 | 3631 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3632 |
propertyID = __MKATOMOBJ(ev->xselectionrequest.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3633 |
targetID = __MKATOMOBJ(ev->xselectionrequest.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3634 |
selectionID = __MKATOMOBJ(ev->xselectionrequest.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3635 |
requestorID = __MKOBJ(ev->xselectionrequest.requestor); |
115 | 3636 |
(*selReq.ilc_func)(theView, |
3637 |
@symbol(selectionRequest:target:selection:from:) |
|
3638 |
COMMA_CON, nil, &selReq, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3639 |
propertyID, targetID, selectionID, requestorID); |
70 | 3640 |
break; |
3641 |
||
3642 |
case ColormapNotify: |
|
115 | 3643 |
(*colormap.ilc_func)(theView, |
3644 |
@symbol(colorMapChange) |
|
3645 |
COMMA_CON, nil, &colormap); |
|
70 | 3646 |
break; |
3647 |
||
3648 |
case MappingNotify: |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3649 |
switch(mape->request) { |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3650 |
case MappingModifier: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3651 |
arg = @symbol(mappingModifier); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3652 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3653 |
case MappingKeyboard: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3654 |
arg = @symbol(mappingKeyboard); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3655 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3656 |
case MappingPointer: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3657 |
arg = @symbol(mappingPointer); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3658 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3659 |
default: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3660 |
arg = nil; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3661 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3662 |
} |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3663 |
(*mapping.ilc_func)(self, |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3664 |
@symbol(mappingChanged:event:) |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3665 |
COMMA_CON, nil, &mapping, arg, eB); |
70 | 3666 |
break; |
0 | 3667 |
} |
135 | 3668 |
#undef ae |
0 | 3669 |
#undef ee |
3670 |
#undef ke |
|
3671 |
#undef be |
|
3672 |
#undef ce |
|
3673 |
#undef me |
|
3674 |
#undef ewe |
|
3675 |
#undef lwe |
|
3676 |
#undef de |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3677 |
#undef mape |
0 | 3678 |
%} |
3679 |
. |
|
3680 |
^ true |
|
3681 |
! |
|
3682 |
||
295 | 3683 |
dispatchPendingEvents |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3684 |
"central event handling method for modal operation. |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3685 |
(i.e. this is now only used in the modal debugger) |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3686 |
This code is somewhat special, since X has a concept of graphic |
295 | 3687 |
expose events (which are sent after a bitblt). After such a bitblt, |
3688 |
we only handle exposes until the graphicsExpose arrives. |
|
3689 |
Other systems may not need such a kludge" |
|
3690 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
3691 |
"interested in exposes only ?" |
295 | 3692 |
dispatchingExpose notNil ifTrue:[ |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3693 |
[self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[ |
295 | 3694 |
self dispatchExposeEventFor:dispatchingExpose |
3695 |
]. |
|
3696 |
^ self |
|
3697 |
]. |
|
3698 |
||
3699 |
"no, general dispatch" |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3700 |
[self eventPendingWithSync:false] whileTrue:[ |
295 | 3701 |
self dispatchEventFor:nil withMask:nil |
3702 |
] |
|
3703 |
! |
|
3704 |
||
81 | 3705 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
3706 |
"dispose (throw away) specific events. If aWindowId is nil, |
|
3707 |
events matching the mask are thrown away regardless of which |
|
3708 |
view they are for. Otherwise, only matching events for that |
|
3709 |
view are flushed." |
|
0 | 3710 |
|
3711 |
%{ /* NOCONTEXT */ |
|
3712 |
||
3713 |
Display *dpy = myDpy; |
|
3714 |
XEvent ev; |
|
3715 |
Window win; |
|
3716 |
||
97 | 3717 |
if (__isSmallInteger(aMask)) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3718 |
if (__isExternalAddress(aWindowIdOrNil)) { |
81 | 3719 |
win = _WindowVal(aWindowIdOrNil); |
555 | 3720 |
while (XCheckWindowEvent(dpy, win, __intVal(aMask), &ev)) ;; |
81 | 3721 |
} else { |
555 | 3722 |
while (XCheckMaskEvent(dpy, __intVal(aMask), &ev)) ;; |
81 | 3723 |
} |
70 | 3724 |
RETURN ( self ); |
0 | 3725 |
} |
3726 |
%} |
|
3727 |
. |
|
3728 |
self primitiveFailed |
|
3729 |
! |
|
3730 |
||
295 | 3731 |
eventMaskFor:anEventSymbol |
3732 |
"return the eventMask bit-constant corresponding to an event symbol" |
|
3733 |
||
3734 |
%{ /* NOCONTEXT */ |
|
3735 |
||
3736 |
int m = 0; |
|
3737 |
||
3738 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
3739 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
3740 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
3741 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
3742 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
3743 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
3744 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
3745 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
3746 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
3747 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
3748 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
3749 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
3750 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
3751 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
3752 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
3753 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3754 |
RETURN (__MKSMALLINT(m)); |
295 | 3755 |
%} |
3756 |
! |
|
3757 |
||
12 | 3758 |
eventPending |
310 | 3759 |
"return true, if any event is pending. |
3760 |
This looks for both the internal queue and the display connection." |
|
12 | 3761 |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3762 |
ConservativeSyncing == true ifTrue:[self sync]. |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3763 |
|
12 | 3764 |
dispatchingExpose notNil ifTrue:[ |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3765 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
12 | 3766 |
]. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3767 |
^ self eventPendingWithSync:false |
0 | 3768 |
! |
3769 |
||
295 | 3770 |
eventPending:anEventSymbol for:aWindowIdOrNil |
3771 |
"return true, if a specific event is pending" |
|
3772 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3773 |
^ self eventsPending:(self eventMaskFor:anEventSymbol) for:aWindowIdOrNil withSync:false |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3774 |
! |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3775 |
|
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3776 |
eventPendingWithSync:doSync |
7 | 3777 |
"return true, if any event is pending. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3778 |
If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed) |
310 | 3779 |
before checking." |
0 | 3780 |
|
12 | 3781 |
%{ /* UNLIMITEDSTACK */ |
0 | 3782 |
|
3783 |
Display *dpy = myDpy; |
|
3784 |
||
150 | 3785 |
if (ISCONNECTED) { |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3786 |
if (doSync == true) { |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3787 |
XSync(dpy, 0); /* make certain everything is flushed */ |
150 | 3788 |
} |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3789 |
if (XPending(dpy)) { |
150 | 3790 |
RETURN (true); |
3791 |
} |
|
3792 |
} |
|
3793 |
RETURN ( false ); |
|
0 | 3794 |
%} |
3795 |
! |
|
3796 |
||
341 | 3797 |
eventQueued |
3798 |
"return true, if any event is queued" |
|
3799 |
||
3800 |
dispatchingExpose notNil ifTrue:[ |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3801 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
341 | 3802 |
]. |
3803 |
^ self eventQueuedAlready |
|
3804 |
||
3805 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
3806 |
! |
|
3807 |
||
3808 |
eventQueuedAlready |
|
3809 |
"return true, if any event is queued internally. |
|
3810 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
3811 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
3812 |
the display connection)." |
|
3813 |
||
3814 |
%{ /* UNLIMITEDSTACK */ |
|
3815 |
||
3816 |
if (ISCONNECTED) { |
|
3817 |
if (XEventsQueued(myDpy, QueuedAlready)) { |
|
3818 |
RETURN (true); |
|
3819 |
} |
|
3820 |
} |
|
3821 |
RETURN ( false ); |
|
3822 |
%} |
|
3823 |
! |
|
3824 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3825 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
295 | 3826 |
"return true, if any of the masked events is pending" |
3827 |
||
3828 |
%{ /* UNLIMITEDSTACK */ |
|
3829 |
||
3830 |
Display *dpy = myDpy; |
|
3831 |
XEvent ev; |
|
3832 |
Window win; |
|
3833 |
int thereIsOne; |
|
3834 |
||
3835 |
if (ISCONNECTED && __isSmallInteger(anEventMask)) { |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3836 |
if (doSync == true) { |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3837 |
XSync(dpy, 0); /* make certain everything is flushed */ |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3838 |
} |
295 | 3839 |
if (__isExternalAddress(aWindowIdOrNil)) { |
3840 |
win = _WindowVal(aWindowIdOrNil); |
|
555 | 3841 |
thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev); |
295 | 3842 |
} else { |
555 | 3843 |
thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev); |
295 | 3844 |
} |
3845 |
if (thereIsOne) { |
|
3846 |
XPutBackEvent(dpy, &ev); |
|
3847 |
RETURN ( true ); |
|
3848 |
} |
|
3849 |
} |
|
3850 |
RETURN ( false ); |
|
3851 |
%} |
|
3852 |
! |
|
3853 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3854 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
310 | 3855 |
"return true, if any expose event is pending for a specific view, |
3856 |
or any view (if the arg is nil). |
|
3857 |
This is an X specific, only required after a scroll operation." |
|
7 | 3858 |
|
12 | 3859 |
%{ /* UNLIMITEDSTACK */ |
7 | 3860 |
|
3861 |
Display *dpy = myDpy; |
|
3862 |
XEvent ev; |
|
3863 |
Window win; |
|
81 | 3864 |
int thereIsOne; |
3865 |
||
150 | 3866 |
if (ISCONNECTED) { |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3867 |
if (doSync == true) { |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3868 |
XSync(dpy, 0); /* make certain everything is flushed */ |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3869 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3870 |
if (__isExternalAddress(aWindowIdOrNil)) { |
150 | 3871 |
win = _WindowVal(aWindowIdOrNil); |
3872 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
3873 |
} else { |
|
3874 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
3875 |
} |
|
3876 |
if (thereIsOne) { |
|
3877 |
XPutBackEvent(dpy, &ev); |
|
3878 |
RETURN ( true ); |
|
3879 |
} |
|
81 | 3880 |
} |
3881 |
RETURN ( false ); |
|
3882 |
%} |
|
3883 |
! |
|
3884 |
||
295 | 3885 |
getEventFor:aViewIdOrNil withMask:eventMask |
3886 |
"read next event - put into local eventBuffer. |
|
3887 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
3888 |
otherwise only events for that specific view will be fetched. |
|
3889 |
Returns true, if there was an event, false otherwise. |
|
3890 |
This method may block - so you better check for pending events |
|
3891 |
before calling for it. |
|
3892 |
||
3893 |
Sorry I had to split dispatch into this fetch method and an extra |
|
3894 |
handle method to allow unlimitedstack here. |
|
3895 |
(some Xlibs do a big alloca there ...) which cannot be done in |
|
3896 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
3897 |
BUG: uses a static buffer - has to be rewritten, to support multiple |
|
3898 |
display connections. |
|
3899 |
" |
|
81 | 3900 |
|
3901 |
%{ /* UNLIMITEDSTACK */ |
|
3902 |
||
3903 |
Display *dpy = myDpy; |
|
295 | 3904 |
Window win, wWanted; |
3905 |
int evMask; |
|
3906 |
OBJ eB; |
|
3907 |
XEvent *ev; |
|
3908 |
||
3909 |
if (! ISCONNECTED) { |
|
3910 |
RETURN (false); |
|
3911 |
} |
|
3912 |
||
555 | 3913 |
eB = __INST(eventBuffer); |
295 | 3914 |
if (__isByteArray(eB)) { |
555 | 3915 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 3916 |
} else { |
3917 |
printf("DISPLAY: no eventBuffer\n"); |
|
3918 |
RETURN (false); |
|
3919 |
} |
|
3920 |
ev->type = 0; |
|
3921 |
||
3922 |
if (__isSmallInteger(eventMask)) { |
|
555 | 3923 |
evMask = __intVal(eventMask); |
295 | 3924 |
} else { |
3925 |
evMask = ~0; |
|
3926 |
} |
|
3927 |
||
3928 |
if (__isExternalAddress(aViewIdOrNil)) { |
|
3929 |
wWanted = _WindowVal(aViewIdOrNil); |
|
3930 |
if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) { |
|
70 | 3931 |
RETURN ( true ); |
3932 |
} |
|
295 | 3933 |
} else { |
3934 |
if (evMask == ~0) { |
|
3935 |
XNextEvent(dpy, ev); |
|
3936 |
RETURN (true); |
|
3937 |
} |
|
3938 |
if (XCheckMaskEvent(dpy, evMask, ev)) { |
|
3939 |
RETURN (true); |
|
3940 |
} |
|
3941 |
} |
|
3942 |
%}. |
|
3943 |
^ false |
|
3944 |
! |
|
3945 |
||
3946 |
handleAllEvents |
|
3947 |
"from now on, handle any kind of event" |
|
3948 |
||
3949 |
dispatchingExpose := nil |
|
3950 |
! |
|
3951 |
||
3952 |
handleExposeOnlyFor:aView |
|
3953 |
"from now on, handle expose events only" |
|
3954 |
||
3955 |
dispatchingExpose := aView id |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3956 |
! |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3957 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3958 |
mappingChanged:what event:eB |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3959 |
"One of Keyboard-, Modifier- or PointerMap has change, probably by xmodmap. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3960 |
Tell xlib about the fact." |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3961 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3962 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3963 |
self refreshKeyboardMapping:eB. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3964 |
"Maybe some of our modifiers have been changed" |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3965 |
self initializeModifierMappings. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3966 |
]. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3967 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3968 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
295 | 3969 |
! |
3970 |
||
3971 |
setEventMask:aMask in:aWindowId |
|
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
3972 |
"tell X that we are only interested in events from aMask, which |
295 | 3973 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
3974 |
||
3975 |
%{ /* NOCONTEXT */ |
|
3976 |
||
3977 |
int mask; |
|
3978 |
||
3979 |
if (__isExternalAddress(aWindowId) |
|
3980 |
&& __isSmallInteger(aMask)) { |
|
555 | 3981 |
mask = __intVal(aMask); |
295 | 3982 |
|
3983 |
#ifdef OLD |
|
3984 |
/* these may not be disabled */ |
|
3985 |
mask |= ExposureMask | StructureNotifyMask | |
|
3986 |
KeyPressMask | KeyReleaseMask | |
|
3987 |
EnterWindowMask | LeaveWindowMask | |
|
3988 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
|
3989 |
#endif |
|
3990 |
||
3991 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
|
3992 |
RETURN ( self ); |
|
3993 |
} |
|
3994 |
%} |
|
3995 |
. |
|
3996 |
self primitiveFailed |
|
3997 |
! |
|
3998 |
||
3999 |
startDispatch |
|
4000 |
"redefined to clear dispatchingExpose, which is a special X feature" |
|
4001 |
||
4002 |
dispatching ifTrue:[^ self]. |
|
4003 |
dispatchingExpose := nil. |
|
4004 |
super startDispatch |
|
0 | 4005 |
! ! |
295 | 4006 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4007 |
!XWorkstation methodsFor:'event sending'! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4008 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4009 |
sendKeyOrButtonEvent:typeSymbol x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask toViewId:targetId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4010 |
"send a keyPress/Release or buttonPress/Release event to some (possibly alien) view. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4011 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4012 |
For buttonEvents, the keySymCodeOrButtonNr must be the buttons number (1, 2 ...); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4013 |
for key events, it can be either a symbol (as listen in X's keySyms) |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4014 |
or a numeric keysym code. If state is nil, the modifier bits (shift & control) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4015 |
are computed from the keyboardMap - if non-nil, these are passed as modifierbits. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4016 |
The non-nil case is the lowlevel entry, where state must include any shift/ctrl information |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4017 |
(not very user friendly)" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4018 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4019 |
%{ /* NOCONTEXT */ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4020 |
Display *dpy = myDpy; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4021 |
int type; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4022 |
int state; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4023 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4024 |
if (__isSmallInteger(stateMask)) { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4025 |
state = __intVal(stateMask); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4026 |
} else { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4027 |
state = 0; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4028 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4029 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4030 |
if (ISCONNECTED |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4031 |
&& __isSmallInteger(xPos) && __isSmallInteger(yPos) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4032 |
&& (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4033 |
&& (__isExternalAddress(targetId) || __isInteger(targetId))) { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4034 |
XEvent ev; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4035 |
Window target; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4036 |
Status result; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4037 |
KeySym keySym, *syms; |
555 | 4038 |
int screen = __intVal(__INST(screen)); |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4039 |
char s[2]; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4040 |
int nSyms; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4041 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4042 |
if ((typeSymbol == @symbol(keyPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4043 |
|| (typeSymbol == @symbol(keyRelease))) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4044 |
if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4045 |
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4046 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4047 |
if (__isCharacter(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4048 |
s[0] = __intVal(__characterVal(keySymCodeOrButtonNr)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4049 |
s[1] = '\0'; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4050 |
keySym = XStringToKeysym(s); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4051 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4052 |
keySym = (KeySym) __intVal(keySymCodeOrButtonNr); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4053 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4054 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4055 |
ev.xkey.keycode = XKeysymToKeycode(dpy, keySym); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4056 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4057 |
if (stateMask == nil) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4058 |
/* |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4059 |
* get the modifier from the keySym |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4060 |
*/ |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4061 |
nSyms = 0; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4062 |
syms = XGetKeyboardMapping(dpy, ev.xkey.keycode, 1, &nSyms); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4063 |
if (syms) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4064 |
int i; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4065 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4066 |
for (i=0; i<nSyms; i++) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4067 |
if (syms[i] == keySym) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4068 |
#ifdef MODIFIERDEBUG |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4069 |
printf("modifier-index is %d\n", i); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4070 |
#endif |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4071 |
if (i) state = (1 << (i-1)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4072 |
break; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4073 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4074 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4075 |
XFree(syms); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4076 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4077 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4078 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4079 |
if ((typeSymbol == @symbol(buttonPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4080 |
|| (typeSymbol == @symbol(buttonRelease))) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4081 |
if (__isSmallInteger(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4082 |
ev.xbutton.button = __intVal(keySymCodeOrButtonNr); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4083 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4084 |
ev.xbutton.button = 1; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4085 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4086 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4087 |
DPRINTF(("invalid sendEvent typeSymbol\n")); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4088 |
RETURN (false); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4089 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4090 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4091 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4092 |
if (typeSymbol == @symbol(keyPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4093 |
ev.xany.type = KeyPress; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4094 |
else if (typeSymbol == @symbol(keyRelease)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4095 |
ev.xany.type = KeyRelease; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4096 |
else if (typeSymbol == @symbol(buttonPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4097 |
ev.xany.type = ButtonPress; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4098 |
else if (typeSymbol == @symbol(buttonRelease)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4099 |
ev.xany.type = ButtonRelease; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4100 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4101 |
if (__isExternalAddress(targetId)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4102 |
target = _WindowVal(targetId); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4103 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4104 |
target = (Window) __longIntVal(targetId); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4105 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4106 |
ev.xkey.window = target; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4107 |
ev.xkey.same_screen = 1; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4108 |
ev.xkey.subwindow = 0; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4109 |
ev.xkey.root = RootWindow(myDpy, screen); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4110 |
ev.xkey.x = __intVal(xPos); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4111 |
ev.xkey.y = __intVal(yPos); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4112 |
ev.xkey.state = state; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4113 |
ev.xkey.time = CurrentTime; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4114 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4115 |
result = XSendEvent(dpy, target, False, 0 , &ev); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4116 |
if ((result == BadValue) || (result == BadWindow)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4117 |
DPRINTF(("bad status\n")); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4118 |
RETURN ( false ) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4119 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4120 |
RETURN (true) |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4121 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4122 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4123 |
self primitiveFailed. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4124 |
^ false |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4125 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4126 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4127 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4128 |
"send input to some other view, by simulating keyPress/keyRelease |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4129 |
events. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4130 |
Only a few control characters are supported. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4131 |
Notice: not all alien views allow this kind of synthetic input; |
850 | 4132 |
some simply ignore it." |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4133 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4134 |
|control code state| |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4135 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4136 |
aCharacterOrString isString ifTrue:[ |
850 | 4137 |
aCharacterOrString do:[:char | |
4138 |
self simulateKeyboardInput:char inViewId:viewId |
|
4139 |
]. |
|
4140 |
^ self |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4141 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4142 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4143 |
control := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4144 |
code := aCharacterOrString asciiValue. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4145 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4146 |
(aCharacterOrString == Character cr) ifTrue:[ |
850 | 4147 |
code := #Return |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4148 |
] ifFalse:[ |
850 | 4149 |
(aCharacterOrString == Character tab) ifTrue:[ |
4150 |
code := #Tab |
|
4151 |
] ifFalse:[ |
|
4152 |
(aCharacterOrString == Character esc) ifTrue:[ |
|
4153 |
code := #Escape |
|
4154 |
] |
|
4155 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4156 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4157 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4158 |
control ifTrue:[ |
850 | 4159 |
state := self controlMask |
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4160 |
]. |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4161 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4162 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4163 |
"/ the stuff below should not be needed |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4164 |
"/ (sendKeyOrButtonevent should be able to figure out things itself) |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4165 |
"/ however, on some linux systems it seems to not work correctly. |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4166 |
"/ Hopefully, this is correct ... |
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4167 |
|
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4168 |
code isNumber ifTrue:[ |
850 | 4169 |
code >= $A asciiValue ifTrue:[ |
4170 |
code <= $Z asciiValue ifTrue:[ |
|
4171 |
state := self shiftMask |
|
4172 |
] |
|
4173 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4174 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4175 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4176 |
self sendKeyOrButtonEvent:#keyPress x:0 y:0 keyOrButton:code state:state toViewId:viewId. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4177 |
self sendKeyOrButtonEvent:#keyRelease x:0 y:0 keyOrButton:code state:state toViewId:viewId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4178 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4179 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4180 |
sending input to some (possibly alien) view: |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4181 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4182 |
|point id| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4183 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4184 |
point := Display pointFromUser. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4185 |
id := Display viewIdFromPoint:point. |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4186 |
Display simulateKeyboardInput:'Hello_world' inViewId:id |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4187 |
" |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4188 |
|
830
76fd3d86dd15
fix for stupid linux keyboardMapping bug (?)
Claus Gittinger <cg@exept.de>
parents:
823
diff
changeset
|
4189 |
"Modified: 11.6.1996 / 10:59:42 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4190 |
! ! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4191 |
|
295 | 4192 |
!XWorkstation methodsFor:'font stuff'! |
4193 |
||
4194 |
ascentOf:aFontId |
|
4195 |
"the normal ascent" |
|
4196 |
||
4197 |
%{ /* NOCONTEXT */ |
|
4198 |
||
4199 |
XFontStruct *f; |
|
4200 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4201 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4202 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4203 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4204 |
RETURN ( __MKSMALLINT(f->ascent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4205 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4206 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4207 |
%}. |
295 | 4208 |
self primitiveFailed. |
4209 |
^ nil |
|
4210 |
! |
|
4211 |
||
4212 |
createFontFor:aFontName |
|
4213 |
"a basic method for X-font allocation; this method allows |
|
4214 |
any font to be aquired (even those not conforming to |
|
4215 |
standard naming conventions, such as cursor, fixed or k14)" |
|
4216 |
||
4217 |
%{ /* UNLIMITEDSTACK */ |
|
4218 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
4219 |
||
4220 |
XFontStruct *newFont; |
|
4221 |
||
4222 |
if (ISCONNECTED) { |
|
4223 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
|
4224 |
BEGIN_INTERRUPTSBLOCKED |
|
4225 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
|
4226 |
END_INTERRUPTSBLOCKED |
|
4227 |
RETURN ( newFont ? __MKOBJ(newFont) : nil ); |
|
4228 |
} |
|
4229 |
} |
|
4230 |
%}. |
|
4231 |
^ nil |
|
4232 |
! |
|
4233 |
||
4234 |
decomposeXFontName:aString into:aBlock |
|
4235 |
"extract family, face, style and size from an |
|
4236 |
X-font name |
|
4237 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
|
4238 |
evaluate aBlock with these" |
|
4239 |
||
4240 |
|origin family face style moreStyle skip fheight size |
|
4241 |
resX resY x1 x2 coding start end | |
|
4242 |
||
4243 |
aString isNil ifTrue:[^ false]. |
|
4244 |
(aString startsWith:'-') ifFalse:[ |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4245 |
" |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4246 |
take care for ill-named fonts (i.e. pre Rel4 fonts) |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4247 |
" |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4248 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4249 |
end := aString indexOf:$- startingAt:1. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4250 |
family := aString copyFrom:1 to:(end - 1). |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4251 |
start := end + 1. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4252 |
end := aString indexOf:$- startingAt:start. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4253 |
style := aString copyFrom:start to:(end - 1). |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4254 |
start := end + 1. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4255 |
size := aString copyFrom:start. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4256 |
size := (Number readFromString:size onError:[^false]). |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4257 |
aBlock value:family value:nil value:style value:size value:nil. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4258 |
^ true. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4259 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4260 |
('*-[0-9]*' match:aString) ifTrue:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4261 |
" |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4262 |
something like lucidasans-24 |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4263 |
" |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4264 |
end := aString indexOf:$- startingAt:1. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4265 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4266 |
family := aString copyFrom:1 to:(end - 1). |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4267 |
start := end + 1. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4268 |
size := aString copyFrom:start. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4269 |
size := (Number readFromString:size onError:[^false]). |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4270 |
aBlock value:family value:nil value:nil value:size value:nil. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4271 |
^ true. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4272 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4273 |
aBlock value:aString value:nil value:nil value:nil value:nil. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4274 |
^ true. |
295 | 4275 |
]. |
4276 |
||
4277 |
end := aString indexOf:$- startingAt:2. |
|
4278 |
(end == 0) ifTrue:[^ false]. |
|
4279 |
origin := aString copyFrom:2 to:(end - 1). |
|
4280 |
||
4281 |
start := end + 1. |
|
4282 |
end := aString indexOf:$- startingAt:start. |
|
4283 |
(end == 0) ifTrue:[^ false]. |
|
4284 |
family := aString copyFrom:start to:(end - 1). |
|
4285 |
||
4286 |
start := end + 1. |
|
4287 |
end := aString indexOf:$- startingAt:start. |
|
4288 |
(end == 0) ifTrue:[^ false]. |
|
4289 |
face := aString copyFrom:start to:(end - 1). |
|
4290 |
||
4291 |
start := end + 1. |
|
4292 |
end := aString indexOf:$- startingAt:start. |
|
4293 |
(end == 0) ifTrue:[^ false]. |
|
4294 |
style := aString copyFrom:start to:(end - 1). |
|
4295 |
(style = 'o') ifTrue:[ |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4296 |
style := 'oblique' |
295 | 4297 |
] ifFalse:[ |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4298 |
(style = 'i') ifTrue:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4299 |
style := 'italic' |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4300 |
] ifFalse:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4301 |
(style = 'r') ifTrue:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4302 |
style := 'roman' |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4303 |
] |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4304 |
] |
295 | 4305 |
]. |
4306 |
||
4307 |
start := end + 1. |
|
4308 |
end := aString indexOf:$- startingAt:start. |
|
4309 |
(end == 0) ifTrue:[^ false]. |
|
4310 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
4311 |
||
4312 |
start := end + 1. |
|
4313 |
end := aString indexOf:$- startingAt:start. |
|
4314 |
(end == 0) ifTrue:[^ false]. |
|
4315 |
skip := aString copyFrom:start to:(end - 1). |
|
4316 |
||
4317 |
start := end + 1. |
|
4318 |
end := aString indexOf:$- startingAt:start. |
|
4319 |
(end == 0) ifTrue:[^ false]. |
|
4320 |
fheight := aString copyFrom:start to:(end - 1). |
|
4321 |
||
4322 |
start := end + 1. |
|
4323 |
end := aString indexOf:$- startingAt:start. |
|
4324 |
(end == 0) ifTrue:[^ false]. |
|
4325 |
size := aString copyFrom:start to:(end - 1). |
|
4326 |
size := (Number readFromString:size) / 10. |
|
4327 |
||
4328 |
start := end + 1. |
|
4329 |
end := aString indexOf:$- startingAt:start. |
|
4330 |
(end == 0) ifTrue:[^ false]. |
|
4331 |
resX := aString copyFrom:start to:(end - 1). |
|
4332 |
||
4333 |
start := end + 1. |
|
4334 |
end := aString indexOf:$- startingAt:start. |
|
4335 |
(end == 0) ifTrue:[^ false]. |
|
4336 |
resY := aString copyFrom:start to:(end - 1). |
|
4337 |
||
4338 |
start := end + 1. |
|
4339 |
end := aString indexOf:$- startingAt:start. |
|
4340 |
(end == 0) ifTrue:[^ false]. |
|
4341 |
x1 := aString copyFrom:start to:(end - 1). |
|
4342 |
||
4343 |
start := end + 1. |
|
4344 |
end := aString indexOf:$- startingAt:start. |
|
4345 |
(end == 0) ifTrue:[^ false]. |
|
4346 |
x2 := aString copyFrom:start to:(end - 1). |
|
4347 |
||
4348 |
start := end + 1. |
|
4349 |
end := aString indexOf:$- startingAt:start. |
|
4350 |
(end == 0) ifTrue:[^ false]. |
|
4351 |
coding := aString copyFrom:start to:(end - 1). |
|
4352 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4353 |
(moreStyle ~= 'normal' and:[moreStyle ~= '']) ifTrue:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4354 |
style := style, '-', moreStyle. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4355 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4356 |
|
295 | 4357 |
aBlock value:family value:face value:style value:size value:coding. |
4358 |
^ true |
|
4359 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4360 |
"Modified: 4.7.1996 / 11:12:25 / stefan" |
295 | 4361 |
! |
4362 |
||
4363 |
descentOf:aFontId |
|
4364 |
"the normal descent" |
|
4365 |
||
4366 |
%{ /* NOCONTEXT */ |
|
4367 |
||
4368 |
XFontStruct *f; |
|
4369 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4370 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4371 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4372 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4373 |
RETURN ( __MKSMALLINT(f->descent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4374 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4375 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4376 |
%}. |
295 | 4377 |
self primitiveFailed. |
4378 |
^ nil |
|
4379 |
! |
|
4380 |
||
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4381 |
encodingOf:aFontId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4382 |
"the fonts encoding - if the font does not provide that info, |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4383 |
return nil (and assume #ascii, which is a subset of #iso8859)." |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4384 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4385 |
|enc fullName fontName registry encoding charSetCollections| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4386 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4387 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4388 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4389 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4390 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4391 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4392 |
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4393 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4394 |
registryAtom = XInternAtom(myDpy, "CHARSET_REGISTRY", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4395 |
encodingAtom = XInternAtom(myDpy, "CHARSET_ENCODING", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4396 |
charSetCollAtom = XInternAtom(myDpy, "CHARSET_COLLECTIONS", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4397 |
fontAtom = XInternAtom(myDpy, "FONT", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4398 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4399 |
if (ISCONNECTED) { |
850 | 4400 |
if (__isExternalAddress(aFontId)) { |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4401 |
|
850 | 4402 |
f = _FontVal(aFontId); |
4403 |
if (f) { |
|
4404 |
n = f->n_properties; |
|
4405 |
prop = f->properties; |
|
4406 |
if (prop) { |
|
4407 |
while (n--) { |
|
4408 |
cp = XGetAtomName(myDpy, prop->name); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4409 |
#ifdef SUPERDEBUG |
850 | 4410 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4411 |
#endif |
850 | 4412 |
if (prop->name == XA_FULL_NAME) { |
4413 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4414 |
if (cp) { |
|
4415 |
fullName = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4416 |
#ifdef SUPERDEBUG |
850 | 4417 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4418 |
#endif |
850 | 4419 |
} |
4420 |
} |
|
4421 |
if (prop->name == fontAtom) { |
|
4422 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4423 |
if (cp) { |
|
4424 |
fontName = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4425 |
#ifdef SUPERDEBUG |
850 | 4426 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4427 |
#endif |
850 | 4428 |
} |
4429 |
} |
|
4430 |
if (prop->name == encodingAtom) { |
|
4431 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4432 |
if (cp) { |
|
4433 |
encoding = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4434 |
#ifdef SUPERDEBUG |
850 | 4435 |
printf(" ENCODING -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4436 |
#endif |
850 | 4437 |
} |
4438 |
} |
|
4439 |
if (prop->name == registryAtom) { |
|
4440 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4441 |
if (cp) { |
|
4442 |
registry = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4443 |
#ifdef SUPERDEBUG |
850 | 4444 |
printf(" REGISTRY -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4445 |
#endif |
850 | 4446 |
} |
4447 |
} |
|
4448 |
if (prop->name == charSetCollAtom) { |
|
4449 |
cp = XGetAtomName(myDpy, prop->card32); |
|
4450 |
if (cp) { |
|
4451 |
charSetCollections = __MKSTRING(cp COMMA_CON); |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4452 |
#ifdef SUPERDEBUG |
850 | 4453 |
printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4454 |
#endif |
850 | 4455 |
} |
4456 |
} |
|
4457 |
prop++; |
|
4458 |
} |
|
4459 |
} |
|
4460 |
} |
|
4461 |
} |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4462 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4463 |
%}. |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4464 |
^ self |
850 | 4465 |
extractEncodingFromRegistry:registry |
4466 |
encoding:encoding |
|
4467 |
charSetCollections:charSetCollections |
|
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4468 |
! |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4469 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4470 |
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4471 |
"this is pure magic ..." |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4472 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4473 |
|enc charSets| |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4474 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4475 |
(registry notNil and:[registry notEmpty]) ifTrue:[ |
850 | 4476 |
enc := registry asLowercase asSymbol. |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4477 |
] ifFalse:[ |
850 | 4478 |
(encoding notNil and:[encoding notEmpty]) ifTrue:[ |
4479 |
enc := encoding asLowercase asSymbol |
|
4480 |
] ifFalse:[ |
|
4481 |
charSets := charSetCollections. |
|
4482 |
(charSets notNil and:[charSets notEmpty]) ifTrue:[ |
|
4483 |
charSets := charSets asUppercase asCollectionOfWords. |
|
4484 |
(charSets includes:'ISO8859-1') ifTrue:[ |
|
4485 |
enc := #iso8859 |
|
4486 |
] ifFalse:[ |
|
4487 |
(charSets includes:'ISO8859') ifTrue:[ |
|
4488 |
enc := #iso8859 |
|
4489 |
] ifFalse:[ |
|
4490 |
(charSets includes:'ASCII') ifTrue:[ |
|
4491 |
enc := #ascii |
|
4492 |
] ifFalse:[ |
|
4493 |
(charSets includes:'ADOBE-STANDARD') ifTrue:[ |
|
4494 |
enc := #iso8859 |
|
4495 |
] |
|
4496 |
] |
|
4497 |
] |
|
4498 |
] |
|
4499 |
] |
|
4500 |
] |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4501 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4502 |
^ enc |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4503 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4504 |
"Created: 17.4.1996 / 14:57:06 / cg" |
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4505 |
"Modified: 17.4.1996 / 17:22:35 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4506 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4507 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4508 |
flushListOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4509 |
"flush the cached list of all available fonts on this display. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4510 |
Required if new fonts have been added on the display server." |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4511 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4512 |
listOfXFonts := nil |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4513 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4514 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4515 |
Display flushListOfAvailableFonts. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4516 |
Display listOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4517 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4518 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4519 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4520 |
"Created: 20.2.1996 / 22:55:52 / cg" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4521 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4522 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4523 |
fullNameOf:aFontId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4524 |
"the fonts fullName - this is very device specific and should only be |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4525 |
used for user feed-back (for example: in the fontPanel). |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4526 |
If the display/font do not provide that info, return nil." |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4527 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4528 |
|fullName fontName| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4529 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4530 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4531 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4532 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4533 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4534 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4535 |
Atom fontAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4536 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4537 |
fontAtom = XInternAtom(myDpy, "FONT", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4538 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4539 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4540 |
if (__isExternalAddress(aFontId)) { |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4541 |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4542 |
f = _FontVal(aFontId); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4543 |
if (f) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4544 |
n = f->n_properties; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4545 |
prop = f->properties; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4546 |
if (prop) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4547 |
while (n--) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4548 |
cp = XGetAtomName(myDpy, prop->name); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4549 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4550 |
printf("%s (%d) -> %d\n", cp, prop->name, prop->card32); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4551 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4552 |
if (prop->name == XA_FULL_NAME) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4553 |
cp = XGetAtomName(myDpy, prop->card32); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4554 |
if (cp) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4555 |
fullName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4556 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4557 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4558 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4559 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4560 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4561 |
if (prop->name == fontAtom) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4562 |
cp = XGetAtomName(myDpy, prop->card32); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4563 |
if (cp) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4564 |
fontName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4565 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4566 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4567 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4568 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4569 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4570 |
prop++; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4571 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4572 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4573 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4574 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4575 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4576 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4577 |
(fullName notNil and:[fullName notEmpty]) ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4578 |
^ fullName |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4579 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4580 |
^ fontName |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4581 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4582 |
|
295 | 4583 |
getAvailableFontsMatching:pattern |
4584 |
"return an Array filled with font names matching aPattern" |
|
4585 |
||
4586 |
%{ /* UNLIMITEDSTACK */ |
|
4587 |
||
4588 |
int nnames = 1500; |
|
4589 |
int available = nnames + 1; |
|
4590 |
char **fonts; |
|
4591 |
OBJ arr, str; |
|
4592 |
int i; |
|
4593 |
||
4594 |
if (ISCONNECTED) { |
|
4595 |
if (__isString(pattern)) { |
|
4596 |
for (;;) { |
|
4597 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
4598 |
if ((fonts == NULL) || (available < nnames)) break; |
|
4599 |
XFreeFontNames(fonts); |
|
4600 |
nnames = available * 2; |
|
4601 |
} |
|
4602 |
if (fonts == NULL) { |
|
4603 |
RETURN ( nil ); |
|
4604 |
} |
|
4605 |
/* |
|
4606 |
* now, that we know the number of font names, |
|
4607 |
* create the array ... |
|
4608 |
*/ |
|
4609 |
arr = __ARRAY_NEW_INT(available); |
|
4610 |
if (! arr) { |
|
4611 |
RETURN (nil); |
|
4612 |
} |
|
4613 |
/* |
|
4614 |
* ... and fill it |
|
4615 |
*/ |
|
4616 |
for (i=0; i<available; i++) { |
|
350 | 4617 |
__PROTECT__(arr); |
295 | 4618 |
str = __MKSTRING(fonts[i] COMMA_CON); |
350 | 4619 |
__UNPROTECT__(arr); |
295 | 4620 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
4621 |
} |
|
4622 |
RETURN (arr); |
|
4623 |
} |
|
4624 |
} |
|
4625 |
%}. |
|
4626 |
^ nil |
|
4627 |
! |
|
4628 |
||
4629 |
getDefaultFont |
|
4630 |
"return a default font id - used when class Font cannot |
|
4631 |
find anything usable" |
|
4632 |
||
4633 |
^ self createFontFor:'fixed' |
|
4634 |
! |
|
4635 |
||
4636 |
getFontWithFamily:familyString face:faceString |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4637 |
style:styleArgString size:sizeArg encoding:encodingSym |
295 | 4638 |
|
4639 |
"try to get the specified font, if not available, try next smaller |
|
4640 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
4641 |
as family and the other parameters as nil. For example, the cursor font |
|
4642 |
can be aquired that way." |
|
4643 |
||
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4644 |
|styleString theName theId xlatedStyle id spacing| |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4645 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4646 |
styleString := styleArgString. |
295 | 4647 |
|
4648 |
"special: if face is nil, allow access to X-fonts" |
|
4649 |
faceString isNil ifTrue:[ |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4650 |
sizeArg notNil ifTrue:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4651 |
theName := familyString , '-' , sizeArg printString |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4652 |
] ifFalse:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4653 |
theName := familyString |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4654 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4655 |
theName isNil ifTrue:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4656 |
" |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4657 |
mhmh - fall back to the default font |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4658 |
" |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4659 |
theName := 'fixed' |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4660 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4661 |
theId := self createFontFor:theName. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4662 |
theId isNil ifTrue:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4663 |
theId := self getDefaultFont |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4664 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4665 |
^ theId |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4666 |
]. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4667 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4668 |
"/ spacing other than 'normal' is contained as last component |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4669 |
"/ in style |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4670 |
|
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4671 |
((styleString endsWith:'-narrow') |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4672 |
or:[styleString endsWith:'-semicondensed']) ifTrue:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4673 |
|i| |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4674 |
i := styleString lastIndexOf:$-. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4675 |
spacing := styleString copyFrom:(i+1). |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4676 |
styleString := styleString copyTo:(i-1). |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4677 |
] ifFalse:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4678 |
spacing := 'normal'. |
295 | 4679 |
]. |
4680 |
||
4681 |
xlatedStyle := styleString. |
|
4682 |
xlatedStyle notNil ifTrue:[ |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4683 |
xlatedStyle := xlatedStyle first asString |
295 | 4684 |
]. |
4685 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4686 |
id := self |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4687 |
getFontWithFoundry:'*' |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4688 |
family:familyString asLowercase |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4689 |
weight:faceString |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4690 |
slant:xlatedStyle |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4691 |
spacing:spacing |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4692 |
pixelSize:nil |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4693 |
size:sizeArg |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4694 |
registry:encodingSym |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4695 |
encoding:'*'. |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4696 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4697 |
id isNil ifTrue:[ |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4698 |
(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4699 |
"/ too stupid: encodings come in both cases |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4700 |
"/ and X does not ignore case |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4701 |
"/ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4702 |
id := self |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4703 |
getFontWithFoundry:'*' |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4704 |
family:familyString asLowercase |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4705 |
weight:faceString |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4706 |
slant:xlatedStyle |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4707 |
spacing:spacing |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4708 |
pixelSize:nil |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4709 |
size:sizeArg |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4710 |
registry:encodingSym asUppercase |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4711 |
encoding:'*'. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4712 |
id isNil ifTrue:[ |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4713 |
id := self |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4714 |
getFontWithFoundry:'*' |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4715 |
family:familyString asLowercase |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4716 |
weight:faceString |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4717 |
slant:xlatedStyle |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4718 |
spacing:spacing |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4719 |
pixelSize:nil |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4720 |
size:sizeArg |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4721 |
registry:encodingSym asLowercase |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4722 |
encoding:'*'. |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4723 |
] |
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4724 |
] |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4725 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4726 |
^ id |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4727 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4728 |
"Modified: 24.2.1996 / 22:37:24 / cg" |
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
4729 |
"Modified: 4.7.1996 / 11:38:47 / stefan" |
295 | 4730 |
! |
4731 |
||
4732 |
getFontWithFoundry:foundry family:family weight:weight |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4733 |
slant:slant spacing:spc pixelSize:pSize size:size |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4734 |
registry:registry encoding:encoding |
295 | 4735 |
|
4736 |
"get the specified font, if not available, return nil. |
|
4737 |
This is the new font creation method - all others will be changed to |
|
4738 |
use this entry. |
|
4739 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
4740 |
||
4741 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
4742 |
family: 'helvetica' 'courier' 'times' ... |
|
4743 |
weight: 'bold' 'medium' 'demi' ... |
|
4744 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
4745 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
4746 |
pixelSize: 16,18 ... usually left empty |
|
4747 |
size: size in point (1/72th of an inch) |
|
4748 |
registry: iso8859, sgi ... '*' |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4749 |
encoding: vendor specific encoding (usually '*') |
295 | 4750 |
" |
4751 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4752 |
|theName sizeMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4753 |
foundryMatch familyMatch weightMatch slantMatch spcMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4754 |
pSizeMatch registryMatch encodingMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4755 |
id| |
295 | 4756 |
|
4757 |
"this works only on 'Release >= 3' - X-servers" |
|
4758 |
"name is: |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4759 |
-foundry-family -weight -slant- |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4760 |
sony helvetica bold r |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4761 |
adobe courier medium i |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4762 |
msic fixed o |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4763 |
... ... |
295 | 4764 |
" |
4765 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4766 |
size isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4767 |
sizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4768 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4769 |
sizeMatch := size printString , '0' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4770 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4771 |
foundry isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4772 |
foundryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4773 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4774 |
foundryMatch := foundry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4775 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4776 |
family isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4777 |
familyMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4778 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4779 |
familyMatch := family |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4780 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4781 |
weight isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4782 |
weightMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4783 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4784 |
weightMatch := weight |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4785 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4786 |
slant isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4787 |
slantMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4788 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4789 |
slantMatch := slant |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4790 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4791 |
spc isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4792 |
spcMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4793 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4794 |
spcMatch := spc |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4795 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4796 |
pSize isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4797 |
pSizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4798 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4799 |
pSizeMatch := pSize printString |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4800 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4801 |
registry isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4802 |
registryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4803 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4804 |
registryMatch := registry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4805 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4806 |
encoding isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4807 |
encodingMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4808 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4809 |
encodingMatch := encoding |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4810 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4811 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4812 |
theName := ('-' , foundryMatch, |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4813 |
'-' , familyMatch, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4814 |
'-' , weightMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4815 |
'-' , slantMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4816 |
'-' , spcMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4817 |
'-*' , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4818 |
'-' , pSizeMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4819 |
'-' , sizeMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4820 |
'-*-*-*-*' , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4821 |
'-' , registryMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4822 |
'-' , encodingMatch). |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4823 |
|
697 | 4824 |
"/ Transcript showCR:theName; endEntry. |
295 | 4825 |
|
4826 |
^ self createFontFor:theName. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4827 |
|
295 | 4828 |
|
4829 |
" |
|
4830 |
Display getFontWithFoundry:'*' |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4831 |
family:'courier' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4832 |
weight:'medium' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4833 |
slant:'r' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4834 |
spacing:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4835 |
pixelSize:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4836 |
size:13 |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4837 |
registry:'iso8859' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4838 |
encoding:'*' |
295 | 4839 |
" |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4840 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4841 |
"Modified: 24.2.1996 / 22:33:29 / cg" |
295 | 4842 |
! |
4843 |
||
4844 |
listOfAvailableFonts |
|
4845 |
"return a list with all available fonts on this display. |
|
4846 |
Since this takes a long time, keep the result of the query for the |
|
4847 |
next time. The elements of the returned collection are instances of |
|
4848 |
FontDescription." |
|
4849 |
||
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
4850 |
|"stream aName fntDescr" names| |
295 | 4851 |
|
4852 |
listOfXFonts isNil ifTrue:[ |
|
4853 |
"/ |
|
4854 |
"/ old code; using a pipe to xlsfonts |
|
4855 |
"/ |
|
4856 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
4857 |
"/ stream isNil ifTrue:[^ nil]. |
|
4858 |
"/ listOfXFonts := OrderedCollection new. |
|
4859 |
"/ [stream atEnd] whileFalse:[ |
|
4860 |
"/ aName := stream nextLine. |
|
4861 |
"/ aName notNil ifTrue:[ |
|
4862 |
"/ self decomposeXFontName:aName into: |
|
4863 |
"/ [:family :face :style :size :coding | |
|
4864 |
"/ family notNil ifTrue:[ |
|
4865 |
"/ fntDescr := FontDescription |
|
4866 |
"/ family:family |
|
4867 |
"/ face:face |
|
4868 |
"/ style:style |
|
4869 |
"/ size:size |
|
4870 |
"/ encoding:coding. |
|
4871 |
"/ listOfXFonts add:fntDescr |
|
4872 |
"/ ] |
|
4873 |
"/ ] |
|
4874 |
"/ ] |
|
4875 |
"/ ]. |
|
4876 |
"/ stream close. |
|
4877 |
"/ "if xlsfont is broken ... (hey sco)" |
|
4878 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
4879 |
"/ listOfXFonts := nil |
|
4880 |
"/ ] ifFalse:[ |
|
4881 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
4882 |
"/ ]. |
|
4883 |
||
850 | 4884 |
"/ |
4885 |
"/ new code: |
|
4886 |
"/ use new primitive to get font names; |
|
4887 |
"/ this is much faster, and also works on systems where |
|
4888 |
"/ a) xlsfonts is broken (sco) |
|
4889 |
"/ b) xlsfonts is not available (aix) |
|
4890 |
"/ |
|
4891 |
names := self getAvailableFontsMatching:'*'. |
|
4892 |
names isNil ifTrue:[ |
|
4893 |
"no names returned ..." |
|
4894 |
^ nil |
|
4895 |
]. |
|
4896 |
listOfXFonts := names collect:[:aName | |
|
4897 |
|fntDescr| |
|
4898 |
||
4899 |
(self decomposeXFontName:aName into: |
|
4900 |
[:family :face :style :size :coding | |
|
4901 |
family notNil ifTrue:[ |
|
4902 |
fntDescr := FontDescription |
|
4903 |
family:family |
|
4904 |
face:face |
|
4905 |
style:style |
|
4906 |
size:size |
|
4907 |
encoding:coding. |
|
4908 |
] ifFalse:[ |
|
4909 |
fntDescr := FontDescription |
|
4910 |
name:aName |
|
4911 |
] |
|
4912 |
] |
|
4913 |
) ifFalse:[ |
|
4914 |
fntDescr := FontDescription name:aName. |
|
4915 |
]. |
|
4916 |
fntDescr |
|
4917 |
]. |
|
295 | 4918 |
|
4919 |
]. |
|
4920 |
^ listOfXFonts |
|
4921 |
||
4922 |
" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4923 |
Display listOfAvailableFonts. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4924 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4925 |
Display getAvailableFontsMatching:'*'. |
295 | 4926 |
" |
4927 |
||
4928 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4929 |
"Modified: 17.4.1996 / 15:27:57 / cg" |
295 | 4930 |
! |
4931 |
||
4932 |
maxAscentOf:aFontId |
|
4933 |
"the max ascent" |
|
4934 |
||
4935 |
%{ /* NOCONTEXT */ |
|
4936 |
||
4937 |
XFontStruct *f; |
|
4938 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4939 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4940 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4941 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4942 |
RETURN ( __MKSMALLINT(f->max_bounds.ascent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4943 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4944 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4945 |
%}. |
295 | 4946 |
self primitiveFailed. |
4947 |
^ nil |
|
4948 |
! |
|
4949 |
||
4950 |
maxDescentOf:aFontId |
|
4951 |
"the max descent" |
|
4952 |
||
4953 |
%{ /* NOCONTEXT */ |
|
4954 |
||
4955 |
XFontStruct *f; |
|
4956 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4957 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4958 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4959 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4960 |
RETURN ( __MKSMALLINT(f->max_bounds.descent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4961 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4962 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4963 |
%}. |
295 | 4964 |
self primitiveFailed. |
4965 |
^ nil |
|
4966 |
! |
|
4967 |
||
4968 |
maxWidthOfFont:aFontId |
|
4969 |
"the width of the widest character" |
|
4970 |
||
4971 |
%{ /* NOCONTEXT */ |
|
4972 |
||
4973 |
XFontStruct *f; |
|
4974 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4975 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4976 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4977 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4978 |
RETURN ( __MKSMALLINT(f->max_bounds.width) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4979 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4980 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4981 |
%}. |
295 | 4982 |
self primitiveFailed. |
4983 |
^ nil |
|
4984 |
! |
|
4985 |
||
4986 |
minWidthOfFont:aFontId |
|
4987 |
||
4988 |
%{ /* NOCONTEXT */ |
|
4989 |
||
4990 |
XFontStruct *f; |
|
4991 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4992 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4993 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4994 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4995 |
RETURN ( __MKSMALLINT(f->min_bounds.width) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4996 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4997 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4998 |
%}. |
295 | 4999 |
self primitiveFailed. |
5000 |
^ nil |
|
5001 |
! |
|
5002 |
||
5003 |
releaseFont:aFontId |
|
5004 |
||
5005 |
%{ /* NOCONTEXT */ |
|
5006 |
||
5007 |
XFontStruct *f; |
|
5008 |
||
5009 |
if (ISCONNECTED) { |
|
5010 |
if (__isExternalAddress(aFontId)) { |
|
5011 |
f = _FontVal(aFontId); |
|
5012 |
BEGIN_INTERRUPTSBLOCKED |
|
5013 |
XFreeFont(myDpy, f); |
|
5014 |
END_INTERRUPTSBLOCKED |
|
5015 |
RETURN ( self ); |
|
5016 |
} |
|
5017 |
} |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5018 |
%}. |
295 | 5019 |
self primitiveFailed |
5020 |
! |
|
5021 |
||
466 | 5022 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
295 | 5023 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
5024 |
on this display. |
|
5025 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
5026 |
||
5027 |
|sizes| |
|
5028 |
||
466 | 5029 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
295 | 5030 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5031 |
"special: in X11R5 and above, size 0 means: |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5032 |
there are scaled versions in all sizes available" |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5033 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
5034 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
295 | 5035 |
]. |
5036 |
^ sizes |
|
5037 |
||
5038 |
" |
|
5039 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
5040 |
" |
|
466 | 5041 |
|
5042 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
295 | 5043 |
! |
5044 |
||
5045 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
|
5046 |
||
5047 |
%{ /* NOCONTEXT */ |
|
5048 |
||
5049 |
XFontStruct *f; |
|
5050 |
char *cp; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5051 |
int len, n, i1, i2, l; |
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
5052 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5053 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5054 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5055 |
int nInstBytes; |
295 | 5056 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5057 |
if (ISCONNECTED) { |
850 | 5058 |
if (__bothSmallInteger(index1, index2) |
5059 |
&& __isExternalAddress(aFontId) |
|
5060 |
&& __isNonNilObject(aString)) { |
|
5061 |
f = _FontVal(aFontId); |
|
5062 |
i1 = __intVal(index1) - 1; |
|
5063 |
cls = __qClass(aString); |
|
5064 |
||
5065 |
if (i1 >= 0) { |
|
5066 |
i2 = __intVal(index2) - 1; |
|
5067 |
if (i2 < i1) { |
|
5068 |
RETURN (self); |
|
5069 |
} |
|
5070 |
||
5071 |
cp = (char *) _stringVal(aString); |
|
5072 |
l = i2 - i1 + 1; |
|
5073 |
||
5074 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
5075 |
n = _stringSize(aString); |
|
5076 |
if (i2 < n) { |
|
5077 |
cp += i1; |
|
5078 |
BEGIN_INTERRUPTSBLOCKED |
|
5079 |
len = XTextWidth(f, cp, l); |
|
5080 |
END_INTERRUPTSBLOCKED |
|
5081 |
RETURN ( __MKSMALLINT(len) ); |
|
5082 |
} |
|
5083 |
} |
|
5084 |
||
5085 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
5086 |
cp += nInstBytes; |
|
5087 |
||
5088 |
if (__isBytes(aString)) { |
|
5089 |
n = __byteArraySize(aString) - nInstBytes; |
|
5090 |
if (i2 < n) { |
|
5091 |
cp += i1; |
|
5092 |
BEGIN_INTERRUPTSBLOCKED |
|
5093 |
len = XTextWidth(f, cp, l); |
|
5094 |
END_INTERRUPTSBLOCKED |
|
5095 |
RETURN ( __MKSMALLINT(len) ); |
|
5096 |
} |
|
5097 |
} |
|
5098 |
||
5099 |
/* TWOBYTESTRINGS */ |
|
5100 |
if (__isWords(aString)) { |
|
5101 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
5102 |
||
5103 |
if (i2 < n) { |
|
5104 |
union { |
|
5105 |
char b[2]; |
|
5106 |
unsigned short s; |
|
5107 |
} u; |
|
5108 |
int i; |
|
5109 |
XChar2b *cp2 = (XChar2b *)0; |
|
5110 |
int mustFree = 0; |
|
5111 |
||
5112 |
cp += (i1 * 2); |
|
5113 |
if (l > 1000) l = 1000; |
|
5114 |
||
5115 |
/* |
|
5116 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
5117 |
* X expects them MSB first |
|
5118 |
* convert as required |
|
5119 |
*/ |
|
5120 |
||
5121 |
u.s = 0x1234; |
|
5122 |
if (u.b[0] != 0x12) { |
|
5123 |
if (l <= NLOCALBUFFER) { |
|
5124 |
cp2 = xlatebuffer; |
|
5125 |
} else { |
|
5126 |
cp2 = (XChar2b *)(malloc(l * 2)); |
|
5127 |
mustFree = 1; |
|
5128 |
} |
|
5129 |
for (i=0; i<l; i++) { |
|
5130 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
5131 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
5132 |
} |
|
5133 |
cp = (char *) cp2; |
|
5134 |
} |
|
5135 |
BEGIN_INTERRUPTSBLOCKED |
|
5136 |
len = XTextWidth16(f, (XChar2b *)cp, l); |
|
5137 |
END_INTERRUPTSBLOCKED |
|
5138 |
||
5139 |
if (mustFree) { |
|
5140 |
free(cp2); |
|
5141 |
} |
|
5142 |
||
5143 |
RETURN ( __MKSMALLINT(len) ); |
|
5144 |
} |
|
5145 |
} |
|
5146 |
} |
|
5147 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5148 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5149 |
#undef NLOCALBUFFER |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5150 |
%}. |
295 | 5151 |
self primitiveFailed. |
5152 |
^ nil |
|
5153 |
! |
|
5154 |
||
5155 |
widthOf:aString inFont:aFontId |
|
5156 |
||
5157 |
%{ /* NOCONTEXT */ |
|
5158 |
||
5159 |
XFontStruct *f; |
|
5160 |
char *cp; |
|
5161 |
int len, n; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
5162 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5163 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5164 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5165 |
int nInstBytes; |
295 | 5166 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5167 |
if (ISCONNECTED) { |
850 | 5168 |
if (__isExternalAddress(aFontId) |
5169 |
&& __isNonNilObject(aString)) { |
|
5170 |
f = _FontVal(aFontId); |
|
5171 |
cls = __qClass(aString); |
|
5172 |
||
5173 |
cp = (char *)_stringVal(aString); |
|
5174 |
||
5175 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
5176 |
n = _stringSize(aString); |
|
5177 |
BEGIN_INTERRUPTSBLOCKED |
|
5178 |
len = XTextWidth(f, cp, n); |
|
5179 |
END_INTERRUPTSBLOCKED |
|
5180 |
RETURN ( __MKSMALLINT(len) ); |
|
5181 |
} |
|
5182 |
||
5183 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
5184 |
cp += nInstBytes; |
|
5185 |
||
5186 |
if (__isBytes(aString)) { |
|
5187 |
n = __byteArraySize(aString) - nInstBytes; |
|
5188 |
||
5189 |
BEGIN_INTERRUPTSBLOCKED |
|
5190 |
len = XTextWidth(f, cp, n); |
|
5191 |
END_INTERRUPTSBLOCKED |
|
5192 |
RETURN ( __MKSMALLINT(len) ); |
|
5193 |
} |
|
5194 |
||
5195 |
/* TWOBYTESTRINGS */ |
|
5196 |
if (__isWords(aString)) { |
|
5197 |
union { |
|
5198 |
char b[2]; |
|
5199 |
unsigned short s; |
|
5200 |
} u; |
|
5201 |
int i; |
|
5202 |
XChar2b *cp2; |
|
5203 |
int mustFree = 0; |
|
5204 |
||
5205 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
|
5206 |
if (n > 1000) n = 1000; |
|
5207 |
||
5208 |
/* |
|
5209 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
|
5210 |
* X expects them MSB first |
|
5211 |
* convert as required |
|
5212 |
*/ |
|
5213 |
||
5214 |
u.s = 0x1234; |
|
5215 |
if (u.b[0] != 0x12) { |
|
5216 |
if (n <= NLOCALBUFFER) { |
|
5217 |
cp2 = xlatebuffer; |
|
5218 |
} else { |
|
5219 |
cp2 = (XChar2b *)(malloc(n * 2)); |
|
5220 |
mustFree = 1; |
|
5221 |
} |
|
5222 |
||
5223 |
for (i=0; i<n; i++) { |
|
5224 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
|
5225 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
|
5226 |
} |
|
5227 |
cp = (char *) cp2; |
|
5228 |
} |
|
5229 |
||
5230 |
BEGIN_INTERRUPTSBLOCKED |
|
5231 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
|
5232 |
END_INTERRUPTSBLOCKED |
|
5233 |
||
5234 |
if (mustFree) { |
|
5235 |
free(cp2); |
|
5236 |
} |
|
5237 |
||
5238 |
RETURN ( __MKSMALLINT(len) ); |
|
5239 |
} |
|
5240 |
} |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5241 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5242 |
#undef NLOCALBUFFER |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5243 |
%}. |
295 | 5244 |
self primitiveFailed. |
5245 |
^ nil |
|
5246 |
! ! |
|
5247 |
||
5248 |
!XWorkstation methodsFor:'grabbing '! |
|
5249 |
||
5250 |
allowEvents:mode |
|
5251 |
%{ /* NOCONTEXT */ |
|
5252 |
||
5253 |
int _mode, ok = 1; |
|
5254 |
||
5255 |
if (mode == @symbol(asyncPointer)) |
|
5256 |
_mode = AsyncPointer; |
|
5257 |
else if (mode == @symbol(syncPointer)) |
|
5258 |
_mode = SyncPointer; |
|
5259 |
else if (mode == @symbol(asyncKeyboard)) |
|
5260 |
_mode = AsyncKeyboard; |
|
5261 |
else if (mode == @symbol(syncKeyboard)) |
|
5262 |
_mode = SyncKeyboard; |
|
5263 |
else if (mode == @symbol(syncBoth)) |
|
5264 |
_mode = SyncBoth; |
|
5265 |
else if (mode == @symbol(asyncBoth)) |
|
5266 |
_mode = AsyncBoth; |
|
5267 |
else if (mode == @symbol(replayPointer)) |
|
5268 |
_mode = ReplayPointer; |
|
5269 |
else if (mode == @symbol(replayKeyboard)) |
|
5270 |
_mode = ReplayKeyboard; |
|
5271 |
else |
|
5272 |
ok = 0; |
|
5273 |
||
5274 |
if (ok) { |
|
5275 |
BEGIN_INTERRUPTSBLOCKED |
|
5276 |
XAllowEvents(myDpy, _mode, CurrentTime); |
|
5277 |
END_INTERRUPTSBLOCKED |
|
5278 |
RETURN (self); |
|
5279 |
} |
|
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5280 |
%}. |
295 | 5281 |
self primitiveFailed |
5282 |
! |
|
5283 |
||
5284 |
grabKeyboardIn:aWindowId |
|
5285 |
"grab the keyboard" |
|
5286 |
||
5287 |
%{ /* NOCONTEXT */ |
|
5288 |
int result, ok; |
|
5289 |
||
5290 |
if (__isExternalAddress(aWindowId)) { |
|
5291 |
BEGIN_INTERRUPTSBLOCKED |
|
5292 |
result = XGrabKeyboard(myDpy, |
|
5293 |
_WindowVal(aWindowId), |
|
5294 |
True /* False */, |
|
5295 |
GrabModeAsync, |
|
5296 |
GrabModeAsync, |
|
5297 |
CurrentTime); |
|
5298 |
END_INTERRUPTSBLOCKED |
|
5299 |
ok = 0; |
|
5300 |
switch(result) { |
|
5301 |
case AlreadyGrabbed: |
|
5302 |
printf("XWORKSTAT: grab keyboard: AlreadyGrabbed\n"); |
|
5303 |
break; |
|
5304 |
case GrabNotViewable: |
|
5305 |
printf("XWORKSTAT: grab keyboard: GrabNotViewable\n"); |
|
5306 |
break; |
|
5307 |
case GrabInvalidTime: |
|
5308 |
printf("XWORKSTAT: grab keyboard: InvalidTime\n"); |
|
5309 |
break; |
|
5310 |
case GrabFrozen: |
|
5311 |
printf("XWORKSTAT: grab keyboard: Frozen\n"); |
|
5312 |
break; |
|
5313 |
default: |
|
5314 |
ok = 1; |
|
5315 |
break; |
|
5316 |
} |
|
5317 |
if (! ok) { |
|
5318 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5319 |
RETURN (false); |
|
5320 |
} |
|
5321 |
||
5322 |
RETURN ( true ); |
|
5323 |
} |
|
5324 |
%} |
|
5325 |
. |
|
5326 |
self primitiveFailed |
|
5327 |
! |
|
5328 |
||
5329 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
|
5330 |
"grap the pointer - return true if ok" |
|
5331 |
||
5332 |
%{ /* NOCONTEXT */ |
|
5333 |
||
5334 |
int result, ok; |
|
5335 |
Window confineWin; |
|
5336 |
Cursor curs; |
|
5337 |
int pointer_mode, keyboard_mode; |
|
5338 |
||
5339 |
if (__isExternalAddress(aWindowId)) { |
|
5340 |
if (__isExternalAddress(confineId)) |
|
5341 |
confineWin = _WindowVal(confineId); |
|
5342 |
else |
|
5343 |
confineWin = (Window) None; |
|
5344 |
||
5345 |
if (__isExternalAddress(aCursorId)) |
|
5346 |
curs = _CursorVal(aCursorId); |
|
5347 |
else |
|
5348 |
curs = (Cursor) None; |
|
5349 |
||
5350 |
if (pMode == @symbol(sync)) |
|
5351 |
pointer_mode = GrabModeSync; |
|
5352 |
else |
|
5353 |
pointer_mode = GrabModeAsync; |
|
5354 |
||
5355 |
if (kMode == @symbol(sync)) |
|
5356 |
keyboard_mode = GrabModeSync; |
|
5357 |
else |
|
5358 |
keyboard_mode = GrabModeAsync; |
|
5359 |
||
5360 |
BEGIN_INTERRUPTSBLOCKED |
|
5361 |
result = XGrabPointer(myDpy, |
|
5362 |
_WindowVal(aWindowId), |
|
5363 |
False, |
|
5364 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
5365 |
pointer_mode, keyboard_mode, |
|
5366 |
confineWin, |
|
5367 |
curs, |
|
5368 |
CurrentTime); |
|
5369 |
END_INTERRUPTSBLOCKED |
|
5370 |
||
5371 |
ok = 0; |
|
5372 |
switch (result) { |
|
5373 |
case AlreadyGrabbed: |
|
5374 |
printf("XWORKSTAT: grab pointer: AlreadyGrabbed\n"); |
|
5375 |
break; |
|
5376 |
case GrabNotViewable: |
|
5377 |
printf("XWORKSTAT: grab pointer: GrabNotViewable\n"); |
|
5378 |
break; |
|
5379 |
case GrabInvalidTime: |
|
5380 |
printf("XWORKSTAT: grab pointer: InvalidTime\n"); |
|
5381 |
break; |
|
5382 |
case GrabFrozen: |
|
5383 |
printf("XWORKSTAT: grab pointer: Frozen\n"); |
|
5384 |
break; |
|
5385 |
default: |
|
5386 |
ok = 1; |
|
5387 |
break; |
|
5388 |
} |
|
5389 |
||
5390 |
if (! ok) { |
|
5391 |
XUngrabPointer(myDpy, CurrentTime); |
|
5392 |
RETURN (false); |
|
5393 |
} |
|
5394 |
RETURN ( true ); |
|
5395 |
} |
|
5396 |
%} |
|
5397 |
. |
|
5398 |
self primitiveFailed |
|
5399 |
! |
|
5400 |
||
5401 |
ungrabKeyboard |
|
5402 |
"release the keyboard" |
|
5403 |
||
5404 |
%{ /* NOCONTEXT */ |
|
5405 |
||
5406 |
if (ISCONNECTED) { |
|
5407 |
BEGIN_INTERRUPTSBLOCKED |
|
5408 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5409 |
XSync(myDpy, 0); |
|
5410 |
END_INTERRUPTSBLOCKED |
|
5411 |
} |
|
5412 |
%}. |
|
5413 |
activeKeyboardGrab := nil |
|
5414 |
! |
|
5415 |
||
5416 |
ungrabPointer |
|
5417 |
"release the pointer" |
|
5418 |
||
5419 |
%{ /* NOCONTEXT */ |
|
5420 |
||
5421 |
if (ISCONNECTED) { |
|
5422 |
BEGIN_INTERRUPTSBLOCKED |
|
5423 |
XUngrabPointer(myDpy, CurrentTime); |
|
5424 |
XSync(myDpy, 0); |
|
5425 |
END_INTERRUPTSBLOCKED |
|
5426 |
} |
|
5427 |
%}. |
|
5428 |
activePointerGrab := nil |
|
5429 |
! ! |
|
5430 |
||
5431 |
!XWorkstation methodsFor:'graphic context stuff'! |
|
5432 |
||
5433 |
noClipIn:aGCId |
|
5434 |
"disable clipping rectangle" |
|
5435 |
||
5436 |
%{ /* NOCONTEXT */ |
|
5437 |
||
5438 |
XGCValues gcv; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5439 |
GC gc; |
295 | 5440 |
|
5441 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5442 |
gc = _GCVal(aGCId); |
295 | 5443 |
gcv.clip_mask = None; |
5444 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
|
5445 |
RETURN ( self ); |
|
5446 |
} |
|
5447 |
%}. |
|
5448 |
self primitiveFailed |
|
5449 |
! |
|
5450 |
||
5451 |
setBackground:bgColorIndex in:aGCId |
|
5452 |
"set background color to be drawn with" |
|
5453 |
||
5454 |
%{ /* NOCONTEXT */ |
|
5455 |
||
5456 |
if (__isExternalAddress(aGCId) |
|
5457 |
&& __isSmallInteger(bgColorIndex)) { |
|
555 | 5458 |
XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex)); |
295 | 5459 |
RETURN ( self ); |
5460 |
} |
|
5461 |
%}. |
|
5462 |
self primitiveFailed |
|
5463 |
! |
|
5464 |
||
5465 |
setBitmapMask:aBitmapId in:aGCId |
|
5466 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
|
5467 |
||
5468 |
%{ /* NOCONTEXT */ |
|
5469 |
||
5470 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5471 |
GC gc; |
295 | 5472 |
Pixmap bitmap; |
5473 |
||
5474 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5475 |
gc = _GCVal(aGCId); |
295 | 5476 |
if (__isExternalAddress(aBitmapId)) { |
5477 |
bitmap = _PixmapVal(aBitmapId); |
|
5478 |
XSetStipple(dpy, gc, bitmap); |
|
5479 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5480 |
RETURN ( self ); |
|
5481 |
} |
|
5482 |
if (aBitmapId == nil) { |
|
5483 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5484 |
RETURN ( self ); |
|
5485 |
} |
|
5486 |
} |
|
5487 |
%}. |
|
5488 |
self primitiveFailed |
|
5489 |
! |
|
5490 |
||
5491 |
setClipByChildren:aBool in:aGCId |
|
5492 |
"enable/disable drawing into child views" |
|
5493 |
||
5494 |
%{ /* NOCONTEXT */ |
|
5495 |
||
5496 |
XGCValues gcv; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5497 |
GC gc; |
295 | 5498 |
|
5499 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5500 |
gc = _GCVal(aGCId); |
295 | 5501 |
if (aBool == true) |
5502 |
gcv.subwindow_mode = ClipByChildren; |
|
5503 |
else |
|
5504 |
gcv.subwindow_mode = IncludeInferiors; |
|
5505 |
||
5506 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
|
5507 |
RETURN ( self ); |
|
5508 |
} |
|
5509 |
%}. |
|
5510 |
self primitiveFailed |
|
5511 |
! |
|
5512 |
||
5513 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId |
|
5514 |
"clip to a rectangle" |
|
5515 |
||
5516 |
%{ /* NOCONTEXT */ |
|
5517 |
||
5518 |
XRectangle r; |
|
5519 |
||
5520 |
if (__isExternalAddress(aGCId) |
|
5521 |
&& __bothSmallInteger(clipX, clipY) |
|
5522 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
555 | 5523 |
r.x = __intVal(clipX); |
5524 |
r.y = __intVal(clipY); |
|
5525 |
r.width = __intVal(clipWidth); |
|
5526 |
r.height = __intVal(clipHeight); |
|
295 | 5527 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
5528 |
RETURN ( self ); |
|
5529 |
} |
|
5530 |
%}. |
|
5531 |
self primitiveFailed |
|
5532 |
! |
|
5533 |
||
788 | 5534 |
setDashes:dashList dashOffset:offset in:aGCId |
5535 |
"set line attributes" |
|
5536 |
||
5537 |
%{ /* NOCONTEXT */ |
|
5538 |
||
5539 |
if (__isExternalAddress(aGCId) |
|
5540 |
&& __isSmallInteger(offset) |
|
5541 |
&& __isByteArray(dashList)) { |
|
850 | 5542 |
XSetDashes(myDpy, _GCVal(aGCId), |
5543 |
__intVal(offset), |
|
5544 |
__ByteArrayInstPtr(dashList)->ba_element, |
|
5545 |
__byteArraySize(dashList)); |
|
5546 |
RETURN ( self ); |
|
788 | 5547 |
} |
5548 |
bad: ; |
|
5549 |
%}. |
|
5550 |
" |
|
5551 |
either aGCId is invalid, |
|
5552 |
and/or dashList is not a byteArray |
|
5553 |
and/or offset is not a smallInteger |
|
5554 |
" |
|
5555 |
self primitiveFailed |
|
5556 |
! |
|
5557 |
||
295 | 5558 |
setFont:aFontId in:aGCId |
5559 |
"set font to be drawn in" |
|
5560 |
||
5561 |
%{ /* NOCONTEXT */ |
|
5562 |
||
5563 |
XFontStruct *f; |
|
5564 |
||
5565 |
if (__isExternalAddress(aFontId) |
|
5566 |
&& __isExternalAddress(aGCId)) { |
|
5567 |
f = (XFontStruct *) _FontVal(aFontId); |
|
5568 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
|
5569 |
RETURN ( self ); |
|
5570 |
} |
|
5571 |
%}. |
|
5572 |
" |
|
5573 |
aGCId and/or aFontId are invalid |
|
5574 |
" |
|
5575 |
self primitiveFailed |
|
5576 |
! |
|
5577 |
||
5578 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
|
5579 |
"set foreground and background colors to be drawn with" |
|
5580 |
||
5581 |
%{ /* NOCONTEXT */ |
|
5582 |
||
5583 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5584 |
GC gc; |
295 | 5585 |
|
5586 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
|
5587 |
&& __isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5588 |
gc = _GCVal(aGCId); |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5589 |
|
555 | 5590 |
XSetForeground(dpy, gc, __intVal(fgColorIndex)); |
5591 |
XSetBackground(dpy, gc, __intVal(bgColorIndex)); |
|
295 | 5592 |
RETURN ( self ); |
5593 |
} |
|
5594 |
%}. |
|
5595 |
self primitiveFailed |
|
5596 |
! |
|
5597 |
||
5598 |
setForeground:fgColor background:bgColor mask:aBitmapId in:aGCId |
|
5599 |
"set foreground and background colors to be drawn with using mask or |
|
5600 |
solid (if aBitmapId is nil)" |
|
5601 |
||
5602 |
%{ /* NOCONTEXT */ |
|
5603 |
||
5604 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5605 |
GC gc; |
295 | 5606 |
|
5607 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5608 |
gc = _GCVal(aGCId); |
295 | 5609 |
if (__isSmallInteger(fgColor)) |
555 | 5610 |
XSetForeground(dpy, gc, __intVal(fgColor)); |
295 | 5611 |
if (__isSmallInteger(bgColor)) |
555 | 5612 |
XSetBackground(dpy, gc, __intVal(bgColor)); |
295 | 5613 |
|
5614 |
if (__isExternalAddress(aBitmapId)) { |
|
5615 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
5616 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5617 |
RETURN ( self ); |
|
5618 |
} |
|
5619 |
if (aBitmapId == nil) { |
|
5620 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5621 |
RETURN ( self ); |
|
5622 |
} |
|
5623 |
} |
|
5624 |
%}. |
|
5625 |
self primitiveFailed |
|
5626 |
! |
|
5627 |
||
5628 |
setForeground:fgColor background:bgColor mask:aBitmapId lineWidth:lw in:aGCId |
|
5629 |
"set foreground and background colors to be drawn with using mask or |
|
5630 |
solid (if aBitmapId is nil); also set lineWidth" |
|
5631 |
||
5632 |
%{ /* NOCONTEXT */ |
|
5633 |
||
5634 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5635 |
GC gc; |
295 | 5636 |
|
5637 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5638 |
gc = _GCVal(aGCId); |
295 | 5639 |
if (__isSmallInteger(lw)) { |
555 | 5640 |
XSetLineAttributes(dpy, gc, __intVal(lw), |
295 | 5641 |
LineSolid, CapNotLast, JoinMiter); |
5642 |
} |
|
5643 |
if (__isSmallInteger(fgColor)) |
|
555 | 5644 |
XSetForeground(dpy, gc, __intVal(fgColor)); |
295 | 5645 |
if (__isSmallInteger(bgColor)) |
555 | 5646 |
XSetBackground(dpy, gc, __intVal(bgColor)); |
295 | 5647 |
|
5648 |
if (__isExternalAddress(aBitmapId)) { |
|
5649 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
5650 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5651 |
RETURN ( self ); |
|
5652 |
} |
|
5653 |
if (aBitmapId == nil) { |
|
5654 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5655 |
RETURN ( self ); |
|
5656 |
} |
|
5657 |
} |
|
5658 |
%}. |
|
5659 |
self primitiveFailed |
|
5660 |
! |
|
5661 |
||
5662 |
setForeground:fgColorIndex in:aGCId |
|
5663 |
"set foreground color to be drawn with" |
|
5664 |
||
5665 |
%{ /* NOCONTEXT */ |
|
5666 |
||
5667 |
if (__isExternalAddress(aGCId) |
|
5668 |
&& __isSmallInteger(fgColorIndex)) { |
|
555 | 5669 |
XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex)); |
295 | 5670 |
RETURN ( self ); |
5671 |
} |
|
5672 |
%}. |
|
5673 |
self primitiveFailed |
|
5674 |
! |
|
5675 |
||
5676 |
setFunction:aFunctionSymbol in:aGCId |
|
5677 |
"set alu function to be drawn with" |
|
5678 |
||
5679 |
%{ /* NOCONTEXT */ |
|
5680 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5681 |
GC gc; |
295 | 5682 |
int fun = -1; |
5683 |
||
5684 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5685 |
gc = _GCVal(aGCId); |
295 | 5686 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
5687 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
5688 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
5689 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
5690 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
5691 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
5692 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
5693 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
5694 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
5695 |
if (fun != -1) { |
|
5696 |
XSetFunction(myDpy, gc, fun); |
|
5697 |
RETURN ( self ); |
|
5698 |
} |
|
5699 |
} |
|
5700 |
%}. |
|
5701 |
" |
|
5702 |
either aGCId is not an integer, or an invalid symbol |
|
5703 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
|
5704 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
5705 |
" |
|
5706 |
self primitiveFailed |
|
5707 |
! |
|
5708 |
||
5709 |
setGraphicsExposures:aBoolean in:aGCId |
|
5710 |
"set or clear the graphics exposures flag" |
|
5711 |
||
5712 |
%{ /* NOCONTEXT */ |
|
5713 |
||
5714 |
if (__isExternalAddress(aGCId)) { |
|
5715 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
|
5716 |
RETURN ( self ); |
|
5717 |
} |
|
5718 |
%} |
|
5719 |
. |
|
5720 |
self primitiveFailed |
|
5721 |
! |
|
5722 |
||
5723 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
|
5724 |
"set line attributes" |
|
5725 |
||
5726 |
%{ /* NOCONTEXT */ |
|
5727 |
||
5728 |
int x_style, x_cap, x_join; |
|
5729 |
||
5730 |
if (__isExternalAddress(aGCId) |
|
5731 |
&& __isSmallInteger(aNumber)) { |
|
5732 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
|
5733 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
|
5734 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
|
5735 |
else goto bad; |
|
5736 |
||
5737 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
|
5738 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
|
5739 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
|
5740 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
|
5741 |
else goto bad; |
|
5742 |
||
5743 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
|
5744 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
|
5745 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
|
5746 |
else goto bad; |
|
5747 |
||
5748 |
XSetLineAttributes(myDpy, |
|
555 | 5749 |
_GCVal(aGCId), __intVal(aNumber), |
295 | 5750 |
x_style, x_cap, x_join); |
5751 |
RETURN ( self ); |
|
5752 |
} |
|
5753 |
bad: ; |
|
5754 |
%}. |
|
5755 |
" |
|
5756 |
either aGCId is invalid, |
|
5757 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
|
5758 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
5759 |
and/or joinStyle is none of #miter, #bevel, #round |
|
5760 |
" |
|
5761 |
self primitiveFailed |
|
5762 |
! |
|
5763 |
||
5764 |
setMaskOriginX:orgX y:orgY in:aGCid |
|
5765 |
"set the mask origin" |
|
5766 |
||
5767 |
%{ /* NOCONTEXT */ |
|
5768 |
||
5769 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
|
555 | 5770 |
XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY)); |
295 | 5771 |
RETURN ( self ); |
5772 |
} |
|
5773 |
%}. |
|
5774 |
self primitiveFailed |
|
5775 |
! |
|
5776 |
||
5777 |
setPixmapMask:aPixmapId in:aGCId |
|
5778 |
"set or clear the drawing mask - a pixmap mask providing full color" |
|
5779 |
||
5780 |
%{ /* NOCONTEXT */ |
|
5781 |
||
5782 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5783 |
GC gc; |
295 | 5784 |
Pixmap pixmap; |
5785 |
||
5786 |
if (__isExternalAddress(aGCId)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5787 |
gc = _GCVal(aGCId); |
295 | 5788 |
if (__isExternalAddress(aPixmapId)) { |
5789 |
pixmap = _PixmapVal(aPixmapId); |
|
5790 |
XSetTile(dpy, gc, pixmap); |
|
5791 |
XSetFillStyle(dpy, gc, FillTiled); |
|
5792 |
RETURN ( self ); |
|
5793 |
} |
|
5794 |
if (aPixmapId == nil) { |
|
5795 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5796 |
RETURN ( self ); |
|
5797 |
} |
|
5798 |
} |
|
5799 |
%}. |
|
5800 |
self primitiveFailed |
|
5801 |
! ! |
|
5802 |
||
5803 |
!XWorkstation methodsFor:'initialize / release'! |
|
5804 |
||
5805 |
close |
|
5806 |
"close down the connection to the X-server" |
|
5807 |
||
5808 |
%{ /* NOCONTEXT */ |
|
5809 |
||
5810 |
if (ISCONNECTED) { |
|
5811 |
BEGIN_INTERRUPTSBLOCKED |
|
5812 |
XCloseDisplay(myDpy); |
|
555 | 5813 |
__INST(displayId) = nil; |
295 | 5814 |
END_INTERRUPTSBLOCKED |
5815 |
} |
|
5816 |
%} |
|
5817 |
! |
|
5818 |
||
5819 |
initializeDefaultValues |
|
5820 |
buttonTranslation := ButtonTranslation. |
|
5821 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
5822 |
||
5823 |
self initializeModifierMappings |
|
5824 |
! |
|
5825 |
||
5826 |
initializeEventBuffer |
|
5827 |
|sz| |
|
5828 |
||
5829 |
%{ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5830 |
sz = __MKSMALLINT(sizeof(XEvent) + 100); |
295 | 5831 |
%}. |
5832 |
eventBuffer isNil ifTrue:[ |
|
5833 |
eventBuffer := ByteArray new:sz. |
|
5834 |
]. |
|
5835 |
! |
|
5836 |
||
5837 |
initializeFor:aDisplayName |
|
5838 |
"initialize the receiver for a connection to an X-Server; |
|
5839 |
the argument, aDisplayName may be nil (for the default server from |
|
5840 |
DISPLAY-variable or command line argument) or the name of the server |
|
5841 |
as hostname:number" |
|
5842 |
||
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5843 |
|dpyName index arguments| |
295 | 5844 |
|
5845 |
dpyName := aDisplayName. |
|
5846 |
dpyName isNil ifTrue:[ |
|
5847 |
"look for a '-display xxx' argument" |
|
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5848 |
(arguments := Smalltalk commandLineArguments) notNil ifTrue:[ |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5849 |
index := arguments indexOf:'-display'. |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5850 |
(index between:1 and:(arguments size - 1)) ifTrue:[ |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5851 |
dpyName := arguments at:index+1 |
295 | 5852 |
] |
5853 |
] |
|
5854 |
]. |
|
5855 |
%{ |
|
5856 |
int scr; |
|
5857 |
Display *dpy; |
|
5858 |
Visual *visual; |
|
5859 |
XVisualInfo viproto; |
|
5860 |
XVisualInfo *vip; /* retured info */ |
|
5861 |
int maxRGBDepth; |
|
5862 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
5863 |
int rgbVisualID; |
|
5864 |
int nvi, i; |
|
5865 |
int shapeEventBase, shapeErrorBase; |
|
5866 |
int shmEventBase, shmErrorBase; |
|
5867 |
int faxEventBase, faxErrorBase; |
|
5868 |
char *type, *nm; |
|
5869 |
int dummy; |
|
5870 |
OBJ dpyID; |
|
5871 |
||
555 | 5872 |
if (__INST(displayId) != nil) { |
295 | 5873 |
/* |
5874 |
* already connected - you bad guy try to |
|
5875 |
* trick me manually ? |
|
5876 |
*/ |
|
5877 |
RETURN ( self ); |
|
5878 |
} |
|
5879 |
||
5880 |
BEGIN_INTERRUPTSBLOCKED |
|
5881 |
||
5882 |
if (__isString(dpyName)) |
|
5883 |
nm = (char *)_stringVal(dpyName); |
|
5884 |
else { |
|
5885 |
dpyName = __MKSTRING((char *)getenv("DISPLAY") COMMA_CON); |
|
5886 |
nm = NULL; |
|
5887 |
} |
|
5888 |
dpy = XOpenDisplay(nm); |
|
5889 |
||
5890 |
if (dpy) { |
|
555 | 5891 |
__INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID); |
295 | 5892 |
|
5893 |
#ifdef SUPERDEBUG |
|
5894 |
XSynchronize(dpy, 1); |
|
5895 |
#endif |
|
5896 |
||
5897 |
XSetErrorHandler(__XErrorHandler__); |
|
5898 |
} |
|
5899 |
||
5900 |
END_INTERRUPTSBLOCKED |
|
5901 |
%}. |
|
5902 |
displayId isNil ifTrue:[ |
|
5903 |
'XWORKSTATION: cannot connect to Display.' errorPrintNL. |
|
5904 |
^ nil |
|
5905 |
]. |
|
5906 |
||
5907 |
dispatching := false. |
|
5908 |
dispatchingExpose := false. |
|
5909 |
isSlow := false. |
|
5910 |
shiftDown := false. |
|
5911 |
ctrlDown := false. |
|
5912 |
metaDown := false. |
|
5913 |
altDown := false. |
|
5914 |
motionEventCompression := true. |
|
5915 |
buttonsPressed := 0. |
|
5916 |
displayName := dpyName. |
|
5917 |
||
5918 |
protocolsAtom := nil. |
|
5919 |
deleteWindowAtom := nil. |
|
5920 |
saveYourselfAtom := nil. |
|
5921 |
quitAppAtom := nil. |
|
5922 |
||
5923 |
self initializeScreenProperties. |
|
5924 |
||
5925 |
self initializeDefaultValues. |
|
5926 |
self initializeEventBuffer. |
|
5927 |
self initializeSpecialFlags. |
|
5928 |
self initializeKeyboardMap. |
|
5929 |
||
5930 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
|
5931 |
! |
|
5932 |
||
5933 |
initializeModifierMappings |
|
5934 |
|map mod| |
|
5935 |
||
5936 |
"/ altModifiers := #(Alt_L Alt_R). |
|
5937 |
"/ metaModifiers := #(Meta_L Meta_R). |
|
5938 |
"/ ctrlModifiers := #(Control_L Control_R). |
|
5939 |
"/ shiftModifiers := #(Shift_L Shift_R). |
|
5940 |
||
5941 |
shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil. |
|
5942 |
altModifierMask := metaModifierMask := nil. |
|
5943 |
||
5944 |
map := self modifierMapping. |
|
342 | 5945 |
map isNil ifTrue:[ |
5946 |
"/ |
|
5947 |
"/ mhmh - a crippled Xlib which does not provide modifier mappings |
|
5948 |
"/ setup some reasonable default. If that is not sufficient, |
|
5949 |
"/ you have to change things from your display.rc file. |
|
5950 |
"/ |
|
5951 |
altModifierMask := self modifier1Mask. |
|
5952 |
metaModifierMask := self modifier2Mask. |
|
5953 |
||
5954 |
shiftModifiers := #(Shift_L Shift_R Shift). |
|
5955 |
ctrlModifiers := #(Control_L Control_R Control). |
|
5956 |
metaModifiers := #(Alt_L Meta_L Meta_R Meta). |
|
5957 |
altModifiers := #(Alt_R Alt). |
|
5958 |
] ifFalse:[ |
|
5959 |
altModifierMask := 0. |
|
374 | 5960 |
metaModifierMask := 0. |
5961 |
||
5962 |
mod := map at:1. |
|
5963 |
mod notNil ifTrue:[ |
|
342 | 5964 |
shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
374 | 5965 |
]. |
5966 |
mod := map at:3. |
|
5967 |
mod notNil ifTrue:[ |
|
342 | 5968 |
ctrlModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
374 | 5969 |
]. |
5970 |
mod := map at:4. |
|
5971 |
mod notNil ifTrue:[ |
|
342 | 5972 |
metaModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
5973 |
metaModifierMask := 1 bitShift:(4-1). |
|
374 | 5974 |
]. |
5975 |
mod := map at:5. |
|
5976 |
mod notNil ifTrue:[ |
|
342 | 5977 |
altModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
5978 |
altModifierMask := 1 bitShift:(5-1). |
|
5979 |
] |
|
295 | 5980 |
]. |
5981 |
||
5982 |
"Modified: 1.12.1995 / 23:44:40 / stefan" |
|
5983 |
! |
|
5984 |
||
5985 |
initializeScreenProperties |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5986 |
super initializeScreenProperties. |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5987 |
|
295 | 5988 |
%{ /* NOCONTEXT */ |
5989 |
||
5990 |
Display *dpy = myDpy; |
|
5991 |
int scr; |
|
5992 |
Visual *visual; |
|
5993 |
XVisualInfo viproto; |
|
5994 |
XVisualInfo *vip; /* retured info */ |
|
5995 |
int maxRGBDepth; |
|
5996 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
5997 |
int rgbVisualID; |
|
5998 |
int nvi, i; |
|
5999 |
int shapeEventBase, shapeErrorBase; |
|
6000 |
int shmEventBase, shmErrorBase; |
|
6001 |
int faxEventBase, faxErrorBase; |
|
6002 |
char *type, *nm; |
|
6003 |
int dummy; |
|
6004 |
int mask, shift, nBits; |
|
6005 |
||
6006 |
if (ISCONNECTED) { |
|
850 | 6007 |
__INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
6008 |
__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
|
6009 |
||
6010 |
BEGIN_INTERRUPTSBLOCKED |
|
6011 |
||
6012 |
__INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
|
6013 |
__INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
|
6014 |
__INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
|
6015 |
__INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
|
6016 |
__INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
|
6017 |
__INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
|
6018 |
__INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
|
6019 |
__INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
|
6020 |
__INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
|
295 | 6021 |
|
6022 |
#ifdef SHAPE |
|
850 | 6023 |
if (XShapeQueryExtension(dpy, &shapeEventBase, &shapeErrorBase)) |
6024 |
__INST(hasShapeExtension) = true; |
|
6025 |
else |
|
295 | 6026 |
#endif |
850 | 6027 |
__INST(hasShapeExtension) = false; |
295 | 6028 |
|
6029 |
#ifdef SHM |
|
850 | 6030 |
if (XShmQueryExtension(dpy, &shmEventBase, &shmErrorBase)) |
6031 |
__INST(hasShmExtension) = true; |
|
6032 |
else |
|
295 | 6033 |
#endif |
850 | 6034 |
__INST(hasShmExtension) = false; |
295 | 6035 |
|
6036 |
#ifdef FAX |
|
850 | 6037 |
if (XFAXImageQueryExtension(dpy, &faxEventBase, &faxErrorBase)) |
6038 |
__INST(hasFaxExtension) = true; |
|
6039 |
else |
|
295 | 6040 |
#endif |
850 | 6041 |
__INST(hasFaxExtension) = false; |
295 | 6042 |
|
6043 |
#ifdef DPS |
|
850 | 6044 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
6045 |
__INST(hasDPSExtension) = true; |
|
6046 |
else |
|
295 | 6047 |
#endif |
850 | 6048 |
__INST(hasDPSExtension) = false; |
295 | 6049 |
|
6050 |
#ifdef XVIDEO |
|
850 | 6051 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
6052 |
__INST(hasXVideoExtension) = true; |
|
6053 |
else |
|
295 | 6054 |
#endif |
850 | 6055 |
__INST(hasXVideoExtension) = false; |
295 | 6056 |
|
6057 |
#ifdef MBUF |
|
850 | 6058 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
6059 |
__INST(hasMbufExtension) = true; |
|
6060 |
else |
|
295 | 6061 |
#endif |
850 | 6062 |
__INST(hasMbufExtension) = false; |
295 | 6063 |
|
6064 |
#ifdef PEX5 |
|
850 | 6065 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
6066 |
__INST(hasPEXExtension) = true; |
|
6067 |
else |
|
295 | 6068 |
#endif |
850 | 6069 |
__INST(hasPEXExtension) = false; |
295 | 6070 |
|
6071 |
#ifdef XIE |
|
850 | 6072 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
6073 |
__INST(hasImageExtension) = true; |
|
6074 |
else |
|
295 | 6075 |
#endif |
850 | 6076 |
__INST(hasImageExtension) = false; |
295 | 6077 |
|
6078 |
#ifdef XI |
|
850 | 6079 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
6080 |
__INST(hasInputExtension) = true; |
|
6081 |
else |
|
295 | 6082 |
#endif |
850 | 6083 |
__INST(hasInputExtension) = false; |
6084 |
||
6085 |
/* |
|
6086 |
* look for RGB visual |
|
6087 |
*/ |
|
6088 |
nvi = 0; |
|
6089 |
viproto.screen = scr; |
|
6090 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
|
6091 |
maxRGBDepth = 0; |
|
6092 |
for (i = 0; i < nvi; i++) { |
|
6093 |
switch (vip[i].class) { |
|
6094 |
case TrueColor: |
|
6095 |
if (vip[i].depth > maxRGBDepth) { |
|
6096 |
maxRGBDepth = vip[i].depth; |
|
6097 |
rgbRedMask = vip[i].red_mask; |
|
6098 |
rgbGreenMask = vip[i].green_mask; |
|
6099 |
rgbBlueMask = vip[i].blue_mask; |
|
6100 |
rgbVisualID = vip[i].visualid; |
|
6101 |
} |
|
6102 |
break; |
|
6103 |
} |
|
6104 |
} |
|
6105 |
if (vip) XFree ((char *) vip); |
|
6106 |
||
6107 |
if (maxRGBDepth) { |
|
6108 |
__INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
|
6109 |
} |
|
6110 |
||
6111 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
|
6112 |
__INST(monitorType) = @symbol(unknown); |
|
6113 |
__INST(hasColors) = true; |
|
6114 |
__INST(hasGreyscales) = true; |
|
6115 |
switch (visual->class) { |
|
6116 |
case StaticGray: |
|
6117 |
__INST(visualType) = @symbol(StaticGray); |
|
6118 |
__INST(hasColors) = false; |
|
6119 |
__INST(monitorType) = @symbol(monochrome); |
|
6120 |
break; |
|
6121 |
case GrayScale: |
|
6122 |
__INST(visualType) = @symbol(GrayScale); |
|
6123 |
__INST(hasColors) = false; |
|
6124 |
__INST(monitorType) = @symbol(monochrome); |
|
6125 |
break; |
|
6126 |
case StaticColor: |
|
6127 |
__INST(visualType) = @symbol(StaticColor); |
|
6128 |
break; |
|
6129 |
case PseudoColor: |
|
6130 |
__INST(visualType) = @symbol(PseudoColor); |
|
6131 |
break; |
|
6132 |
case TrueColor: |
|
6133 |
__INST(visualType) = @symbol(TrueColor); |
|
6134 |
break; |
|
6135 |
case DirectColor: |
|
6136 |
__INST(visualType) = @symbol(DirectColor); |
|
6137 |
break; |
|
6138 |
} |
|
6139 |
if (DisplayCells(dpy, scr) == 2) { |
|
6140 |
__INST(hasColors) = false; |
|
6141 |
__INST(hasGreyscales) = false; |
|
6142 |
__INST(monitorType) = @symbol(monochrome); |
|
6143 |
} |
|
6144 |
__INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
|
6145 |
__INST(redMask) = __MKSMALLINT(visual->red_mask); |
|
6146 |
__INST(greenMask) = __MKSMALLINT(visual->green_mask); |
|
6147 |
__INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
|
6148 |
switch (visual->class) { |
|
6149 |
case TrueColor: |
|
6150 |
/* extract number of bits and shift counts */ |
|
6151 |
mask = visual->red_mask; |
|
6152 |
shift = 0; |
|
6153 |
while (mask && ((mask & 1) == 0)) { |
|
6154 |
mask >>= 1; |
|
6155 |
shift++; |
|
6156 |
} |
|
6157 |
__INST(redShift) = __MKSMALLINT(shift); |
|
6158 |
nBits = 0; |
|
6159 |
while (mask) { |
|
6160 |
mask >>= 1; |
|
6161 |
nBits++; |
|
6162 |
} |
|
6163 |
__INST(bitsRed) = __MKSMALLINT(nBits); |
|
6164 |
||
6165 |
mask = visual->green_mask; |
|
6166 |
shift = 0; |
|
6167 |
while (mask && ((mask & 1) == 0)) { |
|
6168 |
mask >>= 1; |
|
6169 |
shift++; |
|
6170 |
} |
|
6171 |
__INST(greenShift) = __MKSMALLINT(shift); |
|
6172 |
nBits = 0; |
|
6173 |
while (mask) { |
|
6174 |
mask >>= 1; |
|
6175 |
nBits++; |
|
6176 |
} |
|
6177 |
__INST(bitsGreen) = __MKSMALLINT(nBits); |
|
6178 |
||
6179 |
mask = visual->blue_mask; |
|
6180 |
shift = 0; |
|
6181 |
while (mask && ((mask & 1) == 0)) { |
|
6182 |
mask >>= 1; |
|
6183 |
shift++; |
|
6184 |
} |
|
6185 |
__INST(blueShift) = __MKSMALLINT(shift); |
|
6186 |
nBits = 0; |
|
6187 |
while (mask) { |
|
6188 |
mask >>= 1; |
|
6189 |
nBits++; |
|
6190 |
} |
|
6191 |
__INST(bitsBlue) = __MKSMALLINT(nBits); |
|
6192 |
break; |
|
6193 |
} |
|
295 | 6194 |
|
6195 |
#ifndef XA_PRIMARY |
|
850 | 6196 |
__INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
295 | 6197 |
#else |
850 | 6198 |
__INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
295 | 6199 |
#endif |
6200 |
#ifndef XA_SECONDARY |
|
850 | 6201 |
__INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
295 | 6202 |
#else |
850 | 6203 |
__INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
295 | 6204 |
#endif |
6205 |
#ifndef XA_CUT_BUFFER0 |
|
850 | 6206 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
295 | 6207 |
#else |
850 | 6208 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
295 | 6209 |
#endif |
6210 |
#ifndef XA_STRING |
|
850 | 6211 |
__INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
295 | 6212 |
#else |
850 | 6213 |
__INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
295 | 6214 |
#endif |
6215 |
#ifndef XA_LENGTH |
|
850 | 6216 |
__INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
295 | 6217 |
#else |
850 | 6218 |
__INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
295 | 6219 |
#endif |
6220 |
||
850 | 6221 |
END_INTERRUPTSBLOCKED |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6222 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6223 |
%}. |
295 | 6224 |
! |
6225 |
||
6226 |
initializeSpecialFlags |
|
6227 |
"perform additional special server implementation flags" |
|
6228 |
||
6229 |
"/ |
|
6230 |
"/ assume we have it ... (should check) |
|
6231 |
"/ |
|
6232 |
hasSaveUnder := true. |
|
6233 |
ignoreBackingStore := false. |
|
6234 |
||
6235 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
6236 |
"/ |
|
6237 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
6238 |
"/ which does not correctly handle saveUnder |
|
6239 |
"/ |
|
6240 |
hasSaveUnder := false. |
|
6241 |
]. |
|
6242 |
! |
|
6243 |
||
6244 |
reinitialize |
|
6245 |
virtualRootId := rootId := nil. |
|
6246 |
super reinitialize. |
|
6247 |
dispatchingExpose := nil |
|
6248 |
! ! |
|
6249 |
||
6250 |
!XWorkstation methodsFor:'keyboard mapping'! |
|
6251 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6252 |
altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6253 |
"return the mask (in motionEvents) for the alt-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6254 |
Notice: ST/X may use the left ALT key as CMD/Meta key, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6255 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6256 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6257 |
^ altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6258 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6259 |
"Created: 23.3.1996 / 12:43:22 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6260 |
"Modified: 23.3.1996 / 12:44:56 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6261 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6262 |
|
341 | 6263 |
altModifierMask:aSmallInteger |
6264 |
"define which key takes the role of an alt-key. |
|
6265 |
By default, this is X's modifier1, which is the ALT key on |
|
6266 |
most keyboards. However, there may be exceptions to this, |
|
6267 |
and the setting can be changed with: |
|
6268 |
Display altModifierMask:(Display modifier2Mask) |
|
6269 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
|
6270 |
" |
|
6271 |
||
6272 |
altModifierMask := aSmallInteger |
|
6273 |
! |
|
6274 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6275 |
metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6276 |
"return the mask (in motionEvents) for the meta-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6277 |
Notice: ST/X may use the left ALT key as CMD/Meta key, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6278 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6279 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6280 |
^ metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6281 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6282 |
"Created: 23.3.1996 / 12:43:39 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6283 |
"Modified: 23.3.1996 / 12:45:09 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6284 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6285 |
|
341 | 6286 |
metaModifierMask:aSmallInteger |
6287 |
"define which key takes the role of a meta key. |
|
6288 |
By default, this is X's modifier2, which is the 2nd ALT key on |
|
6289 |
most keyboards (if present at all). |
|
6290 |
However, there may be exceptions to this, and the setting can |
|
6291 |
be changed with: |
|
6292 |
Display metaModifierMask:(Display modifier1Mask) |
|
6293 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
|
6294 |
As reported, some Xservers place the Meta-key onto NumLock, |
|
6295 |
and having NumLock enabled makes ST/X think, that meta is pressed |
|
6296 |
all the time. On those, you should disable the meta key by setting |
|
6297 |
the mask to 0. |
|
6298 |
" |
|
6299 |
||
6300 |
metaModifierMask := aSmallInteger |
|
6301 |
! |
|
6302 |
||
6303 |
modifier1Mask |
|
6304 |
"return the Xlib mask bit for the 1st modifier key. |
|
6305 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6306 |
this could be used." |
|
6307 |
||
6308 |
%{ /* NOCONTEXT */ |
|
6309 |
RETURN (__MKSMALLINT(Mod1Mask)); |
|
6310 |
%} |
|
6311 |
! |
|
6312 |
||
6313 |
modifier2Mask |
|
6314 |
"return the Xlib mask bit for the 2nd modifier key. |
|
6315 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6316 |
this could be used." |
|
6317 |
||
6318 |
%{ /* NOCONTEXT */ |
|
6319 |
RETURN (__MKSMALLINT(Mod2Mask)); |
|
6320 |
%} |
|
6321 |
! |
|
6322 |
||
6323 |
modifierMapping |
|
6324 |
"Get the Modifier Mapping. |
|
6325 |
We return an array of arrays of keycodes" |
|
6326 |
||
6327 |
|modifierKeyMap maxKeyPerMod ret nextKey| |
|
6328 |
||
6329 |
%{ |
|
6330 |
Display *dpy = myDpy; |
|
6331 |
XModifierKeymap *modmap; |
|
6332 |
OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT(); |
|
6333 |
||
6334 |
if (ISCONNECTED) { |
|
6335 |
if ((modmap = XGetModifierMapping(myDpy)) != 0) { |
|
6336 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6337 |
modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8); |
|
6338 |
if (modifierKeyMap != nil) { |
|
6339 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6340 |
memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, |
|
6341 |
(char *)modmap->modifiermap, modmap->max_keypermod * 8); |
|
6342 |
} |
|
6343 |
XFreeModifiermap(modmap); |
|
6344 |
} |
|
6345 |
} |
|
6346 |
%}. |
|
6347 |
||
6348 |
modifierKeyMap isNil ifTrue:[^ nil]. |
|
6349 |
||
6350 |
ret := Array new:8. |
|
6351 |
nextKey := 1. |
|
6352 |
1 to:8 do:[ :i | |
|
6353 |
(modifierKeyMap at:nextKey) ~= 0 ifTrue:[ |
|
6354 |
|mod| |
|
6355 |
||
6356 |
mod := OrderedCollection new:maxKeyPerMod. |
|
6357 |
modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key | |
|
6358 |
key ~= 0 ifTrue:[ |
|
6359 |
mod add:key |
|
6360 |
]. |
|
6361 |
]. |
|
6362 |
ret at:i put:mod. |
|
6363 |
]. |
|
6364 |
nextKey := nextKey+maxKeyPerMod. |
|
6365 |
]. |
|
6366 |
||
6367 |
^ ret |
|
6368 |
||
6369 |
" |
|
6370 |
Display modifierMapping |
|
6371 |
" |
|
6372 |
! |
|
6373 |
||
6374 |
stringFromKeycode:code |
|
6375 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
|
6376 |
||
6377 |
|str| |
|
6378 |
||
6379 |
%{ |
|
6380 |
Display *dpy = myDpy; |
|
6381 |
KeySym keysym; |
|
6382 |
char *keystring; |
|
6383 |
||
6384 |
if (ISCONNECTED && __isSmallInteger(code)) { |
|
6385 |
if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol && |
|
6386 |
(keystring = XKeysymToString(keysym)) != 0) |
|
6387 |
str = __MKSTRING(keystring); |
|
6388 |
} |
|
6389 |
%}. |
|
6390 |
^ str |
|
6391 |
||
6392 |
" |
|
6393 |
Display stringFromKeycode:28 |
|
6394 |
" |
|
6395 |
! |
|
6396 |
||
295 | 6397 |
translateKey:untranslatedKey |
6398 |
"Return the key translated via the translation table. |
|
6399 |
Here, we preTranslate the key into a common ST/X symbolic name, |
|
6400 |
which gets further processed in the superclasses translation method." |
|
6401 |
||
6402 |
|key| |
|
6403 |
||
6404 |
(key := untranslatedKey) isString ifTrue:[ |
|
6405 |
key := RawKeysymTranslation at:key ifAbsent:key. |
|
6406 |
key := key asSymbol. |
|
6407 |
]. |
|
6408 |
^ super translateKey:key |
|
6409 |
! ! |
|
6410 |
||
6411 |
!XWorkstation methodsFor:'misc'! |
|
6412 |
||
6413 |
beep |
|
6414 |
"output an audible beep or bell" |
|
6415 |
||
6416 |
self beep:50 |
|
6417 |
! |
|
6418 |
||
6419 |
beep:volumeInPercent |
|
6420 |
"output an audible beep" |
|
6421 |
%{ |
|
6422 |
int volume; |
|
6423 |
||
6424 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
|
6425 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
|
555 | 6426 |
volume = __intVal(volumeInPercent) * 2 - 100; |
295 | 6427 |
if (volume < -100) volume = -100; |
6428 |
else if (volume > 100) volume = 100; |
|
6429 |
BEGIN_INTERRUPTSBLOCKED |
|
6430 |
XBell(myDpy, volume); |
|
6431 |
END_INTERRUPTSBLOCKED |
|
6432 |
} |
|
6433 |
%} |
|
6434 |
! |
|
6435 |
||
6436 |
buffered |
|
6437 |
"buffer drawing - do not send it immediately to the display. |
|
374 | 6438 |
This is the default anyway. |
6439 |
See #unBuffered for additional info." |
|
295 | 6440 |
|
6441 |
%{ /* NOCONTEXT */ |
|
6442 |
||
6443 |
if (ISCONNECTED) { |
|
6444 |
BEGIN_INTERRUPTSBLOCKED |
|
6445 |
XSynchronize(myDpy, 0); |
|
6446 |
END_INTERRUPTSBLOCKED |
|
6447 |
} |
|
6448 |
%} |
|
374 | 6449 |
" |
6450 |
Display buffered |
|
6451 |
" |
|
295 | 6452 |
! |
6453 |
||
6454 |
flush |
|
6455 |
"send all buffered drawing to the display. |
|
6456 |
This may be required to make certain, that all previous operations |
|
6457 |
are really sent to the display before continuing. For example, |
|
6458 |
after a cursor-change with a followup long computation. |
|
374 | 6459 |
(otherwise, the cursor change request may still be in the output buffer) |
6460 |
See also #sync, which even waits until the request has been processed." |
|
295 | 6461 |
|
6462 |
%{ /* NOCONTEXT */ |
|
6463 |
||
6464 |
if (ISCONNECTED) { |
|
6465 |
BEGIN_INTERRUPTSBLOCKED |
|
310 | 6466 |
XFlush(myDpy); |
6467 |
END_INTERRUPTSBLOCKED |
|
6468 |
} |
|
6469 |
%} |
|
6470 |
! |
|
6471 |
||
295 | 6472 |
flushDpsContext:aDPSContext |
6473 |
||
6474 |
%{ /* NOCONTEXT */ |
|
6475 |
#ifdef DPS |
|
6476 |
if (__isExternalAddress(aDPSContext)) { |
|
6477 |
BEGIN_INTERRUPTSBLOCKED |
|
6478 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
|
6479 |
END_INTERRUPTSBLOCKED |
|
6480 |
RETURN ( self ); |
|
6481 |
} |
|
6482 |
#endif |
|
374 | 6483 |
%}. |
295 | 6484 |
self primitiveFailed |
6485 |
! |
|
6486 |
||
6487 |
refreshKeyboardMapping:eB |
|
6488 |
%{ |
|
6489 |
XMappingEvent *ev; |
|
6490 |
||
6491 |
if (__isByteArray(eB)) { |
|
555 | 6492 |
ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 6493 |
XRefreshKeyboardMapping(ev); |
6494 |
} |
|
6495 |
%} |
|
6496 |
! |
|
6497 |
||
6498 |
setInputFocusTo:aWindowId |
|
6499 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
|
6500 |
self setInputFocusTo:aWindowId revertTo:#root |
|
6501 |
! |
|
6502 |
||
6503 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
|
6504 |
"set the focus to the view as defined by aWindowId. |
|
6505 |
Passing nil set the focus to no window and lets the display discard all |
|
6506 |
input until a new focus is set. |
|
6507 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
6508 |
passing one of #parent, #root or nil specifies that the focus should be |
|
6509 |
given to the parent view, the root view or no view." |
|
6510 |
||
6511 |
%{ /* NOCONTEXT */ |
|
6512 |
int arg; |
|
6513 |
Window focusWindow; |
|
6514 |
||
6515 |
if (ISCONNECTED) { |
|
6516 |
if (__isExternalAddress(aWindowId)) { |
|
6517 |
focusWindow = _WindowVal(aWindowId); |
|
6518 |
} else { |
|
6519 |
focusWindow = None; |
|
6520 |
} |
|
6521 |
if (revertSymbol == @symbol(parent)) |
|
6522 |
arg = RevertToParent; |
|
6523 |
else if (revertSymbol == @symbol(root)) |
|
6524 |
arg = RevertToPointerRoot; |
|
6525 |
else |
|
6526 |
arg = RevertToNone; |
|
6527 |
||
6528 |
BEGIN_INTERRUPTSBLOCKED |
|
6529 |
XSetInputFocus(myDpy, focusWindow, arg, CurrentTime); |
|
6530 |
END_INTERRUPTSBLOCKED |
|
6531 |
RETURN ( self ); |
|
6532 |
} |
|
6533 |
%}. |
|
6534 |
self primitiveFailed |
|
6535 |
! |
|
6536 |
||
341 | 6537 |
sync |
6538 |
"send all buffered drawing to the display AND wait until the display |
|
6539 |
has finished drawing it. |
|
6540 |
This is almost never needed, except if you are about to read previously |
|
374 | 6541 |
drawn pixels back from the display screen, or you want to wait for a beep |
6542 |
to be finished. See also #flush." |
|
341 | 6543 |
|
6544 |
%{ /* NOCONTEXT */ |
|
6545 |
||
6546 |
if (ISCONNECTED) { |
|
6547 |
BEGIN_INTERRUPTSBLOCKED |
|
6548 |
XSync(myDpy, 0); |
|
6549 |
END_INTERRUPTSBLOCKED |
|
6550 |
} |
|
6551 |
%} |
|
6552 |
! |
|
6553 |
||
295 | 6554 |
unBuffered |
374 | 6555 |
"make all drawing be sent immediately to the display. |
6556 |
This makes all graphics synchronous and turns off any buffering |
|
6557 |
(i.e. each individual draw-request is sent immediately without |
|
6558 |
packing multiple requests into a larger message buffer). |
|
6559 |
Be prepared, that this slows down graphics considerably. |
|
6560 |
However, it allows display errors to be handled immediately and |
|
6561 |
may be useful if you get Xdisplay errors and want to find the request |
|
6562 |
which was responsiblefor it. See also #buffered." |
|
295 | 6563 |
|
6564 |
%{ /* NOCONTEXT */ |
|
6565 |
||
6566 |
if (ISCONNECTED) { |
|
6567 |
BEGIN_INTERRUPTSBLOCKED |
|
6568 |
XSynchronize(myDpy, 1); |
|
6569 |
END_INTERRUPTSBLOCKED |
|
6570 |
} |
|
6571 |
%} |
|
6572 |
"Display unbuffered" |
|
6573 |
! ! |
|
6574 |
||
6575 |
!XWorkstation methodsFor:'pointer queries '! |
|
6576 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6577 |
anyButtonStateMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6578 |
"return an integer for masking out any button from a |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6579 |
buttonStates value." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6580 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6581 |
"/ should use ``Display buttonXMotionMask bitOr:....'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6582 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6583 |
^ 256 + 512 + 1024 |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6584 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6585 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6586 |
"Created: 23.3.1996 / 12:46:35 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6587 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6588 |
|
295 | 6589 |
buttonStates |
6590 |
"return an integer representing the state of the pointer buttons; |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6591 |
a one-bit in positions 0.. represent a pressed button. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6592 |
See the button1Mask/button2Mask/button3Mask, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6593 |
shiftMask/controlMask and modifierMask methods for the meaning of the bits." |
295 | 6594 |
|
6595 |
%{ /* NOCONTEXT*/ |
|
6596 |
Display *dpy = myDpy; |
|
6597 |
Window w; |
|
555 | 6598 |
int screen = __intVal(__INST(screen)); |
295 | 6599 |
Window rootRet, childRet; |
6600 |
int rootX, rootY, winX, winY; |
|
6601 |
unsigned int mask; |
|
6602 |
||
6603 |
BEGIN_INTERRUPTSBLOCKED |
|
6604 |
#ifdef VIRTUAL_ROOT |
|
6605 |
w = getRootWindow(myDpy, screen); |
|
6606 |
#else |
|
6607 |
w = RootWindow(dpy, screen); |
|
6608 |
#endif |
|
6609 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
|
850 | 6610 |
&rootX, &rootY, |
6611 |
&winX, &winY, |
|
6612 |
&mask); |
|
295 | 6613 |
END_INTERRUPTSBLOCKED |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6614 |
RETURN (__MKSMALLINT(mask)); |
295 | 6615 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6616 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6617 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6618 |
Display buttonStates |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6619 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6620 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6621 |
"is the control-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6622 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6623 |
Display buttonStates bitTest:(Display controlMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6624 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6625 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6626 |
"is the alt/meta-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6627 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6628 |
Display buttonStates bitTest:(Display altModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6629 |
Display buttonStates bitTest:(Display metaModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6630 |
" |
295 | 6631 |
! |
6632 |
||
6633 |
leftButtonStateMask |
|
6634 |
"return an integer for masking out the left button from a |
|
6635 |
buttonStates value" |
|
6636 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6637 |
"/ should use ``Display button1MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6638 |
|
295 | 6639 |
^ 256 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6640 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6641 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
295 | 6642 |
! |
6643 |
||
6644 |
middleButtonStateMask |
|
6645 |
"return an integer for masking out the middle button from a |
|
6646 |
buttonStates value" |
|
6647 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6648 |
"/ should use ``Display button2MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6649 |
|
295 | 6650 |
^ 512 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6651 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6652 |
"Modified: 23.3.1996 / 12:41:43 / cg" |
295 | 6653 |
! |
6654 |
||
6655 |
pointerPosition |
|
6656 |
"return the current pointer position in root-window coordinates" |
|
6657 |
||
6658 |
|xpos ypos| |
|
6659 |
||
6660 |
%{ |
|
6661 |
Display *dpy = myDpy; |
|
6662 |
Window w; |
|
555 | 6663 |
int screen = __intVal(__INST(screen)); |
295 | 6664 |
Window rootRet, childRet; |
6665 |
int rootX, rootY, winX, winY; |
|
6666 |
unsigned int mask; |
|
6667 |
||
6668 |
BEGIN_INTERRUPTSBLOCKED |
|
6669 |
#ifdef VIRTUAL_ROOT |
|
6670 |
w = getRootWindow(myDpy, screen); |
|
6671 |
#else |
|
6672 |
w = RootWindow(dpy, screen); |
|
6673 |
#endif |
|
6674 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
|
6675 |
&rootX, &rootY, |
|
6676 |
&winX, &winY, |
|
6677 |
&mask); |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6678 |
xpos = __MKSMALLINT(rootX); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6679 |
ypos = __MKSMALLINT(rootY); |
295 | 6680 |
END_INTERRUPTSBLOCKED |
6681 |
%} |
|
6682 |
. |
|
6683 |
^ xpos @ ypos |
|
6684 |
! |
|
6685 |
||
6686 |
rightButtonStateMask |
|
6687 |
"return an integer for masking out the right button from a |
|
6688 |
buttonStates value" |
|
6689 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6690 |
"/ should use ``Display button3MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6691 |
|
295 | 6692 |
^ 1024 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6693 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6694 |
"Modified: 23.3.1996 / 12:41:52 / cg" |
295 | 6695 |
! |
6696 |
||
6697 |
rootPositionOfLastEvent |
|
6698 |
"return the position in root-window coordinates |
|
6699 |
of the last button, key or pointer event" |
|
6700 |
||
6701 |
^ eventRootX @ eventRootY |
|
6702 |
! ! |
|
6703 |
||
6704 |
!XWorkstation methodsFor:'resources'! |
|
6705 |
||
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6706 |
atomIDOf:aStringOrSymbol |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6707 |
"return an Atoms ID; dont create if not already present. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6708 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6709 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6710 |
^ self atomIDOf:aStringOrSymbol create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6711 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6712 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6713 |
Display atomIDOf:'FACE_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6714 |
Display atomIDOf:'FULL_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6715 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6716 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6717 |
"Modified: 2.3.1996 / 15:09:29 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6718 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6719 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6720 |
atomIDOf:aStringOrSymbol create:create |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6721 |
"return an Atoms ID; if create is true, create it if not already present. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6722 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6723 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6724 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6725 |
Atom prop; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6726 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6727 |
if (ISCONNECTED) { |
850 | 6728 |
if (__isString(aStringOrSymbol) |
6729 |
|| __isSymbol(aStringOrSymbol)) { |
|
6730 |
prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), |
|
6731 |
(create == true) ? False : True); |
|
6732 |
if (prop == None) { |
|
6733 |
RETURN (nil); |
|
6734 |
} |
|
6735 |
RETURN ( __MKATOMOBJ(prop) ); |
|
6736 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6737 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6738 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6739 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6740 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6741 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6742 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6743 |
Display atomIDOf:'VT_SELECTION' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6744 |
Display atomIDOf:'CUT_BUFFER0' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6745 |
Display atomIDOf:'STRING' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6746 |
Display atomIDOf:'PRIMARY' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6747 |
Display atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6748 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6749 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6750 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6751 |
atomIDOfCUTBUFFER0 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6752 |
"return the CUTBUFFER0 AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6753 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6754 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6755 |
^ cutBuffer0Atom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6756 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6757 |
"Modified: 2.3.1996 / 15:10:36 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6758 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6759 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6760 |
atomIDOfLENGTH |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6761 |
"return the LENGTH AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6762 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6763 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6764 |
^ lengthAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6765 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6766 |
"Modified: 2.3.1996 / 15:10:41 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6767 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6768 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6769 |
atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6770 |
"return the PRIMARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6771 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6772 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6773 |
^ primaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6774 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6775 |
"Modified: 2.3.1996 / 15:10:49 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6776 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6777 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6778 |
atomIDOfSECONDARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6779 |
"return the SECONDARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6780 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6781 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6782 |
^ secondaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6783 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6784 |
"Modified: 2.3.1996 / 15:10:59 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6785 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6786 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6787 |
atomIDOfSTRING |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6788 |
"return the STRING AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6789 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6790 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6791 |
^ stringAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6792 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6793 |
"Modified: 2.3.1996 / 15:11:08 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6794 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6795 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6796 |
atomName:anAtomID |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6797 |
"given an AtomID, return its name. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6798 |
This is highly X specific and only for local use (with selections)." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6799 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6800 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6801 |
OBJ str; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6802 |
char *name; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6803 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6804 |
if (ISCONNECTED) { |
850 | 6805 |
if (__isAtomID(anAtomID)) { |
6806 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
|
6807 |
if (name == 0) { |
|
6808 |
RETURN (nil); |
|
6809 |
} |
|
6810 |
str = __MKSTRING(name COMMA_CON); |
|
6811 |
XFree(name); |
|
6812 |
RETURN ( str ); |
|
6813 |
} |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6814 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6815 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6816 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6817 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6818 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6819 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6820 |
Display atomName:1 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6821 |
Display atomName:130 '_DEC_DEVICE_FONTNAMES' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6822 |
Display atomName:132 'FONTNAME_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6823 |
Display atomName:135 'FOUNDRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6824 |
Display atomName:150 'CHARSET_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6825 |
Display atomName:151 'ISO8859' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6826 |
Display atomName:152 'CHARSET_ENCODING' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6827 |
Display atomName:154 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6828 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6829 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6830 |
|
295 | 6831 |
getResource:name class:cls |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6832 |
"access the displays resource database for a default value |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6833 |
of name in a resource class. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6834 |
This is highly X specific and currently not used. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6835 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6836 |
Notice: |
850 | 6837 |
we do not plan to use X's resources for ST/X's defaults, |
6838 |
styles or resources. This would make porting of applications |
|
6839 |
to different platforms much more difficult (Windows has no resource |
|
6840 |
database). If you stay within ST/X's resource files, these can be |
|
6841 |
easily transported to other platforms. |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6842 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6843 |
This method is provided for special applications which want to access |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6844 |
existing X resources and are not planned to be ever ported to other |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6845 |
platforms." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6846 |
|
295 | 6847 |
%{ |
6848 |
char *rslt; |
|
6849 |
||
6850 |
if ((__isString(name) || __isSymbol(name)) |
|
6851 |
&& (__isString(cls) || __isSymbol(cls)) |
|
6852 |
&& ISCONNECTED) { |
|
850 | 6853 |
BEGIN_INTERRUPTSBLOCKED |
6854 |
rslt = XGetDefault(myDpy, (char *)_stringVal(cls), |
|
6855 |
(char *)_stringVal(name)); |
|
6856 |
END_INTERRUPTSBLOCKED |
|
6857 |
RETURN (rslt ? __MKSTRING(rslt COMMA_CON) : nil ); |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6858 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6859 |
%}. |
295 | 6860 |
self primitiveFailed. |
6861 |
^ nil |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6862 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6863 |
"if your ~/.Xdefaults contains an entry such as: |
850 | 6864 |
OpenWindows.Beep: notices |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6865 |
the following returns 'notices'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6866 |
|
850 | 6867 |
Display getResource:'Beep' class:'OpenWindows' |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6868 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6869 |
if your ~/.Xdefaults contains an entry such as: |
850 | 6870 |
*.beNiceToColormap: false |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6871 |
the following return 'false'. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6872 |
|
850 | 6873 |
Display getResource:'beNiceToColormap' class:'any' |
6874 |
Display getResource:'beNiceToColormap' class:'' |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6875 |
" |
295 | 6876 |
! ! |
6877 |
||
6878 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
6879 |
||
6880 |
getBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
|
6881 |
"get bits from a drawable into the imageBits. The storage for the bits |
|
6882 |
must be big enough for the data to fit. If ok, returns an array with some |
|
6883 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
6884 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
6885 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
6886 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6887 |
|rawInfo info| |
295 | 6888 |
|
6889 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
6890 |
self primitiveFailed. |
|
6891 |
^ nil |
|
6892 |
]. |
|
6893 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6894 |
rawInfo := Array new:8. |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6895 |
"1 -> bit order" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6896 |
"2 -> depth" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6897 |
"3 -> bytes_per_line" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6898 |
"4 -> byte_order" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6899 |
"5 -> format" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6900 |
"6 -> bitmap_unit" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6901 |
"7 -> bitmap_pad" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6902 |
"8 -> bits_per_pixel" |
295 | 6903 |
|
6904 |
"/ had to extract the getPixel call into a separate method, to specify |
|
6905 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
6906 |
"/ of temporary stack space |
|
6907 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6908 |
(self primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:rawInfo) ifTrue:[ |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6909 |
info := IdentityDictionary new. |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6910 |
info at:#bitOrder put:(rawInfo at:1). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6911 |
info at:#depth put:(rawInfo at:2). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6912 |
info at:#bytesPerLine put:(rawInfo at:3). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6913 |
info at:#byteOrder put:(rawInfo at:4). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6914 |
info at:#format put:(rawInfo at:5). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6915 |
info at:#bitmapUnit put:(rawInfo at:6). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6916 |
info at:#bitmapPad put:(rawInfo at:7). |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6917 |
info at:#bitsPerPixel put:(rawInfo at:8). |
295 | 6918 |
^ info |
6919 |
]. |
|
6920 |
" |
|
6921 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
6922 |
or is too small to hold the bits |
|
6923 |
" |
|
6924 |
^ self primitiveFailed |
|
6925 |
! |
|
6926 |
||
6927 |
getPixelX:x y:y from:aDrawableId |
|
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6928 |
"return the pixel value at x/y; coordinates start at 0/0 for the upper left. |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6929 |
Nil is returned for invalid coordinates or if any other problem arises." |
295 | 6930 |
|
6931 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
|
6932 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6933 |
Window win; |
295 | 6934 |
XImage *img; |
6935 |
int ret; |
|
6936 |
int xpos, ypos; |
|
6937 |
||
6938 |
if (__isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
|
850 | 6939 |
win = _WindowVal(aDrawableId); |
6940 |
xpos = __intVal(x); |
|
6941 |
ypos = __intVal(y); |
|
6942 |
if ((xpos < 0) || (ypos < 0)) { |
|
6943 |
RETURN ( __MKSMALLINT(0) ); |
|
6944 |
} |
|
6945 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
|
6946 |
if (img != 0) { |
|
6947 |
ret = XGetPixel(img, 0, 0); |
|
6948 |
XDestroyImage(img); |
|
6949 |
RETURN ( __MKSMALLINT(ret) ); |
|
6950 |
} |
|
295 | 6951 |
} |
6952 |
%}. |
|
6953 |
^ nil |
|
6954 |
! |
|
6955 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6956 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
295 | 6957 |
"since XGetImage may allocate huge amount of stack space |
6958 |
(some implementations use alloca), this must run with unlimited stack." |
|
6959 |
||
6960 |
%{ /* UNLIMITEDSTACK */ |
|
6961 |
||
6962 |
Display *dpy = myDpy; |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6963 |
Window win; |
295 | 6964 |
XImage *image = (XImage *)0; |
6965 |
int pad, bytes_per_line, numBytes; |
|
6966 |
||
6967 |
if (__isExternalAddress(aDrawableId) |
|
6968 |
&& __bothSmallInteger(srcx, srcy) |
|
6969 |
&& __bothSmallInteger(w, h) |
|
6970 |
&& __isArray(info) |
|
6971 |
&& __isByteArray(imageBits)) { |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6972 |
win = _WindowVal(aDrawableId); |
555 | 6973 |
image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy), |
6974 |
__intVal(w), __intVal(h), |
|
295 | 6975 |
(unsigned)AllPlanes, ZPixmap); |
6976 |
||
378 | 6977 |
if (! image) { |
6978 |
RETURN ( false ); |
|
6979 |
} |
|
6980 |
||
295 | 6981 |
pad = image->bitmap_pad; |
6982 |
#ifdef SUPERDEBUG |
|
6983 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
|
6984 |
#endif |
|
6985 |
switch (image->depth) { |
|
6986 |
case 1: |
|
6987 |
case 2: |
|
6988 |
case 4: |
|
6989 |
case 8: |
|
6990 |
case 16: |
|
6991 |
case 24: |
|
6992 |
case 32: |
|
6993 |
numBytes = image->bytes_per_line * image->height; |
|
6994 |
break; |
|
6995 |
default: |
|
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6996 |
/* unsupported depth ? */ |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6997 |
printf("possibly unsupported depth:%d in primGetBits\n", image->depth); |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6998 |
numBytes = image->bytes_per_line * image->height; |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6999 |
break; |
295 | 7000 |
} |
7001 |
||
7002 |
#ifdef SUPERDEBUG |
|
555 | 7003 |
printf("bytes need:%d bytes given:%d\n", numBytes, __byteArraySize(imageBits)); |
295 | 7004 |
#endif |
7005 |
||
555 | 7006 |
if (numBytes > __byteArraySize(imageBits)) { |
295 | 7007 |
/* imageBits too small */ |
378 | 7008 |
printf("provided byteArray too small\n"); |
295 | 7009 |
goto fail; |
7010 |
} |
|
7011 |
if (image->bitmap_bit_order == MSBFirst) |
|
555 | 7012 |
__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
295 | 7013 |
else |
555 | 7014 |
__ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
7015 |
__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth); |
|
7016 |
__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line); |
|
295 | 7017 |
if (image->byte_order == MSBFirst) |
555 | 7018 |
__ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
295 | 7019 |
else |
555 | 7020 |
__ArrayInstPtr(info)->a_element[3] = @symbol(lsbFirst); |
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7021 |
if (image->format == XYBitmap) |
555 | 7022 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYBitmap); |
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7023 |
else if (image->format == XYPixmap) |
555 | 7024 |
__ArrayInstPtr(info)->a_element[4] = @symbol(XYPixmap); |
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
7025 |
else if (image->format == ZPixmap) |
555 | 7026 |
__ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7027 |
|
555 | 7028 |
__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit); |
7029 |
__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad); |
|
7030 |
__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel); |
|
7031 |
bcopy(image->data, __ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
|
295 | 7032 |
XDestroyImage(image); |
7033 |
RETURN ( true ); |
|
7034 |
} |
|
7035 |
fail: |
|
7036 |
if (image) { |
|
7037 |
XDestroyImage(image); |
|
7038 |
} |
|
7039 |
%}. |
|
7040 |
^ false |
|
7041 |
! ! |
|
7042 |
||
7043 |
!XWorkstation methodsFor:'selections'! |
|
7044 |
||
7045 |
getObjectProperty:propertyID from:aWindowID |
|
7046 |
"get an object property; return object or nil" |
|
7047 |
||
7048 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
7049 |
type == stringAtom ifTrue:[ |
|
7050 |
^ value |
|
7051 |
]. |
|
7052 |
(value isMemberOf:ByteArray) ifTrue:[ |
|
7053 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
|
7054 |
] |
|
7055 |
]. |
|
7056 |
^ nil |
|
7057 |
! |
|
7058 |
||
7059 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
|
7060 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
|
7061 |
||
7062 |
|val typeID cls| |
|
7063 |
||
7064 |
cls := ByteArray. |
|
7065 |
%{ |
|
7066 |
Display *dpy = myDpy; |
|
7067 |
Window window; |
|
7068 |
Atom property; |
|
7069 |
char *cp, *cp2; |
|
7070 |
Atom actual_type; |
|
7071 |
int actual_format,i; |
|
7072 |
unsigned long nitems, bytes_after, nread; |
|
7073 |
unsigned char *data; |
|
7074 |
int ok = 1; |
|
7075 |
# define PROP_SIZE 2048 |
|
7076 |
||
7077 |
if (__isAtomID(propertyID)) { |
|
7078 |
property = _AtomVal(propertyID); |
|
7079 |
if (__isExternalAddress(aWindowID)) { |
|
7080 |
window = _WindowVal(aWindowID); |
|
7081 |
} else { |
|
7082 |
window = DefaultRootWindow(dpy); |
|
7083 |
} |
|
7084 |
||
7085 |
nread = 0; |
|
7086 |
cp = 0; |
|
7087 |
/* |
|
7088 |
fprintf(stderr, "getProperty: "); |
|
7089 |
*/ |
|
7090 |
do { |
|
7091 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
7092 |
AnyPropertyType,&actual_type,&actual_format, |
|
7093 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
7094 |
!= Success) { |
|
7095 |
ok = 0; |
|
7096 |
break; |
|
7097 |
} |
|
7098 |
typeID = __MKATOMOBJ(actual_type); |
|
7099 |
if (! cp) { |
|
7100 |
cp = cp2 = (char *)malloc(nitems+1); |
|
7101 |
} else { |
|
7102 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
7103 |
cp2 = cp + nread; |
|
7104 |
} |
|
7105 |
if (! cp) goto fail; |
|
7106 |
||
7107 |
nread += nitems; |
|
7108 |
bcopy(data, cp2, nitems); |
|
7109 |
XFree(data); |
|
7110 |
/* |
|
7111 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
|
7112 |
*/ |
|
7113 |
} while (bytes_after > 0); |
|
7114 |
/* |
|
7115 |
fprintf(stderr, "\n"); |
|
7116 |
*/ |
|
7117 |
||
7118 |
if (ok) { |
|
7119 |
if (actual_type == XA_STRING) { |
|
7120 |
cp[nread] = '\0'; |
|
7121 |
val = __MKSTRING_L(cp, nread COMMA_CON); |
|
7122 |
} else { |
|
7123 |
val = __new(nread + OHDR_SIZE); |
|
7124 |
val->o_class = cls; |
|
555 | 7125 |
bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread); |
295 | 7126 |
} |
7127 |
} |
|
7128 |
if (cp) |
|
7129 |
free(cp); |
|
7130 |
} |
|
7131 |
fail: ; |
|
7132 |
%}. |
|
7133 |
typeID isNil ifTrue:[ |
|
7134 |
^ false |
|
7135 |
]. |
|
7136 |
aTwoArgBlock value:typeID value:val. |
|
7137 |
^ true |
|
7138 |
! |
|
7139 |
||
7140 |
getSelectionFor:drawableId |
|
7141 |
"get the object selection - either immediate, or asynchronous. |
|
7142 |
Returns nil, if async request is on its way" |
|
7143 |
||
7144 |
|selProp sel| |
|
7145 |
||
7146 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
7147 |
"no primary selection - use cut buffer" |
|
7148 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
|
7149 |
^ sel |
|
7150 |
]. |
|
7151 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
7152 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
|
7153 |
^ nil |
|
7154 |
! |
|
7155 |
||
7156 |
getSelectionOwnerOf:selectionAtomID |
|
7157 |
"get the owner of a selection" |
|
7158 |
||
7159 |
%{ /* NOCONTEXT */ |
|
7160 |
Display *dpy = myDpy; |
|
7161 |
Atom selection; |
|
7162 |
Window window; |
|
7163 |
||
7164 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
|
7165 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
|
7166 |
RETURN ((window == None) ? nil : __MKOBJ(window)); |
|
7167 |
} |
|
7168 |
%}. |
|
7169 |
self primitiveFailed. |
|
7170 |
^ nil |
|
7171 |
! |
|
7172 |
||
7173 |
getTextProperty:propertyID from:aWindowID |
|
7174 |
"get a text property; return string or nil" |
|
7175 |
||
7176 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
7177 |
type == stringAtom ifTrue:[ |
|
7178 |
^ value |
|
7179 |
] |
|
7180 |
]. |
|
7181 |
^ nil |
|
7182 |
! |
|
7183 |
||
7184 |
getTextSelectionFor:drawableId |
|
7185 |
"get the text selection - either immediate, or asynchronous. |
|
7186 |
Returns nil, if async request is on its way" |
|
7187 |
||
7188 |
|selProp sel| |
|
7189 |
||
7190 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
7191 |
"no primary selection - use cut buffer" |
|
7192 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
|
7193 |
^ sel |
|
7194 |
]. |
|
7195 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
|
7196 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
7197 |
^ nil |
|
7198 |
! |
|
7199 |
||
7200 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
|
7201 |
"ask the server to send us the selection - the view with ID aWindowID |
|
7202 |
will later receive a SelectionNotify event for it." |
|
7203 |
||
7204 |
^ self requestSelection:selectionID |
|
7205 |
property:propertyID |
|
7206 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7207 |
for:aWindowId |
|
7208 |
! |
|
7209 |
||
7210 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
7211 |
"ask the server to send us the selection - the view with id aWindowID |
|
7212 |
will later receive a SelectionNotify event for it (once the Xserver replies |
|
7213 |
with the selections value)." |
|
7214 |
||
7215 |
%{ /* NOCONTEXT */ |
|
7216 |
Display *dpy = myDpy; |
|
7217 |
Atom sel_prop; |
|
7218 |
char *cp; |
|
7219 |
||
7220 |
if (__isExternalAddress(aWindowId) |
|
7221 |
&& ISCONNECTED |
|
7222 |
&& __isSmallInteger(typeID) |
|
7223 |
&& __isAtomID(selectionID)) { |
|
7224 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
|
7225 |
/* |
|
7226 |
* no owner of primary selection |
|
7227 |
*/ |
|
7228 |
RETURN (false); |
|
7229 |
} |
|
7230 |
/* |
|
7231 |
* PRIMARY selection |
|
7232 |
*/ |
|
7233 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
7234 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
7235 |
RETURN (true); |
|
7236 |
} |
|
7237 |
%}. |
|
7238 |
self primitiveFailed. |
|
7239 |
^ false |
|
7240 |
||
7241 |
" |
|
7242 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
7243 |
property:(Display atomIDOf:'VT_SELECTION') |
|
7244 |
for:0 |
|
7245 |
" |
|
7246 |
! |
|
7247 |
||
7248 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
|
7249 |
"ask the server to send us the selection - the view with ID aWindowID |
|
7250 |
will later receive a SelectionNotify event for it." |
|
7251 |
||
7252 |
^ self requestSelection:selectionID |
|
7253 |
property:propertyID |
|
7254 |
type:stringAtom |
|
7255 |
for:aWindowId |
|
7256 |
! |
|
7257 |
||
7258 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
|
7259 |
"send aString back from a SelectionRequest" |
|
7260 |
||
7261 |
self |
|
7262 |
sendSelection:something |
|
7263 |
selection:primaryAtom |
|
7264 |
property:propertyID |
|
7265 |
target:targetID |
|
7266 |
from:windowID |
|
7267 |
to:requestorID |
|
7268 |
! |
|
7269 |
||
7270 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
7271 |
"send aString back from a SelectionRequest" |
|
7272 |
||
7273 |
self |
|
7274 |
setProperty:propertyID |
|
7275 |
type:targetID |
|
7276 |
value:something |
|
7277 |
for:requestorID. |
|
7278 |
self |
|
7279 |
sendSelectionNotifySelection:selectionID |
|
7280 |
property:propertyID |
|
7281 |
target:targetID |
|
7282 |
from:requestorID |
|
7283 |
to:requestorID. |
|
7284 |
! |
|
7285 |
||
7286 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
7287 |
"send a selectionNotify back from a SelectionRequest" |
|
7288 |
||
7289 |
%{ /* NOCONTEXT */ |
|
7290 |
Display *dpy = myDpy; |
|
7291 |
||
7292 |
if (__isAtomID(propertyID) |
|
7293 |
&& __isExternalAddress(requestorID) |
|
7294 |
&& ISCONNECTED |
|
7295 |
&& __isAtomID(targetID) |
|
7296 |
&& __isAtomID(selectionID)) { |
|
7297 |
XEvent ev; |
|
7298 |
Window requestor = _WindowVal(requestorID); |
|
7299 |
Atom property = _AtomVal(propertyID); |
|
7300 |
Atom target = _AtomVal(targetID); |
|
7301 |
Atom selection = _AtomVal(selectionID); |
|
7302 |
Status result; |
|
7303 |
||
7304 |
ev.xselection.type = SelectionNotify; |
|
7305 |
ev.xselection.selection = selection; |
|
7306 |
ev.xselection.target = target; |
|
7307 |
if (__isExternalAddress(windowID)) |
|
7308 |
ev.xselection.requestor = _WindowVal(windowID); |
|
7309 |
else |
|
7310 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
7311 |
ev.xselection.time = CurrentTime; |
|
7312 |
if (property == None) |
|
7313 |
ev.xselection.property = target; |
|
7314 |
else |
|
7315 |
ev.xselection.property = property; |
|
7316 |
||
7317 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
7318 |
ev.xselection.selection, |
|
7319 |
ev.xselection.property, |
|
7320 |
ev.xselection.target, |
|
7321 |
ev.xselection.requestor, |
|
7322 |
requestor)); |
|
7323 |
||
7324 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
7325 |
if ((result == BadValue) || (result == BadWindow)) { |
|
7326 |
DPRINTF(("bad status\n")); |
|
382 | 7327 |
RETURN (false); |
295 | 7328 |
} |
382 | 7329 |
RETURN (true) |
7330 |
} |
|
7331 |
%}. |
|
7332 |
self primitiveFailed. |
|
7333 |
^ false |
|
295 | 7334 |
! |
7335 |
||
7336 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
|
7337 |
^ self setProperty:propertyID type:(self atomIDOfLENGTH) value:aNumber for:aWindowID |
|
7338 |
! |
|
7339 |
||
7340 |
setObjectProperty:propertyID value:anObject for:aWindowID |
|
7341 |
|s| |
|
7342 |
||
7343 |
(anObject isMemberOf:String) ifTrue:[ |
|
7344 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
|
7345 |
]. |
|
7346 |
s := WriteStream on:(ByteArray new:200). |
|
7347 |
anObject storeBinaryOn:s. |
|
7348 |
^ self |
|
7349 |
setProperty:propertyID |
|
7350 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7351 |
value:(s contents) |
|
7352 |
for:aWindowID |
|
7353 |
! |
|
7354 |
||
7355 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
7356 |
||
7357 |
%{ /* UNLIMITEDSTACK */ |
|
7358 |
||
7359 |
Display *dpy = myDpy; |
|
7360 |
Atom prop, type; |
|
7361 |
Window window; |
|
7362 |
unsigned int value; |
|
7363 |
||
7364 |
if (__isAtomID(propertyID) |
|
7365 |
&& __isAtomID(typeID) |
|
7366 |
&& ISCONNECTED |
|
7367 |
&& (__isString(anObject) |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7368 |
|| __isSmallInteger(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7369 |
|| __isSymbol(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7370 |
|| __isByteArray(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7371 |
|| __isWords(anObject))) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7372 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7373 |
prop = _AtomVal(propertyID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7374 |
type = _AtomVal(typeID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7375 |
if (__isExternalAddress(aWindowID)) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7376 |
window = _WindowVal(aWindowID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7377 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7378 |
window = DefaultRootWindow(dpy); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7379 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7380 |
if (__isSmallInteger(anObject)) { |
555 | 7381 |
value = __intVal(anObject); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7382 |
XChangeProperty(dpy, window, prop, type, 32, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7383 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7384 |
(unsigned char *)(&value), sizeof(unsigned int)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7385 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7386 |
if (__isByteArray(anObject)) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7387 |
XChangeProperty(dpy, window, prop, type, 8, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7388 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7389 |
__ByteArrayInstPtr(anObject)->ba_element, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7390 |
__byteArraySize(anObject)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7391 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7392 |
/* string or symbol or wordArray-like (16bit-string) object */ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7393 |
if (__isWords(__qClass(anObject))) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7394 |
XChangeProperty(dpy, window, prop, XA_STRING, 16, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7395 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7396 |
__stringVal(anObject), |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7397 |
__wordArraySize(anObject)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7398 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7399 |
XChangeProperty(dpy, window, prop, XA_STRING, 8, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7400 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7401 |
__stringVal(anObject), |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7402 |
strlen(__stringVal(anObject))); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7403 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7404 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7405 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7406 |
RETURN (true); |
295 | 7407 |
} |
7408 |
%}. |
|
7409 |
^ false |
|
7410 |
! |
|
7411 |
||
7412 |
setSelection:anObject owner:aWindowId |
|
7413 |
"set the object selection, and make aWindowId be the owner. |
|
7414 |
This can be used by other Smalltalk(X) applications only." |
|
7415 |
||
7416 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
7417 |
^ false |
|
7418 |
]. |
|
7419 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
|
7420 |
^ true |
|
7421 |
! |
|
7422 |
||
7423 |
setSelectionOwner:aWindowId of:selectionID |
|
7424 |
"set the owner of a selection; return false if failed" |
|
7425 |
||
7426 |
%{ /* NOCONTEXT */ |
|
7427 |
Display *dpy = myDpy; |
|
7428 |
Window win; |
|
7429 |
||
7430 |
if (__isExternalAddress(aWindowId) |
|
7431 |
&& __isAtomID(selectionID) |
|
7432 |
&& ISCONNECTED) { |
|
7433 |
win = _WindowVal(aWindowId); |
|
7434 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
|
7435 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
|
7436 |
RETURN (false); |
|
7437 |
} |
|
7438 |
RETURN (true); |
|
7439 |
} |
|
7440 |
%} |
|
7441 |
. |
|
7442 |
self primitiveFailed. |
|
7443 |
^ nil |
|
7444 |
! |
|
7445 |
||
7446 |
setTextProperty:propertyID value:aString for:aWindowID |
|
7447 |
^ self setProperty:propertyID type:(self atomIDOfSTRING) value:aString for:aWindowID |
|
7448 |
! |
|
7449 |
||
7450 |
setTextSelection:aString owner:aWindowId |
|
7451 |
"set the text selection, and make aWindowId be the owner. |
|
7452 |
This can be used by any other X application." |
|
7453 |
||
7454 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
7455 |
'ownerchange failed' errorPrintNL. |
|
7456 |
]. |
|
7457 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
|
7458 |
! ! |
|
7459 |
||
7460 |
!XWorkstation methodsFor:'window stuff'! |
|
7461 |
||
7462 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
|
7463 |
"clear a rectangular area to viewbackground" |
|
7464 |
||
7465 |
%{ /* NOCONTEXT */ |
|
7466 |
||
7467 |
int w, h; |
|
7468 |
||
7469 |
if (__isExternalAddress(aWindowId) |
|
7470 |
&& __bothSmallInteger(x, y) |
|
7471 |
&& __bothSmallInteger(width, height)) { |
|
555 | 7472 |
w = __intVal(width); |
7473 |
h = __intVal(height); |
|
295 | 7474 |
if (w < 0) w = 0; |
7475 |
if (h < 0) h = 0; |
|
555 | 7476 |
XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0); |
295 | 7477 |
RETURN ( self ); |
7478 |
} |
|
7479 |
%} |
|
7480 |
. |
|
7481 |
self primitiveFailed |
|
7482 |
! |
|
7483 |
||
7484 |
clearWindow:aWindowId |
|
7485 |
"clear a window to viewbackground" |
|
7486 |
||
7487 |
%{ /* NOCONTEXT */ |
|
7488 |
||
7489 |
if (__isExternalAddress(aWindowId)) { |
|
7490 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
|
7491 |
RETURN ( self ); |
|
7492 |
} |
|
7493 |
%} |
|
7494 |
. |
|
7495 |
self primitiveFailed |
|
7496 |
! |
|
7497 |
||
7498 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
|
7499 |
"configure stacking operation of aWindowId w.r.t siblingId" |
|
7500 |
||
7501 |
%{ /* NOCONTEXT */ |
|
7502 |
||
7503 |
XWindowChanges chg; |
|
7504 |
int mask = CWSibling | CWStackMode; |
|
7505 |
||
7506 |
if (__isExternalAddress(aWindowId) |
|
7507 |
&& __isExternalAddress(siblingId)) { |
|
7508 |
if (modeSymbol == @symbol(above)) { |
|
7509 |
chg.stack_mode = Above; |
|
7510 |
} else if (modeSymbol == @symbol(below)) { |
|
7511 |
chg.stack_mode = Below; |
|
7512 |
} else if (modeSymbol == @symbol(topIf)) { |
|
7513 |
chg.stack_mode = TopIf; |
|
7514 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
7515 |
chg.stack_mode = BottomIf; |
|
7516 |
} else if (modeSymbol == @symbol(opposite)) { |
|
7517 |
chg.stack_mode = Opposite; |
|
7518 |
} else { |
|
7519 |
mask = CWSibling; |
|
7520 |
} |
|
7521 |
||
7522 |
chg.sibling = _WindowVal(siblingId); |
|
7523 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
|
7524 |
mask, &chg); |
|
7525 |
RETURN ( self ); |
|
7526 |
} |
|
7527 |
bad: ; |
|
7528 |
%} |
|
7529 |
. |
|
7530 |
self primitiveFailed |
|
7531 |
! |
|
7532 |
||
7533 |
lowerWindow:aWindowId |
|
7534 |
"bring a window to back" |
|
7535 |
||
7536 |
%{ /* NOCONTEXT */ |
|
7537 |
||
7538 |
if (__isExternalAddress(aWindowId)) { |
|
7539 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
|
7540 |
RETURN ( self ); |
|
7541 |
} |
|
7542 |
%} |
|
7543 |
. |
|
7544 |
self primitiveFailed |
|
7545 |
! |
|
7546 |
||
7547 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
|
7548 |
"make a window visible - either as icon or as a real view - needed for restart" |
|
7549 |
||
7550 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
7551 |
||
7552 |
aBoolean ifTrue:[ |
|
7553 |
wicon := aView icon. |
|
7554 |
wicon notNil ifTrue:[ |
|
7555 |
wiconId := wicon id |
|
7556 |
]. |
|
7557 |
wiconView := aView iconView. |
|
7558 |
wiconView notNil ifTrue:[ |
|
7559 |
wiconViewId := wiconView id |
|
7560 |
]. |
|
7561 |
wlabel := aView label. |
|
7562 |
]. |
|
7563 |
%{ |
|
7564 |
||
7565 |
XWMHints wmhints; |
|
7566 |
XSizeHints szhints; |
|
7567 |
Display *dpy = myDpy; |
|
7568 |
Window win; |
|
7569 |
||
7570 |
if (__isExternalAddress(aWindowId)) { |
|
7571 |
win = _WindowVal(aWindowId); |
|
7572 |
||
7573 |
szhints.flags = 0; |
|
7574 |
if (__bothSmallInteger(xPos, yPos)) { |
|
555 | 7575 |
szhints.x = __intVal(xPos); |
7576 |
szhints.y = __intVal(yPos); |
|
295 | 7577 |
szhints.flags |= USPosition; |
7578 |
} |
|
7579 |
if (__bothSmallInteger(w, h)) { |
|
555 | 7580 |
szhints.width = __intVal(w); |
7581 |
szhints.height = __intVal(h); |
|
295 | 7582 |
szhints.flags |= USSize; |
7583 |
} |
|
7584 |
||
7585 |
if (aBoolean == true) { |
|
7586 |
char *windowName; |
|
7587 |
Pixmap iconBitmap = (Pixmap)0; |
|
7588 |
Window iconWindow; |
|
7589 |
||
7590 |
if (__isExternalAddress(wiconId)) |
|
7591 |
iconBitmap = _PixmapVal(wiconId); |
|
7592 |
else |
|
7593 |
iconBitmap = (Pixmap)0; |
|
7594 |
||
7595 |
if (__isExternalAddress(wiconViewId)) |
|
7596 |
iconWindow = _WindowVal(wiconViewId); |
|
7597 |
else |
|
7598 |
iconWindow = (Window)0; |
|
7599 |
||
7600 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
7601 |
windowName = (char *)_stringVal(wlabel); |
|
7602 |
else |
|
7603 |
windowName = ""; |
|
7604 |
||
7605 |
if (iconBitmap || windowName) { |
|
7606 |
XSetStandardProperties(dpy, win, |
|
7607 |
windowName, windowName, |
|
7608 |
iconBitmap, |
|
7609 |
0, 0, &szhints); |
|
7610 |
} |
|
7611 |
||
7612 |
wmhints.flags = 0; |
|
7613 |
if (iconBitmap) { |
|
7614 |
wmhints.flags |= IconPixmapHint; |
|
7615 |
wmhints.icon_pixmap = iconBitmap; |
|
7616 |
} |
|
7617 |
if (iconWindow) { |
|
7618 |
wmhints.flags |= IconWindowHint; |
|
7619 |
wmhints.icon_window = iconWindow; |
|
7620 |
} |
|
7621 |
||
7622 |
wmhints.initial_state = IconicState; |
|
7623 |
wmhints.flags |= StateHint; |
|
7624 |
XSetWMHints(dpy, win, &wmhints); |
|
7625 |
} |
|
7626 |
||
7627 |
if (szhints.flags) { |
|
7628 |
XSetNormalHints(dpy, win, &szhints); |
|
7629 |
} |
|
7630 |
||
7631 |
XMapWindow(dpy, win); |
|
7632 |
RETURN ( self ); |
|
7633 |
} |
|
7634 |
%} |
|
7635 |
. |
|
7636 |
self primitiveFailed |
|
7637 |
! |
|
7638 |
||
7639 |
mapWindow:aWindowId |
|
7640 |
"make a window visible" |
|
7641 |
||
7642 |
%{ /* NOCONTEXT */ |
|
7643 |
||
7644 |
if (__isExternalAddress(aWindowId)) { |
|
7645 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
|
7646 |
RETURN ( self ); |
|
7647 |
} |
|
7648 |
%} |
|
7649 |
. |
|
7650 |
self primitiveFailed |
|
7651 |
! |
|
7652 |
||
7653 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
|
7654 |
"move and resize a window" |
|
7655 |
||
7656 |
%{ /* NOCONTEXT */ |
|
7657 |
||
7658 |
int newWidth, newHeight; |
|
7659 |
||
7660 |
if (__isExternalAddress(aWindowId) |
|
7661 |
&& __bothSmallInteger(w, h) |
|
7662 |
&& __bothSmallInteger(x, y)) { |
|
555 | 7663 |
newWidth = __intVal(w); |
7664 |
newHeight = __intVal(h); |
|
295 | 7665 |
if (newWidth < 1) newWidth = 1; |
7666 |
if (newHeight < 1) newHeight = 1; |
|
7667 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
|
555 | 7668 |
__intVal(x), __intVal(y), |
295 | 7669 |
newWidth, newHeight); |
7670 |
RETURN ( self ); |
|
7671 |
} |
|
7672 |
%} |
|
7673 |
. |
|
7674 |
self primitiveFailed |
|
7675 |
! |
|
7676 |
||
7677 |
moveWindow:aWindowId x:x y:y |
|
7678 |
"move a window" |
|
7679 |
||
7680 |
%{ /* NOCONTEXT */ |
|
7681 |
||
7682 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
|
555 | 7683 |
XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y)); |
295 | 7684 |
RETURN ( self ); |
7685 |
} |
|
7686 |
%} |
|
7687 |
. |
|
7688 |
self primitiveFailed |
|
7689 |
! |
|
7690 |
||
7691 |
raiseWindow:aWindowId |
|
7692 |
"bring a window to front" |
|
7693 |
||
7694 |
%{ /* NOCONTEXT */ |
|
7695 |
||
7696 |
if (__isExternalAddress(aWindowId)) { |
|
7697 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
|
7698 |
RETURN ( self ); |
|
7699 |
} |
|
7700 |
%} |
|
7701 |
. |
|
7702 |
self primitiveFailed |
|
7703 |
! |
|
7704 |
||
7705 |
resizeWindow:aWindowId width:w height:h |
|
7706 |
"resize a window" |
|
7707 |
||
7708 |
%{ /* NOCONTEXT */ |
|
7709 |
||
7710 |
int newWidth, newHeight; |
|
7711 |
||
7712 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
|
555 | 7713 |
newWidth = __intVal(w); |
7714 |
newHeight = __intVal(h); |
|
295 | 7715 |
if (newWidth < 1) newWidth = 1; |
7716 |
if (newHeight < 1) newHeight = 1; |
|
7717 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
|
7718 |
RETURN ( self ); |
|
7719 |
} |
|
7720 |
%} |
|
7721 |
. |
|
7722 |
self primitiveFailed |
|
7723 |
! |
|
7724 |
||
7725 |
setBackingStore:how in:aWindowId |
|
7726 |
"turn on/off backing-store for a window" |
|
7727 |
||
7728 |
%{ /* NOCONTEXT */ |
|
7729 |
||
7730 |
XSetWindowAttributes wa; |
|
7731 |
||
7732 |
if (__isExternalAddress(aWindowId)) { |
|
555 | 7733 |
if (__INST(ignoreBackingStore) != true) { |
295 | 7734 |
if (how == @symbol(always)) wa.backing_store = Always; |
7735 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
7736 |
else if (how == true) wa.backing_store = Always; |
|
7737 |
else wa.backing_store = 0; |
|
7738 |
BEGIN_INTERRUPTSBLOCKED |
|
7739 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
|
7740 |
END_INTERRUPTSBLOCKED |
|
7741 |
} |
|
7742 |
RETURN ( self ); |
|
7743 |
} |
|
7744 |
%}. |
|
7745 |
self primitiveFailed |
|
7746 |
! |
|
7747 |
||
7748 |
setBitGravity:how in:aWindowId |
|
7749 |
"set bit gravity for a window" |
|
7750 |
||
7751 |
%{ /* NOCONTEXT */ |
|
7752 |
||
7753 |
XSetWindowAttributes wa; |
|
7754 |
||
7755 |
if (__isExternalAddress(aWindowId)) { |
|
7756 |
if (how == @symbol(NorthWest)) { |
|
7757 |
wa.bit_gravity = NorthWestGravity; |
|
7758 |
} else if (how == @symbol(NorthEast)) { |
|
7759 |
wa.bit_gravity = NorthEastGravity; |
|
7760 |
} else if (how == @symbol(SouthWest)) { |
|
7761 |
wa.bit_gravity = SouthWestGravity; |
|
7762 |
} else if (how == @symbol(SouthEast)) { |
|
7763 |
wa.bit_gravity = SouthEastGravity; |
|
7764 |
} else if (how == @symbol(Center)) { |
|
7765 |
wa.bit_gravity = CenterGravity; |
|
7766 |
} else if (how == @symbol(North)) { |
|
7767 |
wa.bit_gravity = NorthGravity; |
|
7768 |
} else if (how == @symbol(South)) { |
|
7769 |
wa.bit_gravity = SouthGravity; |
|
7770 |
} else if (how == @symbol(West)) { |
|
7771 |
wa.bit_gravity = WestGravity; |
|
7772 |
} else if (how == @symbol(East)) { |
|
7773 |
wa.bit_gravity = EastGravity; |
|
7774 |
} else { |
|
7775 |
wa.bit_gravity = NorthWestGravity; |
|
7776 |
} |
|
7777 |
||
7778 |
BEGIN_INTERRUPTSBLOCKED |
|
7779 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
|
7780 |
END_INTERRUPTSBLOCKED |
|
7781 |
RETURN ( self ); |
|
7782 |
} |
|
7783 |
%}. |
|
7784 |
self primitiveFailed |
|
7785 |
! |
|
7786 |
||
7787 |
setCursor:aCursorId in:aWindowId |
|
7788 |
"define a windows cursor" |
|
7789 |
||
7790 |
%{ /* NOCONTEXT */ |
|
7791 |
||
7792 |
Display *dpy = myDpy; |
|
7793 |
||
7794 |
if (__isExternalAddress(aWindowId) |
|
7795 |
&& __isExternalAddress(aCursorId)) { |
|
7796 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
|
7797 |
RETURN ( self ); |
|
7798 |
} |
|
7799 |
%}. |
|
7800 |
self primitiveFailed |
|
7801 |
! |
|
7802 |
||
7803 |
setIconName:aString in:aWindowId |
|
7804 |
"define a windows iconname" |
|
7805 |
||
7806 |
%{ /* NOCONTEXT */ |
|
7807 |
||
7808 |
if (__isExternalAddress(aWindowId) |
|
7809 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
7810 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
|
7811 |
RETURN ( self ); |
|
7812 |
} |
|
7813 |
%}. |
|
7814 |
self primitiveFailed |
|
7815 |
! |
|
7816 |
||
7817 |
setSaveUnder:yesOrNo in:aWindowId |
|
7818 |
"turn on/off save-under for a window" |
|
7819 |
||
7820 |
%{ /* NOCONTEXT */ |
|
7821 |
||
7822 |
XSetWindowAttributes wa; |
|
7823 |
||
7824 |
if (__isExternalAddress(aWindowId)) { |
|
555 | 7825 |
if (__INST(hasSaveUnder) == true) { |
295 | 7826 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
7827 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
|
7828 |
} |
|
7829 |
RETURN ( self ); |
|
7830 |
} |
|
7831 |
%}. |
|
7832 |
self primitiveFailed |
|
7833 |
! |
|
7834 |
||
7835 |
setTransient:aWindowId for:aMainWindowId |
|
7836 |
"set aWindowId to be a transient of aMainWindow" |
|
7837 |
||
7838 |
%{ /* NOCONTEXT */ |
|
7839 |
||
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7840 |
if (__isExternalAddress(aWindowId)) { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7841 |
Window w; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7842 |
|
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7843 |
if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7844 |
w = (Window) 0; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7845 |
} else { |
374 | 7846 |
if (__isExternalAddress(aMainWindowId)) { |
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7847 |
w = _WindowVal(aMainWindowId); |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7848 |
} else { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7849 |
goto getOutOfHere; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7850 |
} |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7851 |
} |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7852 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), w); |
295 | 7853 |
RETURN ( self ); |
7854 |
} |
|
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7855 |
getOutOfHere: ; |
295 | 7856 |
%}. |
7857 |
self primitiveFailed |
|
7858 |
! |
|
7859 |
||
7860 |
setWindowBackground:aColorIndex in:aWindowId |
|
7861 |
"set the windows background color. This is the color with which |
|
7862 |
the view is filled whenever exposed. Do not confuse this with |
|
7863 |
the background drawing color, which is used with opaque drawing." |
|
7864 |
||
7865 |
%{ /* NOCONTEXT */ |
|
7866 |
||
7867 |
if (__isExternalAddress(aWindowId) |
|
7868 |
&& __isSmallInteger(aColorIndex)) { |
|
555 | 7869 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
295 | 7870 |
RETURN ( self ); |
7871 |
} |
|
7872 |
%}. |
|
7873 |
self primitiveFailed |
|
7874 |
! |
|
7875 |
||
7876 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
|
7877 |
"set the windows background pattern to be a form. |
|
7878 |
This is the pattern with which the view is filled whenever exposed. |
|
7879 |
Do not confuse this with the background drawing color, which is used |
|
7880 |
with opaque drawing." |
|
7881 |
||
7882 |
%{ /* NOCONTEXT */ |
|
7883 |
||
7884 |
if (__isExternalAddress(aWindowId) |
|
7885 |
&& __isExternalAddress(aPixmapId)) { |
|
7886 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
|
7887 |
RETURN ( self ); |
|
7888 |
} |
|
7889 |
%}. |
|
7890 |
self primitiveFailed |
|
7891 |
! |
|
7892 |
||
7893 |
setWindowBorderColor:aColorIndex in:aWindowId |
|
7894 |
"set the windows border color" |
|
7895 |
||
7896 |
%{ /* NOCONTEXT */ |
|
7897 |
||
7898 |
if (__isExternalAddress(aWindowId) |
|
7899 |
&& __isSmallInteger(aColorIndex)) { |
|
555 | 7900 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
295 | 7901 |
RETURN ( self ); |
7902 |
} |
|
7903 |
%}. |
|
7904 |
self primitiveFailed |
|
7905 |
! |
|
7906 |
||
7907 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
|
7908 |
"set the windows border pattern" |
|
7909 |
||
7910 |
%{ /* NOCONTEXT */ |
|
7911 |
||
7912 |
if (__isExternalAddress(aWindowId) |
|
7913 |
&& __isExternalAddress(aPixmapId)) { |
|
7914 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
|
7915 |
RETURN ( self ); |
|
7916 |
} |
|
7917 |
%} |
|
7918 |
. |
|
7919 |
self primitiveFailed |
|
7920 |
! |
|
7921 |
||
7922 |
setWindowBorderShape:aPixmapId in:aWindowId |
|
7923 |
"set the windows border shape" |
|
7924 |
||
7925 |
hasShapeExtension ifFalse:[^ self]. |
|
7926 |
||
7927 |
%{ /* NOCONTEXT */ |
|
7928 |
||
7929 |
#ifdef SHAPE |
|
7930 |
if (__isExternalAddress(aWindowId) |
|
7931 |
&& __isExternalAddress(aPixmapId)) { |
|
7932 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
|
7933 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
7934 |
RETURN ( self ); |
|
7935 |
} |
|
7936 |
#endif |
|
7937 |
%}. |
|
7938 |
self primitiveFailed |
|
7939 |
! |
|
7940 |
||
7941 |
setWindowBorderWidth:aNumber in:aWindowId |
|
7942 |
"set the windows border width" |
|
7943 |
||
7944 |
%{ /* NOCONTEXT */ |
|
7945 |
||
7946 |
if (__isExternalAddress(aWindowId) |
|
7947 |
&& __isSmallInteger(aNumber)) { |
|
555 | 7948 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber)); |
295 | 7949 |
RETURN ( self ); |
7950 |
} |
|
7951 |
%}. |
|
7952 |
self primitiveFailed |
|
7953 |
! |
|
7954 |
||
857
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7955 |
setWindowClass:wClass name:wName in:aWindowId |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7956 |
"define class and name of a window. |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7957 |
This may be used by the window manager to |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7958 |
select client specific resources." |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7959 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7960 |
%{ |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7961 |
if (__isExternalAddress(aWindowId)) { |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7962 |
XClassHint classhint; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7963 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7964 |
classhint.res_class = classhint.res_name = 0; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7965 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7966 |
if (__isString(wClass) || __isSymbol(wClass)) { |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7967 |
classhint.res_class = (char *)_stringVal(wClass); |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7968 |
} else if (wClass != nil) |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7969 |
goto error; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7970 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7971 |
if (__isString(wName) || __isSymbol(wName)) { |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7972 |
classhint.res_name = (char *)_stringVal(wName); |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7973 |
} else if (wName != nil) |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7974 |
goto error; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7975 |
|
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7976 |
XSetClassHint(myDpy, _WindowVal(aWindowId), &classhint); |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7977 |
RETURN ( self ); |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7978 |
error:; |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7979 |
} |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7980 |
%}. |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7981 |
self primitiveFailed |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7982 |
! |
df5125310d86
New method #setWindowClass:name:in: to give a hint to the window manager.
Stefan Vogel <sv@exept.de>
parents:
850
diff
changeset
|
7983 |
|
295 | 7984 |
setWindowGravity:how in:aWindowId |
7985 |
"set window gravity for a window" |
|
7986 |
||
7987 |
%{ /* NOCONTEXT */ |
|
7988 |
||
7989 |
XSetWindowAttributes wa; |
|
7990 |
||
7991 |
if (__isExternalAddress(aWindowId)) { |
|
7992 |
if (how == @symbol(NorthWest)) { |
|
7993 |
wa.win_gravity = NorthWestGravity; |
|
7994 |
} else if (how == @symbol(NorthEast)) { |
|
7995 |
wa.win_gravity = NorthEastGravity; |
|
7996 |
} else if (how == @symbol(SouthWest)) { |
|
7997 |
wa.win_gravity = SouthWestGravity; |
|
7998 |
} else if (how == @symbol(SouthEast)) { |
|
7999 |
wa.win_gravity = SouthEastGravity; |
|
8000 |
} else if (how == @symbol(Center)) { |
|
8001 |
wa.win_gravity = CenterGravity; |
|
8002 |
} else if (how == @symbol(North)) { |
|
8003 |
wa.win_gravity = NorthGravity; |
|
8004 |
} else if (how == @symbol(South)) { |
|
8005 |
wa.win_gravity = SouthGravity; |
|
8006 |
} else if (how == @symbol(West)) { |
|
8007 |
wa.win_gravity = WestGravity; |
|
8008 |
} else if (how == @symbol(East)) { |
|
8009 |
wa.win_gravity = EastGravity; |
|
8010 |
} else { |
|
8011 |
wa.win_gravity = NorthWestGravity; |
|
8012 |
} |
|
8013 |
||
8014 |
BEGIN_INTERRUPTSBLOCKED |
|
8015 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
|
8016 |
END_INTERRUPTSBLOCKED |
|
8017 |
RETURN ( self ); |
|
8018 |
} |
|
8019 |
%}. |
|
8020 |
self primitiveFailed |
|
8021 |
! |
|
8022 |
||
8023 |
setWindowIcon:aForm in:aWindowId |
|
8024 |
"define a bitmap to be used as icon" |
|
8025 |
||
8026 |
|iconId| |
|
8027 |
||
8028 |
aForm notNil ifTrue:[ |
|
8029 |
iconId := aForm id |
|
8030 |
]. |
|
8031 |
%{ |
|
8032 |
if (__isExternalAddress(iconId) |
|
8033 |
&& __isExternalAddress(aWindowId)) { |
|
8034 |
XWMHints hints; |
|
8035 |
||
8036 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
8037 |
hints.flags = IconPixmapHint; |
|
8038 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
8039 |
RETURN ( self ); |
|
8040 |
} |
|
8041 |
%}. |
|
8042 |
self primitiveFailed |
|
8043 |
! |
|
8044 |
||
8045 |
setWindowIconWindow:aView in:aWindowId |
|
8046 |
"define a window to be used as icon" |
|
8047 |
||
8048 |
|iconWindowId| |
|
8049 |
||
8050 |
aView notNil ifTrue:[ |
|
8051 |
iconWindowId := aView id |
|
8052 |
]. |
|
8053 |
%{ |
|
8054 |
if (__isExternalAddress(iconWindowId) |
|
8055 |
&& __isExternalAddress(aWindowId)) { |
|
8056 |
XWMHints wmhints; |
|
8057 |
||
8058 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
8059 |
wmhints.flags = IconWindowHint; |
|
8060 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
8061 |
RETURN ( self ); |
|
8062 |
} |
|
8063 |
%}. |
|
8064 |
self primitiveFailed |
|
8065 |
! |
|
8066 |
||
8067 |
setWindowName:aString in:aWindowId |
|
8068 |
"define a windows name" |
|
8069 |
||
8070 |
%{ /* NOCONTEXT */ |
|
8071 |
||
8072 |
if (__isExternalAddress(aWindowId) |
|
8073 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
8074 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
|
8075 |
RETURN ( self ); |
|
8076 |
} |
|
8077 |
%}. |
|
8078 |
self primitiveFailed |
|
8079 |
! |
|
8080 |
||
8081 |
setWindowShape:aPixmapId in:aWindowId |
|
8082 |
"set the windows shape" |
|
8083 |
||
8084 |
hasShapeExtension ifFalse:[^ self]. |
|
8085 |
||
8086 |
%{ /* NOCONTEXT */ |
|
8087 |
||
8088 |
#ifdef SHAPE |
|
8089 |
if (__isExternalAddress(aWindowId) |
|
8090 |
&& __isExternalAddress(aPixmapId)) { |
|
8091 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
|
8092 |
0, 0, |
|
8093 |
_PixmapVal(aPixmapId), ShapeSet); |
|
8094 |
RETURN ( self ); |
|
8095 |
} |
|
8096 |
#endif |
|
8097 |
%}. |
|
8098 |
self primitiveFailed |
|
8099 |
! |
|
8100 |
||
8101 |
unmapWindow:aWindowId |
|
8102 |
"make a window invisible" |
|
8103 |
||
8104 |
%{ /* NOCONTEXT */ |
|
8105 |
||
8106 |
if (__isExternalAddress(aWindowId)) { |
|
8107 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
|
8108 |
RETURN ( self ); |
|
8109 |
} |
|
8110 |
%} |
|
8111 |
. |
|
8112 |
self primitiveFailed |
|
8113 |
! ! |
|
8114 |
||
898
677e010d0cf8
exit from image restart, if connection is refused
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
8115 |
!XWorkstation class methodsFor:'documentation'! |
295 | 8116 |
|
8117 |
version |
|
914
6cf4cc647095
Account for 'narrow' and 'semicondensed' in X11-Fonts.
Stefan Vogel <sv@exept.de>
parents:
911
diff
changeset
|
8118 |
^ '$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.150 1996-07-04 10:47:08 stefan Exp $' |
295 | 8119 |
! ! |
8120 |
XWorkstation initialize! |