--- a/XWorkstation.st Sun Jul 02 18:48:12 2000 +0200
+++ b/XWorkstation.st Mon Jul 03 10:56:39 2000 +0200
@@ -6191,11 +6191,11 @@
"Modified: 10.4.1997 / 09:45:36 / cg"
!
-encodingOf:aFontId
+encodingInfoOf:aFontId
"the fonts encoding - if the font does not provide that info,
return nil (and assume #ascii, which is a subset of #iso8859)."
- |enc fullName fontName registry encoding charSetCollections|
+ |fullName fontName registry encoding charSetCollections|
%{
XFontStruct *f;
@@ -6205,83 +6205,99 @@
Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom;
if (ISCONNECTED) {
- Display *dpy = myDpy;
-
- registryAtom = XInternAtom(dpy, "CHARSET_REGISTRY", True);
- encodingAtom = XInternAtom(dpy, "CHARSET_ENCODING", True);
- charSetCollAtom = XInternAtom(dpy, "CHARSET_COLLECTIONS", True);
- fontAtom = XInternAtom(dpy, "FONT", True);
-
- if (__isExternalAddress(aFontId)) {
+ Display *dpy = myDpy;
+
+ registryAtom = XInternAtom(dpy, "CHARSET_REGISTRY", True);
+ encodingAtom = XInternAtom(dpy, "CHARSET_ENCODING", True);
+ charSetCollAtom = XInternAtom(dpy, "CHARSET_COLLECTIONS", True);
+ fontAtom = XInternAtom(dpy, "FONT", True);
+
+ if (__isExternalAddress(aFontId)) {
- f = _FontVal(aFontId);
- if (f) {
- n = f->n_properties;
- prop = f->properties;
- if (prop) {
- while (n--) {
+ f = _FontVal(aFontId);
+ if (f) {
+ n = f->n_properties;
+ prop = f->properties;
+ if (prop) {
+ while (n--) {
#ifdef SUPERDEBUG
- cp = XGetAtomName(dpy, prop->name);
- printf("%s (%d) -> %d\n", cp, prop->name, prop->card32);
- XFree(cp);
+ cp = XGetAtomName(dpy, prop->name);
+ printf("%s (%d) -> %d\n", cp, prop->name, prop->card32);
+ XFree(cp);
#endif
- if (prop->name == XA_FULL_NAME) {
- cp = XGetAtomName(dpy, prop->card32);
- if (cp) {
- fullName = __MKSTRING(cp);
+ if (prop->name == XA_FULL_NAME) {
+ cp = XGetAtomName(dpy, prop->card32);
+ if (cp) {
+ fullName = __MKSTRING(cp);
#ifdef SUPERDEBUG
- printf(" FULL_NAME -> %s\n", cp);
+ printf(" FULL_NAME -> %s\n", cp);
#endif
- XFree(cp);
- }
- } else if (prop->name == fontAtom) {
- cp = XGetAtomName(dpy, prop->card32);
- if (cp) {
- fontName = __MKSTRING(cp);
+ XFree(cp);
+ }
+ } else if (prop->name == fontAtom) {
+ cp = XGetAtomName(dpy, prop->card32);
+ if (cp) {
+ fontName = __MKSTRING(cp);
#ifdef SUPERDEBUG
- printf(" FONT -> %s\n", cp);
+ printf(" FONT -> %s\n", cp);
+#endif
+ XFree(cp);
+ }
+ } else if (prop->name == encodingAtom) {
+ cp = XGetAtomName(dpy, prop->card32);
+ if (cp) {
+ encoding = __MKSTRING(cp);
+#ifdef SUPERDEBUG
+ printf(" ENCODING -> %s\n", cp);
#endif
- XFree(cp);
- }
- } else if (prop->name == encodingAtom) {
- cp = XGetAtomName(dpy, prop->card32);
- if (cp) {
- encoding = __MKSTRING(cp);
+ XFree(cp);
+ }
+ } else if (prop->name == registryAtom) {
+ cp = XGetAtomName(dpy, prop->card32);
+ if (cp) {
+ registry = __MKSTRING(cp);
#ifdef SUPERDEBUG
- printf(" ENCODING -> %s\n", cp);
+ printf(" REGISTRY -> %s\n", cp);
#endif
- XFree(cp);
- }
- } else if (prop->name == registryAtom) {
- cp = XGetAtomName(dpy, prop->card32);
- if (cp) {
- registry = __MKSTRING(cp);
+ XFree(cp);
+ }
+ } else if (prop->name == charSetCollAtom) {
+ cp = XGetAtomName(dpy, prop->card32);
+ if (cp) {
+ charSetCollections = __MKSTRING(cp);
#ifdef SUPERDEBUG
- printf(" REGISTRY -> %s\n", cp);
+ printf(" CHARSET_COLLECTIONS -> %s\n", cp);
#endif
- XFree(cp);
- }
- } else if (prop->name == charSetCollAtom) {
- cp = XGetAtomName(dpy, prop->card32);
- if (cp) {
- charSetCollections = __MKSTRING(cp);
-#ifdef SUPERDEBUG
- printf(" CHARSET_COLLECTIONS -> %s\n", cp);
-#endif
- XFree(cp);
- }
- }
- prop++;
- }
- }
- }
- }
- }
-%}.
+ XFree(cp);
+ }
+ }
+ prop++;
+ }
+ }
+ }
+ }
+ }
+%}.
+ ^ Array with:registry with:encoding with:charSetCollections with:fontName with:fullName
+!
+
+encodingOf:aFontId
+ "the fonts encoding - if the font does not provide that info,
+ return nil (and assume #ascii, which is a subset of #iso8859)."
+
+ |info fullName fontName registry encoding charSetCollections|
+
+ info := self encodingInfoOf:aFontId.
+ registry := info at:1.
+ encoding := info at:2.
+ charSetCollections := info at:3.
+ fontName := info at:4.
+ fullName := info at:5.
+
^ self
- extractEncodingFromRegistry:registry
- encoding:encoding
- charSetCollections:charSetCollections
+ extractEncodingFromRegistry:registry
+ encoding:encoding
+ charSetCollections:charSetCollections
!
extractEncodingFromRegistry:registry encoding:encoding charSetCollections:charSetCollections
@@ -6337,7 +6353,7 @@
"Created: 20.2.1996 / 22:55:52 / cg"
!
-fontMetricsOf:fontId into:aBlock
+fontMetricInfoOf:fontId
"evaluate aBlock, passing a fonts metrics as arguments"
|encoding avgAscent avgDescent
@@ -6349,55 +6365,81 @@
int len;
if (ISCONNECTED) {
- if (__isExternalAddress(fontId)) {
- f = _FontVal(fontId);
- if (f) {
+ if (__isExternalAddress(fontId)) {
+ f = _FontVal(fontId);
+ if (f) {
#ifdef NOTDEF
- char *cp;
- XFontProp *prop;
-
- n = f->n_properties;
- prop = f->properties;
-
- if (prop) {
- while (n--) {
- if (prop->name == RESOLUTION_X) {
- resX = __MKSMALLINT(prop->card32);
- } else if (prop->name == RESOLUTION_Y) {
- resY = __MKSMALLINT(prop->card32);
- } else if (prop->name == RESOLUTION) {
- res = __MKSMALLINT(prop->card32);
- }
- prop++;
- }
- }
+ char *cp;
+ XFontProp *prop;
+
+ n = f->n_properties;
+ prop = f->properties;
+
+ if (prop) {
+ while (n--) {
+ if (prop->name == RESOLUTION_X) {
+ resX = __MKSMALLINT(prop->card32);
+ } else if (prop->name == RESOLUTION_Y) {
+ resY = __MKSMALLINT(prop->card32);
+ } else if (prop->name == RESOLUTION) {
+ res = __MKSMALLINT(prop->card32);
+ }
+ prop++;
+ }
+ }
#endif
- avgAscent = __MKSMALLINT(f->ascent);
- avgDescent = __MKSMALLINT(f->descent);
- maxAscent = __MKSMALLINT(f->max_bounds.ascent);
- maxDescent = __MKSMALLINT(f->max_bounds.descent);
- minWidth = __MKSMALLINT(f->min_bounds.width);
- maxWidth = __MKSMALLINT(f->max_bounds.width);
-
- ENTER_XLIB();
- len = XTextWidth(f, " ", 1);
- LEAVE_XLIB();
-
- avgWidth = __MKSMALLINT( len );
- }
- }
- }
-%}.
+ avgAscent = __MKSMALLINT(f->ascent);
+ avgDescent = __MKSMALLINT(f->descent);
+ maxAscent = __MKSMALLINT(f->max_bounds.ascent);
+ maxDescent = __MKSMALLINT(f->max_bounds.descent);
+ minWidth = __MKSMALLINT(f->min_bounds.width);
+ maxWidth = __MKSMALLINT(f->max_bounds.width);
+
+ ENTER_XLIB();
+ len = XTextWidth(f, " ", 1);
+ LEAVE_XLIB();
+
+ avgWidth = __MKSMALLINT( len );
+ }
+ }
+ }
+%}.
+ ^ Array
+ with:avgAscent
+ with:avgDescent
+ with:maxAscent
+ with:maxDescent
+ with:minWidth
+ with:maxWidth
+ with:avgWidth
+!
+
+fontMetricsOf:fontId into:aBlock
+ "evaluate aBlock, passing a fonts metrics as arguments"
+
+ |info encoding avgAscent avgDescent
+ maxAscent maxDescent minWidth maxWidth avgWidth
+ res resX resY|
+
+ info := self fontMetricInfoOf:fontId.
+ avgAscent := info at:1.
+ avgDescent := info at:2.
+ maxAscent := info at:3.
+ maxDescent := info at:4.
+ minWidth := info at:5.
+ maxWidth := info at:6.
+ avgWidth := info at:7.
+
encoding := self encodingOf:fontId.
aBlock value:encoding
- value:avgAscent
- value:avgDescent
- value:maxAscent
- value:maxDescent
- value:minWidth
- value:maxWidth
- value:avgWidth
+ value:avgAscent
+ value:avgDescent
+ value:maxAscent
+ value:maxDescent
+ value:minWidth
+ value:maxWidth
+ value:avgWidth
!
fontResolutionOf:fontId
@@ -7838,6 +7880,12 @@
%}
!
+eventBufferSize
+%{
+ RETURN ( __MKSMALLINT(sizeof(XEvent) + 100) );
+%}
+!
+
initializeDefaultValues
activateOnClick := false.
super initializeDefaultValues.
@@ -7855,13 +7903,8 @@
!
initializeEventBuffer
- |sz|
-
-%{
- sz = __MKSMALLINT(sizeof(XEvent) + 100);
-%}.
eventBuffer isNil ifTrue:[
- eventBuffer := ByteArray new:sz.
+ eventBuffer := ByteArray new:(self eventBufferSize).
].
!
@@ -10521,6 +10564,6 @@
!XWorkstation class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.351 2000-07-02 16:48:12 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.352 2000-07-03 08:56:39 cg Exp $'
! !
XWorkstation initialize!