author | Claus Gittinger <cg@exept.de> |
Mon, 10 Jun 1996 21:18:58 +0200 | |
changeset 823 | 1a0933c804ba |
parent 819 | 88aaa6ff1ca3 |
child 830 | 76fd3d86dd15 |
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 |
/* |
64 |
* shape support works; enabled by -DSHAPE in makefile |
|
65 |
* see RoundClock and RoundGlobe examples |
|
66 |
*/ |
|
67 |
#ifdef SHAPE |
|
68 |
# include <X11/extensions/shape.h> |
|
69 |
#endif |
|
70 |
||
71 |
/* |
|
150 | 72 |
* shared memory extension access is currently not supported |
0 | 73 |
* (only query is implemented) |
74 |
*/ |
|
75 |
#ifdef SHM |
|
76 |
# include <X11/extensions/XShm.h> |
|
77 |
#endif |
|
78 |
||
79 |
/* |
|
150 | 80 |
* multiBuffer extension access is currently not supported |
81 |
* (only query is implemented) |
|
82 |
*/ |
|
83 |
#ifdef MBUF |
|
84 |
# include <X11/extensions/multibuf.h> |
|
85 |
#endif |
|
86 |
||
87 |
/* |
|
88 |
* XVideo extension access is currently not supported |
|
89 |
* (only query is implemented) |
|
90 |
*/ |
|
91 |
#ifdef XVIDEO |
|
92 |
# include <X11/extensions/Xv.h> |
|
93 |
#endif |
|
94 |
||
95 |
/* |
|
0 | 96 |
* this is a non-standard fax-image decompression extension |
97 |
* (only found in megascan servers ported by myself) |
|
98 |
*/ |
|
99 |
#ifdef FAX |
|
100 |
# include <X11/extensions/XFAXImage.h> |
|
101 |
#endif |
|
102 |
||
103 |
/* |
|
186 | 104 |
* PEX extension - if available |
105 |
*/ |
|
106 |
#ifdef PEX5 |
|
107 |
# include <PEX5/PEX.h> |
|
108 |
#endif |
|
109 |
||
110 |
/* |
|
111 |
* XImage extension - if available |
|
112 |
*/ |
|
113 |
#ifdef XIE |
|
114 |
# include <X11/extensions/XIE.h> |
|
115 |
#endif |
|
116 |
||
117 |
/* |
|
90 | 118 |
* when I have more time to check it out, I will support display-PS |
0 | 119 |
*/ |
120 |
#ifdef DPS |
|
121 |
# ifdef sgi |
|
122 |
# include <X11/extensions/XDPS.h> |
|
123 |
# include <X11/extensions/XDPSlib.h> |
|
124 |
# include <X11/extensions/dpsXclient.h> |
|
125 |
# else |
|
126 |
# include <DPS/XDPS.h> |
|
127 |
# include <DPS/XDPSlib.h> |
|
128 |
# include <DPS/dpsXclient.h> |
|
129 |
# endif |
|
130 |
#endif |
|
131 |
||
90 | 132 |
#if defined(IRIX5) || (XlibSpecificationRelease == 6) |
133 |
/* |
|
134 |
* accessing private data in Display ... sorry |
|
135 |
*/ |
|
136 |
# define DISPLAYACCESS(d) ((_XPrivDisplay)d) |
|
137 |
#else |
|
138 |
# define DISPLAYACCESS(d) d |
|
139 |
#endif |
|
140 |
||
78 | 141 |
/* |
142 |
* some defines - tired of typing ... |
|
143 |
*/ |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
144 |
#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
|
145 |
#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
|
146 |
#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
|
147 |
#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
|
148 |
#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
|
149 |
#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
|
150 |
#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
|
151 |
|
211 | 152 |
#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
|
153 |
#define _AtomVal(o) __intVal(o) |
211 | 154 |
#define __isAtomID(o) __isSmallInteger(o) |
155 |
||
555 | 156 |
#define myDpy _DisplayVal(__INST(displayId)) |
157 |
#define ISCONNECTED (__INST(displayId) != nil) |
|
78 | 158 |
|
159 |
#ifndef THISCONTEXT_IN_REGISTER |
|
160 |
# define BEGIN_INTERRUPTSBLOCKED /* */ |
|
161 |
# define END_INTERRUPTSBLOCKED /* */ |
|
162 |
#else |
|
163 |
extern int __interruptsBlocked; |
|
164 |
# define BEGIN_INTERRUPTSBLOCKED \ |
|
165 |
{ \ |
|
166 |
int needUnblock = 0; \ |
|
167 |
extern OBJ __thisContext__; \ |
|
168 |
\ |
|
169 |
__thisContext__ = __thisContext;\ |
|
170 |
if (!__interruptsBlocked) { \ |
|
150 | 171 |
__BLOCKINTERRUPTS(); \ |
78 | 172 |
needUnblock = 1; \ |
173 |
} |
|
174 |
||
175 |
# define END_INTERRUPTSBLOCKED \ |
|
158 | 176 |
__thisContext = __thisContext; \ |
177 |
__thisContext__ = 0; \ |
|
78 | 178 |
if (needUnblock) { \ |
150 | 179 |
__UNBLOCKINTERRUPTS(); \ |
78 | 180 |
} \ |
181 |
} |
|
182 |
||
183 |
#endif |
|
184 |
%} |
|
185 |
! ! |
|
186 |
||
187 |
!XWorkstation primitiveVariables! |
|
188 |
%{ |
|
0 | 189 |
/* |
146 | 190 |
* remembered info from private error handler |
0 | 191 |
*/ |
2 | 192 |
static char lastErrorMsg[80] = ""; |
193 |
static unsigned lastRequestCode = 0; |
|
194 |
static unsigned lastMinorCode = 0; |
|
195 |
static unsigned lastResource = 0; |
|
129 | 196 |
|
197 |
static int __debug__ = 0; |
|
198 |
#define DPRINTF(x) if (__debug__) { printf x; } |
|
78 | 199 |
%} |
200 |
! ! |
|
201 |
||
202 |
!XWorkstation primitiveFunctions! |
|
203 |
%{ |
|
18 | 204 |
/* |
144 | 205 |
* catch X-errors and forward as errorInterrupt:#DisplayError, |
206 |
* (which itself invokes my handler and optionally raises an exceptionSignal) |
|
90 | 207 |
* the implementation below is somewhat wrong: it will |
78 | 208 |
* report all errors for Display, even though there could be |
162 | 209 |
* more than one display connection. (being fixed, new errorInterrupt mechanism |
210 |
* allows passing an additional argument, which is the displayID ...) |
|
18 | 211 |
*/ |
168 | 212 |
static |
12 | 213 |
__XErrorHandler__(dpy, event) |
0 | 214 |
Display *dpy; |
215 |
XErrorEvent *event; |
|
216 |
{ |
|
217 |
XGetErrorText(dpy, event->error_code, lastErrorMsg, 80); |
|
218 |
if (lastErrorMsg[0] == '\0') { |
|
70 | 219 |
sprintf(lastErrorMsg, "code: %d", event->error_code); |
0 | 220 |
} |
2 | 221 |
lastRequestCode = event->request_code; |
222 |
lastMinorCode = event->minor_code; |
|
223 |
lastResource = event->resourceid; |
|
224 |
||
254
d6f12ecd7767
ErrorPrinting variable now correctly detected by stc
Claus Gittinger <cg@exept.de>
parents:
250
diff
changeset
|
225 |
if (@global(ErrorPrinting) == true) { |
219
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
226 |
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
|
227 |
event->request_code, event->request_code, |
9ff0660f447f
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
218
diff
changeset
|
228 |
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
|
229 |
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
|
230 |
} |
43 | 231 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
232 |
__errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy)); |
0 | 233 |
return 0; |
234 |
} |
|
235 |
||
90 | 236 |
#ifdef VIRTUAL_ROOT |
0 | 237 |
/* |
18 | 238 |
* added since RootWindow-macro is not suficient |
239 |
* when virtual root-windows are involved (i.e. tvtwm) |
|
240 |
*/ |
|
241 |
static Window |
|
242 |
getRootWindow(dpy, screen) |
|
243 |
Display *dpy; |
|
244 |
{ |
|
245 |
Window root; |
|
246 |
Atom vRootAtom = None; |
|
247 |
int i; |
|
248 |
Window rootReturn, parentReturn; |
|
249 |
Window* children; |
|
250 |
unsigned int numChildren; |
|
251 |
||
252 |
root = RootWindow(dpy, screen); |
|
253 |
/* |
|
254 |
* on IRIS, this creates a badwindow error - why ? |
|
255 |
* children contains a funny window (000034) |
|
256 |
*/ |
|
90 | 257 |
# if !defined(IRIS) || defined(IRIX5) |
18 | 258 |
if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) { |
70 | 259 |
vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True ); |
260 |
if (vRootAtom != None) { |
|
261 |
for (i=0; i < numChildren; i++) { |
|
262 |
Atom actual_type; |
|
263 |
int actual_format; |
|
264 |
unsigned long nitems, bytesafter; |
|
265 |
Window* newRoot = (Window*) 0; |
|
266 |
||
267 |
if (children[i]) { |
|
268 |
if (XGetWindowProperty(dpy, children[i], vRootAtom, |
|
269 |
0L, 1L, False, XA_WINDOW, |
|
270 |
&actual_type, &actual_format, &nitems, &bytesafter, |
|
271 |
(unsigned char**) &newRoot) == Success && newRoot) { |
|
272 |
root = *newRoot; |
|
273 |
break; |
|
274 |
} |
|
275 |
} |
|
276 |
} |
|
277 |
if (children) XFree( children ); |
|
278 |
} |
|
18 | 279 |
} |
90 | 280 |
# endif |
18 | 281 |
return root; |
282 |
} |
|
90 | 283 |
#endif |
0 | 284 |
%} |
78 | 285 |
! ! |
0 | 286 |
|
295 | 287 |
!XWorkstation class methodsFor:'documentation'! |
288 |
||
289 |
copyright |
|
290 |
" |
|
291 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
292 |
All Rights Reserved |
|
293 |
||
294 |
This software is furnished under a license and may be used |
|
295 |
only in accordance with the terms of that license and with the |
|
296 |
inclusion of the above copyright notice. This software may not |
|
297 |
be provided or otherwise made available to, or used by, any |
|
298 |
other person. No title to or ownership of the software is |
|
299 |
hereby transferred. |
|
300 |
" |
|
301 |
! |
|
302 |
||
303 |
documentation |
|
304 |
" |
|
305 |
this class provides the interface to X11. It redefines all required methods |
|
306 |
from DeviceWorkstation. Notice, that in Smalltalk/X you are not technically |
|
307 |
limited to one display - in theory, you can create Views on many displays |
|
308 |
simultanously. However, the default setup is for one display only. |
|
309 |
To support multiple displays, you will have to start another event dispatcher |
|
310 |
process for the other display(s) and create the other views with a slightly |
|
311 |
different protocol. However, 'normal' applications do not have to care for |
|
312 |
all of this ... |
|
313 |
||
314 |
See more documentation in my superclass, DeviceWorkstation. |
|
613 | 315 |
|
316 |
[author:] |
|
317 |
Claus Gittinger |
|
295 | 318 |
" |
319 |
! ! |
|
320 |
||
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
321 |
!XWorkstation class methodsFor:'initialization'! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
322 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
323 |
initialize |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
324 |
|d| |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
325 |
|
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
326 |
super initialize. |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
327 |
|
386 | 328 |
RawKeysymTranslation isNil ifTrue:[ |
329 |
"/ the following table maps X-keyevents to ST/X |
|
330 |
"/ device independed events. |
|
331 |
"/ It is NOT meant as a keyboardMap replacement. |
|
332 |
||
333 |
RawKeysymTranslation := d := Dictionary new. |
|
334 |
d at:'Delete_line' put:#DeleteLine. |
|
335 |
d at:'Delete_word' put:#DeleteWord. |
|
336 |
d at:'Down' put:#CursorDown. |
|
337 |
d at:'Up' put:#CursorUp. |
|
338 |
d at:'Left' put:#CursorLeft. |
|
339 |
d at:'Right' put:#CursorRight. |
|
340 |
] |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
341 |
! ! |
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
342 |
|
2 | 343 |
!XWorkstation class methodsFor:'error handling'! |
344 |
||
129 | 345 |
debug:aBoolean |
346 |
%{ /* NOCONTEXT */ |
|
347 |
||
348 |
__debug__ = (aBoolean == true) ? 1 : 0; |
|
349 |
%} |
|
350 |
! |
|
351 |
||
78 | 352 |
errorStringOfLastError |
353 |
%{ |
|
216 | 354 |
RETURN ( __MKSTRING(lastErrorMsg COMMA_CON) ); |
78 | 355 |
%} |
356 |
! |
|
357 |
||
135 | 358 |
lastErrorString |
2 | 359 |
"return the last X-error string - |
360 |
when buffering is on, this may be |
|
361 |
an error for a long-ago operation" |
|
78 | 362 |
|
363 |
|string requestCode s match line| |
|
364 |
||
365 |
string := self errorStringOfLastError. |
|
366 |
requestCode := self requestCodeOfLastError. |
|
367 |
" |
|
368 |
X specific: search the requestCode in '/usr/lib/X11/XErrorDB', |
|
369 |
and append the name of the corresponding X-request |
|
370 |
" |
|
371 |
s := '/usr/lib/X11/XErrorDB' asFilename readStream. |
|
372 |
s notNil ifTrue:[ |
|
373 |
match := 'XRequest.' , requestCode printString. |
|
374 |
line := s peekForLineStartingWith:match. |
|
375 |
line notNil ifTrue:[ |
|
376 |
string := string , ' in ' , (line copyFrom:(line indexOf:$:)+1) |
|
377 |
]. |
|
378 |
s close. |
|
379 |
]. |
|
380 |
^ string |
|
295 | 381 |
! |
382 |
||
383 |
minorCodeOfLastError |
|
384 |
%{ /* NOCONTEXT */ |
|
385 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
386 |
RETURN ( __MKSMALLINT(lastMinorCode) ); |
295 | 387 |
%} |
388 |
! |
|
389 |
||
390 |
requestCodeOfLastError |
|
152 | 391 |
%{ /* NOCONTEXT */ |
392 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
393 |
RETURN ( __MKSMALLINT(lastRequestCode) ); |
0 | 394 |
%} |
135 | 395 |
! |
396 |
||
295 | 397 |
resourceIdOfLastError |
0 | 398 |
%{ /* NOCONTEXT */ |
295 | 399 |
|
400 |
RETURN ( __MKOBJ(lastResource) ); |
|
0 | 401 |
%} |
402 |
! ! |
|
403 |
||
104 | 404 |
!XWorkstation class methodsFor:'queries'! |
405 |
||
406 |
platformName |
|
133 | 407 |
"ST-80 compatibility. |
408 |
Return a string describing the display systems platform." |
|
409 |
||
715 | 410 |
^ 'X11' "I don't know what ST-80 returns for X ..." |
411 |
||
412 |
"Modified: 26.5.1996 / 15:32:46 / cg" |
|
104 | 413 |
! ! |
414 |
||
0 | 415 |
!XWorkstation methodsFor:'accessing & queries'! |
416 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
417 |
anyButtonMotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
418 |
"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
|
419 |
This is the devices mask." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
420 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
421 |
%{ /* NOCONTEXT */ |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
422 |
RETURN (__MKSMALLINT(Button1MotionMask | Button2MotionMask | Button3MotionMask)); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
423 |
%}. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
424 |
^ nil |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
425 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
426 |
|
295 | 427 |
blackpixel |
428 |
"return the colornumber of black" |
|
429 |
||
430 |
^ blackpixel |
|
431 |
! |
|
432 |
||
433 |
button1MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
434 |
"return the state-mask for button1 in motion events' state-field. |
295 | 435 |
For backward compatibility." |
436 |
||
437 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
438 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
295 | 439 |
%} |
540
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 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
442 |
Display button1MotionMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
443 |
" |
295 | 444 |
! |
445 |
||
446 |
button2MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
447 |
"return the state-mask for button2 in motion events' state-field |
295 | 448 |
For backward compatibility." |
449 |
||
450 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
451 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
295 | 452 |
%} |
453 |
! |
|
454 |
||
455 |
button3MotionMask |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
456 |
"return the state-mask for button3 in motion events' state-field |
295 | 457 |
For backward compatibility." |
458 |
||
459 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
460 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 461 |
%} |
462 |
! |
|
463 |
||
464 |
buttonMotionMask:aButton |
|
465 |
"return the state-mask for button1 in motion events state-field. |
|
466 |
This is the devices mask." |
|
467 |
||
468 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
469 |
if (aButton == __MKSMALLINT(1)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
470 |
RETURN (__MKSMALLINT(Button1MotionMask)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
471 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
472 |
if (aButton == __MKSMALLINT(2)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
473 |
RETURN (__MKSMALLINT(Button2MotionMask)); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
474 |
} |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
475 |
if (aButton == __MKSMALLINT(3)) { |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
476 |
RETURN (__MKSMALLINT(Button3MotionMask)); |
295 | 477 |
} |
478 |
%}. |
|
479 |
^ nil |
|
480 |
! |
|
481 |
||
382 | 482 |
controlMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
483 |
"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
|
484 |
|
382 | 485 |
%{ /* NOCONTEXT */ |
486 |
RETURN (__MKSMALLINT(ControlMask)); |
|
487 |
%} |
|
488 |
! |
|
489 |
||
295 | 490 |
defaultEventMask |
491 |
"return a mask to enable some events by default." |
|
492 |
||
493 |
%{ /* NOCONTEXT */ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
494 |
RETURN (__MKSMALLINT( ExposureMask | StructureNotifyMask | |
295 | 495 |
KeyPressMask | KeyReleaseMask | |
496 |
EnterWindowMask | LeaveWindowMask | |
|
497 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask )); |
|
498 |
%} |
|
499 |
! |
|
500 |
||
0 | 501 |
displayFileDescriptor |
502 |
"return the displays fileNumber - for select" |
|
503 |
||
504 |
%{ /* NOCONTEXT */ |
|
505 |
||
150 | 506 |
if (ISCONNECTED) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
507 |
RETURN ( __MKSMALLINT(ConnectionNumber(myDpy)) ); |
150 | 508 |
} |
509 |
RETURN (nil); |
|
0 | 510 |
%} |
511 |
! |
|
512 |
||
133 | 513 |
displayName |
514 |
"return the X-connections display name. |
|
515 |
This is (currently) nil for the default display, |
|
516 |
something like foo:0 for any other remote display. |
|
517 |
Future versions may return non-nil strings for the default display as well." |
|
518 |
||
519 |
^ displayName |
|
520 |
! |
|
521 |
||
341 | 522 |
protocolVersion |
523 |
"return the X-servers protocol version - should normally not be of |
|
524 |
any interest" |
|
525 |
||
526 |
%{ /* NOCONTEXT */ |
|
527 |
if (ISCONNECTED) { |
|
528 |
RETURN ( __MKSMALLINT(XProtocolVersion(myDpy)) ); |
|
529 |
} |
|
530 |
RETURN (nil); |
|
531 |
%} |
|
532 |
||
533 |
" |
|
534 |
Display protocolVersion |
|
535 |
" |
|
536 |
! |
|
537 |
||
538 |
serverVendor |
|
539 |
"return the X-server vendor string - this should normally not be of |
|
540 |
any interest, but can be for special cases |
|
541 |
(to avoid bugs in certain implementations)" |
|
542 |
%{ |
|
543 |
if (ISCONNECTED) { |
|
544 |
RETURN ( __MKSTRING(XServerVendor(myDpy) COMMA_CON) ); |
|
545 |
} |
|
546 |
RETURN (nil); |
|
547 |
%} |
|
548 |
||
549 |
" |
|
550 |
Display serverVendor |
|
551 |
" |
|
552 |
! |
|
553 |
||
382 | 554 |
shiftMask |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
555 |
"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
|
556 |
|
382 | 557 |
%{ /* NOCONTEXT */ |
558 |
RETURN (__MKSMALLINT(ShiftMask)); |
|
559 |
%} |
|
560 |
! |
|
561 |
||
341 | 562 |
translatePoint:aPoint from:windowId1 to:windowId2 |
563 |
"given a point in window1, return the coordinate in window2. |
|
564 |
This expects a device coordinate (relative to the first views origin) |
|
565 |
in aPoint and returns a device coordinate relative to the 2nd views origin. |
|
566 |
- use to xlate points from a window to rootwindow" |
|
567 |
||
568 |
|x1 y1 x2 y2| |
|
569 |
||
570 |
x1 := x2 := aPoint x truncated. |
|
571 |
y1 := y2 := aPoint y truncated. |
|
572 |
%{ |
|
573 |
int xpos, ypos; |
|
574 |
Window w1, w2, child_return; |
|
555 | 575 |
int screen = __intVal(__INST(screen)); |
341 | 576 |
Display *dpy = myDpy; |
577 |
||
578 |
if (__isExternalAddress(windowId1) |
|
579 |
&& __isExternalAddress(windowId2) |
|
580 |
&& __bothSmallInteger(x1, y1)) { |
|
581 |
w1 = _WindowVal(windowId1); |
|
582 |
w2 = _WindowVal(windowId2); |
|
583 |
#ifdef VIRTUAL_ROOT |
|
584 |
if ((w1 == RootWindow(dpy, screen)) |
|
585 |
|| (w2 == RootWindow(dpy, screen))) { |
|
586 |
if (w1 == RootWindow(dpy, screen)) { |
|
587 |
w1 = getRootWindow(dpy, screen); |
|
588 |
} |
|
589 |
if (w2 == RootWindow(dpy, screen)) { |
|
590 |
w2 = getRootWindow(dpy, screen); |
|
591 |
} |
|
592 |
} |
|
593 |
#endif |
|
594 |
BEGIN_INTERRUPTSBLOCKED |
|
595 |
XTranslateCoordinates(dpy, w1, w2, |
|
555 | 596 |
__intVal(x1), __intVal(y1), |
341 | 597 |
&xpos, &ypos, &child_return); |
598 |
END_INTERRUPTSBLOCKED |
|
599 |
x2 = __MKSMALLINT(xpos); |
|
600 |
y2 = __MKSMALLINT(ypos); |
|
601 |
} |
|
602 |
%}. |
|
603 |
||
604 |
^ (x2 @ y2) |
|
605 |
! |
|
606 |
||
607 |
vendorRelease |
|
608 |
"return the X-servers vendor release - should normally not be of |
|
609 |
any interest, but can be for special cases. |
|
610 |
(to avoid bugs in certain implementations)" |
|
611 |
||
612 |
%{ /* NOCONTEXT */ |
|
613 |
if (ISCONNECTED) { |
|
614 |
RETURN ( __MKSMALLINT(XVendorRelease(myDpy)) ); |
|
615 |
} |
|
616 |
RETURN (nil); |
|
617 |
%} |
|
618 |
||
619 |
" |
|
620 |
Display vendorRelease |
|
621 |
" |
|
622 |
! |
|
623 |
||
624 |
viewIdFromPoint:aPoint in:windowId |
|
625 |
"given a point in rootWindow, return the viewId of the subview of windowId |
|
626 |
hit by this coordinate. Return nil if no view was hit. |
|
627 |
The returned id may be the id of a non ST view. |
|
628 |
- used to find the window to drop objects after a cross-view drag." |
|
629 |
||
630 |
%{ /* NOCONTEXT */ |
|
631 |
||
632 |
Display *dpy = myDpy; |
|
555 | 633 |
int screen = __intVal(__INST(screen)); |
341 | 634 |
OBJ xp, yp; |
635 |
int xpos, ypos; |
|
636 |
Window child_return; |
|
637 |
||
638 |
if (__isExternalAddress(windowId) |
|
639 |
&& __isPoint(aPoint)) { |
|
640 |
xp = _point_X(aPoint); |
|
641 |
yp = _point_Y(aPoint); |
|
642 |
if (__bothSmallInteger(xp, yp)) { |
|
643 |
BEGIN_INTERRUPTSBLOCKED |
|
644 |
XTranslateCoordinates(dpy, |
|
645 |
RootWindow(dpy, screen), |
|
646 |
_WindowVal(windowId), |
|
555 | 647 |
__intVal(xp), __intVal(yp), |
341 | 648 |
&xpos, &ypos, &child_return); |
649 |
END_INTERRUPTSBLOCKED |
|
650 |
if (child_return) { |
|
651 |
RETURN ( __MKOBJ(child_return) ); |
|
652 |
} |
|
653 |
RETURN ( nil ); |
|
654 |
} |
|
655 |
} |
|
656 |
%}. |
|
657 |
windowId notNil ifTrue:[ |
|
658 |
aPoint isPoint ifTrue:[ |
|
659 |
^ self viewIdFromPoint:aPoint asPoint truncated in:windowId |
|
660 |
] |
|
661 |
]. |
|
662 |
||
663 |
^ nil |
|
664 |
! |
|
665 |
||
666 |
virtualExtent |
|
667 |
"return the virtual extent of the display (in pixels). |
|
668 |
On most systems, this is the same as the physical width; |
|
669 |
except, if a window manager with a virtual desktop like olvwm |
|
670 |
(simulating a bigger screen) is running." |
|
671 |
||
672 |
%{ |
|
555 | 673 |
if ((__INST(rootId) != __INST(virtualRootId)) |
674 |
&& __isExternalAddress(__INST(virtualRootId))) { |
|
341 | 675 |
Window vRootWin; |
676 |
Window root; |
|
677 |
int x, y; |
|
678 |
unsigned int width, height; |
|
679 |
unsigned int dummy; |
|
680 |
||
555 | 681 |
vRootWin = _WindowVal(__INST(virtualRootId)); |
341 | 682 |
if (XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height, |
683 |
&dummy, &dummy)) { |
|
684 |
RETURN ( __MKPOINT_INT(width, height) ); |
|
685 |
} |
|
686 |
} |
|
687 |
%}. |
|
688 |
^ width @ height |
|
689 |
! |
|
690 |
||
691 |
whitepixel |
|
692 |
"return the colornumber of white" |
|
693 |
||
694 |
^ whitepixel |
|
695 |
! ! |
|
696 |
||
697 |
!XWorkstation methodsFor:'accessing display capabilities'! |
|
698 |
||
0 | 699 |
hasDPS |
186 | 700 |
"return true, if this workstation supports display postscript. |
701 |
Both the server must support it, and the feature must have been |
|
702 |
enabled in the smalltalk system, for true to be returned." |
|
0 | 703 |
|
704 |
^ hasDPSExtension |
|
186 | 705 |
|
706 |
" |
|
707 |
Display hasDPS |
|
708 |
" |
|
709 |
! |
|
710 |
||
150 | 711 |
hasExtension:extensionString |
712 |
"query for an X extension. The argument, extensionString |
|
713 |
should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc). |
|
186 | 714 |
Return true, if that extension is available in the server. |
715 |
(which does not imply, that there is support in smalltalk for it." |
|
150 | 716 |
|
717 |
%{ |
|
718 |
int dummy; |
|
719 |
||
720 |
if (__isString(extensionString) && ISCONNECTED) { |
|
721 |
if (XQueryExtension(myDpy, __stringVal(extensionString), &dummy, &dummy, &dummy)) { |
|
722 |
RETURN ( true ); |
|
723 |
} |
|
724 |
} |
|
725 |
%}. |
|
726 |
^ false |
|
186 | 727 |
|
728 |
" |
|
729 |
Display hasExtension:'XVideo' |
|
730 |
Display hasExtension:'Input' |
|
731 |
Display hasExtension:'GLX' |
|
732 |
Display hasExtension:'X3D-PEX' |
|
733 |
Display hasExtension:'XInputExtension' |
|
734 |
Display hasExtension:'SHAPE' |
|
735 |
Display hasExtension:'MIT-SHM' |
|
736 |
Display hasExtension:'SGIFullScreenStereo' |
|
737 |
" |
|
150 | 738 |
! |
739 |
||
295 | 740 |
hasFax |
741 |
"return true, if this workstation supports decompression of fax images. |
|
742 |
Both the server must support it, and the feature must have been |
|
743 |
enabled in the smalltalk system, for true to be returned." |
|
744 |
||
745 |
^ hasFaxExtension |
|
746 |
||
747 |
" |
|
748 |
Display hasFaxExtension |
|
749 |
" |
|
750 |
! |
|
751 |
||
752 |
hasImageExtension |
|
753 |
"return true, if this workstation supports the X image extension. |
|
754 |
Both the server must support it, and the feature must have been |
|
755 |
enabled in the smalltalk system, for true to be returned." |
|
756 |
||
757 |
^ hasImageExtension |
|
758 |
||
759 |
" |
|
760 |
Display hasImageExtension |
|
761 |
" |
|
762 |
! |
|
763 |
||
764 |
hasInputExtension |
|
765 |
"return true, if this workstation supports the X input extension. |
|
766 |
Both the server must support it, and the feature must have been |
|
767 |
enabled in the smalltalk system, for true to be returned." |
|
768 |
||
769 |
^ hasInputExtension |
|
770 |
||
771 |
" |
|
772 |
Display hasInputExtension |
|
773 |
" |
|
774 |
! |
|
775 |
||
776 |
hasMultibuffer |
|
777 |
"return true, if this workstation supports the multibuffer extension. |
|
778 |
Both the server must support it, and the feature must have been |
|
779 |
enabled in the smalltalk system, for true to be returned." |
|
780 |
||
781 |
^ hasMbufExtension |
|
782 |
||
783 |
" |
|
784 |
Display hasMultibuffer |
|
785 |
" |
|
786 |
! |
|
787 |
||
788 |
hasPEX |
|
789 |
"return true, if this workstation supports PEX 3D graphics. |
|
790 |
Both the server must support it, and the feature must have been |
|
791 |
enabled in the smalltalk system, for true to be returned." |
|
792 |
||
793 |
^ hasPEXExtension |
|
794 |
||
795 |
" |
|
796 |
Display hasPEX |
|
797 |
" |
|
798 |
! |
|
799 |
||
800 |
hasShape |
|
801 |
"return true, if this workstation supports non-rectangular windows. |
|
802 |
Both the server must support it, and the feature must have been |
|
803 |
enabled in the smalltalk system, for true to be returned." |
|
804 |
||
805 |
^ hasShapeExtension |
|
806 |
||
807 |
" |
|
808 |
Display hasShape |
|
809 |
" |
|
810 |
! |
|
811 |
||
812 |
hasShm |
|
813 |
"return true, if this workstation supports the shared pixmap extension. |
|
814 |
Both the server must support it, and the feature must have been |
|
815 |
enabled in the smalltalk system, for true to be returned." |
|
816 |
||
817 |
^ hasShmExtension |
|
818 |
||
819 |
" |
|
820 |
Display hasShm |
|
821 |
" |
|
822 |
! |
|
823 |
||
824 |
hasXVideo |
|
825 |
"return true, if this workstation supports the XVideo extension. |
|
826 |
Both the server must support it, and the feature must have been |
|
827 |
enabled in the smalltalk system, for true to be returned." |
|
828 |
||
829 |
^ hasXVideoExtension |
|
830 |
||
831 |
" |
|
832 |
Display hasXVideo |
|
833 |
" |
|
834 |
! |
|
835 |
||
836 |
iconSizes |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
837 |
"Get the preferred/supported icon sizes. These are set by the window manager. |
819 | 838 |
We return nil (if not set) or an OrderedCollection of iconSize specs." |
295 | 839 |
|
840 |
|xIconSizes count ret| |
|
841 |
||
842 |
%{ |
|
843 |
Display *dpy = myDpy; |
|
555 | 844 |
int screen = __intVal(__INST(screen)); |
295 | 845 |
XIconSize *sizeList; |
846 |
int cnt; |
|
847 |
||
848 |
if (ISCONNECTED) { |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
849 |
if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) { |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
850 |
xIconSizes = __MKEXTERNALBYTES(sizeList); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
851 |
count = __MKSMALLINT(cnt); |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
852 |
} |
295 | 853 |
} |
854 |
%}. |
|
855 |
xIconSizes isNil ifTrue:[^ nil]. |
|
856 |
||
857 |
ret := OrderedCollection new:count. |
|
858 |
1 to:count do:[ :i | |
|
819 | 859 |
|minWidth minHeight maxWidth maxHeight widthStep heightStep d| |
295 | 860 |
|
861 |
%{ |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
862 |
XIconSize *slp; |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
863 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
864 |
slp = &((XIconSize *)__externalBytesAddress(xIconSizes))[__intVal(i)-1]; |
819 | 865 |
minWidth = __MKSMALLINT(slp->min_width); |
866 |
minHeight = __MKSMALLINT(slp->min_height); |
|
867 |
maxWidth = __MKSMALLINT(slp->max_width); |
|
868 |
maxHeight = __MKSMALLINT(slp->max_height); |
|
869 |
widthStep = __MKSMALLINT(slp->width_inc); |
|
870 |
heightStep = __MKSMALLINT(slp->height_inc); |
|
295 | 871 |
%}. |
819 | 872 |
d := IdentityDictionary new. |
873 |
d at:#minWidth put:minWidth. |
|
874 |
d at:#maxWidth put:maxWidth. |
|
875 |
d at:#widthStep put:widthStep. |
|
876 |
d at:#minHeight put:minHeight. |
|
877 |
d at:#maxHeight put:maxHeight. |
|
878 |
d at:#heightStep put:heightStep. |
|
879 |
||
880 |
ret add:d |
|
295 | 881 |
]. |
882 |
||
883 |
xIconSizes free. |
|
884 |
^ ret |
|
885 |
||
886 |
" |
|
819 | 887 |
Display iconSizes |
295 | 888 |
" |
889 |
! |
|
890 |
||
341 | 891 |
ignoreBackingStore:aBoolean |
892 |
"if the argument is true, the views backingStore setting will be ignored, and |
|
893 |
no backing store used - this can be used on servers where backing store is |
|
894 |
very slow or is broken (can be put into display-rc-file)" |
|
895 |
||
896 |
ignoreBackingStore := aBoolean |
|
295 | 897 |
! |
898 |
||
823 | 899 |
preferredIconSize |
900 |
"return the displays preferred size for icons. |
|
901 |
Redefined to return a special value on SGI servers." |
|
902 |
||
903 |
self serverVendor = 'Silicon Graphics' ifTrue:[ |
|
904 |
^ 86@68 |
|
905 |
]. |
|
906 |
^ super preferredIconSize |
|
907 |
||
908 |
"Created: 10.6.1996 / 21:06:48 / cg" |
|
909 |
! |
|
910 |
||
43 | 911 |
supportedImageFormats |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
912 |
"return an array with supported image formats; |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
913 |
each array entry is an attribute dictionary, consisting of |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
914 |
depth, bitsPerPixel and padding values." |
43 | 915 |
|
150 | 916 |
|nFormats "{ Class: SmallInteger }" |
917 |
formatArray| |
|
43 | 918 |
%{ |
919 |
Display *dpy = myDpy; |
|
150 | 920 |
|
921 |
if (! ISCONNECTED) { |
|
922 |
RETURN (nil); |
|
923 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
924 |
nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats); |
43 | 925 |
%}. |
926 |
formatArray := Array new:nFormats. |
|
150 | 927 |
1 to:nFormats do:[:index | |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
928 |
|info bitsPerPixelInfo depthInfo paddingInfo i| |
150 | 929 |
|
930 |
i := index. |
|
43 | 931 |
%{ |
70 | 932 |
ScreenFormat *format; |
933 |
Display *dpy = myDpy; |
|
934 |
||
90 | 935 |
format = DISPLAYACCESS(dpy)->pixmap_format; |
555 | 936 |
format += (__intVal(i)-1); |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
937 |
bitsPerPixelInfo = __MKSMALLINT(format->bits_per_pixel); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
938 |
depthInfo = __MKSMALLINT(format->depth); |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
939 |
paddingInfo = __MKSMALLINT(format->scanline_pad); |
43 | 940 |
%}. |
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
941 |
info := IdentityDictionary new. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
942 |
info at:#depth put:depthInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
943 |
info at:#bitsPerPixel put:bitsPerPixelInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
944 |
info at:#padding put:paddingInfo. |
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
945 |
formatArray at:index put:info. |
43 | 946 |
]. |
947 |
^ formatArray |
|
948 |
||
949 |
" |
|
235
579f3f804a46
padding info in supportedFormats
Claus Gittinger <cg@exept.de>
parents:
233
diff
changeset
|
950 |
Display supportedImageFormats |
43 | 951 |
" |
952 |
! |
|
953 |
||
823 | 954 |
supportsIconViews |
955 |
"return true, if this device supports views as icons. |
|
956 |
Only Xservers (currently) support this." |
|
957 |
||
958 |
^ true |
|
959 |
||
960 |
" |
|
961 |
Display supportsIconViews |
|
962 |
" |
|
963 |
||
964 |
"Modified: 10.6.1996 / 20:11:48 / cg" |
|
965 |
"Created: 10.6.1996 / 21:08:18 / cg" |
|
966 |
! |
|
967 |
||
81 | 968 |
supportsViewGravity |
969 |
"return true, if this device supports gravity attributes. |
|
82 | 970 |
We do not depend on it being implemented, but some resizing operations |
81 | 971 |
are faster, it is is." |
972 |
||
973 |
^ true |
|
0 | 974 |
! ! |
975 |
||
976 |
!XWorkstation methodsFor:'bitmap/window creation'! |
|
977 |
||
295 | 978 |
createBitmapFromArray:anArray width:w height:h |
979 |
|bitmapId| |
|
980 |
||
981 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
|
982 |
bitmapId isNil ifTrue:[ |
|
983 |
self primitiveFailed |
|
984 |
]. |
|
985 |
^ bitmapId |
|
986 |
! |
|
987 |
||
988 |
createBitmapFromFile:aString for:aForm |
|
989 |
|id w h| |
|
990 |
||
991 |
%{ |
|
992 |
Display *dpy = myDpy; |
|
555 | 993 |
int screen = __intVal(__INST(screen)); |
295 | 994 |
Pixmap newBitmap; |
995 |
char *filename; |
|
996 |
unsigned b_width, b_height; |
|
997 |
int b_x_hot, b_y_hot; |
|
998 |
int status; |
|
999 |
||
1000 |
if (ISCONNECTED) { |
|
1001 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1002 |
filename = (char *)_stringVal(aString); |
|
1003 |
||
1004 |
BEGIN_INTERRUPTSBLOCKED |
|
1005 |
status = XReadBitmapFile(dpy, RootWindow(dpy, screen), |
|
1006 |
filename, &b_width, &b_height, &newBitmap, |
|
1007 |
&b_x_hot, &b_y_hot); |
|
1008 |
END_INTERRUPTSBLOCKED |
|
1009 |
||
1010 |
if (status == BitmapSuccess) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1011 |
w = __MKSMALLINT(b_width); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1012 |
h = __MKSMALLINT(b_height); |
295 | 1013 |
id = __MKOBJ(newBitmap); |
1014 |
} |
|
1015 |
} |
|
1016 |
} |
|
1017 |
%}. |
|
1018 |
id notNil ifTrue:[ |
|
1019 |
aForm setWidth:w height:h |
|
1020 |
]. |
|
1021 |
^ id |
|
1022 |
! |
|
1023 |
||
1024 |
createBitmapWidth:w height:h |
|
1025 |
"allocate a bitmap on the Xserver, the contents is undefined |
|
1026 |
(i.e. random). Return a bitmap id or nil" |
|
1027 |
||
1028 |
%{ /* NOCONTEXT */ |
|
1029 |
||
1030 |
Display *dpy = myDpy; |
|
555 | 1031 |
int screen = __intVal(__INST(screen)); |
295 | 1032 |
Pixmap newBitmap; |
1033 |
||
1034 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
|
1035 |
BEGIN_INTERRUPTSBLOCKED |
|
1036 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
555 | 1037 |
__intVal(w), __intVal(h), 1); |
295 | 1038 |
END_INTERRUPTSBLOCKED |
1039 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
|
1040 |
} |
|
1041 |
%} |
|
1042 |
. |
|
1043 |
self primitiveFailed. |
|
1044 |
^ nil |
|
1045 |
! |
|
1046 |
||
0 | 1047 |
createFaxImageFromArray:data width:w height:h type:type k:k msbFirst:msbFirst |
1048 |
"create a new faxImage in the workstation |
|
1049 |
type: 0 -> uncompressed |
|
70 | 1050 |
1 -> group3 1D (k is void) |
1051 |
2 -> group3 2D |
|
1052 |
3 -> group4 2D (k is void)" |
|
0 | 1053 |
|
1054 |
|nBytes| |
|
1055 |
||
1056 |
hasFaxExtension ifFalse:[^ nil]. |
|
1057 |
nBytes := data size. |
|
1058 |
%{ |
|
1059 |
#ifdef FAX |
|
1060 |
Display *dpy = myDpy; |
|
555 | 1061 |
int screen = __intVal(__INST(screen)); |
0 | 1062 |
FAXImage newImage; |
1063 |
int _type, _msb, _k = 0; |
|
1064 |
unsigned char *bits; |
|
1065 |
||
97 | 1066 |
if (__bothSmallInteger(w, h) |
1067 |
&& __bothSmallInteger(type, k) |
|
1068 |
&& __isSmallInteger(nBytes) |
|
44 | 1069 |
&& __isByteArray(data)) { |
70 | 1070 |
if (msbFirst == true) |
1071 |
_msb = 1; |
|
1072 |
else |
|
1073 |
_msb = 0; |
|
555 | 1074 |
_type = __intVal(type); |
70 | 1075 |
if ((_type < 0) || (_type > 3)) { |
1076 |
RETURN ( nil ); |
|
1077 |
} |
|
1078 |
if (_type == 2) { |
|
97 | 1079 |
if (! __isSmallInteger(k)) { |
70 | 1080 |
RETURN ( nil ); |
1081 |
} |
|
555 | 1082 |
_k = __intVal(k); |
70 | 1083 |
} |
555 | 1084 |
bits = __ByteArrayInstPtr(data)->ba_element; |
70 | 1085 |
BEGIN_INTERRUPTSBLOCKED |
555 | 1086 |
newImage = XFAXImageCreateImage(dpy, __intVal(w), __intVal(h), |
70 | 1087 |
_type, _k, _msb, |
555 | 1088 |
__intVal(nBytes), bits); |
70 | 1089 |
END_INTERRUPTSBLOCKED |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1090 |
RETURN ( (newImage != (FAXImage)0) ? __MKOBJ(newImage) : nil ); |
0 | 1091 |
} |
1092 |
#else |
|
1093 |
RETURN ( nil ); |
|
1094 |
#endif |
|
1095 |
%} |
|
1096 |
. |
|
43 | 1097 |
self primitiveFailed. |
1098 |
^ nil |
|
0 | 1099 |
! |
1100 |
||
1101 |
createPixmapWidth:w height:h depth:d |
|
1102 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
1103 |
(i.e. random). Return a bitmap id or nil" |
|
1104 |
||
1105 |
%{ /* NOCONTEXT */ |
|
1106 |
||
1107 |
Display *dpy = myDpy; |
|
555 | 1108 |
int screen = __intVal(__INST(screen)); |
0 | 1109 |
Pixmap newBitmap; |
1110 |
||
150 | 1111 |
if (__bothSmallInteger(w, h) && ISCONNECTED) { |
70 | 1112 |
BEGIN_INTERRUPTSBLOCKED |
1113 |
newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen), |
|
555 | 1114 |
__intVal(w), __intVal(h), __intVal(d)); |
70 | 1115 |
END_INTERRUPTSBLOCKED |
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1116 |
RETURN ( (newBitmap != (Pixmap)0) ? __MKOBJ(newBitmap) : nil ); |
0 | 1117 |
} |
1118 |
%} |
|
1119 |
. |
|
43 | 1120 |
self primitiveFailed. |
1121 |
^ nil |
|
0 | 1122 |
! |
1123 |
||
1124 |
createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight |
|
46 | 1125 |
"will vanish - for compatibility with previous versions" |
1126 |
||
1127 |
^ self |
|
780
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1128 |
createWindowFor:aView |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1129 |
origin:(xpos @ ypos) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1130 |
extent:(wwidth @ wheight) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1131 |
minExtent:(aView minExtent) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1132 |
maxExtent:(aView maxExtent) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1133 |
borderWidth:(aView borderWidth) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1134 |
subViewOf:(aView superView) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1135 |
onTop:(aView isPopUpView) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1136 |
inputOnly:(aView isInputOnly) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1137 |
label:(aView label) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1138 |
cursor:(aView cursor) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1139 |
icon:(aView icon) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1140 |
iconView:(aView iconView) |
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1141 |
|
b2f13d436188
renamed #inputOnly to #isInputOnly
Claus Gittinger <cg@exept.de>
parents:
729
diff
changeset
|
1142 |
"Modified: 1.6.1996 / 13:22:48 / cg" |
46 | 1143 |
! |
1144 |
||
1145 |
createWindowFor:aView |
|
70 | 1146 |
origin:origin |
1147 |
extent:extent |
|
1148 |
minExtent:minExt |
|
1149 |
maxExtent:maxExt |
|
1150 |
borderWidth:bWidth |
|
1151 |
subViewOf:wsuperView |
|
157 | 1152 |
onTop:wisPopUpView |
70 | 1153 |
inputOnly:winputOnly |
1154 |
label:wlabel |
|
1155 |
cursor:wcursor |
|
1156 |
icon:wicon |
|
1157 |
iconView:wiconView |
|
46 | 1158 |
|
1159 |
|xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight |
|
1160 |
bColorId wsuperViewId wcursorId wiconId windowId |
|
1161 |
weventMask wiconViewId bitGravity viewGravity vBgColor |
|
150 | 1162 |
vBgForm deepForm preferredVisual preferredDepth| |
1163 |
||
1164 |
displayId isNil ifTrue:[ |
|
1165 |
self primitiveFailed. |
|
1166 |
^ nil |
|
1167 |
]. |
|
0 | 1168 |
|
46 | 1169 |
origin notNil ifTrue:[ |
70 | 1170 |
xpos := origin x. |
1171 |
ypos := origin y. |
|
46 | 1172 |
] ifFalse:[ |
70 | 1173 |
xpos := ypos := 0. |
0 | 1174 |
]. |
46 | 1175 |
extent notNil ifTrue:[ |
70 | 1176 |
wwidth := extent x. |
1177 |
wheight := extent y. |
|
46 | 1178 |
] ifFalse:[ |
70 | 1179 |
wwidth := wheight := 100. |
46 | 1180 |
]. |
1181 |
minExt notNil ifTrue:[ |
|
70 | 1182 |
minWidth := minExt x. |
1183 |
minHeight := minExt y |
|
0 | 1184 |
]. |
46 | 1185 |
maxExt notNil ifTrue:[ |
70 | 1186 |
maxWidth := maxExt x. |
1187 |
maxHeight := maxExt y |
|
46 | 1188 |
]. |
1189 |
||
0 | 1190 |
wsuperView notNil ifTrue:[ |
70 | 1191 |
wsuperViewId := wsuperView id |
0 | 1192 |
]. |
1193 |
wcursor isNil ifTrue:[ |
|
145 | 1194 |
'XWORKSTATION: cursor nil - defaulted' errorPrintNL |
0 | 1195 |
] ifFalse:[ |
70 | 1196 |
wcursorId := wcursor id |
0 | 1197 |
]. |
1198 |
||
1199 |
wicon notNil ifTrue:[ |
|
70 | 1200 |
wiconId := wicon id |
0 | 1201 |
]. |
1202 |
wiconView notNil ifTrue:[ |
|
70 | 1203 |
wiconViewId := wiconView id |
0 | 1204 |
]. |
1205 |
weventMask := aView eventMask. |
|
1206 |
||
150 | 1207 |
preferredVisual := aView preferredVisual. |
1208 |
preferredDepth := aView preferredDepth. |
|
23 | 1209 |
|
72 | 1210 |
%{ /* STACK:16000 */ |
0 | 1211 |
Display *dpy = myDpy; |
555 | 1212 |
int screen = __intVal(__INST(screen)); |
0 | 1213 |
Visual visual; |
1214 |
XGCValues xgcv; |
|
1215 |
XSetWindowAttributes xswa; |
|
1216 |
XSizeHints sizehints; |
|
1217 |
XWMHints wmhints; |
|
46 | 1218 |
int bw, bd, bg; |
0 | 1219 |
Window newWindow, parentWindow; |
1220 |
char *windowName; |
|
1221 |
XFontStruct *f; |
|
1222 |
Pixmap backPixmap = (Pixmap)0, iconBitmap = (Pixmap)0; |
|
1223 |
int flags = 0, depth, ioClass; |
|
1224 |
Window iconWindow; |
|
1225 |
Atom WmDeleteWindowAtom, WmSaveYourselfAtom, WmProtocolsAtom; |
|
1226 |
Atom WmQuitAppAtom; |
|
1227 |
Atom atoms[3]; |
|
1228 |
int atomCount = 0, isTopWindow = 0; |
|
1229 |
||
1230 |
sizehints.flags = 0; |
|
1231 |
sizehints.width = 100; |
|
1232 |
sizehints.height = 100; |
|
1233 |
sizehints.x = 0; |
|
1234 |
sizehints.y = 0; |
|
1235 |
||
97 | 1236 |
if (__bothSmallInteger(wwidth, wheight)) { |
70 | 1237 |
sizehints.flags |= PSize; |
555 | 1238 |
sizehints.width = __intVal(wwidth); |
1239 |
sizehints.height = __intVal(wheight); |
|
0 | 1240 |
} |
97 | 1241 |
if (__bothSmallInteger(xpos, ypos)) { |
70 | 1242 |
sizehints.flags |= PPosition; |
555 | 1243 |
sizehints.x = __intVal(xpos); |
1244 |
sizehints.y = __intVal(ypos); |
|
0 | 1245 |
} |
97 | 1246 |
if (__bothSmallInteger(minWidth, minHeight)) { |
70 | 1247 |
sizehints.flags |= PMinSize; |
555 | 1248 |
sizehints.min_width = __intVal(minWidth); |
1249 |
sizehints.min_height = __intVal(minHeight); |
|
0 | 1250 |
} |
97 | 1251 |
if (__bothSmallInteger(maxWidth, maxHeight)) { |
70 | 1252 |
sizehints.flags |= PMaxSize; |
555 | 1253 |
sizehints.max_width = __intVal(maxWidth); |
1254 |
sizehints.max_height = __intVal(maxHeight); |
|
0 | 1255 |
} |
1256 |
||
37 | 1257 |
bg = WhitePixel(dpy, screen); |
0 | 1258 |
|
97 | 1259 |
if (__isSmallInteger(bWidth)) { |
555 | 1260 |
bw = __intVal(bWidth); |
46 | 1261 |
} else { |
70 | 1262 |
bw = 0; |
0 | 1263 |
} |
1264 |
||
72 | 1265 |
bd = BlackPixel(dpy, screen); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1266 |
|
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1267 |
if (__isExternalAddress(wsuperViewId)) { |
70 | 1268 |
parentWindow = _WindowVal(wsuperViewId); |
0 | 1269 |
} else { |
70 | 1270 |
parentWindow = RootWindow(dpy, screen); |
1271 |
isTopWindow = 1; |
|
0 | 1272 |
} |
1273 |
||
157 | 1274 |
if (wisPopUpView == true) |
70 | 1275 |
xswa.override_redirect = 1; |
0 | 1276 |
else |
70 | 1277 |
xswa.override_redirect = 0; |
0 | 1278 |
|
1279 |
if (winputOnly == true) |
|
70 | 1280 |
ioClass = InputOnly; |
0 | 1281 |
else |
70 | 1282 |
ioClass = InputOutput; |
0 | 1283 |
|
97 | 1284 |
if (__isSmallInteger(weventMask)) { |
555 | 1285 |
xswa.event_mask = __intVal(weventMask); |
0 | 1286 |
} else { |
70 | 1287 |
xswa.event_mask = 0; |
0 | 1288 |
} |
1289 |
||
1290 |
if (ioClass == InputOnly) { |
|
70 | 1291 |
bw = 0; |
1292 |
depth = 0; |
|
1293 |
flags |= CWEventMask; |
|
0 | 1294 |
} else { |
70 | 1295 |
depth = DefaultDepth(dpy,screen); |
1296 |
flags |= CWEventMask | CWBorderPixel | CWOverrideRedirect; |
|
1297 |
||
1298 |
if (backPixmap != (Pixmap)0) { |
|
1299 |
xswa.background_pixmap = backPixmap; |
|
1300 |
flags |= CWBackPixmap; |
|
1301 |
} else { |
|
1302 |
xswa.background_pixel = bg; |
|
1303 |
flags |= CWBackPixel; |
|
1304 |
} |
|
1305 |
xswa.border_pixel = bd; |
|
0 | 1306 |
} |
23 | 1307 |
|
0 | 1308 |
visual.visualid = CopyFromParent; |
150 | 1309 |
if (__isSmallInteger(preferredDepth)) { |
555 | 1310 |
depth = __intVal(preferredDepth); |
23 | 1311 |
} |
54 | 1312 |
|
1313 |
BEGIN_INTERRUPTSBLOCKED |
|
150 | 1314 |
if (preferredVisual != nil) { |
70 | 1315 |
XVisualInfo vi; |
1316 |
int cls; |
|
1317 |
||
150 | 1318 |
if (preferredVisual == @symbol(StaticGray)) |
70 | 1319 |
cls = StaticGray; |
150 | 1320 |
else if (preferredVisual == @symbol(GrayScale)) |
70 | 1321 |
cls = StaticGray; |
150 | 1322 |
else if (preferredVisual == @symbol(StaticColor)) |
70 | 1323 |
cls = StaticColor; |
150 | 1324 |
else if (preferredVisual == @symbol(PseudoColor)) |
70 | 1325 |
cls = PseudoColor; |
150 | 1326 |
else if (preferredVisual == @symbol(TrueColor)) |
70 | 1327 |
cls = TrueColor; |
150 | 1328 |
else if (preferredVisual == @symbol(DirectColor)) |
70 | 1329 |
cls = DirectColor; |
1330 |
else |
|
1331 |
cls = PseudoColor; |
|
200 | 1332 |
|
70 | 1333 |
if (XMatchVisualInfo(dpy, screen, depth, cls, &vi)) { |
1334 |
visual.visualid = vi.visualid; |
|
163 | 1335 |
/* |
1336 |
printf("visualId=%x\n", vi.visualid); |
|
1337 |
*/ |
|
70 | 1338 |
} |
23 | 1339 |
} |
0 | 1340 |
|
1341 |
newWindow = XCreateWindow(dpy, parentWindow, |
|
70 | 1342 |
sizehints.x, sizehints.y, |
1343 |
sizehints.width, sizehints.height, |
|
1344 |
bw, depth, ioClass, &visual, |
|
1345 |
flags, &xswa); |
|
54 | 1346 |
END_INTERRUPTSBLOCKED |
0 | 1347 |
|
1348 |
if (! newWindow) { |
|
70 | 1349 |
RETURN ( nil ); |
0 | 1350 |
} |
1351 |
||
54 | 1352 |
BEGIN_INTERRUPTSBLOCKED |
0 | 1353 |
/* |
1354 |
* define its cursor |
|
1355 |
*/ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1356 |
if (__isExternalAddress(wcursorId)) { |
70 | 1357 |
XDefineCursor(dpy, newWindow, _CursorVal(wcursorId)); |
0 | 1358 |
} |
1359 |
||
1360 |
/* |
|
1361 |
* define its icon and name |
|
1362 |
* (only makes sense for topWindows) |
|
1363 |
*/ |
|
1364 |
if (isTopWindow) { |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1365 |
if (__isExternalAddress(wiconId)) |
70 | 1366 |
iconBitmap = _PixmapVal(wiconId); |
1367 |
else |
|
1368 |
iconBitmap = (Pixmap)0; |
|
1369 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1370 |
if (__isExternalAddress(wiconViewId)) |
70 | 1371 |
iconWindow = _WindowVal(wiconViewId); |
1372 |
else |
|
1373 |
iconWindow = (Window)0; |
|
1374 |
||
1375 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
1376 |
windowName = (char *)_stringVal(wlabel); |
|
1377 |
else |
|
1378 |
windowName = ""; |
|
1379 |
||
1380 |
if (iconBitmap || windowName) { |
|
1381 |
XSetStandardProperties(dpy, newWindow, |
|
1382 |
windowName, windowName, |
|
1383 |
iconBitmap, |
|
1384 |
0, 0, &sizehints); |
|
1385 |
||
1386 |
} |
|
1387 |
||
1388 |
wmhints.flags = 0; |
|
1389 |
if (iconBitmap) { |
|
1390 |
wmhints.flags |= IconPixmapHint; |
|
1391 |
wmhints.icon_pixmap = iconBitmap; |
|
1392 |
} |
|
1393 |
if (iconWindow) { |
|
1394 |
wmhints.flags |= IconWindowHint; |
|
1395 |
wmhints.icon_window = iconWindow; |
|
1396 |
} |
|
0 | 1397 |
/* |
70 | 1398 |
wmhints.flags |= InputHint; |
1399 |
wmhints.input = True; |
|
0 | 1400 |
*/ |
70 | 1401 |
XSetWMHints(dpy, newWindow, &wmhints); |
1402 |
||
1403 |
/* |
|
1404 |
* tell window manager to not kill us but send an event instead |
|
1405 |
*/ |
|
1406 |
/* |
|
1407 |
* get atoms first (if not already known) |
|
1408 |
*/ |
|
555 | 1409 |
if (__INST(protocolsAtom) == nil) { |
70 | 1410 |
WmProtocolsAtom = XInternAtom(dpy, "WM_PROTOCOLS", False); |
555 | 1411 |
__INST(protocolsAtom) = __MKATOMOBJ(WmProtocolsAtom); |
0 | 1412 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 1413 |
WmSaveYourselfAtom = XInternAtom(dpy, "WM_SAVE_YOURSELF", False); |
555 | 1414 |
__INST(saveYourselfAtom) = __MKATOMOBJ(WmSaveYourselfAtom); |
0 | 1415 |
#endif |
1416 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 1417 |
WmQuitAppAtom = XInternAtom(dpy, "_WM_QUIT_APP", False); |
555 | 1418 |
__INST(quitAppAtom) = __MKATOMOBJ(WmQuitAppAtom); |
0 | 1419 |
#endif |
70 | 1420 |
WmDeleteWindowAtom = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
555 | 1421 |
__INST(deleteWindowAtom) = __MKATOMOBJ(WmDeleteWindowAtom); |
70 | 1422 |
} else { |
0 | 1423 |
#ifdef USE_QUIT_APP_ATOM |
555 | 1424 |
WmQuitAppAtom = _AtomVal(__INST(quitAppAtom)); |
0 | 1425 |
#else |
70 | 1426 |
WmQuitAppAtom = 0; |
0 | 1427 |
#endif |
555 | 1428 |
WmProtocolsAtom = _AtomVal(__INST(protocolsAtom)); |
1429 |
WmDeleteWindowAtom = _AtomVal(__INST(deleteWindowAtom)); |
|
0 | 1430 |
#ifdef USE_SAVEYOURSELF_ATOM |
555 | 1431 |
WmSaveYourselfAtom = _AtomVal(__INST(saveYourselfAtom)); |
0 | 1432 |
#else |
70 | 1433 |
WmSaveYourselfAtom = 0; |
0 | 1434 |
#endif |
70 | 1435 |
} |
1436 |
||
1437 |
atoms[0] = WmDeleteWindowAtom; atomCount++; |
|
0 | 1438 |
#ifdef USE_SAVEYOURSELF_ATOM |
70 | 1439 |
atoms[atomCount] = WmSaveYourselfAtom; atomCount++; |
0 | 1440 |
#endif |
1441 |
#ifdef USE_QUIT_APP_ATOM |
|
70 | 1442 |
atoms[atomCount] = WmQuitAppAtom; atomCount++; |
0 | 1443 |
#endif |
70 | 1444 |
XChangeProperty(dpy, newWindow, WmProtocolsAtom, XA_ATOM, |
1445 |
32, PropModeReplace, (unsigned char *)atoms, atomCount); |
|
0 | 1446 |
} |
1447 |
||
54 | 1448 |
END_INTERRUPTSBLOCKED |
1449 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1450 |
windowId = __MKOBJ(newWindow); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1451 |
%}. |
0 | 1452 |
self addKnownView:aView withId:windowId. |
1453 |
^ windowId |
|
1454 |
! |
|
1455 |
||
295 | 1456 |
destroyFaxImage:aFaxImageId |
1457 |
||
1458 |
%{ /* NOCONTEXT */ |
|
1459 |
||
1460 |
#ifdef FAX |
|
1461 |
if (__isExternalAddress(aFaxImageId)) { |
|
70 | 1462 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1463 |
XFAXImageFreeImage(myDpy, (FAXImage)_WindowVal(aFaxImageId)); |
70 | 1464 |
END_INTERRUPTSBLOCKED |
295 | 1465 |
RETURN ( self ); |
1466 |
} |
|
1467 |
#endif |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1468 |
%}. |
295 | 1469 |
self primitiveFailed |
0 | 1470 |
! |
1471 |
||
1472 |
destroyGC:aGCId |
|
1473 |
||
1474 |
%{ /* NOCONTEXT */ |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1475 |
if (__isExternalAddress(aGCId) && ISCONNECTED) { |
366 | 1476 |
GC gc = _GCVal(aGCId); |
1477 |
||
1478 |
if (gc) { |
|
1479 |
BEGIN_INTERRUPTSBLOCKED |
|
1480 |
XFreeGC(myDpy, gc); |
|
1481 |
END_INTERRUPTSBLOCKED |
|
1482 |
} |
|
70 | 1483 |
RETURN ( self ); |
0 | 1484 |
} |
118 | 1485 |
%}. |
0 | 1486 |
self primitiveFailed |
1487 |
! |
|
1488 |
||
295 | 1489 |
destroyPixmap:aDrawableId |
0 | 1490 |
|
1491 |
%{ /* NOCONTEXT */ |
|
1492 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1493 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
70 | 1494 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1495 |
XFreePixmap(myDpy, _PixmapVal(aDrawableId)); |
70 | 1496 |
END_INTERRUPTSBLOCKED |
295 | 1497 |
RETURN ( self ); |
0 | 1498 |
} |
118 | 1499 |
%}. |
295 | 1500 |
self primitiveFailed |
1501 |
! |
|
1502 |
||
1503 |
destroyView:aView withId:aWindowId |
|
1504 |
%{ |
|
1505 |
if (__isExternalAddress(aWindowId) && ISCONNECTED) { |
|
1506 |
BEGIN_INTERRUPTSBLOCKED |
|
1507 |
XDestroyWindow(myDpy, _WindowVal(aWindowId)); |
|
1508 |
END_INTERRUPTSBLOCKED |
|
1509 |
} |
|
1510 |
%}. |
|
1511 |
self removeKnownView:aView |
|
0 | 1512 |
! |
1513 |
||
1514 |
dpsContextFor:aDrawableId and:aGCId |
|
1515 |
||
1516 |
%{ /* NOCONTEXT */ |
|
1517 |
#ifdef XXDPS |
|
555 | 1518 |
int screen = __intVal(__INST(screen)); |
0 | 1519 |
DPSContext dps; |
1520 |
int height; |
|
1521 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1522 |
if (__isExternalAddress(aDrawableId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1523 |
&& __isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1524 |
&& ISCONNECTED) { |
70 | 1525 |
BEGIN_INTERRUPTSBLOCKED |
1526 |
dps = XDPSCreateContext(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1527 |
_GCVal(aGCId), |
|
1528 |
0, height, 0, colormap, NULL, 0, |
|
1529 |
XDPSDefaultTextBackstop, |
|
1530 |
XDPSDefaultErrorProc, |
|
1531 |
NULL); |
|
1532 |
END_INTERRUPTSBLOCKED |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
1533 |
RETURN ( dps ? __MKOBJ(dps) : nil ); |
0 | 1534 |
} |
1535 |
#endif |
|
1536 |
%} |
|
1537 |
. |
|
43 | 1538 |
self primitiveFailed. |
1539 |
^ nil |
|
295 | 1540 |
! |
1541 |
||
1542 |
gcFor:aDrawableId |
|
132 | 1543 |
|
1544 |
%{ /* NOCONTEXT */ |
|
555 | 1545 |
int screen = __intVal(__INST(screen)); |
295 | 1546 |
GC gc; |
1547 |
||
1548 |
if (__isExternalAddress(aDrawableId) && ISCONNECTED) { |
|
1549 |
BEGIN_INTERRUPTSBLOCKED |
|
1550 |
gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId), |
|
1551 |
0L, (XGCValues *)0); |
|
1552 |
END_INTERRUPTSBLOCKED |
|
1553 |
RETURN ( gc ? __MKOBJ(gc) : nil ); |
|
200 | 1554 |
} |
1555 |
%}. |
|
1556 |
self primitiveFailed. |
|
1557 |
^ nil |
|
295 | 1558 |
! |
1559 |
||
1560 |
primCreateBitmapFromArray:anArray width:w height:h |
|
154 | 1561 |
|
1562 |
%{ /* UNLIMITEDSTACK */ |
|
1563 |
||
295 | 1564 |
Display *dpy = myDpy; |
555 | 1565 |
int screen = __intVal(__INST(screen)); |
295 | 1566 |
Pixmap newBitmap; |
1567 |
unsigned int b_width, b_height; |
|
1568 |
REGISTER unsigned char *cp; |
|
1569 |
REGISTER unsigned char *pBits; |
|
1570 |
unsigned char *b_bits, *allocatedBits; |
|
1571 |
int index, row; |
|
1572 |
REGISTER int col; |
|
1573 |
unsigned bits; |
|
1574 |
static char reverseBitTable[256]; |
|
1575 |
static firstCall = 1; |
|
1576 |
int nBytes; |
|
1577 |
unsigned char fastBits[10000]; |
|
1578 |
OBJ num, *op; |
|
1579 |
int bytesPerRow; |
|
1580 |
||
1581 |
if (firstCall) { |
|
1582 |
for (index=0; index < 256; index++) { |
|
1583 |
reverseBitTable[index] = 0; |
|
1584 |
if (index & 128) reverseBitTable[index] |= 1; |
|
1585 |
if (index & 64) reverseBitTable[index] |= 2; |
|
1586 |
if (index & 32) reverseBitTable[index] |= 4; |
|
1587 |
if (index & 16) reverseBitTable[index] |= 8; |
|
1588 |
if (index & 8) reverseBitTable[index] |= 16; |
|
1589 |
if (index & 4) reverseBitTable[index] |= 32; |
|
1590 |
if (index & 2) reverseBitTable[index] |= 64; |
|
1591 |
if (index & 1) reverseBitTable[index] |= 128; |
|
154 | 1592 |
} |
295 | 1593 |
firstCall = 0; |
1594 |
} |
|
1595 |
||
1596 |
if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) { |
|
377 | 1597 |
newBitmap = (Pixmap)0; |
555 | 1598 |
b_width = __intVal(w); |
1599 |
b_height = __intVal(h); |
|
295 | 1600 |
bytesPerRow = (b_width + 7) / 8; |
1601 |
nBytes = b_height * bytesPerRow; |
|
1602 |
if (nBytes < sizeof(fastBits)) { |
|
1603 |
cp = b_bits = fastBits; |
|
1604 |
allocatedBits = 0; |
|
1605 |
} else { |
|
1606 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
1607 |
if (! cp) goto fail; |
|
150 | 1608 |
} |
295 | 1609 |
|
377 | 1610 |
if (__qClass(anArray) == @global(Array)) { |
295 | 1611 |
index = 1; |
555 | 1612 |
op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
295 | 1613 |
for (row = b_height; row; row--) { |
1614 |
for (col = bytesPerRow; col; col--) { |
|
1615 |
num = *op++; |
|
1616 |
if (! __isSmallInteger(num)) goto fail; |
|
555 | 1617 |
bits = __intVal(num); |
295 | 1618 |
*cp++ = reverseBitTable[bits]; |
1619 |
} |
|
1620 |
} |
|
1621 |
} else { |
|
377 | 1622 |
if (__qClass(anArray) == @global(ByteArray)) { |
555 | 1623 |
pBits = __ByteArrayInstPtr(anArray)->ba_element; |
295 | 1624 |
for (col = b_height*bytesPerRow; col; col--) { |
1625 |
*cp++ = reverseBitTable[*pBits++]; |
|
1626 |
} |
|
1627 |
} else { |
|
1628 |
goto fail; |
|
1629 |
} |
|
150 | 1630 |
} |
295 | 1631 |
|
1632 |
BEGIN_INTERRUPTSBLOCKED |
|
1633 |
newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen), |
|
1634 |
(char *)b_bits, |
|
1635 |
b_width, b_height); |
|
1636 |
END_INTERRUPTSBLOCKED |
|
1637 |
fail: ; |
|
1638 |
if (allocatedBits) |
|
1639 |
free(allocatedBits); |
|
1640 |
RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil ); |
|
0 | 1641 |
} |
1642 |
%} |
|
295 | 1643 |
! |
1644 |
||
1645 |
realRootWindowFor:aView |
|
1646 |
"the name of this method is historic; |
|
1647 |
- it will vanish" |
|
1648 |
||
1649 |
|id| |
|
1650 |
||
1651 |
id := self realRootWindowId. |
|
1652 |
self addKnownView:aView withId:id. |
|
1653 |
^ id |
|
1654 |
! |
|
1655 |
||
1656 |
realRootWindowId |
|
1657 |
"return the id of the real root window. |
|
1658 |
This may not be the window you see as background, |
|
1659 |
since some window managers install a virtual root window on top |
|
1660 |
of it. Except for very special cases, use #rootWindowId, which takes |
|
1661 |
care of any virtual root." |
|
0 | 1662 |
|
1663 |
%{ /* NOCONTEXT */ |
|
1664 |
||
555 | 1665 |
int screen = __intVal(__INST(screen)); |
295 | 1666 |
Window root; |
1667 |
OBJ id; |
|
1668 |
||
555 | 1669 |
if (__INST(rootId) != nil) { |
1670 |
RETURN (__INST(rootId)); |
|
295 | 1671 |
} |
0 | 1672 |
|
150 | 1673 |
if (ISCONNECTED) { |
295 | 1674 |
root = RootWindow(myDpy, screen); |
1675 |
if (! root) { |
|
1676 |
id = nil; |
|
1677 |
} else { |
|
555 | 1678 |
__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
|
1679 |
} |
295 | 1680 |
RETURN (id); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1681 |
} |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
1682 |
%}. |
295 | 1683 |
self primitiveFailed |
1684 |
! |
|
1685 |
||
1686 |
rootWindowFor:aView |
|
1687 |
|id| |
|
1688 |
||
1689 |
id := self rootWindowId. |
|
1690 |
self addKnownView:aView withId:id. |
|
0 | 1691 |
^ id |
1692 |
! |
|
1693 |
||
295 | 1694 |
rootWindowId |
1695 |
"return the id of the root window. |
|
1696 |
This is the window you see as background, |
|
1697 |
however, it may or may not be the real physical root window, |
|
1698 |
since some window managers install a virtual root window on top |
|
1699 |
of the real one. If this is the case, that views id is returned here." |
|
23 | 1700 |
|
0 | 1701 |
%{ /* NOCONTEXT */ |
555 | 1702 |
int screen = __intVal(__INST(screen)); |
295 | 1703 |
Window rootWin, vRootWin; |
1704 |
OBJ id; |
|
1705 |
||
555 | 1706 |
if (__INST(virtualRootId) != nil) { |
1707 |
RETURN (__INST(virtualRootId)); |
|
295 | 1708 |
} |
0 | 1709 |
|
169 | 1710 |
if (ISCONNECTED) { |
295 | 1711 |
vRootWin = rootWin = RootWindow(myDpy, screen); |
1712 |
#ifndef IRIS |
|
180 | 1713 |
BEGIN_INTERRUPTSBLOCKED |
295 | 1714 |
/* |
1715 |
* on IRIS, this creates a badwindow error - why ? |
|
1716 |
* children contains a funny window (000034) |
|
1717 |
*/ |
|
1718 |
||
1719 |
/* |
|
1720 |
* care for virtual root windows (tvtwm & friends) |
|
1721 |
*/ |
|
1722 |
{ |
|
1723 |
Atom vRootAtom = None; |
|
1724 |
int i; |
|
1725 |
Window rootReturn, parentReturn; |
|
1726 |
Window* children; |
|
1727 |
unsigned int numChildren; |
|
1728 |
||
1729 |
if (XQueryTree(myDpy, rootWin, |
|
1730 |
&rootReturn, &parentReturn, |
|
1731 |
&children, &numChildren)) { |
|
1732 |
vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True ); |
|
1733 |
if (vRootAtom != None) { |
|
1734 |
for (i=0; i < numChildren; i++) { |
|
1735 |
Atom actual_type; |
|
1736 |
int actual_format; |
|
1737 |
unsigned long nitems, bytesafter; |
|
1738 |
Window* newRoot = (Window*) 0; |
|
1739 |
||
1740 |
if (children[i]) { |
|
1741 |
if (XGetWindowProperty(myDpy, children[i], vRootAtom, |
|
1742 |
0L, 1L, False, XA_WINDOW, |
|
1743 |
&actual_type, &actual_format, |
|
1744 |
&nitems, &bytesafter, |
|
1745 |
(unsigned char**) &newRoot |
|
1746 |
) == Success && newRoot) { |
|
1747 |
vRootWin = *newRoot; |
|
1748 |
break; |
|
1749 |
} |
|
1750 |
} |
|
1751 |
} |
|
1752 |
if (children) XFree( children ); |
|
1753 |
} |
|
1754 |
} |
|
1755 |
} |
|
180 | 1756 |
END_INTERRUPTSBLOCKED |
295 | 1757 |
#endif |
1758 |
} |
|
1759 |
||
1760 |
/* cannot happen */ |
|
1761 |
if (! vRootWin) { |
|
1762 |
vRootWin = rootWin; |
|
1763 |
if (! rootWin) { |
|
1764 |
RETURN ( nil ); |
|
1765 |
} |
|
1766 |
} |
|
555 | 1767 |
__INST(rootId) = id = __MKOBJ(rootWin); __STORE(self, id); |
1768 |
__INST(virtualRootId) = id = __MKOBJ(vRootWin); __STORE(self, id); |
|
295 | 1769 |
RETURN ( id ); |
63 | 1770 |
%} |
0 | 1771 |
! ! |
1772 |
||
1773 |
!XWorkstation methodsFor:'color stuff'! |
|
1774 |
||
295 | 1775 |
colorCell |
1776 |
"allocate a color cell - return index. |
|
1777 |
This method will return nil for StaticGrey and StaticGrey displays." |
|
0 | 1778 |
|
1779 |
%{ /* NOCONTEXT */ |
|
1780 |
||
1781 |
Display *dpy = myDpy; |
|
555 | 1782 |
int screen = __intVal(__INST(screen)); |
295 | 1783 |
XColor color; |
1784 |
unsigned long dummy; |
|
1785 |
Status ok; |
|
1786 |
||
1787 |
BEGIN_INTERRUPTSBLOCKED |
|
1788 |
ok = XAllocColorCells(dpy, DefaultColormap(dpy, screen), (Bool)0, |
|
1789 |
&dummy, 0, &color.pixel, 1); |
|
1790 |
END_INTERRUPTSBLOCKED |
|
1791 |
if (ok) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1792 |
RETURN ( __MKSMALLINT(color.pixel) ); |
0 | 1793 |
} |
1794 |
%} |
|
1795 |
. |
|
43 | 1796 |
^ nil |
0 | 1797 |
! |
1798 |
||
1799 |
colorNamed:aString |
|
1800 |
"allocate a color with color name - return index. |
|
1801 |
Dont use this method, colornames are mostly X specific" |
|
1802 |
||
1803 |
%{ /* NOCONTEXT */ |
|
1804 |
||
1805 |
char *colorname; |
|
1806 |
Display *dpy = myDpy; |
|
1807 |
XColor scolor, ecolor; |
|
555 | 1808 |
int screen = __intVal(__INST(screen)); |
54 | 1809 |
Status ok; |
0 | 1810 |
|
150 | 1811 |
if (ISCONNECTED) { |
1812 |
if (__isString(aString) || __isSymbol(aString)) { |
|
1813 |
colorname = (char *)_stringVal(aString); |
|
1814 |
||
1815 |
BEGIN_INTERRUPTSBLOCKED |
|
1816 |
ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor); |
|
1817 |
if (ok) { |
|
1818 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
|
1819 |
} |
|
1820 |
END_INTERRUPTSBLOCKED |
|
1821 |
if (! ok) { |
|
1822 |
RETURN ( nil ); |
|
1823 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1824 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
70 | 1825 |
} |
0 | 1826 |
} |
1827 |
%} |
|
1828 |
. |
|
43 | 1829 |
self primitiveFailed. |
1830 |
^ nil |
|
0 | 1831 |
! |
1832 |
||
295 | 1833 |
colorRed:redVal green:greenVal blue:blueVal |
1834 |
"allocate a color with rgb values (0..100) - return index" |
|
1835 |
||
1836 |
|r g b| |
|
1837 |
||
1838 |
r := self percentToXColorValue:redVal. |
|
1839 |
g := self percentToXColorValue:greenVal. |
|
1840 |
b := self percentToXColorValue:blueVal. |
|
1841 |
%{ |
|
1842 |
Display *dpy = myDpy; |
|
1843 |
XColor ecolor; |
|
555 | 1844 |
int screen = __intVal(__INST(screen)); |
295 | 1845 |
Status ok; |
1846 |
||
1847 |
if (__bothSmallInteger(r, g) |
|
1848 |
&& __isSmallInteger(b) |
|
1849 |
&& ISCONNECTED) { |
|
555 | 1850 |
ecolor.red = __intVal(r); |
1851 |
ecolor.green= __intVal(g); |
|
1852 |
ecolor.blue = __intVal(b); |
|
295 | 1853 |
BEGIN_INTERRUPTSBLOCKED |
1854 |
ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor); |
|
1855 |
END_INTERRUPTSBLOCKED |
|
1856 |
if (! ok) { |
|
1857 |
RETURN ( nil ); |
|
1858 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1859 |
RETURN ( __MKSMALLINT(ecolor.pixel) ); |
295 | 1860 |
} |
1861 |
%} |
|
1862 |
. |
|
1863 |
self primitiveFailed. |
|
1864 |
^ nil |
|
1865 |
! |
|
1866 |
||
1867 |
freeColor:colorIndex |
|
1868 |
"free a display color when its no longer needed" |
|
0 | 1869 |
|
1870 |
%{ /* NOCONTEXT */ |
|
1871 |
||
1872 |
Display *dpy = myDpy; |
|
295 | 1873 |
unsigned long color; |
555 | 1874 |
int screen = __intVal(__INST(screen)); |
295 | 1875 |
|
1876 |
#ifdef LATER |
|
555 | 1877 |
if (__INST(visualType) == @symbol(TrueColor)) { |
295 | 1878 |
/* no need to do anything on TrueColor displays ... */ |
1879 |
RETURN (self); |
|
1880 |
} |
|
1881 |
#endif |
|
1882 |
if (__isSmallInteger(colorIndex) && ISCONNECTED) { |
|
555 | 1883 |
color = (long) __intVal(colorIndex); |
295 | 1884 |
BEGIN_INTERRUPTSBLOCKED |
1885 |
XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L); |
|
1886 |
END_INTERRUPTSBLOCKED |
|
1887 |
RETURN ( self ); |
|
0 | 1888 |
} |
1889 |
%} |
|
1890 |
. |
|
295 | 1891 |
self primitiveFailed |
1892 |
! |
|
1893 |
||
1894 |
getRGBFrom:index into:aBlock |
|
1895 |
"get rgb components (0..100) of color in map at:index, |
|
1896 |
and evaluate the 3-arg block, aBlock with them" |
|
1897 |
||
1898 |
|r g b| |
|
1899 |
%{ |
|
1900 |
Display *dpy = myDpy; |
|
555 | 1901 |
int screen = __intVal(__INST(screen)); |
295 | 1902 |
XColor color; |
1903 |
double fr, fg, fb; |
|
1904 |
double floor(); |
|
1905 |
int bits, scale, shift; |
|
1906 |
||
1907 |
if (__isSmallInteger(index)) { |
|
555 | 1908 |
color.pixel = __intVal(index); |
295 | 1909 |
BEGIN_INTERRUPTSBLOCKED |
1910 |
XQueryColor(dpy, DefaultColormap(dpy, screen), &color); |
|
1911 |
END_INTERRUPTSBLOCKED |
|
1912 |
||
1913 |
/* scale to 0..100 and round to the first decimal */ |
|
1914 |
||
1915 |
/* |
|
1916 |
* have to compensate for an error in X ?, which does not scale |
|
1917 |
* colors correctly if lesser than 16bits are valid in a color, |
|
1918 |
* (for example, color white on a 4bitsPerRGB server will return |
|
1919 |
* (16rF000 16rF000 16rF000) instead of (16rFFFF 16rFFFF 16rFFFF) |
|
1920 |
*/ |
|
555 | 1921 |
bits = __intVal(__INST(bitsPerRGB)); |
295 | 1922 |
scale = (1<<bits) - 1; |
1923 |
shift = 16 - bits; |
|
1924 |
||
1925 |
fr = floor( ( ((double)(color.red>>shift) * 1000.0) / scale) + 0.5) / 10.0; |
|
1926 |
fg = floor( ( ((double)(color.green>>shift) * 1000.0) / scale) + 0.5) / 10.0; |
|
1927 |
fb = floor( ( ((double)(color.blue>>shift) * 1000.0) / scale) + 0.5) / 10.0; |
|
1928 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1929 |
r = __MKFLOAT(fr COMMA_CON); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1930 |
g = __MKFLOAT(fg COMMA_CON); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1931 |
b = __MKFLOAT(fb COMMA_CON); |
295 | 1932 |
} |
1933 |
%}. |
|
1934 |
aBlock value:r value:g value:b |
|
1935 |
! |
|
1936 |
||
1937 |
getRGBFromName:colorName into:aBlock |
|
1938 |
"get rgb components (0..100) of color named colorName, |
|
1939 |
and evaluate the 3-arg block, aBlock with them" |
|
1940 |
||
1941 |
|r g b| |
|
1942 |
||
1943 |
displayId isNil ifTrue:[ |
|
1944 |
self pimitiveFailed. |
|
1945 |
^ nil |
|
1946 |
]. |
|
1947 |
%{ |
|
1948 |
Display *dpy = myDpy; |
|
555 | 1949 |
int screen = __intVal(__INST(screen)); |
295 | 1950 |
XColor color; |
1951 |
double fr, fg, fb; |
|
1952 |
double floor(); |
|
1953 |
||
1954 |
if (__isString(colorName) || __isSymbol(colorName)) { |
|
1955 |
BEGIN_INTERRUPTSBLOCKED |
|
1956 |
if (XParseColor(dpy, DefaultColormap(dpy, screen), |
|
1957 |
(char *)_stringVal(colorName), &color)) { |
|
1958 |
/* |
|
1959 |
* scale to 0..100 and round to the first decimal |
|
1960 |
*/ |
|
1961 |
fr = floor( ((((double)color.red) * 1000.0) / 0xFFFF) + 0.5) / 10.0; |
|
1962 |
fg = floor( ((((double)color.green) * 1000.0) / 0xFFFF) + 0.5) / 10.0; |
|
1963 |
fb = floor( ((((double)color.blue) * 1000.0) / 0xFFFF) + 0.5) / 10.0; |
|
1964 |
||
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1965 |
r = __MKFLOAT(fr COMMA_CON); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1966 |
g = __MKFLOAT(fg COMMA_CON); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
1967 |
b = __MKFLOAT(fb COMMA_CON); |
295 | 1968 |
} |
1969 |
END_INTERRUPTSBLOCKED |
|
1970 |
} |
|
1971 |
%} |
|
1972 |
. |
|
1973 |
aBlock value:r value:g value:b |
|
1974 |
! |
|
1975 |
||
1976 |
listOfAvailableColors |
|
1977 |
"return a list of all available colornames. |
|
1978 |
This should not be used, since colornames are very |
|
1979 |
display-specific (here X-specific)." |
|
1980 |
||
1981 |
|aStream list line index colorName| |
|
1982 |
||
1983 |
aStream := FileStream readonlyFileNamed:'/usr/lib/X11/rgb.txt'. |
|
1984 |
aStream isNil ifTrue:[^ nil]. |
|
1985 |
list := OrderedCollection new. |
|
1986 |
[aStream atEnd] whileFalse:[ |
|
1987 |
line := aStream nextLine. |
|
1988 |
line notNil ifTrue:[ |
|
1989 |
"skip the r/g/b numbers" |
|
1990 |
index := 1. |
|
1991 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
1992 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
1993 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
1994 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
1995 |
[(line at:index) isDigit] whileTrue:[index := index + 1]. |
|
1996 |
[(line at:index) isSeparator] whileTrue:[index := index + 1]. |
|
1997 |
colorName := line copyFrom:index. |
|
1998 |
((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ |
|
1999 |
list add:colorName |
|
2000 |
] |
|
2001 |
] |
|
2002 |
]. |
|
2003 |
aStream close. |
|
2004 |
^ list sort |
|
2005 |
! |
|
2006 |
||
2007 |
percentToXColorValue:aPercentage |
|
2008 |
"given a color-component value in percent (0..100), return the corresponding |
|
2009 |
x-component value (0..65k) as an integer" |
|
2010 |
||
2011 |
%{ /* NOCONTEXT */ |
|
2012 |
||
2013 |
if (__isSmallInteger(aPercentage)) { |
|
555 | 2014 |
RETURN ( __MKSMALLINT(0xFFFF * __intVal(aPercentage) / 100) ); |
295 | 2015 |
} |
2016 |
if (__isFloat(aPercentage)) { |
|
555 | 2017 |
RETURN ( __MKSMALLINT(0xFFFF * (int)(__floatVal(aPercentage)) / 100) ); |
295 | 2018 |
} |
2019 |
%} |
|
2020 |
. |
|
2021 |
^ (16rFFFF * aPercentage / 100) rounded |
|
0 | 2022 |
! |
2023 |
||
2024 |
setColor:index red:redVal green:greenVal blue:blueVal |
|
2025 |
"change color in map at:index to rgb (0..100). |
|
2026 |
This method is a noop for StaticGrey and StaticGrey displays." |
|
2027 |
||
2028 |
%{ /* NOCONTEXT */ |
|
2029 |
||
2030 |
char *colorname; |
|
2031 |
Display *dpy = myDpy; |
|
2032 |
XColor color; |
|
555 | 2033 |
int screen = __intVal(__INST(screen)); |
0 | 2034 |
int r, g, b; |
2035 |
int ok = 1; |
|
2036 |
||
97 | 2037 |
if (__isSmallInteger(redVal)) |
555 | 2038 |
r = 0xFFFF * __intVal(redVal) / 100; |
36 | 2039 |
else if (__isFloat(redVal)) |
555 | 2040 |
r = 0xFFFF * (int)(__floatVal(redVal)) / 100; |
0 | 2041 |
else ok = 0; |
2042 |
||
97 | 2043 |
if (__isSmallInteger(greenVal)) |
555 | 2044 |
g = 0xFFFF * __intVal(greenVal) / 100; |
36 | 2045 |
else if (__isFloat(greenVal)) |
555 | 2046 |
g = 0xFFFF * (int)(__floatVal(greenVal)) / 100; |
0 | 2047 |
else ok = 0; |
2048 |
||
97 | 2049 |
if (__isSmallInteger(blueVal)) |
555 | 2050 |
b = 0xFFFF * __intVal(blueVal) / 100; |
36 | 2051 |
else if (__isFloat(blueVal)) |
555 | 2052 |
b = 0xFFFF * (int)(__floatVal(blueVal)) / 100; |
0 | 2053 |
else ok = 0; |
2054 |
||
97 | 2055 |
if (__isSmallInteger(index) && ok) { |
555 | 2056 |
color.pixel = __intVal(index); |
70 | 2057 |
color.red = r; |
2058 |
color.green = g; |
|
2059 |
color.blue = b; |
|
2060 |
color.flags = DoRed | DoGreen | DoBlue; |
|
2061 |
||
2062 |
BEGIN_INTERRUPTSBLOCKED |
|
2063 |
XStoreColor(dpy, DefaultColormap(dpy, screen), &color); |
|
2064 |
END_INTERRUPTSBLOCKED |
|
2065 |
RETURN ( self ); |
|
0 | 2066 |
} |
2067 |
%} |
|
2068 |
. |
|
2069 |
self primitiveFailed |
|
295 | 2070 |
! ! |
2071 |
||
2072 |
!XWorkstation methodsFor:'cursor stuff'! |
|
2073 |
||
2074 |
colorCursor:aCursorId foreground:fgColor background:bgColor |
|
2075 |
"change a cursors colors" |
|
2076 |
||
2077 |
|fgR fgG fgB bgR bgG bgB| |
|
2078 |
||
2079 |
fgR := fgColor red. |
|
2080 |
fgG := fgColor green. |
|
2081 |
fgB := fgColor blue. |
|
2082 |
bgR := bgColor red. |
|
2083 |
bgG := bgColor green. |
|
2084 |
bgB := bgColor blue. |
|
2085 |
||
2086 |
fgR := self percentToXColorValue:fgR. |
|
2087 |
fgG := self percentToXColorValue:fgG. |
|
2088 |
fgB := self percentToXColorValue:fgB. |
|
2089 |
bgR := self percentToXColorValue:bgR. |
|
2090 |
bgG := self percentToXColorValue:bgG. |
|
2091 |
bgB := self percentToXColorValue:bgB. |
|
2092 |
||
0 | 2093 |
%{ |
295 | 2094 |
XColor fgcolor, bgcolor; |
2095 |
||
2096 |
if (__isExternalAddress(aCursorId) |
|
2097 |
&& __bothSmallInteger(fgG, fgB) |
|
2098 |
&& __bothSmallInteger(bgR, bgG) |
|
2099 |
&& __bothSmallInteger(bgB, fgR)) { |
|
2100 |
||
555 | 2101 |
fgcolor.red = __intVal(fgR); |
2102 |
fgcolor.green= __intVal(fgG); |
|
2103 |
fgcolor.blue = __intVal(fgB); |
|
2104 |
bgcolor.red = __intVal(bgR); |
|
2105 |
bgcolor.green= __intVal(bgG); |
|
2106 |
bgcolor.blue = __intVal(bgB); |
|
70 | 2107 |
BEGIN_INTERRUPTSBLOCKED |
295 | 2108 |
XRecolorCursor(myDpy, _CursorVal(aCursorId), &fgcolor, &bgcolor); |
72 | 2109 |
END_INTERRUPTSBLOCKED |
2110 |
RETURN ( self ); |
|
2111 |
} |
|
0 | 2112 |
%} |
2113 |
. |
|
2114 |
self primitiveFailed |
|
70 | 2115 |
! |
2116 |
||
295 | 2117 |
createCursorShape:aShape |
2118 |
"create a cursor given a shape-symbol" |
|
2119 |
||
2120 |
|number id| |
|
2121 |
||
2122 |
displayId isNil ifTrue:[ |
|
2123 |
self primitiveFailed. |
|
2124 |
^ nil |
|
2125 |
]. |
|
2126 |
number := self shapeNumberFromSymbol:aShape. |
|
2127 |
%{ |
|
2128 |
Cursor newCursor; |
|
2129 |
||
2130 |
if (__isSmallInteger(number)) { |
|
2131 |
BEGIN_INTERRUPTSBLOCKED |
|
555 | 2132 |
newCursor = XCreateFontCursor(myDpy, __intVal(number)); |
295 | 2133 |
END_INTERRUPTSBLOCKED |
2134 |
if (newCursor != (Cursor)0) { |
|
2135 |
id = __MKOBJ(newCursor); |
|
70 | 2136 |
} |
0 | 2137 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2138 |
%}. |
295 | 2139 |
^ id |
2140 |
! |
|
2141 |
||
2142 |
createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy |
|
2143 |
"create a cursor given 2 bitmaps (source, mask) and a hotspot" |
|
2144 |
||
2145 |
|id sourceId maskId| |
|
2146 |
||
2147 |
displayId isNil ifTrue:[ |
|
2148 |
self primitiveFailed. |
|
2149 |
^ nil |
|
2150 |
]. |
|
2151 |
sourceId := sourceForm id. |
|
2152 |
maskId := maskForm id. |
|
2153 |
%{ |
|
2154 |
Cursor newCursor; |
|
2155 |
XColor fgColor, bgColor; |
|
2156 |
||
2157 |
if (__isExternalAddress(sourceId) |
|
2158 |
&& __isExternalAddress(maskId) |
|
2159 |
&& __bothSmallInteger(hx, hy)) { |
|
2160 |
fgColor.red = 0; /* fg is black */ |
|
2161 |
fgColor.green = 0; |
|
2162 |
fgColor.blue = 0; |
|
2163 |
bgColor.red = 0xFFFF; /* bg is white */ |
|
2164 |
bgColor.green = 0xFFFF; |
|
2165 |
bgColor.blue = 0xFFFF; |
|
2166 |
||
2167 |
BEGIN_INTERRUPTSBLOCKED |
|
2168 |
newCursor = XCreatePixmapCursor(myDpy, |
|
2169 |
_PixmapVal(sourceId), |
|
2170 |
_PixmapVal(maskId), |
|
555 | 2171 |
&fgColor, &bgColor, __intVal(hx), __intVal(hy)); |
295 | 2172 |
END_INTERRUPTSBLOCKED |
2173 |
if (newCursor != (Cursor)0) { |
|
2174 |
id = __MKOBJ(newCursor); |
|
70 | 2175 |
} |
0 | 2176 |
} |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
2177 |
%}. |
295 | 2178 |
^ id |
2179 |
! |
|
2180 |
||
2181 |
destroyCursor:aCursorId |
|
0 | 2182 |
|
2183 |
%{ /* NOCONTEXT */ |
|
2184 |
||
295 | 2185 |
if (ISCONNECTED) { |
2186 |
if (__isExternalAddress(aCursorId)) { |
|
2187 |
BEGIN_INTERRUPTSBLOCKED |
|
2188 |
XFreeCursor(myDpy, _CursorVal(aCursorId)); |
|
2189 |
END_INTERRUPTSBLOCKED |
|
70 | 2190 |
RETURN ( self ); |
2191 |
} |
|
0 | 2192 |
} |
2193 |
%} |
|
2194 |
. |
|
2195 |
self primitiveFailed |
|
295 | 2196 |
! |
2197 |
||
2198 |
shapeNumberFromSymbol:shape |
|
2199 |
"given a shape-symbol, return the corresponding cursor-number" |
|
2200 |
||
2201 |
"this is pure X-knowlegde - but you may easily add more" |
|
2202 |
||
2203 |
(shape == #upLeftArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_left_arrow) %} "132" ]. |
|
2204 |
(shape == #upRightHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand1) %} "58" ]. |
|
2205 |
(shape == #upDownArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_v_double_arrow) %} "116" ]. |
|
2206 |
(shape == #leftRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_sb_h_double_arrow) %} "108" ]. |
|
2207 |
(shape == #upLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_top_side) %} "138" ]. |
|
2208 |
(shape == #downLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_bottom_side) %} "16" ]. |
|
2209 |
(shape == #leftLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_left_side) %} "70" ]. |
|
2210 |
(shape == #rightLimitArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_right_side) %} "96" ]. |
|
2211 |
(shape == #text) ifTrue:[ ^ %{ __MKSMALLINT(XC_xterm) %} "152" ]. |
|
2212 |
(shape == #upRightArrow) ifTrue:[ ^ %{ __MKSMALLINT(XC_draft_large) %} "44" ]. |
|
2213 |
(shape == #leftHand) ifTrue:[ ^ %{ __MKSMALLINT(XC_hand2) %} "60" ]. |
|
2214 |
(shape == #questionMark) ifTrue:[ ^ %{ __MKSMALLINT(XC_question_arrow) %} "92" ]. |
|
2215 |
(shape == #cross) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2216 |
(shape == #wait) ifTrue:[ ^ %{ __MKSMALLINT(XC_watch) %} "150" ]. |
|
2217 |
(shape == #crossHair) ifTrue:[ ^ %{ __MKSMALLINT(XC_tcross) %} "130" ]. |
|
2218 |
((shape == #origin) |
|
2219 |
or:[shape == #topLeft]) ifTrue:[ ^ %{ __MKSMALLINT(XC_ul_angle) %} "144" ]. |
|
2220 |
((shape == #corner) |
|
2221 |
or:[shape == #bottomRight]) ifTrue:[ ^ %{ __MKSMALLINT(XC_lr_angle) %} "78" ]. |
|
2222 |
(shape == #topRight) ifTrue:[ ^ %{ __MKSMALLINT(XC_ur_angle) %} "148" ]. |
|
2223 |
(shape == #bottomLeft) ifTrue:[ ^ %{ __MKSMALLINT(XC_ll_angle) %} "76" ]. |
|
2224 |
(shape == #square) ifTrue:[ ^ %{ __MKSMALLINT(XC_dotbox) %} "40" ]. |
|
2225 |
(shape == #fourWay) ifTrue:[ ^ %{ __MKSMALLINT(XC_fleur) %} "52" ]. |
|
2226 |
(shape == #crossCursor) ifTrue:[ ^ %{ __MKSMALLINT(XC_X_cursor) %} "0" ]. |
|
2227 |
('XWORKSTATION: invalid cursorShape:' , shape printString) errorPrintNL. |
|
2228 |
^ 0 |
|
0 | 2229 |
! ! |
2230 |
||
2231 |
!XWorkstation methodsFor:'drawing'! |
|
2232 |
||
2233 |
copyFromFaxImage:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2234 |
width:w height:h with:aGCId scaleX:scaleX scaleY:scaleY |
12 | 2235 |
|
2236 |
"do a bit-blt of a compressed FAX image |
|
2237 |
- this needs my private FAX extension" |
|
132 | 2238 |
|
2239 |
%{ /* NOCONTEXT */ |
|
0 | 2240 |
#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
|
2241 |
GC gc; |
0 | 2242 |
FAXImage source; |
2243 |
Drawable dest; |
|
2244 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2245 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2246 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2247 |
&& __isExternalAddress(destId) |
97 | 2248 |
&& __bothSmallInteger(scaleX, scaleY) |
2249 |
&& __bothSmallInteger(w, h) |
|
2250 |
&& __bothSmallInteger(srcX, srcY) |
|
2251 |
&& __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
|
2252 |
gc = _GCVal(aGCId); |
70 | 2253 |
source = (FAXImage) _WindowVal(sourceId); |
2254 |
dest = (Drawable) _WindowVal(destId); |
|
2255 |
XFAXImageCopyImage(myDpy, source, dest, gc, |
|
555 | 2256 |
__intVal(srcX), __intVal(srcY), |
2257 |
__intVal(w), __intVal(h), |
|
2258 |
__intVal(dstX), __intVal(dstY), |
|
2259 |
__intVal(scaleX), __intVal(scaleY)); |
|
70 | 2260 |
RETURN ( self ); |
0 | 2261 |
} |
2262 |
#endif |
|
118 | 2263 |
%}. |
0 | 2264 |
self primitiveFailed |
2265 |
! |
|
2266 |
||
2267 |
copyFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2268 |
width:w height:h with:aGCId |
118 | 2269 |
"do a bit-blt; copy bits from the rectangle defined by |
2270 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2271 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2272 |
argument is not integer." |
|
0 | 2273 |
|
2274 |
%{ /* NOCONTEXT */ |
|
2275 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2276 |
GC gc; |
0 | 2277 |
Drawable source, dest; |
2278 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2279 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2280 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2281 |
&& __isExternalAddress(destId) |
97 | 2282 |
&& __bothSmallInteger(w, h) |
2283 |
&& __bothSmallInteger(srcX, srcY) |
|
2284 |
&& __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
|
2285 |
gc = _GCVal(aGCId); |
70 | 2286 |
source = (Drawable) _WindowVal(sourceId); |
2287 |
dest = (Drawable) _WindowVal(destId); |
|
2288 |
XCopyArea(myDpy, source, dest, gc, |
|
555 | 2289 |
__intVal(srcX), __intVal(srcY), |
2290 |
__intVal(w), __intVal(h), |
|
2291 |
__intVal(dstX), __intVal(dstY)); |
|
70 | 2292 |
RETURN ( self ); |
0 | 2293 |
} |
118 | 2294 |
%}. |
2295 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2296 |
or any non integer coordinate" |
|
2297 |
||
0 | 2298 |
self primitiveFailed |
2299 |
! |
|
2300 |
||
2301 |
copyPlaneFromId:sourceId x:srcX y:srcY to:destId x:dstX y:dstY |
|
70 | 2302 |
width:w height:h with:aGCId |
118 | 2303 |
"do a bit-blt, but only copy the low-bit plane; |
2304 |
copy bits from the rectangle defined by |
|
2305 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2306 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2307 |
argument is not integer." |
|
0 | 2308 |
|
2309 |
%{ /* NOCONTEXT */ |
|
2310 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2311 |
GC gc; |
0 | 2312 |
Drawable source, dest; |
2313 |
||
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2314 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2315 |
&& __isExternalAddress(sourceId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2316 |
&& __isExternalAddress(destId) |
97 | 2317 |
&& __bothSmallInteger(w, h) |
2318 |
&& __bothSmallInteger(srcX, srcY) |
|
2319 |
&& __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
|
2320 |
gc = _GCVal(aGCId); |
70 | 2321 |
source = (Drawable) _WindowVal(sourceId); |
2322 |
dest = (Drawable) _WindowVal(destId); |
|
2323 |
XCopyPlane(myDpy, source, dest, gc, |
|
555 | 2324 |
__intVal(srcX), __intVal(srcY), |
2325 |
__intVal(w), __intVal(h), |
|
2326 |
__intVal(dstX), __intVal(dstY), 1); |
|
70 | 2327 |
RETURN ( self ); |
0 | 2328 |
} |
118 | 2329 |
%}. |
2330 |
"badGC, bad sourceDrawableId or destDrawableID |
|
2331 |
or any non integer coordinate" |
|
2332 |
||
0 | 2333 |
self primitiveFailed |
2334 |
! |
|
2335 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2336 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId |
90 | 2337 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
2338 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2339 |
|
2340 |
%{ /* NOCONTEXT */ |
|
2341 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2342 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2343 |
Window win; |
0 | 2344 |
int w, h, angle1, angle2; |
2345 |
double f; |
|
2346 |
||
97 | 2347 |
if (__isSmallInteger(startAngle)) |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2348 |
angle1 = __intVal(startAngle) * 64; |
36 | 2349 |
else if (__isFloat(startAngle)) { |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2350 |
f = __floatVal(startAngle); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2351 |
angle1 = f * 64; |
0 | 2352 |
} |
97 | 2353 |
if (__isSmallInteger(angle)) |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2354 |
angle2 = __intVal(angle) * 64; |
36 | 2355 |
else if (__isFloat(angle)) { |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2356 |
f = __floatVal(angle); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2357 |
angle2 = f * 64; |
0 | 2358 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2359 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2360 |
&& __isExternalAddress(aDrawableId) |
97 | 2361 |
&& __bothSmallInteger(x, y) |
2362 |
&& __bothSmallInteger(width, height)) { |
|
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2363 |
win = _WindowVal(aDrawableId); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2364 |
gc = _GCVal(aGCId); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2365 |
w = __intVal(width); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2366 |
h = __intVal(height); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2367 |
/* |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2368 |
* need this check here: some servers simply dump core with bad args |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2369 |
*/ |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2370 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2371 |
XDrawArc(myDpy, win, gc, __intVal(x), __intVal(y), |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2372 |
w, h, angle1, angle2); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2373 |
} |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2374 |
RETURN ( self ); |
0 | 2375 |
} |
73 | 2376 |
%}. |
2377 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2378 |
self primitiveFailed |
2379 |
! |
|
2380 |
||
295 | 2381 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
2382 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
2383 |
||
2384 |
%{ /* NOCONTEXT */ |
|
2385 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2386 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2387 |
Window win; |
295 | 2388 |
|
2389 |
if (__isExternalAddress(aGCId) |
|
2390 |
&& __isExternalAddress(aDrawableId) |
|
2391 |
&& __bothSmallInteger(x0, y0) |
|
2392 |
&& __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
|
2393 |
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
|
2394 |
win = _WindowVal(aDrawableId); |
555 | 2395 |
XDrawLine(myDpy, win, gc, __intVal(x0), __intVal(y0), |
2396 |
__intVal(x1), __intVal(y1)); |
|
295 | 2397 |
RETURN ( self ); |
2398 |
} |
|
2399 |
%}. |
|
2400 |
"badGC, badDrawable or coordinates not integer" |
|
2401 |
self primitiveFailed |
|
2402 |
! |
|
2403 |
||
2404 |
displayPointX:x y:y in:aDrawableId with:aGCId |
|
2405 |
"draw a point. If x/y are not integers, an error is triggered." |
|
2406 |
||
2407 |
%{ /* NOCONTEXT */ |
|
2408 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2409 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2410 |
Window win; |
295 | 2411 |
|
2412 |
if (__isExternalAddress(aGCId) |
|
2413 |
&& __isExternalAddress(aDrawableId) |
|
2414 |
&& __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
|
2415 |
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
|
2416 |
win = _WindowVal(aDrawableId); |
555 | 2417 |
XDrawPoint(myDpy, win, gc, __intVal(x), __intVal(y)); |
295 | 2418 |
RETURN ( self ); |
2419 |
} |
|
2420 |
%}. |
|
2421 |
"badGC, badDrawable or x/y not integer" |
|
2422 |
self primitiveFailed |
|
2423 |
! |
|
2424 |
||
2425 |
displayPolygon:aPolygon in:aDrawableId with:aGCId |
|
2426 |
"draw a polygon, the argument aPolygon is a Collection of individual points, which |
|
2427 |
define the polygon. |
|
2428 |
If any coordinate is not integer, an error is triggered." |
|
2429 |
||
2430 |
|numberOfPoints newPoints| |
|
2431 |
||
2432 |
numberOfPoints := aPolygon size. |
|
2433 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2434 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2435 |
Window win; |
295 | 2436 |
OBJ point, x, y; |
2437 |
int i, num; |
|
2438 |
XPoint *points; |
|
2439 |
XPoint qPoints[100]; |
|
377 | 2440 |
int mustFree = 0; |
295 | 2441 |
|
2442 |
if (__isExternalAddress(aGCId) |
|
2443 |
&& __isExternalAddress(aDrawableId) |
|
2444 |
&& __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
|
2445 |
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
|
2446 |
win = _WindowVal(aDrawableId); |
555 | 2447 |
num = __intVal(numberOfPoints); |
295 | 2448 |
/* |
2449 |
* avoid a (slow) malloc, if the number of points is small |
|
2450 |
*/ |
|
2451 |
if (num > 100) { |
|
2452 |
points = (XPoint *)malloc(sizeof(XPoint) * num); |
|
2453 |
if (! points) goto fail; |
|
377 | 2454 |
mustFree = 1; |
295 | 2455 |
} else |
2456 |
points = qPoints; |
|
2457 |
||
2458 |
for (i=0; i<num; i++) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
2459 |
point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1)); |
295 | 2460 |
if (! __isPoint(point)) goto fail; |
2461 |
x = _point_X(point); |
|
2462 |
y = _point_Y(point); |
|
2463 |
if (! __bothSmallInteger(x, y)) |
|
2464 |
goto fail; |
|
555 | 2465 |
points[i].x = __intVal(x); |
2466 |
points[i].y = __intVal(y); |
|
295 | 2467 |
} |
2468 |
XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin); |
|
377 | 2469 |
if (mustFree) |
295 | 2470 |
free(points); |
2471 |
RETURN ( self ); |
|
2472 |
} |
|
2473 |
fail: ; |
|
377 | 2474 |
if (mustFree) |
382 | 2475 |
free(points); |
295 | 2476 |
%}. |
2477 |
"badGC, badDrawable or coordinates not integer" |
|
2478 |
self primitiveFailed |
|
2479 |
! |
|
2480 |
||
2481 |
displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
2482 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2483 |
||
2484 |
%{ /* NOCONTEXT */ |
|
2485 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2486 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2487 |
Window win; |
295 | 2488 |
int w, h; |
2489 |
||
2490 |
if (__isExternalAddress(aGCId) |
|
2491 |
&& __isExternalAddress(aDrawableId) |
|
2492 |
&& __bothSmallInteger(x, y) |
|
2493 |
&& __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
|
2494 |
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
|
2495 |
win = _WindowVal(aDrawableId); |
555 | 2496 |
w = __intVal(width); |
2497 |
h = __intVal(height); |
|
295 | 2498 |
/* |
2499 |
* need this check here: some servers simply dump core with bad args |
|
2500 |
*/ |
|
2501 |
if ((w >= 0) && (h >= 0)) { |
|
555 | 2502 |
XDrawRectangle(myDpy, win, gc, __intVal(x), __intVal(y), w, h); |
295 | 2503 |
} |
2504 |
RETURN ( self ); |
|
2505 |
} |
|
2506 |
%}. |
|
2507 |
"badGC, badDrawable or coordinates not integer" |
|
2508 |
self primitiveFailed |
|
2509 |
! |
|
2510 |
||
2511 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2512 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2513 |
foreground and background characters. |
|
2514 |
If the coordinates are not integers, an error is triggered." |
|
2515 |
||
2516 |
%{ /* NOCONTEXT */ |
|
2517 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2518 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2519 |
Window win; |
295 | 2520 |
unsigned char *cp; |
2521 |
OBJ cls; |
|
2522 |
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
|
2523 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2524 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2525 |
int nInstBytes; |
295 | 2526 |
|
2527 |
if (__isExternalAddress(aGCId) |
|
2528 |
&& __isExternalAddress(aDrawableId) |
|
2529 |
&& __isNonNilObject(aString) |
|
2530 |
&& __bothSmallInteger(index1, index2) |
|
2531 |
&& __bothSmallInteger(x, y)) { |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2532 |
gc = _GCVal(aGCId); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2533 |
win = _WindowVal(aDrawableId); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2534 |
cls = __qClass(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2535 |
|
555 | 2536 |
i1 = __intVal(index1) - 1; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2537 |
if (i1 >= 0) { |
555 | 2538 |
i2 = __intVal(index2) - 1; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2539 |
if (i2 < i1) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2540 |
RETURN (self); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2541 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2542 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2543 |
cp = _stringVal(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2544 |
l = i2 - i1 + 1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2545 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2546 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2547 |
n = _stringSize(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2548 |
if (i2 < n) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2549 |
cp += i1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2550 |
if (l > 1000) l = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2551 |
if (opaque == true) |
555 | 2552 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2553 |
else |
555 | 2554 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2555 |
RETURN ( self ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2556 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2557 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2558 |
|
555 | 2559 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2560 |
cp += nInstBytes; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2561 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2562 |
if (__isBytes(aString)) { |
555 | 2563 |
n = __byteArraySize(aString) - nInstBytes - 1; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2564 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2565 |
if (i2 < n) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2566 |
cp += i1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2567 |
if (l > 1000) l = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2568 |
if (opaque == true) |
555 | 2569 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2570 |
else |
555 | 2571 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, l); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2572 |
RETURN ( self ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2573 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2574 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2575 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2576 |
/* TWOBYTESTRINGS */ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2577 |
if (__isWords(aString)) { |
555 | 2578 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2579 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2580 |
if (i2 < n) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2581 |
union { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2582 |
char b[2]; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2583 |
unsigned short s; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2584 |
} u; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2585 |
int i; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2586 |
XChar2b *cp2 = (XChar2b *)0; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2587 |
int mustFree = 0; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2588 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2589 |
cp += (i1 * 2); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2590 |
if (l > 1000) l = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2591 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2592 |
/* |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2593 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2594 |
* X expects them MSB first |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2595 |
* convert as required |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2596 |
*/ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2597 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2598 |
u.s = 0x1234; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2599 |
if (u.b[0] != 0x12) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2600 |
if (l <= NLOCALBUFFER) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2601 |
cp2 = xlatebuffer; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2602 |
} else { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2603 |
cp2 = (XChar2b *)(malloc(l * 2)); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2604 |
mustFree = 1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2605 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2606 |
for (i=0; i<l; i++) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2607 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2608 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2609 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2610 |
cp = (char *) cp2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2611 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2612 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2613 |
if (opaque == true) |
555 | 2614 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2615 |
else |
555 | 2616 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2617 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2618 |
if (mustFree) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2619 |
free(cp2); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2620 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2621 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2622 |
RETURN ( self ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2623 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2624 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2625 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2626 |
} |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2627 |
#undef NLOCALBUFFER |
295 | 2628 |
%}. |
2629 |
"x/y not integer, badGC or drawable, or not a string" |
|
2630 |
self primitiveFailed |
|
2631 |
! |
|
2632 |
||
2633 |
displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque |
|
2634 |
"draw a string - if opaque is false, draw foreground only; otherwise, draw both |
|
2635 |
foreground and background characters. |
|
2636 |
If the coordinates are not integers, an error is triggered." |
|
2637 |
||
2638 |
%{ /* NOCONTEXT */ |
|
2639 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2640 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2641 |
Window win; |
295 | 2642 |
unsigned char *cp; |
2643 |
int n; |
|
2644 |
OBJ cls; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2645 |
# define NLOCALBUFFER 200 |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2646 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
2647 |
int nInstBytes; |
295 | 2648 |
|
2649 |
if (__isExternalAddress(aGCId) |
|
2650 |
&& __isExternalAddress(aDrawableId) |
|
2651 |
&& __isNonNilObject(aString) |
|
2652 |
&& __bothSmallInteger(x, y)) { |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2653 |
gc = _GCVal(aGCId); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2654 |
win = _WindowVal(aDrawableId); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2655 |
cls = __qClass(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2656 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2657 |
cp = _stringVal(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2658 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2659 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2660 |
n = _stringSize(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2661 |
if (n > 1000) n = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2662 |
if (opaque == true) |
555 | 2663 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2664 |
else |
555 | 2665 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2666 |
RETURN ( self ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2667 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2668 |
|
555 | 2669 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2670 |
cp += nInstBytes; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2671 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2672 |
if (__isBytes(aString)) { |
555 | 2673 |
n = __byteArraySize(aString) - nInstBytes - 1; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2674 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2675 |
if (n > 1000) n = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2676 |
if (opaque == true) |
555 | 2677 |
XDrawImageString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2678 |
else |
555 | 2679 |
XDrawString(myDpy, win, gc, __intVal(x), __intVal(y), (char *)cp, n); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2680 |
RETURN ( self ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2681 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2682 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2683 |
/* TWOBYTESTRINGS */ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2684 |
if (__isWords(aString)) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2685 |
union { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2686 |
char b[2]; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2687 |
unsigned short s; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2688 |
} u; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2689 |
int i; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2690 |
XChar2b *cp2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2691 |
int mustFree = 0; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2692 |
|
555 | 2693 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2694 |
if (n > 1000) n = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2695 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2696 |
/* |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2697 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2698 |
* X expects them MSB first |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2699 |
* convert as required |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2700 |
*/ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2701 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2702 |
u.s = 0x1234; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2703 |
if (u.b[0] != 0x12) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2704 |
if (n <= NLOCALBUFFER) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2705 |
cp2 = xlatebuffer; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2706 |
} else { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2707 |
cp2 = (XChar2b *)(malloc(n * 2)); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2708 |
mustFree = 1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2709 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2710 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2711 |
for (i=0; i<n; i++) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2712 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2713 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2714 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2715 |
cp = (char *) cp2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2716 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2717 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2718 |
if (opaque == true) |
555 | 2719 |
XDrawImageString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2720 |
else |
555 | 2721 |
XDrawString16(myDpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2722 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2723 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2724 |
if (mustFree) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2725 |
free(cp2); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2726 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2727 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2728 |
RETURN ( self ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2729 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
2730 |
} |
461
4a4b1384ab76
X wants 16bit strings in MSBfirst
Claus Gittinger <cg@exept.de>
parents:
459
diff
changeset
|
2731 |
#undef NLOCALBUFFER |
295 | 2732 |
%}. |
2733 |
"x/y not integer, badGC or drawable, or not a string" |
|
2734 |
self primitiveFailed |
|
2735 |
! |
|
2736 |
||
2737 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2738 |
width:imageWidth height:imageHeight |
|
2739 |
x:srcx y:srcy |
|
2740 |
into:aDrawableId |
|
2741 |
x:dstx y:dsty |
|
2742 |
width:w height:h |
|
2743 |
with:aGCId |
|
2744 |
||
2745 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2746 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2747 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
2748 |
depth and pixel-units to be different. |
|
2749 |
It has to be checked elsewhere, that the server can do it with the given |
|
2750 |
depth - otherwise, primitive failure will be signalled. |
|
2751 |
Also it is assumed, that the colormap is setup correctly and the |
|
2752 |
colors are allocated - otherwise the colors may be wrong." |
|
2753 |
||
2754 |
" |
|
2755 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
2756 |
an unlimited stack, and thus cannot send primitiveFailed |
|
2757 |
" |
|
2758 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
2759 |
width:imageWidth height:imageHeight |
|
2760 |
x:srcx y:srcy |
|
2761 |
into:aDrawableId |
|
2762 |
x:dstx y:dsty |
|
2763 |
width:w height:h |
|
2764 |
with:aGCId) |
|
2765 |
ifFalse:[ |
|
2766 |
" |
|
2767 |
also happens, if a segmentation violation occurs in the |
|
2768 |
XPutImage ... |
|
2769 |
" |
|
2770 |
self primitiveFailed |
|
2771 |
]. |
|
2772 |
! |
|
2773 |
||
2774 |
drawBits:imageBits depth:imageDepth |
|
2775 |
width:imageWidth height:imageHeight |
|
2776 |
x:srcx y:srcy |
|
2777 |
into:aDrawableId |
|
2778 |
x:dstx y:dsty |
|
2779 |
width:w height:h |
|
2780 |
with:aGCId |
|
2781 |
||
2782 |
"draw a bitImage which has depth id, width iw and height ih into |
|
2783 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
2784 |
Individual source pixels must have imageDepth bits. |
|
2785 |
It has to be checked elsewhere, that the server can do it with the given |
|
2786 |
depth - otherwise, primitive failure will be signalled. |
|
2787 |
Also it is assumed, that the colormap is setup correctly and the |
|
2788 |
colors are allocated - otherwise the colors may be wrong." |
|
2789 |
||
2790 |
^ self drawBits:imageBits bitsPerPixel:imageDepth depth:imageDepth |
|
2791 |
width:imageWidth height:imageHeight |
|
2792 |
x:srcx y:srcy |
|
2793 |
into:aDrawableId |
|
2794 |
x:dstx y:dsty |
|
2795 |
width:w height:h |
|
2796 |
with:aGCId |
|
2797 |
||
2798 |
! |
|
2799 |
||
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2800 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2801 |
in:aDrawableId with:aGCId |
90 | 2802 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
2803 |
The angles may be floats or integer - they are given in degrees." |
|
0 | 2804 |
|
2805 |
%{ /* NOCONTEXT */ |
|
2806 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2807 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2808 |
Window win; |
0 | 2809 |
int w, h, angle1, angle2; |
2810 |
double f; |
|
2811 |
||
97 | 2812 |
if (__isSmallInteger(startAngle)) |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2813 |
angle1 = __intVal(startAngle) * 64; |
36 | 2814 |
else if (__isFloat(startAngle)) { |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2815 |
f = __floatVal(startAngle); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2816 |
angle1 = f * 64; |
0 | 2817 |
} |
97 | 2818 |
if (__isSmallInteger(angle)) |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2819 |
angle2 = __intVal(angle) * 64; |
36 | 2820 |
else if (__isFloat(angle)) { |
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2821 |
f = __floatVal(angle); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2822 |
angle2 = f * 64; |
0 | 2823 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2824 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2825 |
&& __isExternalAddress(aDrawableId) |
97 | 2826 |
&& __bothSmallInteger(x, y) |
2827 |
&& __bothSmallInteger(width, height)) { |
|
652
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2828 |
gc = _GCVal(aGCId); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2829 |
win = _WindowVal(aDrawableId); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2830 |
w = __intVal(width); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2831 |
h = __intVal(height); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2832 |
/* |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2833 |
* need this check here: some servers simply dump core with bad args |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2834 |
*/ |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2835 |
if ((w >= 0) && (h >= 0) && (angle1 >= 0) && (angle2 >= 0)) { |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2836 |
XFillArc(myDpy, win, gc, __intVal(x), __intVal(y), |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2837 |
w, h, angle1, angle2); |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2838 |
} |
30a701619098
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
613
diff
changeset
|
2839 |
RETURN ( self ); |
0 | 2840 |
} |
73 | 2841 |
%}. |
2842 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2843 |
self primitiveFailed |
2844 |
! |
|
2845 |
||
2846 |
fillPolygon:aPolygon in:aDrawableId with:aGCId |
|
118 | 2847 |
"fill a polygon given by its points. |
2848 |
If any coordinate is not integer, an error is triggered." |
|
73 | 2849 |
|
2850 |
|numberOfPoints| |
|
0 | 2851 |
|
2852 |
numberOfPoints := aPolygon size. |
|
2853 |
%{ |
|
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2854 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2855 |
Window win; |
73 | 2856 |
OBJ point, x, y; |
2857 |
int i, num; |
|
2858 |
XPoint *points; |
|
2859 |
XPoint qPoints[100]; |
|
377 | 2860 |
int mustFree = 0; |
73 | 2861 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2862 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2863 |
&& __isExternalAddress(aDrawableId) |
97 | 2864 |
&& __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
|
2865 |
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
|
2866 |
win = _WindowVal(aDrawableId); |
555 | 2867 |
num = __intVal(numberOfPoints); |
73 | 2868 |
if (num < 3) { |
70 | 2869 |
RETURN ( self ); |
2870 |
} |
|
73 | 2871 |
/* |
2872 |
* avoid (slow) malloc, if not many points |
|
2873 |
*/ |
|
96 | 2874 |
if (num > 100) { |
73 | 2875 |
points = (XPoint *) malloc(sizeof(XPoint) * num); |
96 | 2876 |
if (! points) goto fail; |
377 | 2877 |
mustFree = 1; |
96 | 2878 |
} else |
73 | 2879 |
points = qPoints; |
2880 |
for (i=0; i<num; i++) { |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
2881 |
point = __AT_(aPolygon COMMA_CON, __MKSMALLINT(i+1)); |
73 | 2882 |
if (! __isPoint(point)) goto fail; |
2883 |
x = _point_X(point); |
|
2884 |
y = _point_Y(point); |
|
97 | 2885 |
if (! __bothSmallInteger(x, y)) |
73 | 2886 |
goto fail; |
555 | 2887 |
points[i].x = __intVal(x); |
2888 |
points[i].y = __intVal(y); |
|
73 | 2889 |
} |
2890 |
XFillPolygon(myDpy, win, gc, points, num, Complex, CoordModeOrigin); |
|
377 | 2891 |
if (mustFree) |
73 | 2892 |
free(points); |
2893 |
RETURN ( self ); |
|
377 | 2894 |
|
0 | 2895 |
fail: ; |
382 | 2896 |
if (mustFree) |
2897 |
free(points); |
|
0 | 2898 |
} |
73 | 2899 |
%}. |
2900 |
"badGC, badDrawable or coordinates not integer" |
|
0 | 2901 |
self primitiveFailed |
2902 |
! |
|
2903 |
||
295 | 2904 |
fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
2905 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
2906 |
||
2907 |
%{ /* NOCONTEXT */ |
|
2908 |
||
2909 |
int w, h; |
|
2910 |
||
2911 |
if (__isExternalAddress(aGCId) |
|
2912 |
&& __isExternalAddress(aDrawableId) |
|
2913 |
&& __bothSmallInteger(x, y) |
|
2914 |
&& __bothSmallInteger(width, height)) { |
|
555 | 2915 |
w = __intVal(width); |
2916 |
h = __intVal(height); |
|
295 | 2917 |
/* |
2918 |
* need this check here: some servers simply dump core with bad args |
|
2919 |
*/ |
|
2920 |
if ((w >= 0) && (h >= 0)) { |
|
2921 |
XFillRectangle(myDpy, |
|
2922 |
(Drawable)_WindowVal(aDrawableId), _GCVal(aGCId), |
|
555 | 2923 |
__intVal(x), __intVal(y), w, h); |
295 | 2924 |
} |
2925 |
RETURN ( self ); |
|
2926 |
} |
|
2927 |
%}. |
|
2928 |
"badGC, badDrawable or coordinates not integer" |
|
2929 |
self primitiveFailed |
|
43 | 2930 |
! |
2931 |
||
2932 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
|
70 | 2933 |
width:imageWidth height:imageHeight |
2934 |
x:srcx y:srcy |
|
2935 |
into:aDrawableId |
|
2936 |
x:dstx y:dsty |
|
2937 |
width:w height:h |
|
2938 |
with:aGCId |
|
0 | 2939 |
|
132 | 2940 |
"since XPutImage may allocate huge amount of stack space |
2941 |
(some implementations use alloca), this must run with unlimited stack." |
|
2942 |
||
12 | 2943 |
%{ /* UNLIMITEDSTACK */ |
0 | 2944 |
|
43 | 2945 |
/* |
2946 |
* need unlimited stack, since some Xlibs do a huge alloca in |
|
2947 |
* XPutImage |
|
2948 |
*/ |
|
2949 |
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
|
2950 |
GC gc; |
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
2951 |
Window win; |
43 | 2952 |
XImage image; |
377 | 2953 |
int imgWdth; |
43 | 2954 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2955 |
if (__isExternalAddress(aGCId) |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
2956 |
&& __isExternalAddress(aDrawableId) |
97 | 2957 |
&& __bothSmallInteger(srcx, srcy) |
2958 |
&& __bothSmallInteger(dstx, dsty) |
|
2959 |
&& __bothSmallInteger(w, h) |
|
2960 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
2961 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
43 | 2962 |
&& __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
|
2963 |
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
|
2964 |
win = _WindowVal(aDrawableId); |
811 | 2965 |
if (! gc || !win) |
2966 |
goto fail; |
|
46 | 2967 |
#ifdef ARGDEBUG |
70 | 2968 |
printf("args ok\n"); |
46 | 2969 |
#endif |
555 | 2970 |
image.data = (char *)__ByteArrayInstPtr(imageBits)->ba_element; |
2971 |
image.width = imgWdth = __intVal(imageWidth); |
|
2972 |
image.height = __intVal(imageHeight); |
|
70 | 2973 |
image.xoffset = 0; |
2974 |
image.format = ZPixmap; |
|
2975 |
image.byte_order = MSBFirst; |
|
2976 |
image.bitmap_unit = 8; |
|
2977 |
image.bitmap_bit_order = MSBFirst; |
|
2978 |
image.bitmap_pad = 8; |
|
555 | 2979 |
image.depth = __intVal(imageDepth); |
2980 |
image.bits_per_pixel = __intVal(bitsPerPixel); |
|
70 | 2981 |
switch (image.bits_per_pixel) { |
2982 |
case 1: |
|
377 | 2983 |
image.bytes_per_line = (imgWdth + 7) / 8; |
70 | 2984 |
break; |
2985 |
case 2: |
|
377 | 2986 |
image.bytes_per_line = (imgWdth*2 + 7) / 8; |
70 | 2987 |
break; |
2988 |
case 4: |
|
377 | 2989 |
image.bytes_per_line = (imgWdth*4 + 7) / 8; |
70 | 2990 |
break; |
2991 |
case 8: |
|
377 | 2992 |
image.bytes_per_line = imgWdth; |
70 | 2993 |
break; |
2994 |
case 16: |
|
377 | 2995 |
image.bytes_per_line = imgWdth*2; |
70 | 2996 |
break; |
2997 |
case 24: |
|
377 | 2998 |
image.bytes_per_line = imgWdth*3; |
70 | 2999 |
break; |
193 | 3000 |
case 32: |
377 | 3001 |
image.bytes_per_line = imgWdth*4; |
193 | 3002 |
break; |
70 | 3003 |
default: |
46 | 3004 |
#ifdef ARGDEBUG |
70 | 3005 |
printf("bits_per_pixel=%d\n",image.bits_per_pixel); |
46 | 3006 |
#endif |
70 | 3007 |
goto fail; |
3008 |
} |
|
3009 |
image.red_mask = 0xFFFF; |
|
3010 |
image.green_mask = 0xFFFF; |
|
3011 |
image.blue_mask = 0xFFFF; |
|
555 | 3012 |
XPutImage(dpy, win, gc, &image, __intVal(srcx), __intVal(srcy), |
3013 |
__intVal(dstx), __intVal(dsty), |
|
3014 |
__intVal(w), __intVal(h)); |
|
70 | 3015 |
RETURN ( true ); |
43 | 3016 |
} |
46 | 3017 |
#ifdef ARGDEBUG |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3018 |
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
|
3019 |
if (!! __isExternalAddress(aDrawableId)) printf("aDrawableId\n"); |
193 | 3020 |
if (!! __isSmallInteger(srcx)) printf("srcx\n"); |
3021 |
if (!! __isSmallInteger(srcy)) printf("srcy\n"); |
|
3022 |
if (!! __isSmallInteger(dstx)) printf("dstx\n"); |
|
3023 |
if (!! __isSmallInteger(dsty)) printf("dsty\n"); |
|
3024 |
if (!! __isSmallInteger(w)) printf("w\n"); |
|
3025 |
if (!! __isSmallInteger(h)) printf("h\n"); |
|
3026 |
if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n"); |
|
3027 |
if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n"); |
|
3028 |
if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n"); |
|
3029 |
if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n"); |
|
3030 |
if (!! __isByteArray(imageBits)) printf("imageBits\n"); |
|
46 | 3031 |
#endif |
3032 |
||
0 | 3033 |
fail: ; |
3034 |
%} |
|
3035 |
. |
|
12 | 3036 |
^ false |
0 | 3037 |
! ! |
3038 |
||
86 | 3039 |
!XWorkstation methodsFor:'event handling'! |
0 | 3040 |
|
3041 |
dispatchEventFor:aViewIdOrNil withMask:eventMask |
|
3042 |
"central event handling method: |
|
54 | 3043 |
get next event and send appropriate message to the sensor or view. |
0 | 3044 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
12 | 3045 |
otherwise only events for the view with given id are processed. |
3046 |
If the argument aMask is nonNil, only events for this eventMask are |
|
3047 |
handled." |
|
3048 |
||
54 | 3049 |
(self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[ |
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
3050 |
AbortSignal catch:[ |
83 | 3051 |
self dispatchLastEvent. |
3052 |
] |
|
54 | 3053 |
]. |
12 | 3054 |
! |
3055 |
||
295 | 3056 |
dispatchExposeEventFor:aViewIdOrNil |
3057 |
"get next expose event and send appropriate message to the sensor or view. |
|
3058 |
If the argument aViewIdOrNil is nil, events for any view are processed, |
|
3059 |
otherwise only events for the view with given id are processed." |
|
3060 |
||
3061 |
self dispatchEventFor:aViewIdOrNil withMask:(self eventMaskFor:#expose) |
|
12 | 3062 |
! |
3063 |
||
3064 |
dispatchLastEvent |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3065 |
|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
|
3066 |
eventType| |
12 | 3067 |
|
3068 |
%{ /* STACK: 8000 */ |
|
3069 |
# define ANYBUTTON (Button1MotionMask | Button2MotionMask | Button3MotionMask) |
|
0 | 3070 |
|
3071 |
Display *dpy = myDpy; |
|
135 | 3072 |
OBJ eB; |
3073 |
XEvent *ev; |
|
3074 |
||
3075 |
# define ae ((XAnyEvent *)ev) |
|
3076 |
# define ee ((XExposeEvent *)ev) |
|
3077 |
# define ke ((XKeyPressedEvent *)ev) |
|
3078 |
# define be ((XButtonPressedEvent *)ev) |
|
3079 |
# define ce ((XConfigureEvent *)ev) |
|
3080 |
# define me ((XMotionEvent *)ev) |
|
3081 |
# define ewe ((XEnterWindowEvent *)ev) |
|
3082 |
# define lwe ((XLeaveWindowEvent *)ev) |
|
3083 |
# define de ((XDestroyWindowEvent *)ev) |
|
3084 |
# define ve ((XVisibilityEvent *)ev) |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3085 |
# define mape ((XMappingEvent *)ev) |
135 | 3086 |
|
0 | 3087 |
KeySym keySym; |
3088 |
unsigned char buffer[10]; |
|
3089 |
int i, nchars; |
|
3090 |
char *keySymString; |
|
3091 |
char keySymStringBuffer[32]; |
|
3092 |
static unsigned multiClickTime = 0; |
|
3093 |
unsigned nextMultiClickTime; |
|
150 | 3094 |
OBJ upDown; |
115 | 3095 |
|
3096 |
struct inlineCache *ipS; |
|
0 | 3097 |
static struct inlineCache vid = _ILC1; |
12 | 3098 |
|
3099 |
static struct inlineCache expS = _ILC5; |
|
3100 |
static struct inlineCache gexpS = _ILC5; |
|
3101 |
static struct inlineCache nexpS = _ILC1; |
|
3102 |
static struct inlineCache motS = _ILC4; |
|
3103 |
static struct inlineCache bpS = _ILC4; |
|
3104 |
static struct inlineCache bmpS = _ILC4; |
|
3105 |
static struct inlineCache bspS = _ILC4; |
|
3106 |
static struct inlineCache brS = _ILC4; |
|
3107 |
static struct inlineCache focInS = _ILC1; |
|
3108 |
static struct inlineCache focOutS = _ILC1; |
|
3109 |
static struct inlineCache peS = _ILC4; |
|
3110 |
static struct inlineCache plS = _ILC2; |
|
54 | 3111 |
static struct inlineCache termS = _ILC1; |
3112 |
static struct inlineCache savtermS = _ILC1; |
|
3113 |
static struct inlineCache destrS = _ILC1; |
|
3114 |
static struct inlineCache unmapS = _ILC1; |
|
3115 |
static struct inlineCache mapS = _ILC1; |
|
3116 |
static struct inlineCache confS = _ILC5; |
|
70 | 3117 |
static struct inlineCache coveredS = _ILC2; |
12 | 3118 |
|
3119 |
static struct inlineCache keymap = _ILC0; |
|
3120 |
static struct inlineCache created = _ILC0; |
|
3121 |
static struct inlineCache mapReq = _ILC0; |
|
3122 |
static struct inlineCache repar = _ILC0; |
|
3123 |
static struct inlineCache confReq = _ILC0; |
|
3124 |
static struct inlineCache resReq = _ILC0; |
|
3125 |
static struct inlineCache prop = _ILC0; |
|
129 | 3126 |
static struct inlineCache selClear = _ILC1; |
90 | 3127 |
static struct inlineCache selReq = _ILC4; |
3128 |
static struct inlineCache selNotify = _ILC4; |
|
12 | 3129 |
static struct inlineCache colormap = _ILC0; |
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3130 |
static struct inlineCache mapping = _ILC2; |
70 | 3131 |
static struct inlineCache vis = _ILC1; |
12 | 3132 |
|
3133 |
static struct inlineCache skpS = _ILC4; |
|
63 | 3134 |
static struct inlineCache skrS = _ILC4; |
12 | 3135 |
|
555 | 3136 |
eB = __INST(eventBuffer); |
135 | 3137 |
if (__isByteArray(eB)) { |
555 | 3138 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
135 | 3139 |
} else { |
3140 |
printf("DISPLAY: no eventBuffer\n"); |
|
3141 |
RETURN (false); |
|
3142 |
} |
|
3143 |
||
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3144 |
windowID = __MKOBJ(ae->window); |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3145 |
theView = (*vid.ilc_func)(self, @symbol(viewFromId:) COMMA_CON, nil, &vid, windowID); |
12 | 3146 |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3147 |
if ((theView == nil) && (ev->type != MappingNotify)) { |
70 | 3148 |
RETURN (nil); |
12 | 3149 |
} |
3150 |
||
3151 |
/* |
|
3152 |
* key, button and pointer events are sent to the sensor, |
|
3153 |
* or (if there is none) to the delegate. |
|
3154 |
* or (if there is none) to the view. |
|
26 | 3155 |
* |
3156 |
* expose events are sent to the sensor, |
|
3157 |
* or (if there is none) to the view |
|
3158 |
* |
|
12 | 3159 |
* sensor and delegate get view as additional argument |
115 | 3160 |
* all of this has been taken out of here to corresponding methods |
3161 |
* in DeviceWorkstation. |
|
12 | 3162 |
*/ |
90 | 3163 |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3164 |
#ifdef DEBUG |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3165 |
eventType = __MKSMALLINT(ev->type); |
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3166 |
#endif |
135 | 3167 |
switch (ev->type) { |
70 | 3168 |
case KeyRelease: |
115 | 3169 |
symS = @symbol(keyRelease:x:y:view:); |
70 | 3170 |
ipS = &skrS; |
150 | 3171 |
upDown = false; |
70 | 3172 |
goto keyPressAndRelease; |
3173 |
||
3174 |
case KeyPress: |
|
115 | 3175 |
symS = @symbol(keyPress:x:y:view:); |
70 | 3176 |
ipS = &skpS; |
150 | 3177 |
upDown = true; |
3178 |
/* FALL INTO */ |
|
70 | 3179 |
|
3180 |
keyPressAndRelease: |
|
555 | 3181 |
__INST(eventRootX) = __MKSMALLINT(ke->x_root); |
3182 |
__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
|
3183 |
#ifdef OLD |
555 | 3184 |
__INST(altDown) = (ke->state & Mod2Mask) ? true : false; |
3185 |
__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
|
3186 |
#else |
555 | 3187 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3188 |
__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
|
3189 |
#endif |
555 | 3190 |
__INST(shiftDown) = (ke->state & ShiftMask) ? true : false; |
3191 |
__INST(ctrlDown) = (ke->state & ControlMask) ? true : false; |
|
70 | 3192 |
|
3193 |
arg = nil; |
|
3194 |
nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); |
|
3195 |
if (nchars |
|
3196 |
&& (((buffer[0] >= ' ') && (buffer[0] <= '~')) |
|
3197 |
|| (buffer[0] >= 0x80))) { |
|
3198 |
arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; |
|
3199 |
keySymString = NULL; |
|
3200 |
} else { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3201 |
#ifdef OLD |
150 | 3202 |
switch (keySym) { |
3203 |
case XK_Control_L: |
|
3204 |
case XK_Control_R: |
|
555 | 3205 |
__INST(ctrlDown) = upDown; |
150 | 3206 |
break; |
3207 |
case XK_Shift_L: |
|
3208 |
case XK_Shift_R: |
|
555 | 3209 |
__INST(shiftDown) = upDown; |
150 | 3210 |
break; |
3211 |
case XK_Meta_L: |
|
3212 |
case XK_Meta_R: |
|
555 | 3213 |
__INST(metaDown) = upDown; |
150 | 3214 |
break; |
3215 |
case XK_Alt_L: |
|
3216 |
case XK_Alt_R: |
|
555 | 3217 |
__INST(altDown) = upDown; |
150 | 3218 |
break; |
3219 |
} |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3220 |
#endif |
150 | 3221 |
|
70 | 3222 |
keySymString = XKeysymToString(keySym); |
3223 |
if (keySymString) { |
|
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3224 |
#ifdef OLD |
70 | 3225 |
if (keySymString[0] == 'D') { |
3226 |
/* |
|
3227 |
* remove underscore, dont want it in symbols |
|
3228 |
*/ |
|
3229 |
if (strcmp(keySymString, "Delete_line") == 0) { |
|
3230 |
keySymString = "DeleteLine"; |
|
3231 |
} else if (strcmp(keySymString, "Delete_word") == 0) { |
|
3232 |
keySymString = "DeleteWord"; |
|
3233 |
} |
|
3234 |
} |
|
3235 |
/* |
|
3236 |
* make names compatible |
|
3237 |
*/ |
|
3238 |
if (strcmp(keySymString, "Down") == 0) { |
|
3239 |
keySymString = "CursorDown"; |
|
3240 |
} else if (strcmp(keySymString, "Up") == 0) { |
|
3241 |
keySymString = "CursorUp"; |
|
3242 |
} else if (strcmp(keySymString, "Left") == 0) { |
|
3243 |
keySymString = "CursorLeft"; |
|
3244 |
} else if (strcmp(keySymString, "Right") == 0) { |
|
3245 |
keySymString = "CursorRight"; |
|
3246 |
} |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3247 |
arg = __MKSYMBOL(keySymString, (OBJ *)0, __context); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3248 |
#else |
350 | 3249 |
__PROTECT__(theView); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3250 |
arg = __MKSTRING(keySymString COMMA_CON); |
350 | 3251 |
__UNPROTECT__(theView); |
250
eaa532ebcad7
modifierKeyProcessing now done in DevWorkstat via tables;
Claus Gittinger <cg@exept.de>
parents:
240
diff
changeset
|
3252 |
#endif |
70 | 3253 |
} |
3254 |
} |
|
3255 |
||
3256 |
if (arg == nil) { |
|
3257 |
/* happens sometimes (alt-graph on sun has no keysym) */ |
|
3258 |
break; |
|
3259 |
} |
|
3260 |
||
115 | 3261 |
(*(*ipS).ilc_func)(self, symS COMMA_CON, nil, ipS, |
3262 |
arg, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3263 |
__MKSMALLINT(ke->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3264 |
__MKSMALLINT(ke->y), |
115 | 3265 |
theView); |
70 | 3266 |
break; |
3267 |
||
3268 |
case ButtonPress: |
|
555 | 3269 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) | (1 << be->button)); |
3270 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
|
3271 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
|
3272 |
||
3273 |
if (__isSmallInteger(__INST(multiClickTimeDelta))) |
|
3274 |
nextMultiClickTime = be->time + __intVal(__INST(multiClickTimeDelta)); |
|
70 | 3275 |
else |
3276 |
nextMultiClickTime = 0; |
|
3277 |
||
3278 |
if (multiClickTime) { |
|
3279 |
if (be->time < multiClickTime) { |
|
3280 |
multiClickTime = nextMultiClickTime; |
|
3281 |
ipS = &bmpS; |
|
3282 |
symS = @symbol(buttonMultiPress:x:y:view:); |
|
3283 |
goto sendButtonEvent; |
|
3284 |
break; |
|
3285 |
} |
|
3286 |
} |
|
3287 |
multiClickTime = nextMultiClickTime; |
|
3288 |
if (be->state & ShiftMask) { |
|
3289 |
ipS = &bspS; |
|
3290 |
symS = @symbol(buttonShiftPress:x:y:view:); |
|
3291 |
goto sendButtonEvent; |
|
3292 |
} |
|
3293 |
ipS = &bpS; |
|
3294 |
symS = @symbol(buttonPress:x:y:view:); |
|
3295 |
goto sendButtonEvent; |
|
200 | 3296 |
|
70 | 3297 |
/* NOT REACHED */ |
3298 |
||
3299 |
case ButtonRelease: |
|
555 | 3300 |
__INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) & ~(1 << be->button)); |
3301 |
__INST(eventRootX) = __MKSMALLINT(be->x_root); |
|
3302 |
__INST(eventRootY) = __MKSMALLINT(be->y_root); |
|
70 | 3303 |
ipS = &brS; |
3304 |
symS = @symbol(buttonRelease:x:y:view:); |
|
3305 |
/* fall into */ |
|
3306 |
||
3307 |
sendButtonEvent: |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3308 |
butt = __MKSMALLINT(be->button); |
12 | 3309 |
#ifdef NOTDEF |
70 | 3310 |
/* |
3311 |
* this allows operation with single button mouses: meta-click is always Button 2 |
|
3312 |
*/ |
|
555 | 3313 |
if (__INST(metaDown) == true) |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3314 |
butt = __MKSMALLINT(2); |
70 | 3315 |
else |
0 | 3316 |
#endif |
555 | 3317 |
butt = __AT_(__INST(buttonTranslation), butt); |
200 | 3318 |
|
12 | 3319 |
|
115 | 3320 |
(*(*ipS).ilc_func)(self, |
3321 |
symS |
|
3322 |
COMMA_CON, nil, ipS, |
|
3323 |
butt, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3324 |
__MKSMALLINT(ke->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3325 |
__MKSMALLINT(ke->y), |
115 | 3326 |
theView); |
70 | 3327 |
break; |
3328 |
||
3329 |
case MotionNotify: |
|
555 | 3330 |
if (__INST(motionEventCompression) != false) { |
135 | 3331 |
while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; |
70 | 3332 |
} |
3333 |
||
555 | 3334 |
__INST(eventRootX) = __MKSMALLINT(me->x_root); |
3335 |
__INST(eventRootY) = __MKSMALLINT(me->y_root); |
|
70 | 3336 |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3337 |
#ifdef OLD |
555 | 3338 |
__INST(altDown) = (me->state & Mod2Mask) ? true : false; |
3339 |
__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
|
3340 |
#else |
555 | 3341 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3342 |
__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
|
3343 |
#endif |
555 | 3344 |
__INST(shiftDown) = (me->state & ShiftMask) ? true : false; |
3345 |
__INST(ctrlDown) = (me->state & ControlMask) ? true : false; |
|
150 | 3346 |
|
115 | 3347 |
(*motS.ilc_func)(self, |
3348 |
@symbol(buttonMotion:x:y:view:) |
|
3349 |
COMMA_CON, nil, &motS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3350 |
__MKSMALLINT(me->state), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3351 |
__MKSMALLINT(me->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3352 |
__MKSMALLINT(me->y), |
115 | 3353 |
theView); |
70 | 3354 |
break; |
3355 |
||
3356 |
case FocusIn: |
|
115 | 3357 |
(*focInS.ilc_func)(self, |
3358 |
@symbol(focusInView:) |
|
3359 |
COMMA_CON, nil, &focInS, |
|
3360 |
theView); |
|
70 | 3361 |
break; |
3362 |
||
3363 |
case FocusOut: |
|
115 | 3364 |
(*focOutS.ilc_func)(self, |
3365 |
@symbol(focusOutView:) |
|
3366 |
COMMA_CON, nil, &focOutS, |
|
3367 |
theView); |
|
70 | 3368 |
break; |
3369 |
||
3370 |
case EnterNotify: |
|
240
bdbab643c0e7
allow change of the Alt- and Meta modifiermasks
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
3371 |
#ifdef OLD |
555 | 3372 |
__INST(altDown) = (ewe->state & Mod2Mask) ? true : false; |
3373 |
__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
|
3374 |
#else |
555 | 3375 |
__INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; |
3376 |
__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
|
3377 |
#endif |
555 | 3378 |
__INST(shiftDown) = (ewe->state & ShiftMask) ? true : false; |
3379 |
__INST(ctrlDown) = (ewe->state & ControlMask) ? true : false; |
|
150 | 3380 |
|
115 | 3381 |
(*peS.ilc_func)(self, |
3382 |
@symbol(pointerEnter:x:y:view:) |
|
3383 |
COMMA_CON, nil, &peS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3384 |
__MKSMALLINT(ewe->state), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3385 |
__MKSMALLINT(ewe->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3386 |
__MKSMALLINT(ewe->y), |
115 | 3387 |
theView); |
70 | 3388 |
break; |
3389 |
||
3390 |
case LeaveNotify: |
|
115 | 3391 |
(*plS.ilc_func)(self, |
3392 |
@symbol(pointerLeave:view:) |
|
3393 |
COMMA_CON, nil, &plS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3394 |
__MKSMALLINT(lwe->state), |
115 | 3395 |
theView); |
70 | 3396 |
break; |
3397 |
||
3398 |
case GraphicsExpose: |
|
115 | 3399 |
(*gexpS.ilc_func)(self, |
3400 |
@symbol(graphicExposeX:y:width:height:view:) |
|
3401 |
COMMA_CON, nil, &gexpS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3402 |
__MKSMALLINT(ee->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3403 |
__MKSMALLINT(ee->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3404 |
__MKSMALLINT(ee->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3405 |
__MKSMALLINT(ee->height), |
115 | 3406 |
theView); |
3407 |
||
3408 |
if (ee->count != 0) { |
|
70 | 3409 |
break; |
3410 |
} |
|
115 | 3411 |
/* fall into */ |
3412 |
||
3413 |
case NoExpose: |
|
3414 |
(*nexpS.ilc_func)(self, |
|
3415 |
@symbol(noExposeView:) |
|
3416 |
COMMA_CON, nil, &nexpS, |
|
3417 |
theView); |
|
3418 |
break; |
|
3419 |
||
3420 |
case Expose: |
|
3421 |
(*expS.ilc_func)(self, |
|
3422 |
@symbol(exposeX:y:width:height:view:) |
|
3423 |
COMMA_CON, nil, &expS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3424 |
__MKSMALLINT(ee->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3425 |
__MKSMALLINT(ee->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3426 |
__MKSMALLINT(ee->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3427 |
__MKSMALLINT(ee->height), |
115 | 3428 |
theView); |
70 | 3429 |
break; |
3430 |
||
3431 |
case ConfigureNotify: |
|
3432 |
if (ce->above != None) { |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3433 |
siblingID = __MKOBJ(ce->above); |
70 | 3434 |
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
|
3435 |
COMMA_CON, nil, &vid, siblingID); |
70 | 3436 |
} |
3437 |
||
115 | 3438 |
(*confS.ilc_func)(self, |
3439 |
@symbol(configureX:y:width:height:view:) |
|
3440 |
COMMA_CON, nil, &confS, |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3441 |
__MKSMALLINT(ce->x), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3442 |
__MKSMALLINT(ce->y), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3443 |
__MKSMALLINT(ce->width), |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3444 |
__MKSMALLINT(ce->height), |
115 | 3445 |
theView); |
70 | 3446 |
if (sibling != nil) { |
115 | 3447 |
(*coveredS.ilc_func)(self, |
3448 |
@symbol(coveredBy:view:) |
|
3449 |
COMMA_CON, nil, &coveredS, |
|
3450 |
theView, |
|
3451 |
sibling); |
|
70 | 3452 |
} |
3453 |
break; |
|
3454 |
||
3455 |
case ClientMessage: |
|
555 | 3456 |
if (ev->xclient.message_type == (int) _AtomVal(__INST(protocolsAtom))) { |
3457 |
if ((ev->xclient.data.l[0] == (int) _AtomVal(__INST(quitAppAtom))) |
|
3458 |
|| (ev->xclient.data.l[0] == (int) _AtomVal(__INST(deleteWindowAtom)))) { |
|
115 | 3459 |
(*termS.ilc_func)(self, |
3460 |
@symbol(terminateView:) |
|
3461 |
COMMA_CON, nil, &termS, theView); |
|
70 | 3462 |
break; |
3463 |
} |
|
555 | 3464 |
if (ev->xclient.data.l[0] == (int) _AtomVal(__INST(saveYourselfAtom))) { |
115 | 3465 |
(*savtermS.ilc_func)(self, |
3466 |
@symbol(saveAndTerminateView:) |
|
3467 |
COMMA_CON, nil, &savtermS, theView); |
|
70 | 3468 |
break; |
3469 |
} |
|
3470 |
} |
|
3471 |
break; |
|
3472 |
||
3473 |
case DestroyNotify: |
|
115 | 3474 |
(*destrS.ilc_func)(self, @symbol(destroyedView:) |
3475 |
COMMA_CON, nil, &destrS, theView); |
|
70 | 3476 |
break; |
3477 |
||
3478 |
case UnmapNotify: |
|
115 | 3479 |
(*unmapS.ilc_func)(self, @symbol(unmappedView:) |
3480 |
COMMA_CON, nil, &unmapS, theView); |
|
70 | 3481 |
break; |
3482 |
||
3483 |
case MapNotify: |
|
115 | 3484 |
(*mapS.ilc_func)(self, |
3485 |
@symbol(mappedView:) |
|
3486 |
COMMA_CON, nil, &mapS, theView); |
|
70 | 3487 |
break; |
3488 |
||
3489 |
case KeymapNotify: |
|
115 | 3490 |
(*keymap.ilc_func)(theView, |
3491 |
@symbol(keyMapChange) |
|
3492 |
COMMA_CON, nil, &keymap); |
|
70 | 3493 |
break; |
3494 |
||
3495 |
case VisibilityNotify: |
|
3496 |
switch (ve->state) { |
|
3497 |
case VisibilityUnobscured: |
|
3498 |
arg = @symbol(unobscured); |
|
3499 |
break; |
|
3500 |
case VisibilityPartiallyObscured: |
|
3501 |
arg = @symbol(partiallyObscured); |
|
3502 |
break; |
|
3503 |
case VisibilityFullyObscured: |
|
3504 |
arg = @symbol(fullyObscured); |
|
3505 |
break; |
|
3506 |
} |
|
3507 |
(*vis.ilc_func)(theView, @symbol(visibilityChange:) COMMA_CON, nil, &vis, arg); |
|
3508 |
break; |
|
3509 |
||
3510 |
case CreateNotify: |
|
3511 |
(*created.ilc_func)(theView, @symbol(created) COMMA_CON, nil, &created); |
|
3512 |
break; |
|
3513 |
||
3514 |
case MapRequest: |
|
3515 |
(*mapReq.ilc_func)(theView, @symbol(mapRequest) COMMA_CON, nil, &mapReq); |
|
3516 |
break; |
|
3517 |
||
3518 |
case ReparentNotify: |
|
3519 |
(*repar.ilc_func)(theView, @symbol(reparented) COMMA_CON, nil, &repar); |
|
3520 |
break; |
|
3521 |
||
3522 |
case ConfigureRequest: |
|
3523 |
(*confReq.ilc_func)(theView, @symbol(configRequest) COMMA_CON, nil, &confReq); |
|
3524 |
break; |
|
3525 |
||
3526 |
case GravityNotify: |
|
3527 |
case ResizeRequest: |
|
3528 |
(*resReq.ilc_func)(theView, @symbol(resizeRequest) COMMA_CON, nil, &resReq); |
|
3529 |
break; |
|
3530 |
||
3531 |
case CirculateNotify: |
|
3532 |
case CirculateRequest: |
|
3533 |
break; |
|
3534 |
||
3535 |
case PropertyNotify: |
|
115 | 3536 |
(*prop.ilc_func)(theView, |
3537 |
@symbol(propertyChange) |
|
3538 |
COMMA_CON, nil, &prop); |
|
70 | 3539 |
break; |
3540 |
||
3541 |
case SelectionClear: |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3542 |
selectionID = __MKATOMOBJ(ev->xselectionclear.selection); |
115 | 3543 |
(*selClear.ilc_func)(theView, |
129 | 3544 |
@symbol(selectionClear:) |
3545 |
COMMA_CON, nil, &selClear, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3546 |
selectionID); |
70 | 3547 |
break; |
3548 |
||
90 | 3549 |
case SelectionNotify: |
3550 |
/* |
|
3551 |
* returned selection value (answer from SelectionRequest) |
|
3552 |
*/ |
|
129 | 3553 |
DPRINTF(("SelectionNotify prop=%x target=%x selection= %x requestor=%x\n", |
135 | 3554 |
ev->xselection.property, ev->xselection.target, |
3555 |
ev->xselection.selection, ev->xselection.requestor)); |
|
129 | 3556 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3557 |
propertyID = __MKATOMOBJ(ev->xselection.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3558 |
targetID = __MKATOMOBJ(ev->xselection.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3559 |
selectionID = __MKATOMOBJ(ev->xselection.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3560 |
requestorID = __MKOBJ(ev->xselection.requestor); |
115 | 3561 |
(*selNotify.ilc_func)(theView, |
3562 |
@symbol(selectionNotify:target:selection:from:) |
|
3563 |
COMMA_CON, nil, &selNotify, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3564 |
propertyID, targetID, selectionID, requestorID); |
70 | 3565 |
break; |
3566 |
||
90 | 3567 |
case SelectionRequest: |
129 | 3568 |
/* |
3569 |
* someone wants the selection |
|
3570 |
*/ |
|
3571 |
DPRINTF(("SelectionRequest prop=%x target=%x selection=%x requestor=%x\n", |
|
135 | 3572 |
ev->xselectionrequest.property, |
3573 |
ev->xselectionrequest.target, |
|
3574 |
ev->xselectionrequest.selection, |
|
3575 |
ev->xselectionrequest.requestor)); |
|
129 | 3576 |
|
207
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3577 |
propertyID = __MKATOMOBJ(ev->xselectionrequest.property); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3578 |
targetID = __MKATOMOBJ(ev->xselectionrequest.target); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3579 |
selectionID = __MKATOMOBJ(ev->xselectionrequest.selection); |
9124817bbb03
use new c-pointer wrapper macros (based on externalAddress)
Claus Gittinger <cg@exept.de>
parents:
206
diff
changeset
|
3580 |
requestorID = __MKOBJ(ev->xselectionrequest.requestor); |
115 | 3581 |
(*selReq.ilc_func)(theView, |
3582 |
@symbol(selectionRequest:target:selection:from:) |
|
3583 |
COMMA_CON, nil, &selReq, |
|
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3584 |
propertyID, targetID, selectionID, requestorID); |
70 | 3585 |
break; |
3586 |
||
3587 |
case ColormapNotify: |
|
115 | 3588 |
(*colormap.ilc_func)(theView, |
3589 |
@symbol(colorMapChange) |
|
3590 |
COMMA_CON, nil, &colormap); |
|
70 | 3591 |
break; |
3592 |
||
3593 |
case MappingNotify: |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3594 |
switch(mape->request) { |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3595 |
case MappingModifier: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3596 |
arg = @symbol(mappingModifier); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3597 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3598 |
case MappingKeyboard: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3599 |
arg = @symbol(mappingKeyboard); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3600 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3601 |
case MappingPointer: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3602 |
arg = @symbol(mappingPointer); |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3603 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3604 |
default: |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3605 |
arg = nil; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3606 |
break; |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3607 |
} |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3608 |
(*mapping.ilc_func)(self, |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3609 |
@symbol(mappingChanged:event:) |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3610 |
COMMA_CON, nil, &mapping, arg, eB); |
70 | 3611 |
break; |
0 | 3612 |
} |
135 | 3613 |
#undef ae |
0 | 3614 |
#undef ee |
3615 |
#undef ke |
|
3616 |
#undef be |
|
3617 |
#undef ce |
|
3618 |
#undef me |
|
3619 |
#undef ewe |
|
3620 |
#undef lwe |
|
3621 |
#undef de |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3622 |
#undef mape |
0 | 3623 |
%} |
3624 |
. |
|
3625 |
^ true |
|
3626 |
! |
|
3627 |
||
295 | 3628 |
dispatchPendingEvents |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3629 |
"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
|
3630 |
(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
|
3631 |
This code is somewhat special, since X has a concept of graphic |
295 | 3632 |
expose events (which are sent after a bitblt). After such a bitblt, |
3633 |
we only handle exposes until the graphicsExpose arrives. |
|
3634 |
Other systems may not need such a kludge" |
|
3635 |
||
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
3636 |
"interested in exposes only ?" |
295 | 3637 |
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
|
3638 |
[self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[ |
295 | 3639 |
self dispatchExposeEventFor:dispatchingExpose |
3640 |
]. |
|
3641 |
^ self |
|
3642 |
]. |
|
3643 |
||
3644 |
"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
|
3645 |
[self eventPendingWithSync:false] whileTrue:[ |
295 | 3646 |
self dispatchEventFor:nil withMask:nil |
3647 |
] |
|
3648 |
! |
|
3649 |
||
81 | 3650 |
disposeEventsWithMask:aMask for:aWindowIdOrNil |
3651 |
"dispose (throw away) specific events. If aWindowId is nil, |
|
3652 |
events matching the mask are thrown away regardless of which |
|
3653 |
view they are for. Otherwise, only matching events for that |
|
3654 |
view are flushed." |
|
0 | 3655 |
|
3656 |
%{ /* NOCONTEXT */ |
|
3657 |
||
3658 |
Display *dpy = myDpy; |
|
3659 |
XEvent ev; |
|
3660 |
Window win; |
|
3661 |
||
97 | 3662 |
if (__isSmallInteger(aMask)) { |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3663 |
if (__isExternalAddress(aWindowIdOrNil)) { |
81 | 3664 |
win = _WindowVal(aWindowIdOrNil); |
555 | 3665 |
while (XCheckWindowEvent(dpy, win, __intVal(aMask), &ev)) ;; |
81 | 3666 |
} else { |
555 | 3667 |
while (XCheckMaskEvent(dpy, __intVal(aMask), &ev)) ;; |
81 | 3668 |
} |
70 | 3669 |
RETURN ( self ); |
0 | 3670 |
} |
3671 |
%} |
|
3672 |
. |
|
3673 |
self primitiveFailed |
|
3674 |
! |
|
3675 |
||
295 | 3676 |
eventMaskFor:anEventSymbol |
3677 |
"return the eventMask bit-constant corresponding to an event symbol" |
|
3678 |
||
3679 |
%{ /* NOCONTEXT */ |
|
3680 |
||
3681 |
int m = 0; |
|
3682 |
||
3683 |
if (anEventSymbol == @symbol(keyPress)) m = KeyPressMask; |
|
3684 |
else if (anEventSymbol == @symbol(keyRelease)) m = KeyReleaseMask; |
|
3685 |
else if (anEventSymbol == @symbol(buttonPress)) m = ButtonPressMask; |
|
3686 |
else if (anEventSymbol == @symbol(buttonRelease)) m = ButtonReleaseMask; |
|
3687 |
else if (anEventSymbol == @symbol(buttonMotion)) m = ButtonMotionMask; |
|
3688 |
else if (anEventSymbol == @symbol(pointerMotion)) m = PointerMotionMask; |
|
3689 |
else if (anEventSymbol == @symbol(expose)) m = ExposureMask; |
|
3690 |
else if (anEventSymbol == @symbol(focusChange)) m = FocusChangeMask; |
|
3691 |
else if (anEventSymbol == @symbol(enter)) m = EnterWindowMask; |
|
3692 |
else if (anEventSymbol == @symbol(leave)) m = LeaveWindowMask; |
|
3693 |
else if (anEventSymbol == @symbol(keymapState)) m = KeymapStateMask; |
|
3694 |
else if (anEventSymbol == @symbol(visibilityChange)) m = VisibilityChangeMask; |
|
3695 |
else if (anEventSymbol == @symbol(structureNotify)) m = StructureNotifyMask; |
|
3696 |
else if (anEventSymbol == @symbol(resizeRedirect)) m = ResizeRedirectMask; |
|
3697 |
else if (anEventSymbol == @symbol(propertyChange)) m = PropertyChangeMask; |
|
3698 |
else if (anEventSymbol == @symbol(colormapChange)) m = ColormapChangeMask; |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
3699 |
RETURN (__MKSMALLINT(m)); |
295 | 3700 |
%} |
3701 |
! |
|
3702 |
||
12 | 3703 |
eventPending |
310 | 3704 |
"return true, if any event is pending. |
3705 |
This looks for both the internal queue and the display connection." |
|
12 | 3706 |
|
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3707 |
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
|
3708 |
|
12 | 3709 |
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
|
3710 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
12 | 3711 |
]. |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3712 |
^ self eventPendingWithSync:false |
0 | 3713 |
! |
3714 |
||
295 | 3715 |
eventPending:anEventSymbol for:aWindowIdOrNil |
3716 |
"return true, if a specific event is pending" |
|
3717 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3718 |
^ 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
|
3719 |
! |
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3720 |
|
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3721 |
eventPendingWithSync:doSync |
7 | 3722 |
"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
|
3723 |
If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed) |
310 | 3724 |
before checking." |
0 | 3725 |
|
12 | 3726 |
%{ /* UNLIMITEDSTACK */ |
0 | 3727 |
|
3728 |
Display *dpy = myDpy; |
|
3729 |
||
150 | 3730 |
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
|
3731 |
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
|
3732 |
XSync(dpy, 0); /* make certain everything is flushed */ |
150 | 3733 |
} |
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3734 |
if (XPending(dpy)) { |
150 | 3735 |
RETURN (true); |
3736 |
} |
|
3737 |
} |
|
3738 |
RETURN ( false ); |
|
0 | 3739 |
%} |
3740 |
! |
|
3741 |
||
341 | 3742 |
eventQueued |
3743 |
"return true, if any event is queued" |
|
3744 |
||
3745 |
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
|
3746 |
^ self exposeEventPendingFor:dispatchingExpose withSync:false |
341 | 3747 |
]. |
3748 |
^ self eventQueuedAlready |
|
3749 |
||
3750 |
"Created: 12.12.1995 / 21:43:00 / stefan" |
|
3751 |
! |
|
3752 |
||
3753 |
eventQueuedAlready |
|
3754 |
"return true, if any event is queued internally. |
|
3755 |
(i.e. in X's internal event queue, which is both filled by explicit |
|
3756 |
nextEvent calls AND whenever drawing is done and events are pending on |
|
3757 |
the display connection)." |
|
3758 |
||
3759 |
%{ /* UNLIMITEDSTACK */ |
|
3760 |
||
3761 |
if (ISCONNECTED) { |
|
3762 |
if (XEventsQueued(myDpy, QueuedAlready)) { |
|
3763 |
RETURN (true); |
|
3764 |
} |
|
3765 |
} |
|
3766 |
RETURN ( false ); |
|
3767 |
%} |
|
3768 |
! |
|
3769 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3770 |
eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync |
295 | 3771 |
"return true, if any of the masked events is pending" |
3772 |
||
3773 |
%{ /* UNLIMITEDSTACK */ |
|
3774 |
||
3775 |
Display *dpy = myDpy; |
|
3776 |
XEvent ev; |
|
3777 |
Window win; |
|
3778 |
int thereIsOne; |
|
3779 |
||
3780 |
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
|
3781 |
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
|
3782 |
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
|
3783 |
} |
295 | 3784 |
if (__isExternalAddress(aWindowIdOrNil)) { |
3785 |
win = _WindowVal(aWindowIdOrNil); |
|
555 | 3786 |
thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev); |
295 | 3787 |
} else { |
555 | 3788 |
thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev); |
295 | 3789 |
} |
3790 |
if (thereIsOne) { |
|
3791 |
XPutBackEvent(dpy, &ev); |
|
3792 |
RETURN ( true ); |
|
3793 |
} |
|
3794 |
} |
|
3795 |
RETURN ( false ); |
|
3796 |
%} |
|
3797 |
! |
|
3798 |
||
404
0db38d8283a4
removed implicit XSync calls - optionally perform conservative XSync if classvar says so
Claus Gittinger <cg@exept.de>
parents:
402
diff
changeset
|
3799 |
exposeEventPendingFor:aWindowIdOrNil withSync:doSync |
310 | 3800 |
"return true, if any expose event is pending for a specific view, |
3801 |
or any view (if the arg is nil). |
|
3802 |
This is an X specific, only required after a scroll operation." |
|
7 | 3803 |
|
12 | 3804 |
%{ /* UNLIMITEDSTACK */ |
7 | 3805 |
|
3806 |
Display *dpy = myDpy; |
|
3807 |
XEvent ev; |
|
3808 |
Window win; |
|
81 | 3809 |
int thereIsOne; |
3810 |
||
150 | 3811 |
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
|
3812 |
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
|
3813 |
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
|
3814 |
} |
206
4284b80bebdf
changed to use ExternalAddress handles for all Window, Font,
Claus Gittinger <cg@exept.de>
parents:
202
diff
changeset
|
3815 |
if (__isExternalAddress(aWindowIdOrNil)) { |
150 | 3816 |
win = _WindowVal(aWindowIdOrNil); |
3817 |
thereIsOne = XCheckWindowEvent(dpy, win, ExposureMask, &ev); |
|
3818 |
} else { |
|
3819 |
thereIsOne = XCheckMaskEvent(dpy, ExposureMask, &ev); |
|
3820 |
} |
|
3821 |
if (thereIsOne) { |
|
3822 |
XPutBackEvent(dpy, &ev); |
|
3823 |
RETURN ( true ); |
|
3824 |
} |
|
81 | 3825 |
} |
3826 |
RETURN ( false ); |
|
3827 |
%} |
|
3828 |
! |
|
3829 |
||
295 | 3830 |
getEventFor:aViewIdOrNil withMask:eventMask |
3831 |
"read next event - put into local eventBuffer. |
|
3832 |
If aViewIdOrNil is nil, events for any view are fetched; |
|
3833 |
otherwise only events for that specific view will be fetched. |
|
3834 |
Returns true, if there was an event, false otherwise. |
|
3835 |
This method may block - so you better check for pending events |
|
3836 |
before calling for it. |
|
3837 |
||
3838 |
Sorry I had to split dispatch into this fetch method and an extra |
|
3839 |
handle method to allow unlimitedstack here. |
|
3840 |
(some Xlibs do a big alloca there ...) which cannot be done in |
|
3841 |
dispatchLastEvent, since it dispatches out into ST-methods. |
|
3842 |
BUG: uses a static buffer - has to be rewritten, to support multiple |
|
3843 |
display connections. |
|
3844 |
" |
|
81 | 3845 |
|
3846 |
%{ /* UNLIMITEDSTACK */ |
|
3847 |
||
3848 |
Display *dpy = myDpy; |
|
295 | 3849 |
Window win, wWanted; |
3850 |
int evMask; |
|
3851 |
OBJ eB; |
|
3852 |
XEvent *ev; |
|
3853 |
||
3854 |
if (! ISCONNECTED) { |
|
3855 |
RETURN (false); |
|
3856 |
} |
|
3857 |
||
555 | 3858 |
eB = __INST(eventBuffer); |
295 | 3859 |
if (__isByteArray(eB)) { |
555 | 3860 |
ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 3861 |
} else { |
3862 |
printf("DISPLAY: no eventBuffer\n"); |
|
3863 |
RETURN (false); |
|
3864 |
} |
|
3865 |
ev->type = 0; |
|
3866 |
||
3867 |
if (__isSmallInteger(eventMask)) { |
|
555 | 3868 |
evMask = __intVal(eventMask); |
295 | 3869 |
} else { |
3870 |
evMask = ~0; |
|
3871 |
} |
|
3872 |
||
3873 |
if (__isExternalAddress(aViewIdOrNil)) { |
|
3874 |
wWanted = _WindowVal(aViewIdOrNil); |
|
3875 |
if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) { |
|
70 | 3876 |
RETURN ( true ); |
3877 |
} |
|
295 | 3878 |
} else { |
3879 |
if (evMask == ~0) { |
|
3880 |
XNextEvent(dpy, ev); |
|
3881 |
RETURN (true); |
|
3882 |
} |
|
3883 |
if (XCheckMaskEvent(dpy, evMask, ev)) { |
|
3884 |
RETURN (true); |
|
3885 |
} |
|
3886 |
} |
|
3887 |
%}. |
|
3888 |
^ false |
|
3889 |
! |
|
3890 |
||
3891 |
handleAllEvents |
|
3892 |
"from now on, handle any kind of event" |
|
3893 |
||
3894 |
dispatchingExpose := nil |
|
3895 |
! |
|
3896 |
||
3897 |
handleExposeOnlyFor:aView |
|
3898 |
"from now on, handle expose events only" |
|
3899 |
||
3900 |
dispatchingExpose := aView id |
|
288
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3901 |
! |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3902 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3903 |
mappingChanged:what event:eB |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3904 |
"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
|
3905 |
Tell xlib about the fact." |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3906 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3907 |
(what == #mappingKeyboard or:[what == #mappingModifier]) ifTrue:[ |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3908 |
self refreshKeyboardMapping:eB. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3909 |
"Maybe some of our modifiers have been changed" |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3910 |
self initializeModifierMappings. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3911 |
]. |
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3912 |
|
5d49b00f2bad
changes for modifierMappings from stefan
Claus Gittinger <cg@exept.de>
parents:
277
diff
changeset
|
3913 |
"Created: 1.12.1995 / 16:28:23 / stefan" |
295 | 3914 |
! |
3915 |
||
3916 |
setEventMask:aMask in:aWindowId |
|
320
b7b8dc88fe9f
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
315
diff
changeset
|
3917 |
"tell X that we are only interested in events from aMask, which |
295 | 3918 |
is the bitwise or of the eventMask bits (see 'eventMaskFor:')" |
3919 |
||
3920 |
%{ /* NOCONTEXT */ |
|
3921 |
||
3922 |
int mask; |
|
3923 |
||
3924 |
if (__isExternalAddress(aWindowId) |
|
3925 |
&& __isSmallInteger(aMask)) { |
|
555 | 3926 |
mask = __intVal(aMask); |
295 | 3927 |
|
3928 |
#ifdef OLD |
|
3929 |
/* these may not be disabled */ |
|
3930 |
mask |= ExposureMask | StructureNotifyMask | |
|
3931 |
KeyPressMask | KeyReleaseMask | |
|
3932 |
EnterWindowMask | LeaveWindowMask | |
|
3933 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; |
|
3934 |
#endif |
|
3935 |
||
3936 |
XSelectInput(myDpy, _WindowVal(aWindowId), mask); |
|
3937 |
RETURN ( self ); |
|
3938 |
} |
|
3939 |
%} |
|
3940 |
. |
|
3941 |
self primitiveFailed |
|
3942 |
! |
|
3943 |
||
3944 |
startDispatch |
|
3945 |
"redefined to clear dispatchingExpose, which is a special X feature" |
|
3946 |
||
3947 |
dispatching ifTrue:[^ self]. |
|
3948 |
dispatchingExpose := nil. |
|
3949 |
super startDispatch |
|
0 | 3950 |
! ! |
295 | 3951 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3952 |
!XWorkstation methodsFor:'event sending'! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3953 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3954 |
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
|
3955 |
"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
|
3956 |
TypeSymbol must be one of: #keyPress, #keyRelease, #buttonPress , #buttonRelease. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3957 |
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
|
3958 |
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
|
3959 |
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
|
3960 |
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
|
3961 |
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
|
3962 |
(not very user friendly)" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3963 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3964 |
%{ /* NOCONTEXT */ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3965 |
Display *dpy = myDpy; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3966 |
int type; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3967 |
int state; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3968 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3969 |
if (__isSmallInteger(stateMask)) { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3970 |
state = __intVal(stateMask); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3971 |
} else { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3972 |
state = 0; |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
3973 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3974 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3975 |
if (ISCONNECTED |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3976 |
&& __isSmallInteger(xPos) && __isSmallInteger(yPos) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3977 |
&& (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
3978 |
&& (__isExternalAddress(targetId) || __isInteger(targetId))) { |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3979 |
XEvent ev; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3980 |
Window target; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3981 |
Status result; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3982 |
KeySym keySym, *syms; |
555 | 3983 |
int screen = __intVal(__INST(screen)); |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3984 |
char s[2]; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3985 |
int nSyms; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3986 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3987 |
if ((typeSymbol == @symbol(keyPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3988 |
|| (typeSymbol == @symbol(keyRelease))) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3989 |
if (__isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3990 |
keySym = XStringToKeysym(__stringVal(keySymCodeOrButtonNr)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3991 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3992 |
if (__isCharacter(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3993 |
s[0] = __intVal(__characterVal(keySymCodeOrButtonNr)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3994 |
s[1] = '\0'; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3995 |
keySym = XStringToKeysym(s); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3996 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3997 |
keySym = (KeySym) __intVal(keySymCodeOrButtonNr); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3998 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
3999 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4000 |
ev.xkey.keycode = XKeysymToKeycode(dpy, keySym); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4001 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4002 |
if (stateMask == nil) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4003 |
/* |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4004 |
* get the modifier from the keySym |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4005 |
*/ |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4006 |
nSyms = 0; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4007 |
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
|
4008 |
if (syms) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4009 |
int i; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4010 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4011 |
for (i=0; i<nSyms; i++) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4012 |
if (syms[i] == keySym) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4013 |
#ifdef MODIFIERDEBUG |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4014 |
printf("modifier-index is %d\n", i); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4015 |
#endif |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4016 |
if (i) state = (1 << (i-1)); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4017 |
break; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4018 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4019 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4020 |
XFree(syms); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4021 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4022 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4023 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4024 |
if ((typeSymbol == @symbol(buttonPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4025 |
|| (typeSymbol == @symbol(buttonRelease))) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4026 |
if (__isSmallInteger(keySymCodeOrButtonNr)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4027 |
ev.xbutton.button = __intVal(keySymCodeOrButtonNr); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4028 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4029 |
ev.xbutton.button = 1; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4030 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4031 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4032 |
DPRINTF(("invalid sendEvent typeSymbol\n")); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4033 |
RETURN (false); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4034 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4035 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4036 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4037 |
if (typeSymbol == @symbol(keyPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4038 |
ev.xany.type = KeyPress; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4039 |
else if (typeSymbol == @symbol(keyRelease)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4040 |
ev.xany.type = KeyRelease; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4041 |
else if (typeSymbol == @symbol(buttonPress)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4042 |
ev.xany.type = ButtonPress; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4043 |
else if (typeSymbol == @symbol(buttonRelease)) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4044 |
ev.xany.type = ButtonRelease; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4045 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4046 |
if (__isExternalAddress(targetId)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4047 |
target = _WindowVal(targetId); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4048 |
} else { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4049 |
target = (Window) __longIntVal(targetId); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4050 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4051 |
ev.xkey.window = target; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4052 |
ev.xkey.same_screen = 1; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4053 |
ev.xkey.subwindow = 0; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4054 |
ev.xkey.root = RootWindow(myDpy, screen); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4055 |
ev.xkey.x = __intVal(xPos); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4056 |
ev.xkey.y = __intVal(yPos); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4057 |
ev.xkey.state = state; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4058 |
ev.xkey.time = CurrentTime; |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4059 |
|
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4060 |
result = XSendEvent(dpy, target, False, 0 , &ev); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4061 |
if ((result == BadValue) || (result == BadWindow)) { |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4062 |
DPRINTF(("bad status\n")); |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4063 |
RETURN ( false ) |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4064 |
} |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4065 |
RETURN (true) |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4066 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4067 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4068 |
self primitiveFailed. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4069 |
^ false |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4070 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4071 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4072 |
simulateKeyboardInput:aCharacterOrString inViewId:viewId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4073 |
"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
|
4074 |
events. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4075 |
Only a few control characters are supported. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4076 |
Notice: not all alien views allow this kind of synthetic input; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4077 |
some simply ignore it." |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4078 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4079 |
|control code state| |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4080 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4081 |
aCharacterOrString isString ifTrue:[ |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4082 |
aCharacterOrString do:[:char | |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4083 |
self simulateKeyboardInput:char inViewId:viewId |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4084 |
]. |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4085 |
^ self |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4086 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4087 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4088 |
control := false. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4089 |
code := aCharacterOrString asciiValue. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4090 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4091 |
(aCharacterOrString == Character cr) ifTrue:[ |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4092 |
code := #Return |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4093 |
] ifFalse:[ |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4094 |
(aCharacterOrString == Character tab) ifTrue:[ |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4095 |
code := #Tab |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4096 |
] ifFalse:[ |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4097 |
(aCharacterOrString == Character esc) ifTrue:[ |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4098 |
code := #Escape |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4099 |
] |
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4100 |
] |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4101 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4102 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4103 |
control ifTrue:[ |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4104 |
state := state bitOr:(self controlMask) |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4105 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4106 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4107 |
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
|
4108 |
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
|
4109 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4110 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4111 |
sending input to some (possibly alien) view: |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4112 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4113 |
|point id| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4114 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4115 |
point := Display pointFromUser. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4116 |
id := Display viewIdFromPoint:point. |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4117 |
Display simulateKeyboardInput:'Hello_world' inViewId:id |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4118 |
" |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4119 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4120 |
"Modified: 1.3.1996 / 18:31:15 / cg" |
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 |
|
295 | 4123 |
!XWorkstation methodsFor:'font stuff'! |
4124 |
||
4125 |
ascentOf:aFontId |
|
4126 |
"the normal ascent" |
|
4127 |
||
4128 |
%{ /* NOCONTEXT */ |
|
4129 |
||
4130 |
XFontStruct *f; |
|
4131 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4132 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4133 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4134 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4135 |
RETURN ( __MKSMALLINT(f->ascent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4136 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4137 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4138 |
%}. |
295 | 4139 |
self primitiveFailed. |
4140 |
^ nil |
|
4141 |
! |
|
4142 |
||
4143 |
createFontFor:aFontName |
|
4144 |
"a basic method for X-font allocation; this method allows |
|
4145 |
any font to be aquired (even those not conforming to |
|
4146 |
standard naming conventions, such as cursor, fixed or k14)" |
|
4147 |
||
4148 |
%{ /* UNLIMITEDSTACK */ |
|
4149 |
/* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ |
|
4150 |
||
4151 |
XFontStruct *newFont; |
|
4152 |
||
4153 |
if (ISCONNECTED) { |
|
4154 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
|
4155 |
BEGIN_INTERRUPTSBLOCKED |
|
4156 |
newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); |
|
4157 |
END_INTERRUPTSBLOCKED |
|
4158 |
RETURN ( newFont ? __MKOBJ(newFont) : nil ); |
|
4159 |
} |
|
4160 |
} |
|
4161 |
%}. |
|
4162 |
^ nil |
|
4163 |
! |
|
4164 |
||
4165 |
decomposeXFontName:aString into:aBlock |
|
4166 |
"extract family, face, style and size from an |
|
4167 |
X-font name |
|
4168 |
(-brand-family-face-style-moreStyle--height-size-res-res-?-??-coding); |
|
4169 |
evaluate aBlock with these" |
|
4170 |
||
4171 |
|origin family face style moreStyle skip fheight size |
|
4172 |
resX resY x1 x2 coding start end | |
|
4173 |
||
4174 |
aString isNil ifTrue:[^ false]. |
|
4175 |
(aString startsWith:'-') ifFalse:[ |
|
4176 |
" |
|
4177 |
take care for ill-named fonts (i.e. pre Rel4 fonts) |
|
4178 |
" |
|
4179 |
('*-*-[0-9]*' match:aString) ifTrue:[ |
|
4180 |
end := aString indexOf:$- startingAt:1. |
|
4181 |
family := aString copyFrom:1 to:(end - 1). |
|
4182 |
start := end + 1. |
|
4183 |
end := aString indexOf:$- startingAt:start. |
|
4184 |
style := aString copyFrom:start to:(end - 1). |
|
4185 |
start := end + 1. |
|
4186 |
size := aString copyFrom:start. |
|
4187 |
size := (Number readFromString:size onError:[^false]). |
|
4188 |
aBlock value:family value:nil value:style value:size value:nil. |
|
4189 |
^ true. |
|
4190 |
]. |
|
4191 |
('*-[0-9]*' match:aString) ifTrue:[ |
|
4192 |
" |
|
4193 |
something like lucidasans-24 |
|
4194 |
" |
|
4195 |
end := aString indexOf:$- startingAt:1. |
|
4196 |
||
4197 |
family := aString copyFrom:1 to:(end - 1). |
|
4198 |
start := end + 1. |
|
4199 |
size := aString copyFrom:start. |
|
4200 |
size := (Number readFromString:size onError:[^false]). |
|
4201 |
aBlock value:family value:nil value:nil value:size value:nil. |
|
4202 |
^ true. |
|
4203 |
]. |
|
4204 |
aBlock value:aString value:nil value:nil value:nil value:nil. |
|
4205 |
^ true. |
|
4206 |
]. |
|
4207 |
||
4208 |
end := aString indexOf:$- startingAt:2. |
|
4209 |
(end == 0) ifTrue:[^ false]. |
|
4210 |
origin := aString copyFrom:2 to:(end - 1). |
|
4211 |
||
4212 |
start := end + 1. |
|
4213 |
end := aString indexOf:$- startingAt:start. |
|
4214 |
(end == 0) ifTrue:[^ false]. |
|
4215 |
family := aString copyFrom:start to:(end - 1). |
|
4216 |
||
4217 |
start := end + 1. |
|
4218 |
end := aString indexOf:$- startingAt:start. |
|
4219 |
(end == 0) ifTrue:[^ false]. |
|
4220 |
face := aString copyFrom:start to:(end - 1). |
|
4221 |
||
4222 |
start := end + 1. |
|
4223 |
end := aString indexOf:$- startingAt:start. |
|
4224 |
(end == 0) ifTrue:[^ false]. |
|
4225 |
style := aString copyFrom:start to:(end - 1). |
|
4226 |
(style = 'o') ifTrue:[ |
|
4227 |
style := 'oblique' |
|
4228 |
] ifFalse:[ |
|
4229 |
(style = 'i') ifTrue:[ |
|
4230 |
style := 'italic' |
|
4231 |
] ifFalse:[ |
|
4232 |
(style = 'r') ifTrue:[ |
|
4233 |
style := 'roman' |
|
4234 |
] |
|
4235 |
] |
|
4236 |
]. |
|
4237 |
||
4238 |
start := end + 1. |
|
4239 |
end := aString indexOf:$- startingAt:start. |
|
4240 |
(end == 0) ifTrue:[^ false]. |
|
4241 |
moreStyle := aString copyFrom:start to:(end - 1). |
|
4242 |
||
4243 |
start := end + 1. |
|
4244 |
end := aString indexOf:$- startingAt:start. |
|
4245 |
(end == 0) ifTrue:[^ false]. |
|
4246 |
skip := aString copyFrom:start to:(end - 1). |
|
4247 |
||
4248 |
start := end + 1. |
|
4249 |
end := aString indexOf:$- startingAt:start. |
|
4250 |
(end == 0) ifTrue:[^ false]. |
|
4251 |
fheight := aString copyFrom:start to:(end - 1). |
|
4252 |
||
4253 |
start := end + 1. |
|
4254 |
end := aString indexOf:$- startingAt:start. |
|
4255 |
(end == 0) ifTrue:[^ false]. |
|
4256 |
size := aString copyFrom:start to:(end - 1). |
|
4257 |
size := (Number readFromString:size) / 10. |
|
4258 |
||
4259 |
start := end + 1. |
|
4260 |
end := aString indexOf:$- startingAt:start. |
|
4261 |
(end == 0) ifTrue:[^ false]. |
|
4262 |
resX := aString copyFrom:start to:(end - 1). |
|
4263 |
||
4264 |
start := end + 1. |
|
4265 |
end := aString indexOf:$- startingAt:start. |
|
4266 |
(end == 0) ifTrue:[^ false]. |
|
4267 |
resY := aString copyFrom:start to:(end - 1). |
|
4268 |
||
4269 |
start := end + 1. |
|
4270 |
end := aString indexOf:$- startingAt:start. |
|
4271 |
(end == 0) ifTrue:[^ false]. |
|
4272 |
x1 := aString copyFrom:start to:(end - 1). |
|
4273 |
||
4274 |
start := end + 1. |
|
4275 |
end := aString indexOf:$- startingAt:start. |
|
4276 |
(end == 0) ifTrue:[^ false]. |
|
4277 |
x2 := aString copyFrom:start to:(end - 1). |
|
4278 |
||
4279 |
start := end + 1. |
|
4280 |
end := aString indexOf:$- startingAt:start. |
|
4281 |
(end == 0) ifTrue:[^ false]. |
|
4282 |
coding := aString copyFrom:start to:(end - 1). |
|
4283 |
||
4284 |
aBlock value:family value:face value:style value:size value:coding. |
|
4285 |
^ true |
|
4286 |
||
4287 |
"Modified: 27.9.1995 / 10:46:52 / stefan" |
|
4288 |
! |
|
4289 |
||
4290 |
descentOf:aFontId |
|
4291 |
"the normal descent" |
|
4292 |
||
4293 |
%{ /* NOCONTEXT */ |
|
4294 |
||
4295 |
XFontStruct *f; |
|
4296 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4297 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4298 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4299 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4300 |
RETURN ( __MKSMALLINT(f->descent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4301 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4302 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4303 |
%}. |
295 | 4304 |
self primitiveFailed. |
4305 |
^ nil |
|
4306 |
! |
|
4307 |
||
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4308 |
encodingOf:aFontId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4309 |
"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
|
4310 |
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
|
4311 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4312 |
|enc fullName fontName registry encoding charSetCollections| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4313 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4314 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4315 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4316 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4317 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4318 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4319 |
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4320 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4321 |
registryAtom = XInternAtom(myDpy, "CHARSET_REGISTRY", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4322 |
encodingAtom = XInternAtom(myDpy, "CHARSET_ENCODING", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4323 |
charSetCollAtom = XInternAtom(myDpy, "CHARSET_COLLECTIONS", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4324 |
fontAtom = XInternAtom(myDpy, "FONT", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4325 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4326 |
if (ISCONNECTED) { |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4327 |
if (__isExternalAddress(aFontId)) { |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4328 |
|
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4329 |
f = _FontVal(aFontId); |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4330 |
if (f) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4331 |
n = f->n_properties; |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4332 |
prop = f->properties; |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4333 |
if (prop) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4334 |
while (n--) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4335 |
cp = XGetAtomName(myDpy, prop->name); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4336 |
#ifdef SUPERDEBUG |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4337 |
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
|
4338 |
#endif |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4339 |
if (prop->name == XA_FULL_NAME) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4340 |
cp = XGetAtomName(myDpy, prop->card32); |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4341 |
if (cp) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4342 |
fullName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4343 |
#ifdef SUPERDEBUG |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4344 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4345 |
#endif |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4346 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4347 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4348 |
if (prop->name == fontAtom) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4349 |
cp = XGetAtomName(myDpy, prop->card32); |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4350 |
if (cp) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4351 |
fontName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4352 |
#ifdef SUPERDEBUG |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4353 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4354 |
#endif |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4355 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4356 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4357 |
if (prop->name == encodingAtom) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4358 |
cp = XGetAtomName(myDpy, prop->card32); |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4359 |
if (cp) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4360 |
encoding = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4361 |
#ifdef SUPERDEBUG |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4362 |
printf(" ENCODING -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4363 |
#endif |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4364 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4365 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4366 |
if (prop->name == registryAtom) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4367 |
cp = XGetAtomName(myDpy, prop->card32); |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4368 |
if (cp) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4369 |
registry = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4370 |
#ifdef SUPERDEBUG |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4371 |
printf(" REGISTRY -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4372 |
#endif |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4373 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4374 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4375 |
if (prop->name == charSetCollAtom) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4376 |
cp = XGetAtomName(myDpy, prop->card32); |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4377 |
if (cp) { |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4378 |
charSetCollections = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4379 |
#ifdef SUPERDEBUG |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4380 |
printf(" CHARSET_COLLECTIONS -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4381 |
#endif |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4382 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4383 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4384 |
prop++; |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4385 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4386 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4387 |
} |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4388 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4389 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4390 |
%}. |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4391 |
^ self |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4392 |
extractEncodingFromRegistry:registry |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4393 |
encoding:encoding |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4394 |
charSetCollections:charSetCollections |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4395 |
! |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4396 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4397 |
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4398 |
"this is pure magic ..." |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4399 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4400 |
|enc charSets| |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4401 |
|
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4402 |
(registry notNil and:[registry notEmpty]) ifTrue:[ |
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4403 |
enc := registry asLowercase asSymbol. |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4404 |
] ifFalse:[ |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4405 |
(encoding notNil and:[encoding notEmpty]) ifTrue:[ |
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4406 |
enc := encoding asLowercase asSymbol |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4407 |
] ifFalse:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4408 |
charSets := charSetCollections. |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4409 |
(charSets notNil and:[charSets notEmpty]) ifTrue:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4410 |
charSets := charSets asUppercase asCollectionOfWords. |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4411 |
(charSets includes:'ISO8859-1') ifTrue:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4412 |
enc := #iso8859 |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4413 |
] ifFalse:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4414 |
(charSets includes:'ISO8859') ifTrue:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4415 |
enc := #iso8859 |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4416 |
] ifFalse:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4417 |
(charSets includes:'ASCII') ifTrue:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4418 |
enc := #ascii |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4419 |
] ifFalse:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4420 |
(charSets includes:'ADOBE-STANDARD') ifTrue:[ |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4421 |
enc := #iso8859 |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4422 |
] |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4423 |
] |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4424 |
] |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4425 |
] |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4426 |
] |
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4427 |
] |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4428 |
]. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4429 |
^ enc |
567
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4430 |
|
7b735ef0974b
separated encoding-extraction into extra method
Claus Gittinger <cg@exept.de>
parents:
558
diff
changeset
|
4431 |
"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
|
4432 |
"Modified: 17.4.1996 / 17:22:35 / cg" |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4433 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4434 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4435 |
flushListOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4436 |
"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
|
4437 |
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
|
4438 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4439 |
listOfXFonts := nil |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4440 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4441 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4442 |
Display flushListOfAvailableFonts. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4443 |
Display listOfAvailableFonts |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4444 |
" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4445 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4446 |
"Modified: 27.9.1995 / 10:54:47 / stefan" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4447 |
"Created: 20.2.1996 / 22:55:52 / cg" |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4448 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4449 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4450 |
fullNameOf:aFontId |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4451 |
"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
|
4452 |
used for user feed-back (for example: in the fontPanel). |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4453 |
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
|
4454 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4455 |
|fullName fontName| |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4456 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4457 |
%{ |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4458 |
XFontStruct *f; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4459 |
XFontProp *prop; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4460 |
int n; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4461 |
char *cp; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4462 |
Atom fontAtom; |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4463 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4464 |
fontAtom = XInternAtom(myDpy, "FONT", True); |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4465 |
|
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4466 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4467 |
if (__isExternalAddress(aFontId)) { |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4468 |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4469 |
f = _FontVal(aFontId); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4470 |
if (f) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4471 |
n = f->n_properties; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4472 |
prop = f->properties; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4473 |
if (prop) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4474 |
while (n--) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4475 |
cp = XGetAtomName(myDpy, prop->name); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4476 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4477 |
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
|
4478 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4479 |
if (prop->name == XA_FULL_NAME) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4480 |
cp = XGetAtomName(myDpy, prop->card32); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4481 |
if (cp) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4482 |
fullName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4483 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4484 |
printf(" FULL_NAME -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4485 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4486 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4487 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4488 |
if (prop->name == fontAtom) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4489 |
cp = XGetAtomName(myDpy, prop->card32); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4490 |
if (cp) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4491 |
fontName = __MKSTRING(cp COMMA_CON); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4492 |
#ifdef SUPERDEBUG |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4493 |
printf(" FONT -> %s\n", cp); |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4494 |
#endif |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4495 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4496 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4497 |
prop++; |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4498 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4499 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4500 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4501 |
} |
440
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4502 |
} |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4503 |
%}. |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4504 |
(fullName notNil and:[fullName notEmpty]) ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4505 |
^ fullName |
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 |
^ fontName |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4508 |
! |
e959b8e18453
font encoding & fullName support
Claus Gittinger <cg@exept.de>
parents:
404
diff
changeset
|
4509 |
|
295 | 4510 |
getAvailableFontsMatching:pattern |
4511 |
"return an Array filled with font names matching aPattern" |
|
4512 |
||
4513 |
%{ /* UNLIMITEDSTACK */ |
|
4514 |
||
4515 |
int nnames = 1500; |
|
4516 |
int available = nnames + 1; |
|
4517 |
char **fonts; |
|
4518 |
OBJ arr, str; |
|
4519 |
int i; |
|
4520 |
||
4521 |
if (ISCONNECTED) { |
|
4522 |
if (__isString(pattern)) { |
|
4523 |
for (;;) { |
|
4524 |
fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available); |
|
4525 |
if ((fonts == NULL) || (available < nnames)) break; |
|
4526 |
XFreeFontNames(fonts); |
|
4527 |
nnames = available * 2; |
|
4528 |
} |
|
4529 |
if (fonts == NULL) { |
|
4530 |
RETURN ( nil ); |
|
4531 |
} |
|
4532 |
/* |
|
4533 |
* now, that we know the number of font names, |
|
4534 |
* create the array ... |
|
4535 |
*/ |
|
4536 |
arr = __ARRAY_NEW_INT(available); |
|
4537 |
if (! arr) { |
|
4538 |
RETURN (nil); |
|
4539 |
} |
|
4540 |
/* |
|
4541 |
* ... and fill it |
|
4542 |
*/ |
|
4543 |
for (i=0; i<available; i++) { |
|
350 | 4544 |
__PROTECT__(arr); |
295 | 4545 |
str = __MKSTRING(fonts[i] COMMA_CON); |
350 | 4546 |
__UNPROTECT__(arr); |
295 | 4547 |
__ArrayInstPtr(arr)->a_element[i] = str; __STORE(arr, str); |
4548 |
} |
|
4549 |
RETURN (arr); |
|
4550 |
} |
|
4551 |
} |
|
4552 |
%}. |
|
4553 |
^ nil |
|
4554 |
! |
|
4555 |
||
4556 |
getDefaultFont |
|
4557 |
"return a default font id - used when class Font cannot |
|
4558 |
find anything usable" |
|
4559 |
||
4560 |
^ self createFontFor:'fixed' |
|
4561 |
! |
|
4562 |
||
4563 |
getFontWithFamily:familyString face:faceString |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4564 |
style:styleString size:sizeArg encoding:encodingSym |
295 | 4565 |
|
4566 |
"try to get the specified font, if not available, try next smaller |
|
4567 |
font. Access to X-fonts by name is possible, by passing the X font name |
|
4568 |
as family and the other parameters as nil. For example, the cursor font |
|
4569 |
can be aquired that way." |
|
4570 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4571 |
|theName theId xlatedStyle id | |
295 | 4572 |
|
4573 |
"special: if face is nil, allow access to X-fonts" |
|
4574 |
faceString isNil ifTrue:[ |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4575 |
sizeArg notNil ifTrue:[ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4576 |
theName := familyString , '-' , sizeArg printString |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4577 |
] ifFalse:[ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4578 |
theName := familyString |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4579 |
]. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4580 |
theName isNil ifTrue:[ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4581 |
" |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4582 |
mhmh - fall back to the default font |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4583 |
" |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4584 |
theName := 'fixed' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4585 |
]. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4586 |
theId := self createFontFor:theName. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4587 |
theId isNil ifTrue:[ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4588 |
theId := self getDefaultFont |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4589 |
]. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4590 |
^ theId |
295 | 4591 |
]. |
4592 |
||
4593 |
xlatedStyle := styleString. |
|
4594 |
xlatedStyle notNil ifTrue:[ |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4595 |
xlatedStyle := xlatedStyle first asString |
295 | 4596 |
]. |
4597 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4598 |
id := self |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4599 |
getFontWithFoundry:'*' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4600 |
family:familyString asLowercase |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4601 |
weight:faceString |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4602 |
slant:xlatedStyle |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4603 |
spacing:'normal' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4604 |
pixelSize:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4605 |
size:sizeArg |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4606 |
registry:encodingSym |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4607 |
encoding:'*'. |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4608 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4609 |
id isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4610 |
(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4611 |
"/ too stupid: encodings come in both cases |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4612 |
"/ and X does not ignore case |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4613 |
"/ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4614 |
id := self |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4615 |
getFontWithFoundry:'*' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4616 |
family:familyString asLowercase |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4617 |
weight:faceString |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4618 |
slant:xlatedStyle |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4619 |
spacing:'normal' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4620 |
pixelSize:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4621 |
size:sizeArg |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4622 |
registry:encodingSym asUppercase |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4623 |
encoding:'*'. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4624 |
id isNil ifTrue:[ |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4625 |
id := self |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4626 |
getFontWithFoundry:'*' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4627 |
family:familyString asLowercase |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4628 |
weight:faceString |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4629 |
slant:xlatedStyle |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4630 |
spacing:'normal' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4631 |
pixelSize:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4632 |
size:sizeArg |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4633 |
registry:encodingSym asLowercase |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4634 |
encoding:'*'. |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4635 |
] |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4636 |
] |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4637 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4638 |
^ id |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4639 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4640 |
"Modified: 24.2.1996 / 22:37:24 / cg" |
295 | 4641 |
! |
4642 |
||
4643 |
getFontWithFoundry:foundry family:family weight:weight |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4644 |
slant:slant spacing:spc pixelSize:pSize size:size |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4645 |
registry:registry encoding:encoding |
295 | 4646 |
|
4647 |
"get the specified font, if not available, return nil. |
|
4648 |
This is the new font creation method - all others will be changed to |
|
4649 |
use this entry. |
|
4650 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
4651 |
||
4652 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
4653 |
family: 'helvetica' 'courier' 'times' ... |
|
4654 |
weight: 'bold' 'medium' 'demi' ... |
|
4655 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
4656 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
4657 |
pixelSize: 16,18 ... usually left empty |
|
4658 |
size: size in point (1/72th of an inch) |
|
4659 |
registry: iso8859, sgi ... '*' |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4660 |
encoding: vendor specific encoding (usually '*') |
295 | 4661 |
" |
4662 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4663 |
|theName sizeMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4664 |
foundryMatch familyMatch weightMatch slantMatch spcMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4665 |
pSizeMatch registryMatch encodingMatch |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4666 |
id| |
295 | 4667 |
|
4668 |
"this works only on 'Release >= 3' - X-servers" |
|
4669 |
"name is: |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4670 |
-foundry-family -weight -slant- |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4671 |
sony helvetica bold r |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4672 |
adobe courier medium i |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4673 |
msic fixed o |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4674 |
... ... |
295 | 4675 |
" |
4676 |
||
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4677 |
size isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4678 |
sizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4679 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4680 |
sizeMatch := size printString , '0' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4681 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4682 |
foundry isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4683 |
foundryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4684 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4685 |
foundryMatch := foundry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4686 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4687 |
family isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4688 |
familyMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4689 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4690 |
familyMatch := family |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4691 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4692 |
weight isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4693 |
weightMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4694 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4695 |
weightMatch := weight |
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 |
slant isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4698 |
slantMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4699 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4700 |
slantMatch := slant |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4701 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4702 |
spc isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4703 |
spcMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4704 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4705 |
spcMatch := spc |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4706 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4707 |
pSize isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4708 |
pSizeMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4709 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4710 |
pSizeMatch := pSize printString |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4711 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4712 |
registry isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4713 |
registryMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4714 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4715 |
registryMatch := registry |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4716 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4717 |
encoding isNil ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4718 |
encodingMatch := '*' |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4719 |
] ifFalse:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4720 |
encodingMatch := encoding |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4721 |
]. |
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4722 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4723 |
theName := ('-' , foundryMatch, |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4724 |
'-' , familyMatch, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4725 |
'-' , weightMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4726 |
'-' , slantMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4727 |
'-' , spcMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4728 |
'-*' , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4729 |
'-' , pSizeMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4730 |
'-' , sizeMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4731 |
'-*-*-*-*' , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4732 |
'-' , registryMatch , |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4733 |
'-' , encodingMatch). |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4734 |
|
697 | 4735 |
"/ Transcript showCR:theName; endEntry. |
295 | 4736 |
|
4737 |
^ self createFontFor:theName. |
|
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4738 |
|
295 | 4739 |
|
4740 |
" |
|
4741 |
Display getFontWithFoundry:'*' |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4742 |
family:'courier' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4743 |
weight:'medium' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4744 |
slant:'r' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4745 |
spacing:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4746 |
pixelSize:nil |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4747 |
size:13 |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4748 |
registry:'iso8859' |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4749 |
encoding:'*' |
295 | 4750 |
" |
457
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4751 |
|
b40bf5d8727c
ignore vendor-encoding (use only registry for match)
Claus Gittinger <cg@exept.de>
parents:
449
diff
changeset
|
4752 |
"Modified: 24.2.1996 / 22:33:29 / cg" |
295 | 4753 |
! |
4754 |
||
4755 |
listOfAvailableFonts |
|
4756 |
"return a list with all available fonts on this display. |
|
4757 |
Since this takes a long time, keep the result of the query for the |
|
4758 |
next time. The elements of the returned collection are instances of |
|
4759 |
FontDescription." |
|
4760 |
||
392
caf4452ec3dd
merged sendKey/ButtonEvent into one method;
Claus Gittinger <cg@exept.de>
parents:
391
diff
changeset
|
4761 |
|"stream aName fntDescr" names| |
295 | 4762 |
|
4763 |
listOfXFonts isNil ifTrue:[ |
|
4764 |
"/ |
|
4765 |
"/ old code; using a pipe to xlsfonts |
|
4766 |
"/ |
|
4767 |
"/ stream := PipeStream readingFrom:'xlsfonts ''*'''. |
|
4768 |
"/ stream isNil ifTrue:[^ nil]. |
|
4769 |
"/ listOfXFonts := OrderedCollection new. |
|
4770 |
"/ [stream atEnd] whileFalse:[ |
|
4771 |
"/ aName := stream nextLine. |
|
4772 |
"/ aName notNil ifTrue:[ |
|
4773 |
"/ self decomposeXFontName:aName into: |
|
4774 |
"/ [:family :face :style :size :coding | |
|
4775 |
"/ family notNil ifTrue:[ |
|
4776 |
"/ fntDescr := FontDescription |
|
4777 |
"/ family:family |
|
4778 |
"/ face:face |
|
4779 |
"/ style:style |
|
4780 |
"/ size:size |
|
4781 |
"/ encoding:coding. |
|
4782 |
"/ listOfXFonts add:fntDescr |
|
4783 |
"/ ] |
|
4784 |
"/ ] |
|
4785 |
"/ ] |
|
4786 |
"/ ]. |
|
4787 |
"/ stream close. |
|
4788 |
"/ "if xlsfont is broken ... (hey sco)" |
|
4789 |
"/ (listOfXFonts size == 0) ifTrue:[ |
|
4790 |
"/ listOfXFonts := nil |
|
4791 |
"/ ] ifFalse:[ |
|
4792 |
"/ listOfXFonts sort:[:a :b | a family < b family]. |
|
4793 |
"/ ]. |
|
4794 |
||
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4795 |
"/ |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4796 |
"/ new code: |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4797 |
"/ use new primitive to get font names; |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4798 |
"/ this is much faster, and also works on systems where |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4799 |
"/ a) xlsfonts is broken (sco) |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4800 |
"/ b) xlsfonts is not available (aix) |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4801 |
"/ |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4802 |
names := self getAvailableFontsMatching:'*'. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4803 |
names isNil ifTrue:[ |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4804 |
"no names returned ..." |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4805 |
^ nil |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4806 |
]. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4807 |
listOfXFonts := names collect:[:aName | |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4808 |
|fntDescr| |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4809 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4810 |
(self decomposeXFontName:aName into: |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4811 |
[:family :face :style :size :coding | |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4812 |
family notNil ifTrue:[ |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4813 |
fntDescr := FontDescription |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4814 |
family:family |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4815 |
face:face |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4816 |
style:style |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4817 |
size:size |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4818 |
encoding:coding. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4819 |
] ifFalse:[ |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4820 |
fntDescr := FontDescription |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4821 |
name:aName |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4822 |
] |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4823 |
] |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4824 |
) ifFalse:[ |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4825 |
fntDescr := FontDescription name:aName. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4826 |
]. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4827 |
fntDescr |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4828 |
]. |
295 | 4829 |
|
4830 |
]. |
|
4831 |
^ listOfXFonts |
|
4832 |
||
4833 |
" |
|
568
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4834 |
Display listOfAvailableFonts. |
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4835 |
|
ded98de3475f
return encoding as a symbol (faster compare)
Claus Gittinger <cg@exept.de>
parents:
567
diff
changeset
|
4836 |
Display getAvailableFontsMatching:'*'. |
295 | 4837 |
" |
4838 |
||
4839 |
"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
|
4840 |
"Modified: 17.4.1996 / 15:27:57 / cg" |
295 | 4841 |
! |
4842 |
||
4843 |
maxAscentOf:aFontId |
|
4844 |
"the max ascent" |
|
4845 |
||
4846 |
%{ /* NOCONTEXT */ |
|
4847 |
||
4848 |
XFontStruct *f; |
|
4849 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4850 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4851 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4852 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4853 |
RETURN ( __MKSMALLINT(f->max_bounds.ascent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4854 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4855 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4856 |
%}. |
295 | 4857 |
self primitiveFailed. |
4858 |
^ nil |
|
4859 |
! |
|
4860 |
||
4861 |
maxDescentOf:aFontId |
|
4862 |
"the max descent" |
|
4863 |
||
4864 |
%{ /* NOCONTEXT */ |
|
4865 |
||
4866 |
XFontStruct *f; |
|
4867 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4868 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4869 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4870 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4871 |
RETURN ( __MKSMALLINT(f->max_bounds.descent) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4872 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4873 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4874 |
%}. |
295 | 4875 |
self primitiveFailed. |
4876 |
^ nil |
|
4877 |
! |
|
4878 |
||
4879 |
maxWidthOfFont:aFontId |
|
4880 |
"the width of the widest character" |
|
4881 |
||
4882 |
%{ /* NOCONTEXT */ |
|
4883 |
||
4884 |
XFontStruct *f; |
|
4885 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4886 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4887 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4888 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4889 |
RETURN ( __MKSMALLINT(f->max_bounds.width) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4890 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4891 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4892 |
%}. |
295 | 4893 |
self primitiveFailed. |
4894 |
^ nil |
|
4895 |
! |
|
4896 |
||
4897 |
minWidthOfFont:aFontId |
|
4898 |
||
4899 |
%{ /* NOCONTEXT */ |
|
4900 |
||
4901 |
XFontStruct *f; |
|
4902 |
||
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4903 |
if (ISCONNECTED) { |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4904 |
if (__isExternalAddress(aFontId)) { |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4905 |
f = _FontVal(aFontId); |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4906 |
RETURN ( __MKSMALLINT(f->min_bounds.width) ); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4907 |
} |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4908 |
} |
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4909 |
%}. |
295 | 4910 |
self primitiveFailed. |
4911 |
^ nil |
|
4912 |
! |
|
4913 |
||
4914 |
releaseFont:aFontId |
|
4915 |
||
4916 |
%{ /* NOCONTEXT */ |
|
4917 |
||
4918 |
XFontStruct *f; |
|
4919 |
||
4920 |
if (ISCONNECTED) { |
|
4921 |
if (__isExternalAddress(aFontId)) { |
|
4922 |
f = _FontVal(aFontId); |
|
4923 |
BEGIN_INTERRUPTSBLOCKED |
|
4924 |
XFreeFont(myDpy, f); |
|
4925 |
END_INTERRUPTSBLOCKED |
|
4926 |
RETURN ( self ); |
|
4927 |
} |
|
4928 |
} |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4929 |
%}. |
295 | 4930 |
self primitiveFailed |
4931 |
! |
|
4932 |
||
466 | 4933 |
sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter |
295 | 4934 |
"return a set of all available font sizes in aFamily/aFace/aStyle |
4935 |
on this display. |
|
4936 |
Redefined to handle X's special case of 0-size (which stands for any)" |
|
4937 |
||
4938 |
|sizes| |
|
4939 |
||
466 | 4940 |
sizes := super sizesInFamily:aFamilyName face:aFaceName style:aStyleName filtering:filter. |
295 | 4941 |
(sizes notNil and:[sizes includes:0]) ifTrue:[ |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4942 |
"special: in X11R5 and above, size 0 means: |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4943 |
there are scaled versions in all sizes available" |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4944 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
4945 |
^ #(4 5 6 7 8 9 10 11 12 14 16 18 20 22 24 28 32 48 64) |
295 | 4946 |
]. |
4947 |
^ sizes |
|
4948 |
||
4949 |
" |
|
4950 |
Display sizesInFamily:'courier' face:'bold' style:'roman' |
|
4951 |
" |
|
466 | 4952 |
|
4953 |
"Created: 27.2.1996 / 01:38:15 / cg" |
|
295 | 4954 |
! |
4955 |
||
4956 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
|
4957 |
||
4958 |
%{ /* NOCONTEXT */ |
|
4959 |
||
4960 |
XFontStruct *f; |
|
4961 |
char *cp; |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4962 |
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
|
4963 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4964 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4965 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
4966 |
int nInstBytes; |
295 | 4967 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
4968 |
if (ISCONNECTED) { |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4969 |
if (__bothSmallInteger(index1, index2) |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4970 |
&& __isExternalAddress(aFontId) |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4971 |
&& __isNonNilObject(aString)) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4972 |
f = _FontVal(aFontId); |
555 | 4973 |
i1 = __intVal(index1) - 1; |
4974 |
cls = __qClass(aString); |
|
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4975 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4976 |
if (i1 >= 0) { |
555 | 4977 |
i2 = __intVal(index2) - 1; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4978 |
if (i2 < i1) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4979 |
RETURN (self); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4980 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4981 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4982 |
cp = (char *) _stringVal(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4983 |
l = i2 - i1 + 1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4984 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4985 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4986 |
n = _stringSize(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4987 |
if (i2 < n) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4988 |
cp += i1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4989 |
BEGIN_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4990 |
len = XTextWidth(f, cp, l); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4991 |
END_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4992 |
RETURN ( __MKSMALLINT(len) ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4993 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4994 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4995 |
|
555 | 4996 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4997 |
cp += nInstBytes; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4998 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
4999 |
if (__isBytes(aString)) { |
555 | 5000 |
n = __byteArraySize(aString) - nInstBytes; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5001 |
if (i2 < n) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5002 |
cp += i1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5003 |
BEGIN_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5004 |
len = XTextWidth(f, cp, l); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5005 |
END_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5006 |
RETURN ( __MKSMALLINT(len) ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5007 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5008 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5009 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5010 |
/* TWOBYTESTRINGS */ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5011 |
if (__isWords(aString)) { |
555 | 5012 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5013 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5014 |
if (i2 < n) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5015 |
union { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5016 |
char b[2]; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5017 |
unsigned short s; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5018 |
} u; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5019 |
int i; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5020 |
XChar2b *cp2 = (XChar2b *)0; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5021 |
int mustFree = 0; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5022 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5023 |
cp += (i1 * 2); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5024 |
if (l > 1000) l = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5025 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5026 |
/* |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5027 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5028 |
* X expects them MSB first |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5029 |
* convert as required |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5030 |
*/ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5031 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5032 |
u.s = 0x1234; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5033 |
if (u.b[0] != 0x12) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5034 |
if (l <= NLOCALBUFFER) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5035 |
cp2 = xlatebuffer; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5036 |
} else { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5037 |
cp2 = (XChar2b *)(malloc(l * 2)); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5038 |
mustFree = 1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5039 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5040 |
for (i=0; i<l; i++) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5041 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5042 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5043 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5044 |
cp = (char *) cp2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5045 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5046 |
BEGIN_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5047 |
len = XTextWidth16(f, (XChar2b *)cp, l); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5048 |
END_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5049 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5050 |
if (mustFree) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5051 |
free(cp2); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5052 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5053 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5054 |
RETURN ( __MKSMALLINT(len) ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5055 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5056 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5057 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5058 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5059 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5060 |
#undef NLOCALBUFFER |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5061 |
%}. |
295 | 5062 |
self primitiveFailed. |
5063 |
^ nil |
|
5064 |
! |
|
5065 |
||
5066 |
widthOf:aString inFont:aFontId |
|
5067 |
||
5068 |
%{ /* NOCONTEXT */ |
|
5069 |
||
5070 |
XFontStruct *f; |
|
5071 |
char *cp; |
|
5072 |
int len, n; |
|
447
9a58924e921b
dont hardcode TwoByteString - use __isWords to check for doubleByteStringDraw
Claus Gittinger <cg@exept.de>
parents:
440
diff
changeset
|
5073 |
OBJ cls; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5074 |
# define NLOCALBUFFER 200 |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5075 |
XChar2b xlatebuffer[NLOCALBUFFER]; |
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5076 |
int nInstBytes; |
295 | 5077 |
|
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5078 |
if (ISCONNECTED) { |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5079 |
if (__isExternalAddress(aFontId) |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5080 |
&& __isNonNilObject(aString)) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5081 |
f = _FontVal(aFontId); |
555 | 5082 |
cls = __qClass(aString); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5083 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5084 |
cp = (char *)_stringVal(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5085 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5086 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5087 |
n = _stringSize(aString); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5088 |
BEGIN_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5089 |
len = XTextWidth(f, cp, n); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5090 |
END_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5091 |
RETURN ( __MKSMALLINT(len) ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5092 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5093 |
|
555 | 5094 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5095 |
cp += nInstBytes; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5096 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5097 |
if (__isBytes(aString)) { |
555 | 5098 |
n = __byteArraySize(aString) - nInstBytes; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5099 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5100 |
BEGIN_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5101 |
len = XTextWidth(f, cp, n); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5102 |
END_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5103 |
RETURN ( __MKSMALLINT(len) ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5104 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5105 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5106 |
/* TWOBYTESTRINGS */ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5107 |
if (__isWords(aString)) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5108 |
union { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5109 |
char b[2]; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5110 |
unsigned short s; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5111 |
} u; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5112 |
int i; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5113 |
XChar2b *cp2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5114 |
int mustFree = 0; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5115 |
|
555 | 5116 |
n = (__byteArraySize(aString) - nInstBytes) / 2; |
486
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5117 |
if (n > 1000) n = 1000; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5118 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5119 |
/* |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5120 |
* ST/X TwoByteStrings store the asciiValue in native byteOrder; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5121 |
* X expects them MSB first |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5122 |
* convert as required |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5123 |
*/ |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5124 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5125 |
u.s = 0x1234; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5126 |
if (u.b[0] != 0x12) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5127 |
if (n <= NLOCALBUFFER) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5128 |
cp2 = xlatebuffer; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5129 |
} else { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5130 |
cp2 = (XChar2b *)(malloc(n * 2)); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5131 |
mustFree = 1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5132 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5133 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5134 |
for (i=0; i<n; i++) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5135 |
cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5136 |
cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5137 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5138 |
cp = (char *) cp2; |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5139 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5140 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5141 |
BEGIN_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5142 |
len = XTextWidth16(f, (XChar2b *)cp, n); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5143 |
END_INTERRUPTSBLOCKED |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5144 |
|
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5145 |
if (mustFree) { |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5146 |
free(cp2); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5147 |
} |
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 |
RETURN ( __MKSMALLINT(len) ); |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5150 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5151 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5152 |
} |
0c35ed67797d
oops - 16bit drawing was corrupted / fixed widthOf-16bit for byteSwapped displays
Claus Gittinger <cg@exept.de>
parents:
481
diff
changeset
|
5153 |
#undef NLOCALBUFFER |
402
f5a53e2a868d
check for being connected in font query methods
Claus Gittinger <cg@exept.de>
parents:
397
diff
changeset
|
5154 |
%}. |
295 | 5155 |
self primitiveFailed. |
5156 |
^ nil |
|
5157 |
! ! |
|
5158 |
||
5159 |
!XWorkstation methodsFor:'grabbing '! |
|
5160 |
||
5161 |
allowEvents:mode |
|
5162 |
%{ /* NOCONTEXT */ |
|
5163 |
||
5164 |
int _mode, ok = 1; |
|
5165 |
||
5166 |
if (mode == @symbol(asyncPointer)) |
|
5167 |
_mode = AsyncPointer; |
|
5168 |
else if (mode == @symbol(syncPointer)) |
|
5169 |
_mode = SyncPointer; |
|
5170 |
else if (mode == @symbol(asyncKeyboard)) |
|
5171 |
_mode = AsyncKeyboard; |
|
5172 |
else if (mode == @symbol(syncKeyboard)) |
|
5173 |
_mode = SyncKeyboard; |
|
5174 |
else if (mode == @symbol(syncBoth)) |
|
5175 |
_mode = SyncBoth; |
|
5176 |
else if (mode == @symbol(asyncBoth)) |
|
5177 |
_mode = AsyncBoth; |
|
5178 |
else if (mode == @symbol(replayPointer)) |
|
5179 |
_mode = ReplayPointer; |
|
5180 |
else if (mode == @symbol(replayKeyboard)) |
|
5181 |
_mode = ReplayKeyboard; |
|
5182 |
else |
|
5183 |
ok = 0; |
|
5184 |
||
5185 |
if (ok) { |
|
5186 |
BEGIN_INTERRUPTSBLOCKED |
|
5187 |
XAllowEvents(myDpy, _mode, CurrentTime); |
|
5188 |
END_INTERRUPTSBLOCKED |
|
5189 |
RETURN (self); |
|
5190 |
} |
|
481
62f1be5db8aa
also support string-subclasses in stringDraw methods
Claus Gittinger <cg@exept.de>
parents:
480
diff
changeset
|
5191 |
%}. |
295 | 5192 |
self primitiveFailed |
5193 |
! |
|
5194 |
||
5195 |
grabKeyboardIn:aWindowId |
|
5196 |
"grab the keyboard" |
|
5197 |
||
5198 |
%{ /* NOCONTEXT */ |
|
5199 |
int result, ok; |
|
5200 |
||
5201 |
if (__isExternalAddress(aWindowId)) { |
|
5202 |
BEGIN_INTERRUPTSBLOCKED |
|
5203 |
result = XGrabKeyboard(myDpy, |
|
5204 |
_WindowVal(aWindowId), |
|
5205 |
True /* False */, |
|
5206 |
GrabModeAsync, |
|
5207 |
GrabModeAsync, |
|
5208 |
CurrentTime); |
|
5209 |
END_INTERRUPTSBLOCKED |
|
5210 |
ok = 0; |
|
5211 |
switch(result) { |
|
5212 |
case AlreadyGrabbed: |
|
5213 |
printf("XWORKSTAT: grab keyboard: AlreadyGrabbed\n"); |
|
5214 |
break; |
|
5215 |
case GrabNotViewable: |
|
5216 |
printf("XWORKSTAT: grab keyboard: GrabNotViewable\n"); |
|
5217 |
break; |
|
5218 |
case GrabInvalidTime: |
|
5219 |
printf("XWORKSTAT: grab keyboard: InvalidTime\n"); |
|
5220 |
break; |
|
5221 |
case GrabFrozen: |
|
5222 |
printf("XWORKSTAT: grab keyboard: Frozen\n"); |
|
5223 |
break; |
|
5224 |
default: |
|
5225 |
ok = 1; |
|
5226 |
break; |
|
5227 |
} |
|
5228 |
if (! ok) { |
|
5229 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5230 |
RETURN (false); |
|
5231 |
} |
|
5232 |
||
5233 |
RETURN ( true ); |
|
5234 |
} |
|
5235 |
%} |
|
5236 |
. |
|
5237 |
self primitiveFailed |
|
5238 |
! |
|
5239 |
||
5240 |
grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId |
|
5241 |
"grap the pointer - return true if ok" |
|
5242 |
||
5243 |
%{ /* NOCONTEXT */ |
|
5244 |
||
5245 |
int result, ok; |
|
5246 |
Window confineWin; |
|
5247 |
Cursor curs; |
|
5248 |
int pointer_mode, keyboard_mode; |
|
5249 |
||
5250 |
if (__isExternalAddress(aWindowId)) { |
|
5251 |
if (__isExternalAddress(confineId)) |
|
5252 |
confineWin = _WindowVal(confineId); |
|
5253 |
else |
|
5254 |
confineWin = (Window) None; |
|
5255 |
||
5256 |
if (__isExternalAddress(aCursorId)) |
|
5257 |
curs = _CursorVal(aCursorId); |
|
5258 |
else |
|
5259 |
curs = (Cursor) None; |
|
5260 |
||
5261 |
if (pMode == @symbol(sync)) |
|
5262 |
pointer_mode = GrabModeSync; |
|
5263 |
else |
|
5264 |
pointer_mode = GrabModeAsync; |
|
5265 |
||
5266 |
if (kMode == @symbol(sync)) |
|
5267 |
keyboard_mode = GrabModeSync; |
|
5268 |
else |
|
5269 |
keyboard_mode = GrabModeAsync; |
|
5270 |
||
5271 |
BEGIN_INTERRUPTSBLOCKED |
|
5272 |
result = XGrabPointer(myDpy, |
|
5273 |
_WindowVal(aWindowId), |
|
5274 |
False, |
|
5275 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, |
|
5276 |
pointer_mode, keyboard_mode, |
|
5277 |
confineWin, |
|
5278 |
curs, |
|
5279 |
CurrentTime); |
|
5280 |
END_INTERRUPTSBLOCKED |
|
5281 |
||
5282 |
ok = 0; |
|
5283 |
switch (result) { |
|
5284 |
case AlreadyGrabbed: |
|
5285 |
printf("XWORKSTAT: grab pointer: AlreadyGrabbed\n"); |
|
5286 |
break; |
|
5287 |
case GrabNotViewable: |
|
5288 |
printf("XWORKSTAT: grab pointer: GrabNotViewable\n"); |
|
5289 |
break; |
|
5290 |
case GrabInvalidTime: |
|
5291 |
printf("XWORKSTAT: grab pointer: InvalidTime\n"); |
|
5292 |
break; |
|
5293 |
case GrabFrozen: |
|
5294 |
printf("XWORKSTAT: grab pointer: Frozen\n"); |
|
5295 |
break; |
|
5296 |
default: |
|
5297 |
ok = 1; |
|
5298 |
break; |
|
5299 |
} |
|
5300 |
||
5301 |
if (! ok) { |
|
5302 |
XUngrabPointer(myDpy, CurrentTime); |
|
5303 |
RETURN (false); |
|
5304 |
} |
|
5305 |
RETURN ( true ); |
|
5306 |
} |
|
5307 |
%} |
|
5308 |
. |
|
5309 |
self primitiveFailed |
|
5310 |
! |
|
5311 |
||
5312 |
ungrabKeyboard |
|
5313 |
"release the keyboard" |
|
5314 |
||
5315 |
%{ /* NOCONTEXT */ |
|
5316 |
||
5317 |
if (ISCONNECTED) { |
|
5318 |
BEGIN_INTERRUPTSBLOCKED |
|
5319 |
XUngrabKeyboard(myDpy, CurrentTime); |
|
5320 |
XSync(myDpy, 0); |
|
5321 |
END_INTERRUPTSBLOCKED |
|
5322 |
} |
|
5323 |
%}. |
|
5324 |
activeKeyboardGrab := nil |
|
5325 |
! |
|
5326 |
||
5327 |
ungrabPointer |
|
5328 |
"release the pointer" |
|
5329 |
||
5330 |
%{ /* NOCONTEXT */ |
|
5331 |
||
5332 |
if (ISCONNECTED) { |
|
5333 |
BEGIN_INTERRUPTSBLOCKED |
|
5334 |
XUngrabPointer(myDpy, CurrentTime); |
|
5335 |
XSync(myDpy, 0); |
|
5336 |
END_INTERRUPTSBLOCKED |
|
5337 |
} |
|
5338 |
%}. |
|
5339 |
activePointerGrab := nil |
|
5340 |
! ! |
|
5341 |
||
5342 |
!XWorkstation methodsFor:'graphic context stuff'! |
|
5343 |
||
5344 |
noClipIn:aGCId |
|
5345 |
"disable clipping rectangle" |
|
5346 |
||
5347 |
%{ /* NOCONTEXT */ |
|
5348 |
||
5349 |
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
|
5350 |
GC gc; |
295 | 5351 |
|
5352 |
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
|
5353 |
gc = _GCVal(aGCId); |
295 | 5354 |
gcv.clip_mask = None; |
5355 |
XChangeGC(myDpy, gc, GCClipMask, &gcv); |
|
5356 |
RETURN ( self ); |
|
5357 |
} |
|
5358 |
%}. |
|
5359 |
self primitiveFailed |
|
5360 |
! |
|
5361 |
||
5362 |
setBackground:bgColorIndex in:aGCId |
|
5363 |
"set background color to be drawn with" |
|
5364 |
||
5365 |
%{ /* NOCONTEXT */ |
|
5366 |
||
5367 |
if (__isExternalAddress(aGCId) |
|
5368 |
&& __isSmallInteger(bgColorIndex)) { |
|
555 | 5369 |
XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex)); |
295 | 5370 |
RETURN ( self ); |
5371 |
} |
|
5372 |
%}. |
|
5373 |
self primitiveFailed |
|
5374 |
! |
|
5375 |
||
5376 |
setBitmapMask:aBitmapId in:aGCId |
|
5377 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
|
5378 |
||
5379 |
%{ /* NOCONTEXT */ |
|
5380 |
||
5381 |
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
|
5382 |
GC gc; |
295 | 5383 |
Pixmap bitmap; |
5384 |
||
5385 |
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
|
5386 |
gc = _GCVal(aGCId); |
295 | 5387 |
if (__isExternalAddress(aBitmapId)) { |
5388 |
bitmap = _PixmapVal(aBitmapId); |
|
5389 |
XSetStipple(dpy, gc, bitmap); |
|
5390 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5391 |
RETURN ( self ); |
|
5392 |
} |
|
5393 |
if (aBitmapId == nil) { |
|
5394 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5395 |
RETURN ( self ); |
|
5396 |
} |
|
5397 |
} |
|
5398 |
%}. |
|
5399 |
self primitiveFailed |
|
5400 |
! |
|
5401 |
||
5402 |
setClipByChildren:aBool in:aGCId |
|
5403 |
"enable/disable drawing into child views" |
|
5404 |
||
5405 |
%{ /* NOCONTEXT */ |
|
5406 |
||
5407 |
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
|
5408 |
GC gc; |
295 | 5409 |
|
5410 |
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
|
5411 |
gc = _GCVal(aGCId); |
295 | 5412 |
if (aBool == true) |
5413 |
gcv.subwindow_mode = ClipByChildren; |
|
5414 |
else |
|
5415 |
gcv.subwindow_mode = IncludeInferiors; |
|
5416 |
||
5417 |
XChangeGC(myDpy, gc, GCSubwindowMode, &gcv); |
|
5418 |
RETURN ( self ); |
|
5419 |
} |
|
5420 |
%}. |
|
5421 |
self primitiveFailed |
|
5422 |
! |
|
5423 |
||
5424 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:aGCId |
|
5425 |
"clip to a rectangle" |
|
5426 |
||
5427 |
%{ /* NOCONTEXT */ |
|
5428 |
||
5429 |
XRectangle r; |
|
5430 |
||
5431 |
if (__isExternalAddress(aGCId) |
|
5432 |
&& __bothSmallInteger(clipX, clipY) |
|
5433 |
&& __bothSmallInteger(clipWidth, clipHeight)) { |
|
555 | 5434 |
r.x = __intVal(clipX); |
5435 |
r.y = __intVal(clipY); |
|
5436 |
r.width = __intVal(clipWidth); |
|
5437 |
r.height = __intVal(clipHeight); |
|
295 | 5438 |
XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted); |
5439 |
RETURN ( self ); |
|
5440 |
} |
|
5441 |
%}. |
|
5442 |
self primitiveFailed |
|
5443 |
! |
|
5444 |
||
788 | 5445 |
setDashes:dashList dashOffset:offset in:aGCId |
5446 |
"set line attributes" |
|
5447 |
||
5448 |
%{ /* NOCONTEXT */ |
|
5449 |
||
5450 |
if (__isExternalAddress(aGCId) |
|
5451 |
&& __isSmallInteger(offset) |
|
5452 |
&& __isByteArray(dashList)) { |
|
5453 |
XSetDashes(myDpy, _GCVal(aGCId), |
|
5454 |
__intVal(offset), |
|
5455 |
__ByteArrayInstPtr(dashList)->ba_element, |
|
5456 |
__byteArraySize(dashList)); |
|
5457 |
RETURN ( self ); |
|
5458 |
} |
|
5459 |
bad: ; |
|
5460 |
%}. |
|
5461 |
" |
|
5462 |
either aGCId is invalid, |
|
5463 |
and/or dashList is not a byteArray |
|
5464 |
and/or offset is not a smallInteger |
|
5465 |
" |
|
5466 |
self primitiveFailed |
|
5467 |
! |
|
5468 |
||
295 | 5469 |
setFont:aFontId in:aGCId |
5470 |
"set font to be drawn in" |
|
5471 |
||
5472 |
%{ /* NOCONTEXT */ |
|
5473 |
||
5474 |
XFontStruct *f; |
|
5475 |
||
5476 |
if (__isExternalAddress(aFontId) |
|
5477 |
&& __isExternalAddress(aGCId)) { |
|
5478 |
f = (XFontStruct *) _FontVal(aFontId); |
|
5479 |
XSetFont(myDpy, _GCVal(aGCId), f->fid); |
|
5480 |
RETURN ( self ); |
|
5481 |
} |
|
5482 |
%}. |
|
5483 |
" |
|
5484 |
aGCId and/or aFontId are invalid |
|
5485 |
" |
|
5486 |
self primitiveFailed |
|
5487 |
! |
|
5488 |
||
5489 |
setForeground:fgColorIndex background:bgColorIndex in:aGCId |
|
5490 |
"set foreground and background colors to be drawn with" |
|
5491 |
||
5492 |
%{ /* NOCONTEXT */ |
|
5493 |
||
5494 |
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
|
5495 |
GC gc; |
295 | 5496 |
|
5497 |
if (__bothSmallInteger(fgColorIndex, bgColorIndex) |
|
5498 |
&& __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
|
5499 |
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
|
5500 |
|
555 | 5501 |
XSetForeground(dpy, gc, __intVal(fgColorIndex)); |
5502 |
XSetBackground(dpy, gc, __intVal(bgColorIndex)); |
|
295 | 5503 |
RETURN ( self ); |
5504 |
} |
|
5505 |
%}. |
|
5506 |
self primitiveFailed |
|
5507 |
! |
|
5508 |
||
5509 |
setForeground:fgColor background:bgColor mask:aBitmapId in:aGCId |
|
5510 |
"set foreground and background colors to be drawn with using mask or |
|
5511 |
solid (if aBitmapId is nil)" |
|
5512 |
||
5513 |
%{ /* NOCONTEXT */ |
|
5514 |
||
5515 |
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
|
5516 |
GC gc; |
295 | 5517 |
|
5518 |
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
|
5519 |
gc = _GCVal(aGCId); |
295 | 5520 |
if (__isSmallInteger(fgColor)) |
555 | 5521 |
XSetForeground(dpy, gc, __intVal(fgColor)); |
295 | 5522 |
if (__isSmallInteger(bgColor)) |
555 | 5523 |
XSetBackground(dpy, gc, __intVal(bgColor)); |
295 | 5524 |
|
5525 |
if (__isExternalAddress(aBitmapId)) { |
|
5526 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
5527 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5528 |
RETURN ( self ); |
|
5529 |
} |
|
5530 |
if (aBitmapId == nil) { |
|
5531 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5532 |
RETURN ( self ); |
|
5533 |
} |
|
5534 |
} |
|
5535 |
%}. |
|
5536 |
self primitiveFailed |
|
5537 |
! |
|
5538 |
||
5539 |
setForeground:fgColor background:bgColor mask:aBitmapId lineWidth:lw in:aGCId |
|
5540 |
"set foreground and background colors to be drawn with using mask or |
|
5541 |
solid (if aBitmapId is nil); also set lineWidth" |
|
5542 |
||
5543 |
%{ /* NOCONTEXT */ |
|
5544 |
||
5545 |
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
|
5546 |
GC gc; |
295 | 5547 |
|
5548 |
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
|
5549 |
gc = _GCVal(aGCId); |
295 | 5550 |
if (__isSmallInteger(lw)) { |
555 | 5551 |
XSetLineAttributes(dpy, gc, __intVal(lw), |
295 | 5552 |
LineSolid, CapNotLast, JoinMiter); |
5553 |
} |
|
5554 |
if (__isSmallInteger(fgColor)) |
|
555 | 5555 |
XSetForeground(dpy, gc, __intVal(fgColor)); |
295 | 5556 |
if (__isSmallInteger(bgColor)) |
555 | 5557 |
XSetBackground(dpy, gc, __intVal(bgColor)); |
295 | 5558 |
|
5559 |
if (__isExternalAddress(aBitmapId)) { |
|
5560 |
XSetStipple(dpy, gc, _PixmapVal(aBitmapId)); |
|
5561 |
XSetFillStyle(dpy, gc, FillOpaqueStippled); |
|
5562 |
RETURN ( self ); |
|
5563 |
} |
|
5564 |
if (aBitmapId == nil) { |
|
5565 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5566 |
RETURN ( self ); |
|
5567 |
} |
|
5568 |
} |
|
5569 |
%}. |
|
5570 |
self primitiveFailed |
|
5571 |
! |
|
5572 |
||
5573 |
setForeground:fgColorIndex in:aGCId |
|
5574 |
"set foreground color to be drawn with" |
|
5575 |
||
5576 |
%{ /* NOCONTEXT */ |
|
5577 |
||
5578 |
if (__isExternalAddress(aGCId) |
|
5579 |
&& __isSmallInteger(fgColorIndex)) { |
|
555 | 5580 |
XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex)); |
295 | 5581 |
RETURN ( self ); |
5582 |
} |
|
5583 |
%}. |
|
5584 |
self primitiveFailed |
|
5585 |
! |
|
5586 |
||
5587 |
setFunction:aFunctionSymbol in:aGCId |
|
5588 |
"set alu function to be drawn with" |
|
5589 |
||
5590 |
%{ /* NOCONTEXT */ |
|
5591 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
5592 |
GC gc; |
295 | 5593 |
int fun = -1; |
5594 |
||
5595 |
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
|
5596 |
gc = _GCVal(aGCId); |
295 | 5597 |
if (aFunctionSymbol == @symbol(copy)) fun = GXcopy; |
5598 |
else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted; |
|
5599 |
else if (aFunctionSymbol == @symbol(xor)) fun = GXxor; |
|
5600 |
else if (aFunctionSymbol == @symbol(and)) fun = GXand; |
|
5601 |
else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse; |
|
5602 |
else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted; |
|
5603 |
else if (aFunctionSymbol == @symbol(or)) fun = GXor; |
|
5604 |
else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse; |
|
5605 |
else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted; |
|
5606 |
if (fun != -1) { |
|
5607 |
XSetFunction(myDpy, gc, fun); |
|
5608 |
RETURN ( self ); |
|
5609 |
} |
|
5610 |
} |
|
5611 |
%}. |
|
5612 |
" |
|
5613 |
either aGCId is not an integer, or an invalid symbol |
|
5614 |
was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse, |
|
5615 |
#andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details. |
|
5616 |
" |
|
5617 |
self primitiveFailed |
|
5618 |
! |
|
5619 |
||
5620 |
setGraphicsExposures:aBoolean in:aGCId |
|
5621 |
"set or clear the graphics exposures flag" |
|
5622 |
||
5623 |
%{ /* NOCONTEXT */ |
|
5624 |
||
5625 |
if (__isExternalAddress(aGCId)) { |
|
5626 |
XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0); |
|
5627 |
RETURN ( self ); |
|
5628 |
} |
|
5629 |
%} |
|
5630 |
. |
|
5631 |
self primitiveFailed |
|
5632 |
! |
|
5633 |
||
5634 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId |
|
5635 |
"set line attributes" |
|
5636 |
||
5637 |
%{ /* NOCONTEXT */ |
|
5638 |
||
5639 |
int x_style, x_cap, x_join; |
|
5640 |
||
5641 |
if (__isExternalAddress(aGCId) |
|
5642 |
&& __isSmallInteger(aNumber)) { |
|
5643 |
if (lineStyle == @symbol(solid)) x_style = LineSolid; |
|
5644 |
else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash; |
|
5645 |
else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash; |
|
5646 |
else goto bad; |
|
5647 |
||
5648 |
if (capStyle == @symbol(notLast)) x_cap = CapNotLast; |
|
5649 |
else if (capStyle == @symbol(butt)) x_cap = CapButt; |
|
5650 |
else if (capStyle == @symbol(round)) x_cap = CapRound; |
|
5651 |
else if (capStyle == @symbol(projecting)) x_cap = CapProjecting; |
|
5652 |
else goto bad; |
|
5653 |
||
5654 |
if (joinStyle == @symbol(miter)) x_join = JoinMiter; |
|
5655 |
else if (joinStyle == @symbol(bevel)) x_join = JoinBevel; |
|
5656 |
else if (joinStyle == @symbol(round)) x_join = JoinRound; |
|
5657 |
else goto bad; |
|
5658 |
||
5659 |
XSetLineAttributes(myDpy, |
|
555 | 5660 |
_GCVal(aGCId), __intVal(aNumber), |
295 | 5661 |
x_style, x_cap, x_join); |
5662 |
RETURN ( self ); |
|
5663 |
} |
|
5664 |
bad: ; |
|
5665 |
%}. |
|
5666 |
" |
|
5667 |
either aGCId is invalid, |
|
5668 |
and/or lineStyle is none of #solid, #dashed, #doubleDashed |
|
5669 |
and/or capStyle is none of #notLast, #butt, #round, #projecting |
|
5670 |
and/or joinStyle is none of #miter, #bevel, #round |
|
5671 |
" |
|
5672 |
self primitiveFailed |
|
5673 |
! |
|
5674 |
||
5675 |
setMaskOriginX:orgX y:orgY in:aGCid |
|
5676 |
"set the mask origin" |
|
5677 |
||
5678 |
%{ /* NOCONTEXT */ |
|
5679 |
||
5680 |
if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) { |
|
555 | 5681 |
XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY)); |
295 | 5682 |
RETURN ( self ); |
5683 |
} |
|
5684 |
%}. |
|
5685 |
self primitiveFailed |
|
5686 |
! |
|
5687 |
||
5688 |
setPixmapMask:aPixmapId in:aGCId |
|
5689 |
"set or clear the drawing mask - a pixmap mask providing full color" |
|
5690 |
||
5691 |
%{ /* NOCONTEXT */ |
|
5692 |
||
5693 |
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
|
5694 |
GC gc; |
295 | 5695 |
Pixmap pixmap; |
5696 |
||
5697 |
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
|
5698 |
gc = _GCVal(aGCId); |
295 | 5699 |
if (__isExternalAddress(aPixmapId)) { |
5700 |
pixmap = _PixmapVal(aPixmapId); |
|
5701 |
XSetTile(dpy, gc, pixmap); |
|
5702 |
XSetFillStyle(dpy, gc, FillTiled); |
|
5703 |
RETURN ( self ); |
|
5704 |
} |
|
5705 |
if (aPixmapId == nil) { |
|
5706 |
XSetFillStyle(dpy, gc, FillSolid); |
|
5707 |
RETURN ( self ); |
|
5708 |
} |
|
5709 |
} |
|
5710 |
%}. |
|
5711 |
self primitiveFailed |
|
5712 |
! ! |
|
5713 |
||
5714 |
!XWorkstation methodsFor:'initialize / release'! |
|
5715 |
||
5716 |
close |
|
5717 |
"close down the connection to the X-server" |
|
5718 |
||
5719 |
%{ /* NOCONTEXT */ |
|
5720 |
||
5721 |
if (ISCONNECTED) { |
|
5722 |
BEGIN_INTERRUPTSBLOCKED |
|
5723 |
XCloseDisplay(myDpy); |
|
555 | 5724 |
__INST(displayId) = nil; |
295 | 5725 |
END_INTERRUPTSBLOCKED |
5726 |
} |
|
5727 |
%} |
|
5728 |
! |
|
5729 |
||
5730 |
initializeDefaultValues |
|
5731 |
buttonTranslation := ButtonTranslation. |
|
5732 |
multiClickTimeDelta := MultiClickTimeDelta. |
|
5733 |
||
5734 |
self initializeModifierMappings |
|
5735 |
! |
|
5736 |
||
5737 |
initializeEventBuffer |
|
5738 |
|sz| |
|
5739 |
||
5740 |
%{ |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
5741 |
sz = __MKSMALLINT(sizeof(XEvent) + 100); |
295 | 5742 |
%}. |
5743 |
eventBuffer isNil ifTrue:[ |
|
5744 |
eventBuffer := ByteArray new:sz. |
|
5745 |
]. |
|
5746 |
! |
|
5747 |
||
5748 |
initializeFor:aDisplayName |
|
5749 |
"initialize the receiver for a connection to an X-Server; |
|
5750 |
the argument, aDisplayName may be nil (for the default server from |
|
5751 |
DISPLAY-variable or command line argument) or the name of the server |
|
5752 |
as hostname:number" |
|
5753 |
||
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5754 |
|dpyName index arguments| |
295 | 5755 |
|
5756 |
dpyName := aDisplayName. |
|
5757 |
dpyName isNil ifTrue:[ |
|
5758 |
"look for a '-display xxx' argument" |
|
334
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5759 |
(arguments := Smalltalk commandLineArguments) notNil ifTrue:[ |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5760 |
index := arguments indexOf:'-display'. |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5761 |
(index between:1 and:(arguments size - 1)) ifTrue:[ |
8c851e8a0b05
access comandline args via access method
Claus Gittinger <cg@exept.de>
parents:
320
diff
changeset
|
5762 |
dpyName := arguments at:index+1 |
295 | 5763 |
] |
5764 |
] |
|
5765 |
]. |
|
5766 |
%{ |
|
5767 |
int scr; |
|
5768 |
Display *dpy; |
|
5769 |
Visual *visual; |
|
5770 |
XVisualInfo viproto; |
|
5771 |
XVisualInfo *vip; /* retured info */ |
|
5772 |
int maxRGBDepth; |
|
5773 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
5774 |
int rgbVisualID; |
|
5775 |
int nvi, i; |
|
5776 |
int shapeEventBase, shapeErrorBase; |
|
5777 |
int shmEventBase, shmErrorBase; |
|
5778 |
int faxEventBase, faxErrorBase; |
|
5779 |
char *type, *nm; |
|
5780 |
int dummy; |
|
5781 |
OBJ dpyID; |
|
5782 |
||
555 | 5783 |
if (__INST(displayId) != nil) { |
295 | 5784 |
/* |
5785 |
* already connected - you bad guy try to |
|
5786 |
* trick me manually ? |
|
5787 |
*/ |
|
5788 |
RETURN ( self ); |
|
5789 |
} |
|
5790 |
||
5791 |
BEGIN_INTERRUPTSBLOCKED |
|
5792 |
||
5793 |
if (__isString(dpyName)) |
|
5794 |
nm = (char *)_stringVal(dpyName); |
|
5795 |
else { |
|
5796 |
dpyName = __MKSTRING((char *)getenv("DISPLAY") COMMA_CON); |
|
5797 |
nm = NULL; |
|
5798 |
} |
|
5799 |
dpy = XOpenDisplay(nm); |
|
5800 |
||
5801 |
if (dpy) { |
|
555 | 5802 |
__INST(displayId) = dpyID = __MKOBJ(dpy); __STORE(self, dpyID); |
295 | 5803 |
|
5804 |
#ifdef SUPERDEBUG |
|
5805 |
XSynchronize(dpy, 1); |
|
5806 |
#endif |
|
5807 |
||
5808 |
XSetErrorHandler(__XErrorHandler__); |
|
5809 |
} |
|
5810 |
||
5811 |
END_INTERRUPTSBLOCKED |
|
5812 |
%}. |
|
5813 |
displayId isNil ifTrue:[ |
|
5814 |
'XWORKSTATION: cannot connect to Display.' errorPrintNL. |
|
5815 |
^ nil |
|
5816 |
]. |
|
5817 |
||
5818 |
dispatching := false. |
|
5819 |
dispatchingExpose := false. |
|
5820 |
isSlow := false. |
|
5821 |
shiftDown := false. |
|
5822 |
ctrlDown := false. |
|
5823 |
metaDown := false. |
|
5824 |
altDown := false. |
|
5825 |
motionEventCompression := true. |
|
5826 |
buttonsPressed := 0. |
|
5827 |
displayName := dpyName. |
|
5828 |
||
5829 |
protocolsAtom := nil. |
|
5830 |
deleteWindowAtom := nil. |
|
5831 |
saveYourselfAtom := nil. |
|
5832 |
quitAppAtom := nil. |
|
5833 |
||
5834 |
self initializeScreenProperties. |
|
5835 |
||
5836 |
self initializeDefaultValues. |
|
5837 |
self initializeEventBuffer. |
|
5838 |
self initializeSpecialFlags. |
|
5839 |
self initializeKeyboardMap. |
|
5840 |
||
5841 |
ObjectMemory registerErrorInterruptHandler:self class forID:#DisplayError. |
|
5842 |
! |
|
5843 |
||
5844 |
initializeModifierMappings |
|
5845 |
|map mod| |
|
5846 |
||
5847 |
"/ altModifiers := #(Alt_L Alt_R). |
|
5848 |
"/ metaModifiers := #(Meta_L Meta_R). |
|
5849 |
"/ ctrlModifiers := #(Control_L Control_R). |
|
5850 |
"/ shiftModifiers := #(Shift_L Shift_R). |
|
5851 |
||
5852 |
shiftModifiers := ctrlModifiers := altModifiers := metaModifiers := nil. |
|
5853 |
altModifierMask := metaModifierMask := nil. |
|
5854 |
||
5855 |
map := self modifierMapping. |
|
342 | 5856 |
map isNil ifTrue:[ |
5857 |
"/ |
|
5858 |
"/ mhmh - a crippled Xlib which does not provide modifier mappings |
|
5859 |
"/ setup some reasonable default. If that is not sufficient, |
|
5860 |
"/ you have to change things from your display.rc file. |
|
5861 |
"/ |
|
5862 |
altModifierMask := self modifier1Mask. |
|
5863 |
metaModifierMask := self modifier2Mask. |
|
5864 |
||
5865 |
shiftModifiers := #(Shift_L Shift_R Shift). |
|
5866 |
ctrlModifiers := #(Control_L Control_R Control). |
|
5867 |
metaModifiers := #(Alt_L Meta_L Meta_R Meta). |
|
5868 |
altModifiers := #(Alt_R Alt). |
|
5869 |
] ifFalse:[ |
|
5870 |
altModifierMask := 0. |
|
374 | 5871 |
metaModifierMask := 0. |
5872 |
||
5873 |
mod := map at:1. |
|
5874 |
mod notNil ifTrue:[ |
|
342 | 5875 |
shiftModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
374 | 5876 |
]. |
5877 |
mod := map at:3. |
|
5878 |
mod notNil ifTrue:[ |
|
342 | 5879 |
ctrlModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
374 | 5880 |
]. |
5881 |
mod := map at:4. |
|
5882 |
mod notNil ifTrue:[ |
|
342 | 5883 |
metaModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
5884 |
metaModifierMask := 1 bitShift:(4-1). |
|
374 | 5885 |
]. |
5886 |
mod := map at:5. |
|
5887 |
mod notNil ifTrue:[ |
|
342 | 5888 |
altModifiers := mod collect:[ :key | self stringFromKeycode:key ]. |
5889 |
altModifierMask := 1 bitShift:(5-1). |
|
5890 |
] |
|
295 | 5891 |
]. |
5892 |
||
5893 |
"Modified: 1.12.1995 / 23:44:40 / stefan" |
|
5894 |
! |
|
5895 |
||
5896 |
initializeScreenProperties |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5897 |
super initializeScreenProperties. |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5898 |
|
295 | 5899 |
%{ /* NOCONTEXT */ |
5900 |
||
5901 |
Display *dpy = myDpy; |
|
5902 |
int scr; |
|
5903 |
Visual *visual; |
|
5904 |
XVisualInfo viproto; |
|
5905 |
XVisualInfo *vip; /* retured info */ |
|
5906 |
int maxRGBDepth; |
|
5907 |
int rgbRedMask, rgbGreenMask, rgbBlueMask; |
|
5908 |
int rgbVisualID; |
|
5909 |
int nvi, i; |
|
5910 |
int shapeEventBase, shapeErrorBase; |
|
5911 |
int shmEventBase, shmErrorBase; |
|
5912 |
int faxEventBase, faxErrorBase; |
|
5913 |
char *type, *nm; |
|
5914 |
int dummy; |
|
5915 |
int mask, shift, nBits; |
|
5916 |
||
5917 |
if (ISCONNECTED) { |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5918 |
__INST(altModifierMask) = __MKSMALLINT(Mod2Mask); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5919 |
__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5920 |
|
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5921 |
BEGIN_INTERRUPTSBLOCKED |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5922 |
|
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5923 |
__INST(screen) = __MKSMALLINT(scr = DefaultScreen(dpy)); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5924 |
__INST(depth) = __MKSMALLINT(DisplayPlanes(dpy, scr)); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5925 |
__INST(ncells) = __MKSMALLINT(DisplayCells(dpy, scr)); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5926 |
__INST(width) = __MKSMALLINT(DisplayWidth(dpy, scr)); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5927 |
__INST(height) = __MKSMALLINT(DisplayHeight(dpy, scr)); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5928 |
__INST(widthMM) = __MKSMALLINT(DisplayWidthMM(dpy, scr)); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5929 |
__INST(heightMM) = __MKSMALLINT(DisplayHeightMM(dpy, scr)); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5930 |
__INST(blackpixel) = __MKSMALLINT(BlackPixel(dpy, scr)); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5931 |
__INST(whitepixel) = __MKSMALLINT(WhitePixel(dpy, scr)); |
295 | 5932 |
|
5933 |
#ifdef SHAPE |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5934 |
if (XShapeQueryExtension(dpy, &shapeEventBase, &shapeErrorBase)) |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5935 |
__INST(hasShapeExtension) = true; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5936 |
else |
295 | 5937 |
#endif |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5938 |
__INST(hasShapeExtension) = false; |
295 | 5939 |
|
5940 |
#ifdef SHM |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5941 |
if (XShmQueryExtension(dpy, &shmEventBase, &shmErrorBase)) |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5942 |
__INST(hasShmExtension) = true; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5943 |
else |
295 | 5944 |
#endif |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5945 |
__INST(hasShmExtension) = false; |
295 | 5946 |
|
5947 |
#ifdef FAX |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5948 |
if (XFAXImageQueryExtension(dpy, &faxEventBase, &faxErrorBase)) |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5949 |
__INST(hasFaxExtension) = true; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5950 |
else |
295 | 5951 |
#endif |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5952 |
__INST(hasFaxExtension) = false; |
295 | 5953 |
|
5954 |
#ifdef DPS |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5955 |
if (XQueryExtension(dpy, "DPSExtension", &dummy, &dummy, &dummy)) |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5956 |
__INST(hasDPSExtension) = true; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5957 |
else |
295 | 5958 |
#endif |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5959 |
__INST(hasDPSExtension) = false; |
295 | 5960 |
|
5961 |
#ifdef XVIDEO |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5962 |
if (XQueryExtension(dpy, "XVideo", &dummy, &dummy, &dummy)) |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5963 |
__INST(hasXVideoExtension) = true; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5964 |
else |
295 | 5965 |
#endif |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5966 |
__INST(hasXVideoExtension) = false; |
295 | 5967 |
|
5968 |
#ifdef MBUF |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5969 |
if (XQueryExtension(dpy, "Multi-Buffering", &dummy, &dummy, &dummy)) |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5970 |
__INST(hasMbufExtension) = true; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5971 |
else |
295 | 5972 |
#endif |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5973 |
__INST(hasMbufExtension) = false; |
295 | 5974 |
|
5975 |
#ifdef PEX5 |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5976 |
if (XQueryExtension(dpy, PEX_NAME_STRING, &dummy, &dummy, &dummy)) |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5977 |
__INST(hasPEXExtension) = true; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5978 |
else |
295 | 5979 |
#endif |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5980 |
__INST(hasPEXExtension) = false; |
295 | 5981 |
|
5982 |
#ifdef XIE |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5983 |
if (XQueryExtension(dpy, xieExtName, &dummy, &dummy, &dummy)) |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5984 |
__INST(hasImageExtension) = true; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5985 |
else |
295 | 5986 |
#endif |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5987 |
__INST(hasImageExtension) = false; |
295 | 5988 |
|
5989 |
#ifdef XI |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5990 |
if (XQueryExtension(dpy, "XInputExtension", &dummy, &dummy, &dummy)) |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5991 |
__INST(hasInputExtension) = true; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5992 |
else |
295 | 5993 |
#endif |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5994 |
__INST(hasInputExtension) = false; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5995 |
|
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5996 |
/* |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5997 |
* look for RGB visual |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5998 |
*/ |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
5999 |
nvi = 0; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6000 |
viproto.screen = scr; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6001 |
vip = XGetVisualInfo (dpy, VisualScreenMask, &viproto, &nvi); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6002 |
maxRGBDepth = 0; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6003 |
for (i = 0; i < nvi; i++) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6004 |
switch (vip[i].class) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6005 |
case TrueColor: |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6006 |
if (vip[i].depth > maxRGBDepth) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6007 |
maxRGBDepth = vip[i].depth; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6008 |
rgbRedMask = vip[i].red_mask; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6009 |
rgbGreenMask = vip[i].green_mask; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6010 |
rgbBlueMask = vip[i].blue_mask; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6011 |
rgbVisualID = vip[i].visualid; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6012 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6013 |
break; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6014 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6015 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6016 |
if (vip) XFree ((char *) vip); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6017 |
|
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6018 |
if (maxRGBDepth) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6019 |
__INST(rgbVisual) = __MKOBJ(rgbVisualID); __STORESELF(rgbVisual); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6020 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6021 |
|
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6022 |
visual = DefaultVisualOfScreen(DefaultScreenOfDisplay(dpy)); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6023 |
__INST(monitorType) = @symbol(unknown); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6024 |
__INST(hasColors) = true; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6025 |
__INST(hasGreyscales) = true; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6026 |
switch (visual->class) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6027 |
case StaticGray: |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6028 |
__INST(visualType) = @symbol(StaticGray); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6029 |
__INST(hasColors) = false; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6030 |
__INST(monitorType) = @symbol(monochrome); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6031 |
break; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6032 |
case GrayScale: |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6033 |
__INST(visualType) = @symbol(GrayScale); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6034 |
__INST(hasColors) = false; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6035 |
__INST(monitorType) = @symbol(monochrome); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6036 |
break; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6037 |
case StaticColor: |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6038 |
__INST(visualType) = @symbol(StaticColor); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6039 |
break; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6040 |
case PseudoColor: |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6041 |
__INST(visualType) = @symbol(PseudoColor); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6042 |
break; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6043 |
case TrueColor: |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6044 |
__INST(visualType) = @symbol(TrueColor); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6045 |
break; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6046 |
case DirectColor: |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6047 |
__INST(visualType) = @symbol(DirectColor); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6048 |
break; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6049 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6050 |
if (DisplayCells(dpy, scr) == 2) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6051 |
__INST(hasColors) = false; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6052 |
__INST(hasGreyscales) = false; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6053 |
__INST(monitorType) = @symbol(monochrome); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6054 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6055 |
__INST(bitsPerRGB) = __MKSMALLINT(visual->bits_per_rgb); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6056 |
__INST(redMask) = __MKSMALLINT(visual->red_mask); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6057 |
__INST(greenMask) = __MKSMALLINT(visual->green_mask); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6058 |
__INST(blueMask) = __MKSMALLINT(visual->blue_mask); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6059 |
switch (visual->class) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6060 |
case TrueColor: |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6061 |
/* extract number of bits and shift counts */ |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6062 |
mask = visual->red_mask; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6063 |
shift = 0; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6064 |
while (mask && ((mask & 1) == 0)) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6065 |
mask >>= 1; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6066 |
shift++; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6067 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6068 |
__INST(redShift) = __MKSMALLINT(shift); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6069 |
nBits = 0; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6070 |
while (mask) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6071 |
mask >>= 1; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6072 |
nBits++; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6073 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6074 |
__INST(bitsRed) = __MKSMALLINT(nBits); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6075 |
|
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6076 |
mask = visual->green_mask; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6077 |
shift = 0; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6078 |
while (mask && ((mask & 1) == 0)) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6079 |
mask >>= 1; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6080 |
shift++; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6081 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6082 |
__INST(greenShift) = __MKSMALLINT(shift); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6083 |
nBits = 0; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6084 |
while (mask) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6085 |
mask >>= 1; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6086 |
nBits++; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6087 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6088 |
__INST(bitsGreen) = __MKSMALLINT(nBits); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6089 |
|
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6090 |
mask = visual->blue_mask; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6091 |
shift = 0; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6092 |
while (mask && ((mask & 1) == 0)) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6093 |
mask >>= 1; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6094 |
shift++; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6095 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6096 |
__INST(blueShift) = __MKSMALLINT(shift); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6097 |
nBits = 0; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6098 |
while (mask) { |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6099 |
mask >>= 1; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6100 |
nBits++; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6101 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6102 |
__INST(bitsBlue) = __MKSMALLINT(nBits); |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6103 |
break; |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6104 |
} |
295 | 6105 |
|
6106 |
#ifndef XA_PRIMARY |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6107 |
__INST(primaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "PRIMARY", True) ); |
295 | 6108 |
#else |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6109 |
__INST(primaryAtom) = __MKATOMOBJ( XA_PRIMARY ); |
295 | 6110 |
#endif |
6111 |
#ifndef XA_SECONDARY |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6112 |
__INST(secondaryAtom) = __MKATOMOBJ( XInternAtom(dpy, "SECONDARY", True) ); |
295 | 6113 |
#else |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6114 |
__INST(secondaryAtom) = __MKATOMOBJ( XA_SECONDARY ); |
295 | 6115 |
#endif |
6116 |
#ifndef XA_CUT_BUFFER0 |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6117 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XInternAtom(dpy, "CUT_BUFFER0", True) ); |
295 | 6118 |
#else |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6119 |
__INST(cutBuffer0Atom) = __MKATOMOBJ( XA_CUT_BUFFER0 ); |
295 | 6120 |
#endif |
6121 |
#ifndef XA_STRING |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6122 |
__INST(stringAtom) = __MKATOMOBJ( XInternAtom(dpy, "STRING", True) ); |
295 | 6123 |
#else |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6124 |
__INST(stringAtom) = __MKATOMOBJ( XA_STRING ); |
295 | 6125 |
#endif |
6126 |
#ifndef XA_LENGTH |
|
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6127 |
__INST(lengthAtom) = __MKATOMOBJ( XInternAtom(dpy, "LENGTH", True) ); |
295 | 6128 |
#else |
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6129 |
__INST(lengthAtom) = __MKATOMOBJ( XA_LENGTH ); |
295 | 6130 |
#endif |
6131 |
||
815
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6132 |
END_INTERRUPTSBLOCKED |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6133 |
} |
1e659479b292
call super in initScreenProps
Claus Gittinger <cg@exept.de>
parents:
811
diff
changeset
|
6134 |
%}. |
295 | 6135 |
! |
6136 |
||
6137 |
initializeSpecialFlags |
|
6138 |
"perform additional special server implementation flags" |
|
6139 |
||
6140 |
"/ |
|
6141 |
"/ assume we have it ... (should check) |
|
6142 |
"/ |
|
6143 |
hasSaveUnder := true. |
|
6144 |
ignoreBackingStore := false. |
|
6145 |
||
6146 |
(self serverVendor = 'X11/NeWS') ifTrue:[ |
|
6147 |
"/ |
|
6148 |
"/ this is a kludge around a bug in the X11/NeWS server, |
|
6149 |
"/ which does not correctly handle saveUnder |
|
6150 |
"/ |
|
6151 |
hasSaveUnder := false. |
|
6152 |
]. |
|
6153 |
! |
|
6154 |
||
6155 |
reinitialize |
|
6156 |
virtualRootId := rootId := nil. |
|
6157 |
super reinitialize. |
|
6158 |
dispatchingExpose := nil |
|
6159 |
! ! |
|
6160 |
||
6161 |
!XWorkstation methodsFor:'keyboard mapping'! |
|
6162 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6163 |
altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6164 |
"return the mask (in motionEvents) for the alt-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6165 |
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
|
6166 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6167 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6168 |
^ altModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6169 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6170 |
"Created: 23.3.1996 / 12:43:22 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6171 |
"Modified: 23.3.1996 / 12:44:56 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6172 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6173 |
|
341 | 6174 |
altModifierMask:aSmallInteger |
6175 |
"define which key takes the role of an alt-key. |
|
6176 |
By default, this is X's modifier1, which is the ALT key on |
|
6177 |
most keyboards. However, there may be exceptions to this, |
|
6178 |
and the setting can be changed with: |
|
6179 |
Display altModifierMask:(Display modifier2Mask) |
|
6180 |
Setting the mask to 0 disables the ALT key (in ST/X) altogether. |
|
6181 |
" |
|
6182 |
||
6183 |
altModifierMask := aSmallInteger |
|
6184 |
! |
|
6185 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6186 |
metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6187 |
"return the mask (in motionEvents) for the meta-key modifier. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6188 |
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
|
6189 |
therefore return a variable here, which can be changed during startup." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6190 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6191 |
^ metaModifierMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6192 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6193 |
"Created: 23.3.1996 / 12:43:39 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6194 |
"Modified: 23.3.1996 / 12:45:09 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6195 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6196 |
|
341 | 6197 |
metaModifierMask:aSmallInteger |
6198 |
"define which key takes the role of a meta key. |
|
6199 |
By default, this is X's modifier2, which is the 2nd ALT key on |
|
6200 |
most keyboards (if present at all). |
|
6201 |
However, there may be exceptions to this, and the setting can |
|
6202 |
be changed with: |
|
6203 |
Display metaModifierMask:(Display modifier1Mask) |
|
6204 |
Setting the mask to 0 disables the META key (in ST/X) altogether. |
|
6205 |
As reported, some Xservers place the Meta-key onto NumLock, |
|
6206 |
and having NumLock enabled makes ST/X think, that meta is pressed |
|
6207 |
all the time. On those, you should disable the meta key by setting |
|
6208 |
the mask to 0. |
|
6209 |
" |
|
6210 |
||
6211 |
metaModifierMask := aSmallInteger |
|
6212 |
! |
|
6213 |
||
6214 |
modifier1Mask |
|
6215 |
"return the Xlib mask bit for the 1st modifier key. |
|
6216 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6217 |
this could be used." |
|
6218 |
||
6219 |
%{ /* NOCONTEXT */ |
|
6220 |
RETURN (__MKSMALLINT(Mod1Mask)); |
|
6221 |
%} |
|
6222 |
! |
|
6223 |
||
6224 |
modifier2Mask |
|
6225 |
"return the Xlib mask bit for the 2nd modifier key. |
|
6226 |
See comment in altModifierMask: / metaModifierMask: for what |
|
6227 |
this could be used." |
|
6228 |
||
6229 |
%{ /* NOCONTEXT */ |
|
6230 |
RETURN (__MKSMALLINT(Mod2Mask)); |
|
6231 |
%} |
|
6232 |
! |
|
6233 |
||
6234 |
modifierMapping |
|
6235 |
"Get the Modifier Mapping. |
|
6236 |
We return an array of arrays of keycodes" |
|
6237 |
||
6238 |
|modifierKeyMap maxKeyPerMod ret nextKey| |
|
6239 |
||
6240 |
%{ |
|
6241 |
Display *dpy = myDpy; |
|
6242 |
XModifierKeymap *modmap; |
|
6243 |
OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT(); |
|
6244 |
||
6245 |
if (ISCONNECTED) { |
|
6246 |
if ((modmap = XGetModifierMapping(myDpy)) != 0) { |
|
6247 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6248 |
modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8); |
|
6249 |
if (modifierKeyMap != nil) { |
|
6250 |
maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod); |
|
6251 |
memcpy((char *)__ByteArrayInstPtr(modifierKeyMap)->ba_element, |
|
6252 |
(char *)modmap->modifiermap, modmap->max_keypermod * 8); |
|
6253 |
} |
|
6254 |
XFreeModifiermap(modmap); |
|
6255 |
} |
|
6256 |
} |
|
6257 |
%}. |
|
6258 |
||
6259 |
modifierKeyMap isNil ifTrue:[^ nil]. |
|
6260 |
||
6261 |
ret := Array new:8. |
|
6262 |
nextKey := 1. |
|
6263 |
1 to:8 do:[ :i | |
|
6264 |
(modifierKeyMap at:nextKey) ~= 0 ifTrue:[ |
|
6265 |
|mod| |
|
6266 |
||
6267 |
mod := OrderedCollection new:maxKeyPerMod. |
|
6268 |
modifierKeyMap from:nextKey to:(nextKey+maxKeyPerMod-1) do:[ :key | |
|
6269 |
key ~= 0 ifTrue:[ |
|
6270 |
mod add:key |
|
6271 |
]. |
|
6272 |
]. |
|
6273 |
ret at:i put:mod. |
|
6274 |
]. |
|
6275 |
nextKey := nextKey+maxKeyPerMod. |
|
6276 |
]. |
|
6277 |
||
6278 |
^ ret |
|
6279 |
||
6280 |
" |
|
6281 |
Display modifierMapping |
|
6282 |
" |
|
6283 |
! |
|
6284 |
||
6285 |
stringFromKeycode:code |
|
6286 |
"Get a KeySymbol (a smalltalk symbol) from the keycode." |
|
6287 |
||
6288 |
|str| |
|
6289 |
||
6290 |
%{ |
|
6291 |
Display *dpy = myDpy; |
|
6292 |
KeySym keysym; |
|
6293 |
char *keystring; |
|
6294 |
||
6295 |
if (ISCONNECTED && __isSmallInteger(code)) { |
|
6296 |
if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol && |
|
6297 |
(keystring = XKeysymToString(keysym)) != 0) |
|
6298 |
str = __MKSTRING(keystring); |
|
6299 |
} |
|
6300 |
%}. |
|
6301 |
^ str |
|
6302 |
||
6303 |
" |
|
6304 |
Display stringFromKeycode:28 |
|
6305 |
" |
|
6306 |
! |
|
6307 |
||
295 | 6308 |
translateKey:untranslatedKey |
6309 |
"Return the key translated via the translation table. |
|
6310 |
Here, we preTranslate the key into a common ST/X symbolic name, |
|
6311 |
which gets further processed in the superclasses translation method." |
|
6312 |
||
6313 |
|key| |
|
6314 |
||
6315 |
(key := untranslatedKey) isString ifTrue:[ |
|
6316 |
key := RawKeysymTranslation at:key ifAbsent:key. |
|
6317 |
key := key asSymbol. |
|
6318 |
]. |
|
6319 |
^ super translateKey:key |
|
6320 |
! ! |
|
6321 |
||
6322 |
!XWorkstation methodsFor:'misc'! |
|
6323 |
||
6324 |
beep |
|
6325 |
"output an audible beep or bell" |
|
6326 |
||
6327 |
self beep:50 |
|
6328 |
! |
|
6329 |
||
6330 |
beep:volumeInPercent |
|
6331 |
"output an audible beep" |
|
6332 |
%{ |
|
6333 |
int volume; |
|
6334 |
||
6335 |
if (__isSmallInteger(volumeInPercent) && ISCONNECTED) { |
|
6336 |
/* stupid: X wants -100 .. 100 and calls this percent */ |
|
555 | 6337 |
volume = __intVal(volumeInPercent) * 2 - 100; |
295 | 6338 |
if (volume < -100) volume = -100; |
6339 |
else if (volume > 100) volume = 100; |
|
6340 |
BEGIN_INTERRUPTSBLOCKED |
|
6341 |
XBell(myDpy, volume); |
|
6342 |
END_INTERRUPTSBLOCKED |
|
6343 |
} |
|
6344 |
%} |
|
6345 |
! |
|
6346 |
||
6347 |
buffered |
|
6348 |
"buffer drawing - do not send it immediately to the display. |
|
374 | 6349 |
This is the default anyway. |
6350 |
See #unBuffered for additional info." |
|
295 | 6351 |
|
6352 |
%{ /* NOCONTEXT */ |
|
6353 |
||
6354 |
if (ISCONNECTED) { |
|
6355 |
BEGIN_INTERRUPTSBLOCKED |
|
6356 |
XSynchronize(myDpy, 0); |
|
6357 |
END_INTERRUPTSBLOCKED |
|
6358 |
} |
|
6359 |
%} |
|
374 | 6360 |
" |
6361 |
Display buffered |
|
6362 |
" |
|
295 | 6363 |
! |
6364 |
||
6365 |
flush |
|
6366 |
"send all buffered drawing to the display. |
|
6367 |
This may be required to make certain, that all previous operations |
|
6368 |
are really sent to the display before continuing. For example, |
|
6369 |
after a cursor-change with a followup long computation. |
|
374 | 6370 |
(otherwise, the cursor change request may still be in the output buffer) |
6371 |
See also #sync, which even waits until the request has been processed." |
|
295 | 6372 |
|
6373 |
%{ /* NOCONTEXT */ |
|
6374 |
||
6375 |
if (ISCONNECTED) { |
|
6376 |
BEGIN_INTERRUPTSBLOCKED |
|
310 | 6377 |
XFlush(myDpy); |
6378 |
END_INTERRUPTSBLOCKED |
|
6379 |
} |
|
6380 |
%} |
|
6381 |
! |
|
6382 |
||
295 | 6383 |
flushDpsContext:aDPSContext |
6384 |
||
6385 |
%{ /* NOCONTEXT */ |
|
6386 |
#ifdef DPS |
|
6387 |
if (__isExternalAddress(aDPSContext)) { |
|
6388 |
BEGIN_INTERRUPTSBLOCKED |
|
6389 |
DPSFlushContext(MKDPSCONTEXT(aDPSContext)); |
|
6390 |
END_INTERRUPTSBLOCKED |
|
6391 |
RETURN ( self ); |
|
6392 |
} |
|
6393 |
#endif |
|
374 | 6394 |
%}. |
295 | 6395 |
self primitiveFailed |
6396 |
! |
|
6397 |
||
6398 |
refreshKeyboardMapping:eB |
|
6399 |
%{ |
|
6400 |
XMappingEvent *ev; |
|
6401 |
||
6402 |
if (__isByteArray(eB)) { |
|
555 | 6403 |
ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element); |
295 | 6404 |
XRefreshKeyboardMapping(ev); |
6405 |
} |
|
6406 |
%} |
|
6407 |
! |
|
6408 |
||
6409 |
setInputFocusTo:aWindowId |
|
6410 |
"/ self setInputFocusTo:aWindowId revertTo:#parent |
|
6411 |
self setInputFocusTo:aWindowId revertTo:#root |
|
6412 |
! |
|
6413 |
||
6414 |
setInputFocusTo:aWindowId revertTo:revertSymbol |
|
6415 |
"set the focus to the view as defined by aWindowId. |
|
6416 |
Passing nil set the focus to no window and lets the display discard all |
|
6417 |
input until a new focus is set. |
|
6418 |
RevertSymbol specifies what should happen if the view becomes invisible; |
|
6419 |
passing one of #parent, #root or nil specifies that the focus should be |
|
6420 |
given to the parent view, the root view or no view." |
|
6421 |
||
6422 |
%{ /* NOCONTEXT */ |
|
6423 |
int arg; |
|
6424 |
Window focusWindow; |
|
6425 |
||
6426 |
if (ISCONNECTED) { |
|
6427 |
if (__isExternalAddress(aWindowId)) { |
|
6428 |
focusWindow = _WindowVal(aWindowId); |
|
6429 |
} else { |
|
6430 |
focusWindow = None; |
|
6431 |
} |
|
6432 |
if (revertSymbol == @symbol(parent)) |
|
6433 |
arg = RevertToParent; |
|
6434 |
else if (revertSymbol == @symbol(root)) |
|
6435 |
arg = RevertToPointerRoot; |
|
6436 |
else |
|
6437 |
arg = RevertToNone; |
|
6438 |
||
6439 |
BEGIN_INTERRUPTSBLOCKED |
|
6440 |
XSetInputFocus(myDpy, focusWindow, arg, CurrentTime); |
|
6441 |
END_INTERRUPTSBLOCKED |
|
6442 |
RETURN ( self ); |
|
6443 |
} |
|
6444 |
%}. |
|
6445 |
self primitiveFailed |
|
6446 |
! |
|
6447 |
||
341 | 6448 |
sync |
6449 |
"send all buffered drawing to the display AND wait until the display |
|
6450 |
has finished drawing it. |
|
6451 |
This is almost never needed, except if you are about to read previously |
|
374 | 6452 |
drawn pixels back from the display screen, or you want to wait for a beep |
6453 |
to be finished. See also #flush." |
|
341 | 6454 |
|
6455 |
%{ /* NOCONTEXT */ |
|
6456 |
||
6457 |
if (ISCONNECTED) { |
|
6458 |
BEGIN_INTERRUPTSBLOCKED |
|
6459 |
XSync(myDpy, 0); |
|
6460 |
END_INTERRUPTSBLOCKED |
|
6461 |
} |
|
6462 |
%} |
|
6463 |
! |
|
6464 |
||
295 | 6465 |
unBuffered |
374 | 6466 |
"make all drawing be sent immediately to the display. |
6467 |
This makes all graphics synchronous and turns off any buffering |
|
6468 |
(i.e. each individual draw-request is sent immediately without |
|
6469 |
packing multiple requests into a larger message buffer). |
|
6470 |
Be prepared, that this slows down graphics considerably. |
|
6471 |
However, it allows display errors to be handled immediately and |
|
6472 |
may be useful if you get Xdisplay errors and want to find the request |
|
6473 |
which was responsiblefor it. See also #buffered." |
|
295 | 6474 |
|
6475 |
%{ /* NOCONTEXT */ |
|
6476 |
||
6477 |
if (ISCONNECTED) { |
|
6478 |
BEGIN_INTERRUPTSBLOCKED |
|
6479 |
XSynchronize(myDpy, 1); |
|
6480 |
END_INTERRUPTSBLOCKED |
|
6481 |
} |
|
6482 |
%} |
|
6483 |
"Display unbuffered" |
|
6484 |
! ! |
|
6485 |
||
6486 |
!XWorkstation methodsFor:'pointer queries '! |
|
6487 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6488 |
anyButtonStateMask |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6489 |
"return an integer for masking out any button from a |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6490 |
buttonStates value." |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6491 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6492 |
"/ should use ``Display buttonXMotionMask bitOr:....'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6493 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6494 |
^ 256 + 512 + 1024 |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6495 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6496 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6497 |
"Created: 23.3.1996 / 12:46:35 / cg" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6498 |
! |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6499 |
|
295 | 6500 |
buttonStates |
6501 |
"return an integer representing the state of the pointer buttons; |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6502 |
a one-bit in positions 0.. represent a pressed button. |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6503 |
See the button1Mask/button2Mask/button3Mask, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6504 |
shiftMask/controlMask and modifierMask methods for the meaning of the bits." |
295 | 6505 |
|
6506 |
%{ /* NOCONTEXT*/ |
|
6507 |
Display *dpy = myDpy; |
|
6508 |
Window w; |
|
555 | 6509 |
int screen = __intVal(__INST(screen)); |
295 | 6510 |
Window rootRet, childRet; |
6511 |
int rootX, rootY, winX, winY; |
|
6512 |
unsigned int mask; |
|
6513 |
||
6514 |
BEGIN_INTERRUPTSBLOCKED |
|
6515 |
#ifdef VIRTUAL_ROOT |
|
6516 |
w = getRootWindow(myDpy, screen); |
|
6517 |
#else |
|
6518 |
w = RootWindow(dpy, screen); |
|
6519 |
#endif |
|
6520 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
|
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6521 |
&rootX, &rootY, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6522 |
&winX, &winY, |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6523 |
&mask); |
295 | 6524 |
END_INTERRUPTSBLOCKED |
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6525 |
RETURN (__MKSMALLINT(mask)); |
295 | 6526 |
%} |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6527 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6528 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6529 |
Display buttonStates |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6530 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6531 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6532 |
"is the control-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6533 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6534 |
Display buttonStates bitTest:(Display controlMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6535 |
" |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6536 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6537 |
"is the alt/meta-key pressed ? |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6538 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6539 |
Display buttonStates bitTest:(Display altModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6540 |
Display buttonStates bitTest:(Display metaModifierMask) |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6541 |
" |
295 | 6542 |
! |
6543 |
||
6544 |
leftButtonStateMask |
|
6545 |
"return an integer for masking out the left button from a |
|
6546 |
buttonStates value" |
|
6547 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6548 |
"/ should use ``Display button1MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6549 |
|
295 | 6550 |
^ 256 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6551 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6552 |
"Modified: 23.3.1996 / 12:41:33 / cg" |
295 | 6553 |
! |
6554 |
||
6555 |
middleButtonStateMask |
|
6556 |
"return an integer for masking out the middle button from a |
|
6557 |
buttonStates value" |
|
6558 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6559 |
"/ should use ``Display button2MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6560 |
|
295 | 6561 |
^ 512 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6562 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6563 |
"Modified: 23.3.1996 / 12:41:43 / cg" |
295 | 6564 |
! |
6565 |
||
6566 |
pointerPosition |
|
6567 |
"return the current pointer position in root-window coordinates" |
|
6568 |
||
6569 |
|xpos ypos| |
|
6570 |
||
6571 |
%{ |
|
6572 |
Display *dpy = myDpy; |
|
6573 |
Window w; |
|
555 | 6574 |
int screen = __intVal(__INST(screen)); |
295 | 6575 |
Window rootRet, childRet; |
6576 |
int rootX, rootY, winX, winY; |
|
6577 |
unsigned int mask; |
|
6578 |
||
6579 |
BEGIN_INTERRUPTSBLOCKED |
|
6580 |
#ifdef VIRTUAL_ROOT |
|
6581 |
w = getRootWindow(myDpy, screen); |
|
6582 |
#else |
|
6583 |
w = RootWindow(dpy, screen); |
|
6584 |
#endif |
|
6585 |
XQueryPointer(dpy, w, &rootRet, &childRet, |
|
6586 |
&rootX, &rootY, |
|
6587 |
&winX, &winY, |
|
6588 |
&mask); |
|
315
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6589 |
xpos = __MKSMALLINT(rootX); |
2abc494f0c45
_-macros replaced by __-macros
Claus Gittinger <cg@exept.de>
parents:
310
diff
changeset
|
6590 |
ypos = __MKSMALLINT(rootY); |
295 | 6591 |
END_INTERRUPTSBLOCKED |
6592 |
%} |
|
6593 |
. |
|
6594 |
^ xpos @ ypos |
|
6595 |
! |
|
6596 |
||
6597 |
rightButtonStateMask |
|
6598 |
"return an integer for masking out the right button from a |
|
6599 |
buttonStates value" |
|
6600 |
||
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6601 |
"/ should use ``Display button3MotionMask'' |
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6602 |
|
295 | 6603 |
^ 1024 |
540
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6604 |
|
c954c490c8be
stateMask methods & commentary
Claus Gittinger <cg@exept.de>
parents:
487
diff
changeset
|
6605 |
"Modified: 23.3.1996 / 12:41:52 / cg" |
295 | 6606 |
! |
6607 |
||
6608 |
rootPositionOfLastEvent |
|
6609 |
"return the position in root-window coordinates |
|
6610 |
of the last button, key or pointer event" |
|
6611 |
||
6612 |
^ eventRootX @ eventRootY |
|
6613 |
! ! |
|
6614 |
||
6615 |
!XWorkstation methodsFor:'resources'! |
|
6616 |
||
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6617 |
atomIDOf:aStringOrSymbol |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6618 |
"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
|
6619 |
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
|
6620 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6621 |
^ self atomIDOf:aStringOrSymbol create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6622 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6623 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6624 |
Display atomIDOf:'FACE_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6625 |
Display atomIDOf:'FULL_NAME' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6626 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6627 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6628 |
"Modified: 2.3.1996 / 15:09:29 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6629 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6630 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6631 |
atomIDOf:aStringOrSymbol create:create |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6632 |
"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
|
6633 |
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
|
6634 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6635 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6636 |
Atom prop; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6637 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6638 |
if (ISCONNECTED) { |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6639 |
if (__isString(aStringOrSymbol) |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6640 |
|| __isSymbol(aStringOrSymbol)) { |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6641 |
prop = XInternAtom(myDpy, _stringVal(aStringOrSymbol), |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6642 |
(create == true) ? False : True); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6643 |
if (prop == None) { |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6644 |
RETURN (nil); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6645 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6646 |
RETURN ( __MKATOMOBJ(prop) ); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6647 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6648 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6649 |
%}. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6650 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6651 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6652 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6653 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6654 |
Display atomIDOf:'VT_SELECTION' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6655 |
Display atomIDOf:'CUT_BUFFER0' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6656 |
Display atomIDOf:'STRING' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6657 |
Display atomIDOf:'PRIMARY' create:false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6658 |
Display atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6659 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6660 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6661 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6662 |
atomIDOfCUTBUFFER0 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6663 |
"return the CUTBUFFER0 AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6664 |
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
|
6665 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6666 |
^ cutBuffer0Atom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6667 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6668 |
"Modified: 2.3.1996 / 15:10:36 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6669 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6670 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6671 |
atomIDOfLENGTH |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6672 |
"return the LENGTH AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6673 |
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
|
6674 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6675 |
^ lengthAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6676 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6677 |
"Modified: 2.3.1996 / 15:10:41 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6678 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6679 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6680 |
atomIDOfPRIMARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6681 |
"return the PRIMARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6682 |
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
|
6683 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6684 |
^ primaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6685 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6686 |
"Modified: 2.3.1996 / 15:10:49 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6687 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6688 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6689 |
atomIDOfSECONDARY |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6690 |
"return the SECONDARY AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6691 |
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
|
6692 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6693 |
^ secondaryAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6694 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6695 |
"Modified: 2.3.1996 / 15:10:59 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6696 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6697 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6698 |
atomIDOfSTRING |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6699 |
"return the STRING AtomID. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6700 |
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
|
6701 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6702 |
^ stringAtom |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6703 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6704 |
"Modified: 2.3.1996 / 15:11:08 / cg" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6705 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6706 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6707 |
atomName:anAtomID |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6708 |
"given an AtomID, return its name. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6709 |
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
|
6710 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6711 |
%{ /* NOCONTEXT */ |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6712 |
OBJ str; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6713 |
char *name; |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6714 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6715 |
if (ISCONNECTED) { |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6716 |
if (__isAtomID(anAtomID)) { |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6717 |
name = XGetAtomName(myDpy, _AtomVal(anAtomID)); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6718 |
if (name == 0) { |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6719 |
RETURN (nil); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6720 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6721 |
str = __MKSTRING(name COMMA_CON); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6722 |
XFree(name); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6723 |
RETURN ( str ); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6724 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6725 |
} |
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 |
self primitiveFailed. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6728 |
^ nil |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6729 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6730 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6731 |
Display atomName:1 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6732 |
Display atomName:130 '_DEC_DEVICE_FONTNAMES' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6733 |
Display atomName:132 'FONTNAME_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6734 |
Display atomName:135 'FOUNDRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6735 |
Display atomName:150 'CHARSET_REGISTRY' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6736 |
Display atomName:151 'ISO8859' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6737 |
Display atomName:152 'CHARSET_ENCODING' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6738 |
Display atomName:154 |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6739 |
" |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6740 |
! |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6741 |
|
295 | 6742 |
getResource:name class:cls |
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6743 |
"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
|
6744 |
of name in a resource class. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6745 |
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
|
6746 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6747 |
Notice: |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6748 |
we do not plan to use X's resources for ST/X's defaults, |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6749 |
styles or resources. This would make porting of applications |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6750 |
to different platforms much more difficult (Windows has no resource |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6751 |
database). If you stay within ST/X's resource files, these can be |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6752 |
easily transported to other platforms. |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6753 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6754 |
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
|
6755 |
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
|
6756 |
platforms." |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6757 |
|
295 | 6758 |
%{ |
6759 |
char *rslt; |
|
6760 |
||
6761 |
if ((__isString(name) || __isSymbol(name)) |
|
6762 |
&& (__isString(cls) || __isSymbol(cls)) |
|
6763 |
&& ISCONNECTED) { |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6764 |
BEGIN_INTERRUPTSBLOCKED |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6765 |
rslt = XGetDefault(myDpy, (char *)_stringVal(cls), |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6766 |
(char *)_stringVal(name)); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6767 |
END_INTERRUPTSBLOCKED |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6768 |
RETURN (rslt ? __MKSTRING(rslt COMMA_CON) : nil ); |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6769 |
} |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6770 |
%}. |
295 | 6771 |
self primitiveFailed. |
6772 |
^ nil |
|
487
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6773 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6774 |
"if your ~/.Xdefaults contains an entry such as: |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6775 |
OpenWindows.Beep: notices |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6776 |
the following returns 'notices'. |
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 |
Display getResource:'Beep' class:'OpenWindows' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6779 |
|
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6780 |
if your ~/.Xdefaults contains an entry such as: |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6781 |
*.beNiceToColormap: false |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6782 |
the following return 'false'. |
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 |
Display getResource:'beNiceToColormap' class:'any' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6785 |
Display getResource:'beNiceToColormap' class:'' |
f6ac7231749e
category changes & comments in atomXXX methods
Claus Gittinger <cg@exept.de>
parents:
486
diff
changeset
|
6786 |
" |
295 | 6787 |
! ! |
6788 |
||
6789 |
!XWorkstation methodsFor:'retrieving pixels'! |
|
6790 |
||
6791 |
getBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits |
|
6792 |
"get bits from a drawable into the imageBits. The storage for the bits |
|
6793 |
must be big enough for the data to fit. If ok, returns an array with some |
|
6794 |
info and the bits in imageBits. The info contains the depth, bitOrder and |
|
6795 |
number of bytes per scanline. The number of bytes per scanline is not known |
|
6796 |
in advance, since the X-server is free to return whatever it thinks is a good padding." |
|
6797 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6798 |
|rawInfo info| |
295 | 6799 |
|
6800 |
((w <= 0) or:[h <= 0]) ifTrue:[ |
|
6801 |
self primitiveFailed. |
|
6802 |
^ nil |
|
6803 |
]. |
|
6804 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6805 |
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
|
6806 |
"1 -> bit order" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6807 |
"2 -> depth" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6808 |
"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
|
6809 |
"4 -> byte_order" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6810 |
"5 -> format" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6811 |
"6 -> bitmap_unit" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6812 |
"7 -> bitmap_pad" |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6813 |
"8 -> bits_per_pixel" |
295 | 6814 |
|
6815 |
"/ had to extract the getPixel call into a separate method, to specify |
|
6816 |
"/ unlimitedStack (some implementations use alloca and require huge amounts |
|
6817 |
"/ of temporary stack space |
|
6818 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6819 |
(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
|
6820 |
info := IdentityDictionary new. |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6821 |
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
|
6822 |
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
|
6823 |
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
|
6824 |
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
|
6825 |
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
|
6826 |
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
|
6827 |
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
|
6828 |
info at:#bitsPerPixel put:(rawInfo at:8). |
295 | 6829 |
^ info |
6830 |
]. |
|
6831 |
" |
|
6832 |
some error occured - either args are not smallintegers, imageBits is not a ByteArray |
|
6833 |
or is too small to hold the bits |
|
6834 |
" |
|
6835 |
^ self primitiveFailed |
|
6836 |
! |
|
6837 |
||
6838 |
getPixelX:x y:y from:aDrawableId |
|
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6839 |
"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
|
6840 |
Nil is returned for invalid coordinates or if any other problem arises." |
295 | 6841 |
|
6842 |
%{ /* UNLIMITEDSTACK NOCONTEXT */ |
|
6843 |
||
303
f2021d90f12d
dont access GC's Windows before checking them for being ExternalBytes instances
Claus Gittinger <cg@exept.de>
parents:
295
diff
changeset
|
6844 |
Window win; |
295 | 6845 |
XImage *img; |
6846 |
int ret; |
|
6847 |
int xpos, ypos; |
|
6848 |
||
6849 |
if (__isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) { |
|
790
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6850 |
win = _WindowVal(aDrawableId); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6851 |
xpos = __intVal(x); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6852 |
ypos = __intVal(y); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6853 |
if ((xpos < 0) || (ypos < 0)) { |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6854 |
RETURN ( __MKSMALLINT(0) ); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6855 |
} |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6856 |
img = XGetImage(myDpy, win, xpos, ypos, 1, 1, (unsigned)~0, ZPixmap); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6857 |
if (img != 0) { |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6858 |
ret = XGetPixel(img, 0, 0); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6859 |
XDestroyImage(img); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6860 |
RETURN ( __MKSMALLINT(ret) ); |
05ea637c94c3
care for null return from XGetImage
Claus Gittinger <cg@exept.de>
parents:
788
diff
changeset
|
6861 |
} |
295 | 6862 |
} |
6863 |
%}. |
|
6864 |
^ nil |
|
6865 |
! |
|
6866 |
||
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6867 |
primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info |
295 | 6868 |
"since XGetImage may allocate huge amount of stack space |
6869 |
(some implementations use alloca), this must run with unlimited stack." |
|
6870 |
||
6871 |
%{ /* UNLIMITEDSTACK */ |
|
6872 |
||
6873 |
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
|
6874 |
Window win; |
295 | 6875 |
XImage *image = (XImage *)0; |
6876 |
int pad, bytes_per_line, numBytes; |
|
6877 |
||
6878 |
if (__isExternalAddress(aDrawableId) |
|
6879 |
&& __bothSmallInteger(srcx, srcy) |
|
6880 |
&& __bothSmallInteger(w, h) |
|
6881 |
&& __isArray(info) |
|
6882 |
&& __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
|
6883 |
win = _WindowVal(aDrawableId); |
555 | 6884 |
image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy), |
6885 |
__intVal(w), __intVal(h), |
|
295 | 6886 |
(unsigned)AllPlanes, ZPixmap); |
6887 |
||
378 | 6888 |
if (! image) { |
6889 |
RETURN ( false ); |
|
6890 |
} |
|
6891 |
||
295 | 6892 |
pad = image->bitmap_pad; |
6893 |
#ifdef SUPERDEBUG |
|
6894 |
printf("pad:%d depth:%d\n", image->bitmap_pad, image->depth); |
|
6895 |
#endif |
|
6896 |
switch (image->depth) { |
|
6897 |
case 1: |
|
6898 |
case 2: |
|
6899 |
case 4: |
|
6900 |
case 8: |
|
6901 |
case 16: |
|
6902 |
case 24: |
|
6903 |
case 32: |
|
6904 |
numBytes = image->bytes_per_line * image->height; |
|
6905 |
break; |
|
6906 |
default: |
|
397
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6907 |
/* unsupported depth ? */ |
094b8604ea72
return more info from getBits (bitsPerPixel); return it as a dictionary
Claus Gittinger <cg@exept.de>
parents:
395
diff
changeset
|
6908 |
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
|
6909 |
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
|
6910 |
break; |
295 | 6911 |
} |
6912 |
||
6913 |
#ifdef SUPERDEBUG |
|
555 | 6914 |
printf("bytes need:%d bytes given:%d\n", numBytes, __byteArraySize(imageBits)); |
295 | 6915 |
#endif |
6916 |
||
555 | 6917 |
if (numBytes > __byteArraySize(imageBits)) { |
295 | 6918 |
/* imageBits too small */ |
378 | 6919 |
printf("provided byteArray too small\n"); |
295 | 6920 |
goto fail; |
6921 |
} |
|
6922 |
if (image->bitmap_bit_order == MSBFirst) |
|
555 | 6923 |
__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst); |
295 | 6924 |
else |
555 | 6925 |
__ArrayInstPtr(info)->a_element[0] = @symbol(lsbFirst); |
6926 |
__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(image->depth); |
|
6927 |
__ArrayInstPtr(info)->a_element[2] = __MKSMALLINT(image->bytes_per_line); |
|
295 | 6928 |
if (image->byte_order == MSBFirst) |
555 | 6929 |
__ArrayInstPtr(info)->a_element[3] = @symbol(msbFirst); |
295 | 6930 |
else |
555 | 6931 |
__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
|
6932 |
if (image->format == XYBitmap) |
555 | 6933 |
__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
|
6934 |
else if (image->format == XYPixmap) |
555 | 6935 |
__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
|
6936 |
else if (image->format == ZPixmap) |
555 | 6937 |
__ArrayInstPtr(info)->a_element[4] = @symbol(ZPixmap); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
6938 |
|
555 | 6939 |
__ArrayInstPtr(info)->a_element[5] = __MKSMALLINT(image->bitmap_unit); |
6940 |
__ArrayInstPtr(info)->a_element[6] = __MKSMALLINT(image->bitmap_pad); |
|
6941 |
__ArrayInstPtr(info)->a_element[7] = __MKSMALLINT(image->bits_per_pixel); |
|
6942 |
bcopy(image->data, __ByteArrayInstPtr(imageBits)->ba_element, numBytes); |
|
295 | 6943 |
XDestroyImage(image); |
6944 |
RETURN ( true ); |
|
6945 |
} |
|
6946 |
fail: |
|
6947 |
if (image) { |
|
6948 |
XDestroyImage(image); |
|
6949 |
} |
|
6950 |
%}. |
|
6951 |
^ false |
|
6952 |
! ! |
|
6953 |
||
6954 |
!XWorkstation methodsFor:'selections'! |
|
6955 |
||
6956 |
getObjectProperty:propertyID from:aWindowID |
|
6957 |
"get an object property; return object or nil" |
|
6958 |
||
6959 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
6960 |
type == stringAtom ifTrue:[ |
|
6961 |
^ value |
|
6962 |
]. |
|
6963 |
(value isMemberOf:ByteArray) ifTrue:[ |
|
6964 |
^ (Object readBinaryFrom:(ReadStream on:value) onError:[nil]) |
|
6965 |
] |
|
6966 |
]. |
|
6967 |
^ nil |
|
6968 |
! |
|
6969 |
||
6970 |
getProperty:propertyID from:aWindowID into:aTwoArgBlock |
|
6971 |
"get a property, evaluate aTwoArgBlock with typeID and value" |
|
6972 |
||
6973 |
|val typeID cls| |
|
6974 |
||
6975 |
cls := ByteArray. |
|
6976 |
%{ |
|
6977 |
Display *dpy = myDpy; |
|
6978 |
Window window; |
|
6979 |
Atom property; |
|
6980 |
char *cp, *cp2; |
|
6981 |
Atom actual_type; |
|
6982 |
int actual_format,i; |
|
6983 |
unsigned long nitems, bytes_after, nread; |
|
6984 |
unsigned char *data; |
|
6985 |
int ok = 1; |
|
6986 |
# define PROP_SIZE 2048 |
|
6987 |
||
6988 |
if (__isAtomID(propertyID)) { |
|
6989 |
property = _AtomVal(propertyID); |
|
6990 |
if (__isExternalAddress(aWindowID)) { |
|
6991 |
window = _WindowVal(aWindowID); |
|
6992 |
} else { |
|
6993 |
window = DefaultRootWindow(dpy); |
|
6994 |
} |
|
6995 |
||
6996 |
nread = 0; |
|
6997 |
cp = 0; |
|
6998 |
/* |
|
6999 |
fprintf(stderr, "getProperty: "); |
|
7000 |
*/ |
|
7001 |
do { |
|
7002 |
if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False, |
|
7003 |
AnyPropertyType,&actual_type,&actual_format, |
|
7004 |
&nitems,&bytes_after,(unsigned char **)&data) |
|
7005 |
!= Success) { |
|
7006 |
ok = 0; |
|
7007 |
break; |
|
7008 |
} |
|
7009 |
typeID = __MKATOMOBJ(actual_type); |
|
7010 |
if (! cp) { |
|
7011 |
cp = cp2 = (char *)malloc(nitems+1); |
|
7012 |
} else { |
|
7013 |
cp = (char *)realloc(cp, nread + nitems + 1); |
|
7014 |
cp2 = cp + nread; |
|
7015 |
} |
|
7016 |
if (! cp) goto fail; |
|
7017 |
||
7018 |
nread += nitems; |
|
7019 |
bcopy(data, cp2, nitems); |
|
7020 |
XFree(data); |
|
7021 |
/* |
|
7022 |
fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after); |
|
7023 |
*/ |
|
7024 |
} while (bytes_after > 0); |
|
7025 |
/* |
|
7026 |
fprintf(stderr, "\n"); |
|
7027 |
*/ |
|
7028 |
||
7029 |
if (ok) { |
|
7030 |
if (actual_type == XA_STRING) { |
|
7031 |
cp[nread] = '\0'; |
|
7032 |
val = __MKSTRING_L(cp, nread COMMA_CON); |
|
7033 |
} else { |
|
7034 |
val = __new(nread + OHDR_SIZE); |
|
7035 |
val->o_class = cls; |
|
555 | 7036 |
bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread); |
295 | 7037 |
} |
7038 |
} |
|
7039 |
if (cp) |
|
7040 |
free(cp); |
|
7041 |
} |
|
7042 |
fail: ; |
|
7043 |
%}. |
|
7044 |
typeID isNil ifTrue:[ |
|
7045 |
^ false |
|
7046 |
]. |
|
7047 |
aTwoArgBlock value:typeID value:val. |
|
7048 |
^ true |
|
7049 |
! |
|
7050 |
||
7051 |
getSelectionFor:drawableId |
|
7052 |
"get the object selection - either immediate, or asynchronous. |
|
7053 |
Returns nil, if async request is on its way" |
|
7054 |
||
7055 |
|selProp sel| |
|
7056 |
||
7057 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
7058 |
"no primary selection - use cut buffer" |
|
7059 |
sel := self getObjectProperty:cutBuffer0Atom from:nil. |
|
7060 |
^ sel |
|
7061 |
]. |
|
7062 |
selProp := self atomIDOf:'ST_SELECTION' create:true. |
|
7063 |
self requestObjectSelection:primaryAtom property:selProp for:drawableId. |
|
7064 |
^ nil |
|
7065 |
! |
|
7066 |
||
7067 |
getSelectionOwnerOf:selectionAtomID |
|
7068 |
"get the owner of a selection" |
|
7069 |
||
7070 |
%{ /* NOCONTEXT */ |
|
7071 |
Display *dpy = myDpy; |
|
7072 |
Atom selection; |
|
7073 |
Window window; |
|
7074 |
||
7075 |
if (__isAtomID(selectionAtomID) && ISCONNECTED) { |
|
7076 |
window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID)); |
|
7077 |
RETURN ((window == None) ? nil : __MKOBJ(window)); |
|
7078 |
} |
|
7079 |
%}. |
|
7080 |
self primitiveFailed. |
|
7081 |
^ nil |
|
7082 |
! |
|
7083 |
||
7084 |
getTextProperty:propertyID from:aWindowID |
|
7085 |
"get a text property; return string or nil" |
|
7086 |
||
7087 |
self getProperty:propertyID from:aWindowID into:[:type :value | |
|
7088 |
type == stringAtom ifTrue:[ |
|
7089 |
^ value |
|
7090 |
] |
|
7091 |
]. |
|
7092 |
^ nil |
|
7093 |
! |
|
7094 |
||
7095 |
getTextSelectionFor:drawableId |
|
7096 |
"get the text selection - either immediate, or asynchronous. |
|
7097 |
Returns nil, if async request is on its way" |
|
7098 |
||
7099 |
|selProp sel| |
|
7100 |
||
7101 |
(self getSelectionOwnerOf:primaryAtom) isNil ifTrue:[ |
|
7102 |
"no primary selection - use cut buffer" |
|
7103 |
sel := self getTextProperty:cutBuffer0Atom from:nil. |
|
7104 |
^ sel |
|
7105 |
]. |
|
7106 |
selProp := self atomIDOf:'VT_SELECTION' create:true. |
|
7107 |
self requestTextSelection:primaryAtom property:selProp for:drawableId. |
|
7108 |
^ nil |
|
7109 |
! |
|
7110 |
||
7111 |
requestObjectSelection:selectionID property:propertyID for:aWindowId |
|
7112 |
"ask the server to send us the selection - the view with ID aWindowID |
|
7113 |
will later receive a SelectionNotify event for it." |
|
7114 |
||
7115 |
^ self requestSelection:selectionID |
|
7116 |
property:propertyID |
|
7117 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7118 |
for:aWindowId |
|
7119 |
! |
|
7120 |
||
7121 |
requestSelection:selectionID property:propertyID type:typeID for:aWindowId |
|
7122 |
"ask the server to send us the selection - the view with id aWindowID |
|
7123 |
will later receive a SelectionNotify event for it (once the Xserver replies |
|
7124 |
with the selections value)." |
|
7125 |
||
7126 |
%{ /* NOCONTEXT */ |
|
7127 |
Display *dpy = myDpy; |
|
7128 |
Atom sel_prop; |
|
7129 |
char *cp; |
|
7130 |
||
7131 |
if (__isExternalAddress(aWindowId) |
|
7132 |
&& ISCONNECTED |
|
7133 |
&& __isSmallInteger(typeID) |
|
7134 |
&& __isAtomID(selectionID)) { |
|
7135 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) { |
|
7136 |
/* |
|
7137 |
* no owner of primary selection |
|
7138 |
*/ |
|
7139 |
RETURN (false); |
|
7140 |
} |
|
7141 |
/* |
|
7142 |
* PRIMARY selection |
|
7143 |
*/ |
|
7144 |
XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), |
|
7145 |
_AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime); |
|
7146 |
RETURN (true); |
|
7147 |
} |
|
7148 |
%}. |
|
7149 |
self primitiveFailed. |
|
7150 |
^ false |
|
7151 |
||
7152 |
" |
|
7153 |
Display requestSelection:(Display atomIDOf:'PRIMARY') |
|
7154 |
property:(Display atomIDOf:'VT_SELECTION') |
|
7155 |
for:0 |
|
7156 |
" |
|
7157 |
! |
|
7158 |
||
7159 |
requestTextSelection:selectionID property:propertyID for:aWindowId |
|
7160 |
"ask the server to send us the selection - the view with ID aWindowID |
|
7161 |
will later receive a SelectionNotify event for it." |
|
7162 |
||
7163 |
^ self requestSelection:selectionID |
|
7164 |
property:propertyID |
|
7165 |
type:stringAtom |
|
7166 |
for:aWindowId |
|
7167 |
! |
|
7168 |
||
7169 |
sendSelection:something property:propertyID target:targetID from:windowID to:requestorID |
|
7170 |
"send aString back from a SelectionRequest" |
|
7171 |
||
7172 |
self |
|
7173 |
sendSelection:something |
|
7174 |
selection:primaryAtom |
|
7175 |
property:propertyID |
|
7176 |
target:targetID |
|
7177 |
from:windowID |
|
7178 |
to:requestorID |
|
7179 |
! |
|
7180 |
||
7181 |
sendSelection:something selection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
7182 |
"send aString back from a SelectionRequest" |
|
7183 |
||
7184 |
self |
|
7185 |
setProperty:propertyID |
|
7186 |
type:targetID |
|
7187 |
value:something |
|
7188 |
for:requestorID. |
|
7189 |
self |
|
7190 |
sendSelectionNotifySelection:selectionID |
|
7191 |
property:propertyID |
|
7192 |
target:targetID |
|
7193 |
from:requestorID |
|
7194 |
to:requestorID. |
|
7195 |
! |
|
7196 |
||
7197 |
sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID |
|
7198 |
"send a selectionNotify back from a SelectionRequest" |
|
7199 |
||
7200 |
%{ /* NOCONTEXT */ |
|
7201 |
Display *dpy = myDpy; |
|
7202 |
||
7203 |
if (__isAtomID(propertyID) |
|
7204 |
&& __isExternalAddress(requestorID) |
|
7205 |
&& ISCONNECTED |
|
7206 |
&& __isAtomID(targetID) |
|
7207 |
&& __isAtomID(selectionID)) { |
|
7208 |
XEvent ev; |
|
7209 |
Window requestor = _WindowVal(requestorID); |
|
7210 |
Atom property = _AtomVal(propertyID); |
|
7211 |
Atom target = _AtomVal(targetID); |
|
7212 |
Atom selection = _AtomVal(selectionID); |
|
7213 |
Status result; |
|
7214 |
||
7215 |
ev.xselection.type = SelectionNotify; |
|
7216 |
ev.xselection.selection = selection; |
|
7217 |
ev.xselection.target = target; |
|
7218 |
if (__isExternalAddress(windowID)) |
|
7219 |
ev.xselection.requestor = _WindowVal(windowID); |
|
7220 |
else |
|
7221 |
ev.xselection.requestor = DefaultRootWindow(dpy); |
|
7222 |
ev.xselection.time = CurrentTime; |
|
7223 |
if (property == None) |
|
7224 |
ev.xselection.property = target; |
|
7225 |
else |
|
7226 |
ev.xselection.property = property; |
|
7227 |
||
7228 |
DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n", |
|
7229 |
ev.xselection.selection, |
|
7230 |
ev.xselection.property, |
|
7231 |
ev.xselection.target, |
|
7232 |
ev.xselection.requestor, |
|
7233 |
requestor)); |
|
7234 |
||
7235 |
result = XSendEvent(dpy, requestor, False, 0 , &ev); |
|
7236 |
if ((result == BadValue) || (result == BadWindow)) { |
|
7237 |
DPRINTF(("bad status\n")); |
|
382 | 7238 |
RETURN (false); |
295 | 7239 |
} |
382 | 7240 |
RETURN (true) |
7241 |
} |
|
7242 |
%}. |
|
7243 |
self primitiveFailed. |
|
7244 |
^ false |
|
295 | 7245 |
! |
7246 |
||
7247 |
setLengthProperty:propertyID value:aNumber for:aWindowID |
|
7248 |
^ self setProperty:propertyID type:(self atomIDOfLENGTH) value:aNumber for:aWindowID |
|
7249 |
! |
|
7250 |
||
7251 |
setObjectProperty:propertyID value:anObject for:aWindowID |
|
7252 |
|s| |
|
7253 |
||
7254 |
(anObject isMemberOf:String) ifTrue:[ |
|
7255 |
^ self setTextProperty:propertyID value:anObject for:aWindowID |
|
7256 |
]. |
|
7257 |
s := WriteStream on:(ByteArray new:200). |
|
7258 |
anObject storeBinaryOn:s. |
|
7259 |
^ self |
|
7260 |
setProperty:propertyID |
|
7261 |
type:(self atomIDOf:'ST_OBJECT' create:true) |
|
7262 |
value:(s contents) |
|
7263 |
for:aWindowID |
|
7264 |
! |
|
7265 |
||
7266 |
setProperty:propertyID type:typeID value:anObject for:aWindowID |
|
7267 |
||
7268 |
%{ /* UNLIMITEDSTACK */ |
|
7269 |
||
7270 |
Display *dpy = myDpy; |
|
7271 |
Atom prop, type; |
|
7272 |
Window window; |
|
7273 |
unsigned int value; |
|
7274 |
||
7275 |
if (__isAtomID(propertyID) |
|
7276 |
&& __isAtomID(typeID) |
|
7277 |
&& ISCONNECTED |
|
7278 |
&& (__isString(anObject) |
|
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7279 |
|| __isSmallInteger(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7280 |
|| __isSymbol(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7281 |
|| __isByteArray(anObject) |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7282 |
|| __isWords(anObject))) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7283 |
|
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7284 |
prop = _AtomVal(propertyID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7285 |
type = _AtomVal(typeID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7286 |
if (__isExternalAddress(aWindowID)) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7287 |
window = _WindowVal(aWindowID); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7288 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7289 |
window = DefaultRootWindow(dpy); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7290 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7291 |
if (__isSmallInteger(anObject)) { |
555 | 7292 |
value = __intVal(anObject); |
480
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7293 |
XChangeProperty(dpy, window, prop, type, 32, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7294 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7295 |
(unsigned char *)(&value), sizeof(unsigned int)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7296 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7297 |
if (__isByteArray(anObject)) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7298 |
XChangeProperty(dpy, window, prop, type, 8, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7299 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7300 |
__ByteArrayInstPtr(anObject)->ba_element, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7301 |
__byteArraySize(anObject)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7302 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7303 |
/* 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
|
7304 |
if (__isWords(__qClass(anObject))) { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7305 |
XChangeProperty(dpy, window, prop, XA_STRING, 16, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7306 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7307 |
__stringVal(anObject), |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7308 |
__wordArraySize(anObject)); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7309 |
} else { |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7310 |
XChangeProperty(dpy, window, prop, XA_STRING, 8, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7311 |
PropModeReplace, |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7312 |
__stringVal(anObject), |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7313 |
strlen(__stringVal(anObject))); |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7314 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7315 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7316 |
} |
07ab9bbaea5f
create modifierState when sending keyboard events
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
7317 |
RETURN (true); |
295 | 7318 |
} |
7319 |
%}. |
|
7320 |
^ false |
|
7321 |
! |
|
7322 |
||
7323 |
setSelection:anObject owner:aWindowId |
|
7324 |
"set the object selection, and make aWindowId be the owner. |
|
7325 |
This can be used by other Smalltalk(X) applications only." |
|
7326 |
||
7327 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
7328 |
^ false |
|
7329 |
]. |
|
7330 |
"/ ^ self setObjectProperty:cutBuffer0Atom value:anObject for:nil |
|
7331 |
^ true |
|
7332 |
! |
|
7333 |
||
7334 |
setSelectionOwner:aWindowId of:selectionID |
|
7335 |
"set the owner of a selection; return false if failed" |
|
7336 |
||
7337 |
%{ /* NOCONTEXT */ |
|
7338 |
Display *dpy = myDpy; |
|
7339 |
Window win; |
|
7340 |
||
7341 |
if (__isExternalAddress(aWindowId) |
|
7342 |
&& __isAtomID(selectionID) |
|
7343 |
&& ISCONNECTED) { |
|
7344 |
win = _WindowVal(aWindowId); |
|
7345 |
XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime); |
|
7346 |
if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) { |
|
7347 |
RETURN (false); |
|
7348 |
} |
|
7349 |
RETURN (true); |
|
7350 |
} |
|
7351 |
%} |
|
7352 |
. |
|
7353 |
self primitiveFailed. |
|
7354 |
^ nil |
|
7355 |
! |
|
7356 |
||
7357 |
setTextProperty:propertyID value:aString for:aWindowID |
|
7358 |
^ self setProperty:propertyID type:(self atomIDOfSTRING) value:aString for:aWindowID |
|
7359 |
! |
|
7360 |
||
7361 |
setTextSelection:aString owner:aWindowId |
|
7362 |
"set the text selection, and make aWindowId be the owner. |
|
7363 |
This can be used by any other X application." |
|
7364 |
||
7365 |
(self setSelectionOwner:aWindowId of:primaryAtom) ifFalse:[ |
|
7366 |
'ownerchange failed' errorPrintNL. |
|
7367 |
]. |
|
7368 |
^ self setTextProperty:cutBuffer0Atom value:aString for:nil |
|
7369 |
! ! |
|
7370 |
||
7371 |
!XWorkstation methodsFor:'window stuff'! |
|
7372 |
||
7373 |
clearRectangleX:x y:y width:width height:height in:aWindowId |
|
7374 |
"clear a rectangular area to viewbackground" |
|
7375 |
||
7376 |
%{ /* NOCONTEXT */ |
|
7377 |
||
7378 |
int w, h; |
|
7379 |
||
7380 |
if (__isExternalAddress(aWindowId) |
|
7381 |
&& __bothSmallInteger(x, y) |
|
7382 |
&& __bothSmallInteger(width, height)) { |
|
555 | 7383 |
w = __intVal(width); |
7384 |
h = __intVal(height); |
|
295 | 7385 |
if (w < 0) w = 0; |
7386 |
if (h < 0) h = 0; |
|
555 | 7387 |
XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0); |
295 | 7388 |
RETURN ( self ); |
7389 |
} |
|
7390 |
%} |
|
7391 |
. |
|
7392 |
self primitiveFailed |
|
7393 |
! |
|
7394 |
||
7395 |
clearWindow:aWindowId |
|
7396 |
"clear a window to viewbackground" |
|
7397 |
||
7398 |
%{ /* NOCONTEXT */ |
|
7399 |
||
7400 |
if (__isExternalAddress(aWindowId)) { |
|
7401 |
XClearWindow(myDpy, _WindowVal(aWindowId)); |
|
7402 |
RETURN ( self ); |
|
7403 |
} |
|
7404 |
%} |
|
7405 |
. |
|
7406 |
self primitiveFailed |
|
7407 |
! |
|
7408 |
||
7409 |
configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol |
|
7410 |
"configure stacking operation of aWindowId w.r.t siblingId" |
|
7411 |
||
7412 |
%{ /* NOCONTEXT */ |
|
7413 |
||
7414 |
XWindowChanges chg; |
|
7415 |
int mask = CWSibling | CWStackMode; |
|
7416 |
||
7417 |
if (__isExternalAddress(aWindowId) |
|
7418 |
&& __isExternalAddress(siblingId)) { |
|
7419 |
if (modeSymbol == @symbol(above)) { |
|
7420 |
chg.stack_mode = Above; |
|
7421 |
} else if (modeSymbol == @symbol(below)) { |
|
7422 |
chg.stack_mode = Below; |
|
7423 |
} else if (modeSymbol == @symbol(topIf)) { |
|
7424 |
chg.stack_mode = TopIf; |
|
7425 |
} else if (modeSymbol == @symbol(bottomIf)) { |
|
7426 |
chg.stack_mode = BottomIf; |
|
7427 |
} else if (modeSymbol == @symbol(opposite)) { |
|
7428 |
chg.stack_mode = Opposite; |
|
7429 |
} else { |
|
7430 |
mask = CWSibling; |
|
7431 |
} |
|
7432 |
||
7433 |
chg.sibling = _WindowVal(siblingId); |
|
7434 |
XConfigureWindow(myDpy, _WindowVal(aWindowId), |
|
7435 |
mask, &chg); |
|
7436 |
RETURN ( self ); |
|
7437 |
} |
|
7438 |
bad: ; |
|
7439 |
%} |
|
7440 |
. |
|
7441 |
self primitiveFailed |
|
7442 |
! |
|
7443 |
||
7444 |
lowerWindow:aWindowId |
|
7445 |
"bring a window to back" |
|
7446 |
||
7447 |
%{ /* NOCONTEXT */ |
|
7448 |
||
7449 |
if (__isExternalAddress(aWindowId)) { |
|
7450 |
XLowerWindow(myDpy, _WindowVal(aWindowId)); |
|
7451 |
RETURN ( self ); |
|
7452 |
} |
|
7453 |
%} |
|
7454 |
. |
|
7455 |
self primitiveFailed |
|
7456 |
! |
|
7457 |
||
7458 |
mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos width:w height:h |
|
7459 |
"make a window visible - either as icon or as a real view - needed for restart" |
|
7460 |
||
7461 |
|wicon wiconId wiconView wiconViewId wlabel| |
|
7462 |
||
7463 |
aBoolean ifTrue:[ |
|
7464 |
wicon := aView icon. |
|
7465 |
wicon notNil ifTrue:[ |
|
7466 |
wiconId := wicon id |
|
7467 |
]. |
|
7468 |
wiconView := aView iconView. |
|
7469 |
wiconView notNil ifTrue:[ |
|
7470 |
wiconViewId := wiconView id |
|
7471 |
]. |
|
7472 |
wlabel := aView label. |
|
7473 |
]. |
|
7474 |
%{ |
|
7475 |
||
7476 |
XWMHints wmhints; |
|
7477 |
XSizeHints szhints; |
|
7478 |
Display *dpy = myDpy; |
|
7479 |
Window win; |
|
7480 |
||
7481 |
if (__isExternalAddress(aWindowId)) { |
|
7482 |
win = _WindowVal(aWindowId); |
|
7483 |
||
7484 |
szhints.flags = 0; |
|
7485 |
if (__bothSmallInteger(xPos, yPos)) { |
|
555 | 7486 |
szhints.x = __intVal(xPos); |
7487 |
szhints.y = __intVal(yPos); |
|
295 | 7488 |
szhints.flags |= USPosition; |
7489 |
} |
|
7490 |
if (__bothSmallInteger(w, h)) { |
|
555 | 7491 |
szhints.width = __intVal(w); |
7492 |
szhints.height = __intVal(h); |
|
295 | 7493 |
szhints.flags |= USSize; |
7494 |
} |
|
7495 |
||
7496 |
if (aBoolean == true) { |
|
7497 |
char *windowName; |
|
7498 |
Pixmap iconBitmap = (Pixmap)0; |
|
7499 |
Window iconWindow; |
|
7500 |
||
7501 |
if (__isExternalAddress(wiconId)) |
|
7502 |
iconBitmap = _PixmapVal(wiconId); |
|
7503 |
else |
|
7504 |
iconBitmap = (Pixmap)0; |
|
7505 |
||
7506 |
if (__isExternalAddress(wiconViewId)) |
|
7507 |
iconWindow = _WindowVal(wiconViewId); |
|
7508 |
else |
|
7509 |
iconWindow = (Window)0; |
|
7510 |
||
7511 |
if (__isString(wlabel) || __isSymbol(wlabel)) |
|
7512 |
windowName = (char *)_stringVal(wlabel); |
|
7513 |
else |
|
7514 |
windowName = ""; |
|
7515 |
||
7516 |
if (iconBitmap || windowName) { |
|
7517 |
XSetStandardProperties(dpy, win, |
|
7518 |
windowName, windowName, |
|
7519 |
iconBitmap, |
|
7520 |
0, 0, &szhints); |
|
7521 |
} |
|
7522 |
||
7523 |
wmhints.flags = 0; |
|
7524 |
if (iconBitmap) { |
|
7525 |
wmhints.flags |= IconPixmapHint; |
|
7526 |
wmhints.icon_pixmap = iconBitmap; |
|
7527 |
} |
|
7528 |
if (iconWindow) { |
|
7529 |
wmhints.flags |= IconWindowHint; |
|
7530 |
wmhints.icon_window = iconWindow; |
|
7531 |
} |
|
7532 |
||
7533 |
wmhints.initial_state = IconicState; |
|
7534 |
wmhints.flags |= StateHint; |
|
7535 |
XSetWMHints(dpy, win, &wmhints); |
|
7536 |
} |
|
7537 |
||
7538 |
if (szhints.flags) { |
|
7539 |
XSetNormalHints(dpy, win, &szhints); |
|
7540 |
} |
|
7541 |
||
7542 |
XMapWindow(dpy, win); |
|
7543 |
RETURN ( self ); |
|
7544 |
} |
|
7545 |
%} |
|
7546 |
. |
|
7547 |
self primitiveFailed |
|
7548 |
! |
|
7549 |
||
7550 |
mapWindow:aWindowId |
|
7551 |
"make a window visible" |
|
7552 |
||
7553 |
%{ /* NOCONTEXT */ |
|
7554 |
||
7555 |
if (__isExternalAddress(aWindowId)) { |
|
7556 |
XMapWindow(myDpy, _WindowVal(aWindowId)); |
|
7557 |
RETURN ( self ); |
|
7558 |
} |
|
7559 |
%} |
|
7560 |
. |
|
7561 |
self primitiveFailed |
|
7562 |
! |
|
7563 |
||
7564 |
moveResizeWindow:aWindowId x:x y:y width:w height:h |
|
7565 |
"move and resize a window" |
|
7566 |
||
7567 |
%{ /* NOCONTEXT */ |
|
7568 |
||
7569 |
int newWidth, newHeight; |
|
7570 |
||
7571 |
if (__isExternalAddress(aWindowId) |
|
7572 |
&& __bothSmallInteger(w, h) |
|
7573 |
&& __bothSmallInteger(x, y)) { |
|
555 | 7574 |
newWidth = __intVal(w); |
7575 |
newHeight = __intVal(h); |
|
295 | 7576 |
if (newWidth < 1) newWidth = 1; |
7577 |
if (newHeight < 1) newHeight = 1; |
|
7578 |
XMoveResizeWindow(myDpy, _WindowVal(aWindowId), |
|
555 | 7579 |
__intVal(x), __intVal(y), |
295 | 7580 |
newWidth, newHeight); |
7581 |
RETURN ( self ); |
|
7582 |
} |
|
7583 |
%} |
|
7584 |
. |
|
7585 |
self primitiveFailed |
|
7586 |
! |
|
7587 |
||
7588 |
moveWindow:aWindowId x:x y:y |
|
7589 |
"move a window" |
|
7590 |
||
7591 |
%{ /* NOCONTEXT */ |
|
7592 |
||
7593 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) { |
|
555 | 7594 |
XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y)); |
295 | 7595 |
RETURN ( self ); |
7596 |
} |
|
7597 |
%} |
|
7598 |
. |
|
7599 |
self primitiveFailed |
|
7600 |
! |
|
7601 |
||
7602 |
raiseWindow:aWindowId |
|
7603 |
"bring a window to front" |
|
7604 |
||
7605 |
%{ /* NOCONTEXT */ |
|
7606 |
||
7607 |
if (__isExternalAddress(aWindowId)) { |
|
7608 |
XRaiseWindow(myDpy, _WindowVal(aWindowId)); |
|
7609 |
RETURN ( self ); |
|
7610 |
} |
|
7611 |
%} |
|
7612 |
. |
|
7613 |
self primitiveFailed |
|
7614 |
! |
|
7615 |
||
7616 |
resizeWindow:aWindowId width:w height:h |
|
7617 |
"resize a window" |
|
7618 |
||
7619 |
%{ /* NOCONTEXT */ |
|
7620 |
||
7621 |
int newWidth, newHeight; |
|
7622 |
||
7623 |
if (__isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) { |
|
555 | 7624 |
newWidth = __intVal(w); |
7625 |
newHeight = __intVal(h); |
|
295 | 7626 |
if (newWidth < 1) newWidth = 1; |
7627 |
if (newHeight < 1) newHeight = 1; |
|
7628 |
XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight); |
|
7629 |
RETURN ( self ); |
|
7630 |
} |
|
7631 |
%} |
|
7632 |
. |
|
7633 |
self primitiveFailed |
|
7634 |
! |
|
7635 |
||
7636 |
setBackingStore:how in:aWindowId |
|
7637 |
"turn on/off backing-store for a window" |
|
7638 |
||
7639 |
%{ /* NOCONTEXT */ |
|
7640 |
||
7641 |
XSetWindowAttributes wa; |
|
7642 |
||
7643 |
if (__isExternalAddress(aWindowId)) { |
|
555 | 7644 |
if (__INST(ignoreBackingStore) != true) { |
295 | 7645 |
if (how == @symbol(always)) wa.backing_store = Always; |
7646 |
else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped; |
|
7647 |
else if (how == true) wa.backing_store = Always; |
|
7648 |
else wa.backing_store = 0; |
|
7649 |
BEGIN_INTERRUPTSBLOCKED |
|
7650 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBackingStore, &wa); |
|
7651 |
END_INTERRUPTSBLOCKED |
|
7652 |
} |
|
7653 |
RETURN ( self ); |
|
7654 |
} |
|
7655 |
%}. |
|
7656 |
self primitiveFailed |
|
7657 |
! |
|
7658 |
||
7659 |
setBitGravity:how in:aWindowId |
|
7660 |
"set bit gravity for a window" |
|
7661 |
||
7662 |
%{ /* NOCONTEXT */ |
|
7663 |
||
7664 |
XSetWindowAttributes wa; |
|
7665 |
||
7666 |
if (__isExternalAddress(aWindowId)) { |
|
7667 |
if (how == @symbol(NorthWest)) { |
|
7668 |
wa.bit_gravity = NorthWestGravity; |
|
7669 |
} else if (how == @symbol(NorthEast)) { |
|
7670 |
wa.bit_gravity = NorthEastGravity; |
|
7671 |
} else if (how == @symbol(SouthWest)) { |
|
7672 |
wa.bit_gravity = SouthWestGravity; |
|
7673 |
} else if (how == @symbol(SouthEast)) { |
|
7674 |
wa.bit_gravity = SouthEastGravity; |
|
7675 |
} else if (how == @symbol(Center)) { |
|
7676 |
wa.bit_gravity = CenterGravity; |
|
7677 |
} else if (how == @symbol(North)) { |
|
7678 |
wa.bit_gravity = NorthGravity; |
|
7679 |
} else if (how == @symbol(South)) { |
|
7680 |
wa.bit_gravity = SouthGravity; |
|
7681 |
} else if (how == @symbol(West)) { |
|
7682 |
wa.bit_gravity = WestGravity; |
|
7683 |
} else if (how == @symbol(East)) { |
|
7684 |
wa.bit_gravity = EastGravity; |
|
7685 |
} else { |
|
7686 |
wa.bit_gravity = NorthWestGravity; |
|
7687 |
} |
|
7688 |
||
7689 |
BEGIN_INTERRUPTSBLOCKED |
|
7690 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWBitGravity, &wa); |
|
7691 |
END_INTERRUPTSBLOCKED |
|
7692 |
RETURN ( self ); |
|
7693 |
} |
|
7694 |
%}. |
|
7695 |
self primitiveFailed |
|
7696 |
! |
|
7697 |
||
7698 |
setCursor:aCursorId in:aWindowId |
|
7699 |
"define a windows cursor" |
|
7700 |
||
7701 |
%{ /* NOCONTEXT */ |
|
7702 |
||
7703 |
Display *dpy = myDpy; |
|
7704 |
||
7705 |
if (__isExternalAddress(aWindowId) |
|
7706 |
&& __isExternalAddress(aCursorId)) { |
|
7707 |
XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId)); |
|
7708 |
RETURN ( self ); |
|
7709 |
} |
|
7710 |
%}. |
|
7711 |
self primitiveFailed |
|
7712 |
! |
|
7713 |
||
7714 |
setIconName:aString in:aWindowId |
|
7715 |
"define a windows iconname" |
|
7716 |
||
7717 |
%{ /* NOCONTEXT */ |
|
7718 |
||
7719 |
if (__isExternalAddress(aWindowId) |
|
7720 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
7721 |
XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
|
7722 |
RETURN ( self ); |
|
7723 |
} |
|
7724 |
%}. |
|
7725 |
self primitiveFailed |
|
7726 |
! |
|
7727 |
||
7728 |
setSaveUnder:yesOrNo in:aWindowId |
|
7729 |
"turn on/off save-under for a window" |
|
7730 |
||
7731 |
%{ /* NOCONTEXT */ |
|
7732 |
||
7733 |
XSetWindowAttributes wa; |
|
7734 |
||
7735 |
if (__isExternalAddress(aWindowId)) { |
|
555 | 7736 |
if (__INST(hasSaveUnder) == true) { |
295 | 7737 |
wa.save_under = (yesOrNo == true) ? 1 : 0; |
7738 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa); |
|
7739 |
} |
|
7740 |
RETURN ( self ); |
|
7741 |
} |
|
7742 |
%}. |
|
7743 |
self primitiveFailed |
|
7744 |
! |
|
7745 |
||
7746 |
setTransient:aWindowId for:aMainWindowId |
|
7747 |
"set aWindowId to be a transient of aMainWindow" |
|
7748 |
||
7749 |
%{ /* NOCONTEXT */ |
|
7750 |
||
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7751 |
if (__isExternalAddress(aWindowId)) { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7752 |
Window w; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7753 |
|
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7754 |
if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7755 |
w = (Window) 0; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7756 |
} else { |
374 | 7757 |
if (__isExternalAddress(aMainWindowId)) { |
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7758 |
w = _WindowVal(aMainWindowId); |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7759 |
} else { |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7760 |
goto getOutOfHere; |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7761 |
} |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7762 |
} |
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7763 |
XSetTransientForHint(myDpy, _WindowVal(aWindowId), w); |
295 | 7764 |
RETURN ( self ); |
7765 |
} |
|
353
5be3ae3c8838
sorry stefan - need eventPending (instead of eventQueued)
Claus Gittinger <cg@exept.de>
parents:
350
diff
changeset
|
7766 |
getOutOfHere: ; |
295 | 7767 |
%}. |
7768 |
self primitiveFailed |
|
7769 |
! |
|
7770 |
||
7771 |
setWindowBackground:aColorIndex in:aWindowId |
|
7772 |
"set the windows background color. This is the color with which |
|
7773 |
the view is filled whenever exposed. Do not confuse this with |
|
7774 |
the background drawing color, which is used with opaque drawing." |
|
7775 |
||
7776 |
%{ /* NOCONTEXT */ |
|
7777 |
||
7778 |
if (__isExternalAddress(aWindowId) |
|
7779 |
&& __isSmallInteger(aColorIndex)) { |
|
555 | 7780 |
XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
295 | 7781 |
RETURN ( self ); |
7782 |
} |
|
7783 |
%}. |
|
7784 |
self primitiveFailed |
|
7785 |
! |
|
7786 |
||
7787 |
setWindowBackgroundPixmap:aPixmapId in:aWindowId |
|
7788 |
"set the windows background pattern to be a form. |
|
7789 |
This is the pattern with which the view is filled whenever exposed. |
|
7790 |
Do not confuse this with the background drawing color, which is used |
|
7791 |
with opaque drawing." |
|
7792 |
||
7793 |
%{ /* NOCONTEXT */ |
|
7794 |
||
7795 |
if (__isExternalAddress(aWindowId) |
|
7796 |
&& __isExternalAddress(aPixmapId)) { |
|
7797 |
XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
|
7798 |
RETURN ( self ); |
|
7799 |
} |
|
7800 |
%}. |
|
7801 |
self primitiveFailed |
|
7802 |
! |
|
7803 |
||
7804 |
setWindowBorderColor:aColorIndex in:aWindowId |
|
7805 |
"set the windows border color" |
|
7806 |
||
7807 |
%{ /* NOCONTEXT */ |
|
7808 |
||
7809 |
if (__isExternalAddress(aWindowId) |
|
7810 |
&& __isSmallInteger(aColorIndex)) { |
|
555 | 7811 |
XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex)); |
295 | 7812 |
RETURN ( self ); |
7813 |
} |
|
7814 |
%}. |
|
7815 |
self primitiveFailed |
|
7816 |
! |
|
7817 |
||
7818 |
setWindowBorderPixmap:aPixmapId in:aWindowId |
|
7819 |
"set the windows border pattern" |
|
7820 |
||
7821 |
%{ /* NOCONTEXT */ |
|
7822 |
||
7823 |
if (__isExternalAddress(aWindowId) |
|
7824 |
&& __isExternalAddress(aPixmapId)) { |
|
7825 |
XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId)); |
|
7826 |
RETURN ( self ); |
|
7827 |
} |
|
7828 |
%} |
|
7829 |
. |
|
7830 |
self primitiveFailed |
|
7831 |
! |
|
7832 |
||
7833 |
setWindowBorderShape:aPixmapId in:aWindowId |
|
7834 |
"set the windows border shape" |
|
7835 |
||
7836 |
hasShapeExtension ifFalse:[^ self]. |
|
7837 |
||
7838 |
%{ /* NOCONTEXT */ |
|
7839 |
||
7840 |
#ifdef SHAPE |
|
7841 |
if (__isExternalAddress(aWindowId) |
|
7842 |
&& __isExternalAddress(aPixmapId)) { |
|
7843 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding, |
|
7844 |
0, 0, _PixmapVal(aPixmapId), ShapeSet); |
|
7845 |
RETURN ( self ); |
|
7846 |
} |
|
7847 |
#endif |
|
7848 |
%}. |
|
7849 |
self primitiveFailed |
|
7850 |
! |
|
7851 |
||
7852 |
setWindowBorderWidth:aNumber in:aWindowId |
|
7853 |
"set the windows border width" |
|
7854 |
||
7855 |
%{ /* NOCONTEXT */ |
|
7856 |
||
7857 |
if (__isExternalAddress(aWindowId) |
|
7858 |
&& __isSmallInteger(aNumber)) { |
|
555 | 7859 |
XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber)); |
295 | 7860 |
RETURN ( self ); |
7861 |
} |
|
7862 |
%}. |
|
7863 |
self primitiveFailed |
|
7864 |
! |
|
7865 |
||
7866 |
setWindowGravity:how in:aWindowId |
|
7867 |
"set window gravity for a window" |
|
7868 |
||
7869 |
%{ /* NOCONTEXT */ |
|
7870 |
||
7871 |
XSetWindowAttributes wa; |
|
7872 |
||
7873 |
if (__isExternalAddress(aWindowId)) { |
|
7874 |
if (how == @symbol(NorthWest)) { |
|
7875 |
wa.win_gravity = NorthWestGravity; |
|
7876 |
} else if (how == @symbol(NorthEast)) { |
|
7877 |
wa.win_gravity = NorthEastGravity; |
|
7878 |
} else if (how == @symbol(SouthWest)) { |
|
7879 |
wa.win_gravity = SouthWestGravity; |
|
7880 |
} else if (how == @symbol(SouthEast)) { |
|
7881 |
wa.win_gravity = SouthEastGravity; |
|
7882 |
} else if (how == @symbol(Center)) { |
|
7883 |
wa.win_gravity = CenterGravity; |
|
7884 |
} else if (how == @symbol(North)) { |
|
7885 |
wa.win_gravity = NorthGravity; |
|
7886 |
} else if (how == @symbol(South)) { |
|
7887 |
wa.win_gravity = SouthGravity; |
|
7888 |
} else if (how == @symbol(West)) { |
|
7889 |
wa.win_gravity = WestGravity; |
|
7890 |
} else if (how == @symbol(East)) { |
|
7891 |
wa.win_gravity = EastGravity; |
|
7892 |
} else { |
|
7893 |
wa.win_gravity = NorthWestGravity; |
|
7894 |
} |
|
7895 |
||
7896 |
BEGIN_INTERRUPTSBLOCKED |
|
7897 |
XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWWinGravity, &wa); |
|
7898 |
END_INTERRUPTSBLOCKED |
|
7899 |
RETURN ( self ); |
|
7900 |
} |
|
7901 |
%}. |
|
7902 |
self primitiveFailed |
|
7903 |
! |
|
7904 |
||
7905 |
setWindowIcon:aForm in:aWindowId |
|
7906 |
"define a bitmap to be used as icon" |
|
7907 |
||
7908 |
|iconId| |
|
7909 |
||
7910 |
aForm notNil ifTrue:[ |
|
7911 |
iconId := aForm id |
|
7912 |
]. |
|
7913 |
%{ |
|
7914 |
if (__isExternalAddress(iconId) |
|
7915 |
&& __isExternalAddress(aWindowId)) { |
|
7916 |
XWMHints hints; |
|
7917 |
||
7918 |
hints.icon_pixmap = _PixmapVal(iconId); |
|
7919 |
hints.flags = IconPixmapHint; |
|
7920 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &hints); |
|
7921 |
RETURN ( self ); |
|
7922 |
} |
|
7923 |
%}. |
|
7924 |
self primitiveFailed |
|
7925 |
! |
|
7926 |
||
7927 |
setWindowIconWindow:aView in:aWindowId |
|
7928 |
"define a window to be used as icon" |
|
7929 |
||
7930 |
|iconWindowId| |
|
7931 |
||
7932 |
aView notNil ifTrue:[ |
|
7933 |
iconWindowId := aView id |
|
7934 |
]. |
|
7935 |
%{ |
|
7936 |
if (__isExternalAddress(iconWindowId) |
|
7937 |
&& __isExternalAddress(aWindowId)) { |
|
7938 |
XWMHints wmhints; |
|
7939 |
||
7940 |
wmhints.icon_window = _WindowVal(iconWindowId); |
|
7941 |
wmhints.flags = IconWindowHint; |
|
7942 |
XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints); |
|
7943 |
RETURN ( self ); |
|
7944 |
} |
|
7945 |
%}. |
|
7946 |
self primitiveFailed |
|
7947 |
! |
|
7948 |
||
7949 |
setWindowName:aString in:aWindowId |
|
7950 |
"define a windows name" |
|
7951 |
||
7952 |
%{ /* NOCONTEXT */ |
|
7953 |
||
7954 |
if (__isExternalAddress(aWindowId) |
|
7955 |
&& (__isString(aString) || __isSymbol(aString))) { |
|
7956 |
XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString)); |
|
7957 |
RETURN ( self ); |
|
7958 |
} |
|
7959 |
%}. |
|
7960 |
self primitiveFailed |
|
7961 |
! |
|
7962 |
||
7963 |
setWindowShape:aPixmapId in:aWindowId |
|
7964 |
"set the windows shape" |
|
7965 |
||
7966 |
hasShapeExtension ifFalse:[^ self]. |
|
7967 |
||
7968 |
%{ /* NOCONTEXT */ |
|
7969 |
||
7970 |
#ifdef SHAPE |
|
7971 |
if (__isExternalAddress(aWindowId) |
|
7972 |
&& __isExternalAddress(aPixmapId)) { |
|
7973 |
XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip, |
|
7974 |
0, 0, |
|
7975 |
_PixmapVal(aPixmapId), ShapeSet); |
|
7976 |
RETURN ( self ); |
|
7977 |
} |
|
7978 |
#endif |
|
7979 |
%}. |
|
7980 |
self primitiveFailed |
|
7981 |
! |
|
7982 |
||
7983 |
unmapWindow:aWindowId |
|
7984 |
"make a window invisible" |
|
7985 |
||
7986 |
%{ /* NOCONTEXT */ |
|
7987 |
||
7988 |
if (__isExternalAddress(aWindowId)) { |
|
7989 |
XUnmapWindow(myDpy, _WindowVal(aWindowId)); |
|
7990 |
RETURN ( self ); |
|
7991 |
} |
|
7992 |
%} |
|
7993 |
. |
|
7994 |
self primitiveFailed |
|
7995 |
! ! |
|
7996 |
||
7997 |
!XWorkstation class methodsFor:'documentation'! |
|
7998 |
||
7999 |
version |
|
823 | 8000 |
^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.140 1996-06-10 19:18:58 cg Exp $' |
295 | 8001 |
! ! |
8002 |
XWorkstation initialize! |