#REFACTORING by cg
authorClaus Gittinger <cg@exept.de>
Sun, 03 Mar 2019 23:15:47 +0100
changeset 8655 9036cf74582d
parent 8654 07d3251ec28f
child 8656 d1f007b1273d
#REFACTORING by cg class: XWorkstation changed: #getFontWithFoundry:family:weight:slant:spacing:pixelSize:size:encoding:
XWorkstation.st
--- a/XWorkstation.st	Sat Mar 02 11:54:04 2019 +0100
+++ b/XWorkstation.st	Sun Mar 03 23:15:47 2019 +0100
@@ -3799,6 +3799,104 @@
 
 !XWorkstation methodsFor:'drawing'!
 
+_displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId
+    "draw a line. If the coordinates are not integers, an error is triggered."
+
+    <context: #return>
+
+    operationsUntilFlush notNil ifTrue:[
+	operationsUntilFlush <= 0 ifTrue:[
+	    self flush.
+	] ifFalse:[
+	    operationsUntilFlush := operationsUntilFlush - 1.
+	].
+    ].
+%{
+
+    GC gc;
+    Window win;
+
+    if (ISCONNECTED
+     && __isExternalAddress(aGCId)
+     && __isExternalAddress(aDrawableId)
+     && __bothSmallInteger(x0, y0)
+     && __bothSmallInteger(x1, y1)) {
+	Display *dpy = myDpy;
+	int ix0, iy0, ix1, iy1;
+	gc = __GCVal(aGCId);
+	win = __WindowVal(aDrawableId);
+
+	ix0 = __intVal(x0);
+	iy0 = __intVal(y0);
+	ix1 = __intVal(x1);
+	iy1 = __intVal(y1);
+
+	/* attention: coordinates in X are shorts and wrap; clamp here. */
+	if (ix0 > 0x7FFF) ix0 = 0x7FFF;
+	else if (ix0 < -0x8000) ix0 = -0x8000;
+	if (iy0 > 0x7FFF) iy0 = 0x7FFF;
+	else if (iy0 < -0x8000) iy0 = -0x8000;
+	if (ix1 > 0x7FFF) ix1 = 0x7FFF;
+	else if (ix1 < -0x8000) ix1 = -0x8000;
+	if (iy1 > 0x7FFF) iy1 = 0x7FFF;
+	else if (iy1 < -0x8000) iy1 = -0x8000;
+
+	ENTER_XLIB();
+	if ((ix0 == ix1) && (iy0 == iy1)) {
+	    /* little bit shorter X-lib message (better with slow connections...) */
+	    XDrawPoint(dpy, win, gc, ix0, iy0);
+	} else {
+	    XDrawLine(dpy, win, gc, ix0, iy0, ix1, iy1);
+	}
+	LEAVE_XLIB();
+	RETURN ( self );
+    }
+%}.
+    "badGC, badDrawable or coordinates not integer"
+    self primitiveFailedOrClosedConnection
+!
+
+_fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
+    "fill a rectangle.
+     If any coordinate is not integer, an error is triggered."
+
+    <context: #return>
+
+    operationsUntilFlush notNil ifTrue:[
+	operationsUntilFlush <= 0 ifTrue:[
+	    self flush.
+	] ifFalse:[
+	    operationsUntilFlush := operationsUntilFlush - 1.
+	].
+    ].
+%{
+
+    int w, h;
+
+    if (ISCONNECTED
+     && __isExternalAddress(aGCId)
+     && __isExternalAddress(aDrawableId)
+     && __bothSmallInteger(x, y)
+     && __bothSmallInteger(width, height)) {
+	w = __intVal(width);
+	h = __intVal(height);
+	/*
+	 * need this check here: some servers simply dump core with bad args
+	 */
+	if ((w >= 0) && (h >= 0)) {
+	    ENTER_XLIB();
+	    XFillRectangle(myDpy,
+			   __DrawableVal(aDrawableId), __GCVal(aGCId),
+			   __intVal(x), __intVal(y), w, h);
+	    LEAVE_XLIB();
+	}
+	RETURN ( self );
+    }
+%}.
+    "badGC, badDrawable or coordinates not integer"
+    self primitiveFailedOrClosedConnection
+!
+
 clearRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
     "clear (fill with background) a rectangle. If any coordinate is not integer, an error is triggered."
 
@@ -4152,63 +4250,6 @@
     self _displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId
 !
 
-_displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId
-    "draw a line. If the coordinates are not integers, an error is triggered."
-
-    <context: #return>
-
-    operationsUntilFlush notNil ifTrue:[
-	operationsUntilFlush <= 0 ifTrue:[
-	    self flush.
-	] ifFalse:[
-	    operationsUntilFlush := operationsUntilFlush - 1.
-	].
-    ].
-%{
-
-    GC gc;
-    Window win;
-
-    if (ISCONNECTED
-     && __isExternalAddress(aGCId)
-     && __isExternalAddress(aDrawableId)
-     && __bothSmallInteger(x0, y0)
-     && __bothSmallInteger(x1, y1)) {
-	Display *dpy = myDpy;
-	int ix0, iy0, ix1, iy1;
-	gc = __GCVal(aGCId);
-	win = __WindowVal(aDrawableId);
-
-	ix0 = __intVal(x0);
-	iy0 = __intVal(y0);
-	ix1 = __intVal(x1);
-	iy1 = __intVal(y1);
-
-	/* attention: coordinates in X are shorts and wrap; clamp here. */
-	if (ix0 > 0x7FFF) ix0 = 0x7FFF;
-	else if (ix0 < -0x8000) ix0 = -0x8000;
-	if (iy0 > 0x7FFF) iy0 = 0x7FFF;
-	else if (iy0 < -0x8000) iy0 = -0x8000;
-	if (ix1 > 0x7FFF) ix1 = 0x7FFF;
-	else if (ix1 < -0x8000) ix1 = -0x8000;
-	if (iy1 > 0x7FFF) iy1 = 0x7FFF;
-	else if (iy1 < -0x8000) iy1 = -0x8000;
-
-	ENTER_XLIB();
-	if ((ix0 == ix1) && (iy0 == iy1)) {
-	    /* little bit shorter X-lib message (better with slow connections...) */
-	    XDrawPoint(dpy, win, gc, ix0, iy0);
-	} else {
-	    XDrawLine(dpy, win, gc, ix0, iy0, ix1, iy1);
-	}
-	LEAVE_XLIB();
-	RETURN ( self );
-    }
-%}.
-    "badGC, badDrawable or coordinates not integer"
-    self primitiveFailedOrClosedConnection
-!
-
 displayLinesFromX:startX step:stepX yValues:yValues scaleY:scaleY transY:transY in:aDrawableId with:aGCId
     "draw a polygon starting at x; the y values derives from the collection yValues.
      The associated x is a multiple of step. Each y value will be scaled and translated
@@ -5199,47 +5240,6 @@
     self _fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
 !
 
-_fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
-    "fill a rectangle.
-     If any coordinate is not integer, an error is triggered."
-
-    <context: #return>
-
-    operationsUntilFlush notNil ifTrue:[
-	operationsUntilFlush <= 0 ifTrue:[
-	    self flush.
-	] ifFalse:[
-	    operationsUntilFlush := operationsUntilFlush - 1.
-	].
-    ].
-%{
-
-    int w, h;
-
-    if (ISCONNECTED
-     && __isExternalAddress(aGCId)
-     && __isExternalAddress(aDrawableId)
-     && __bothSmallInteger(x, y)
-     && __bothSmallInteger(width, height)) {
-	w = __intVal(width);
-	h = __intVal(height);
-	/*
-	 * need this check here: some servers simply dump core with bad args
-	 */
-	if ((w >= 0) && (h >= 0)) {
-	    ENTER_XLIB();
-	    XFillRectangle(myDpy,
-			   __DrawableVal(aDrawableId), __GCVal(aGCId),
-			   __intVal(x), __intVal(y), w, h);
-	    LEAVE_XLIB();
-	}
-	RETURN ( self );
-    }
-%}.
-    "badGC, badDrawable or coordinates not integer"
-    self primitiveFailedOrClosedConnection
-!
-
 primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth
     msb:msb masks:maskArray padding:bitPadding
     extent:imageExtent sourceOrigin:srcOrg
@@ -8037,8 +8037,8 @@
 !
 
 getFontWithFoundry:foundry family:family weight:weight
-	      slant:slant spacing:spc pixelSize:pSize size:size
-	      encoding:encoding
+              slant:slant spacing:spc pixelSize:pSize size:size
+              encoding:encoding
 
     "get the specified font, if not available, return nil.
      Individual attributes can be left empty (i.e. '') or nil to match any.
@@ -8059,64 +8059,40 @@
 
     "this works only on 'Release >= 3' - X-servers"
     "name is:
-	-foundry-family    -weight -slant-
-	 sony    helvetica bold     r
-	 adobe   courier   medium   i
-	 msic    fixed              o
-	 ...     ...
+        -foundry-family    -weight -slant-
+         sony    helvetica bold     r
+         adobe   courier   medium   i
+         msic    fixed              o
+         ...     ...
     "
 
     size isNil ifTrue:[
-	sizeMatch := '*'
-    ] ifFalse:[
-	sizeMatch := size printString , '0'
-    ].
-    foundry isNil ifTrue:[
-	foundryMatch := '*'
-    ] ifFalse:[
-	foundryMatch := foundry
-    ].
-    family isNil ifTrue:[
-	familyMatch := '*'
-    ] ifFalse:[
-	familyMatch := family
-    ].
-    weight isNil ifTrue:[
-	weightMatch := '*'
+        sizeMatch := '*'
     ] ifFalse:[
-	weightMatch := weight
-    ].
-    slant isNil ifTrue:[
-	slantMatch := '*'
-    ] ifFalse:[
-	slantMatch := slant
-    ].
-    spc isNil ifTrue:[
-	spcMatch := '*'
+        sizeMatch := size printString , '0'
+    ].
+    foundryMatch := foundry ? '*'.
+    familyMatch := family ? '*'.
+    weightMatch := weight ? '*'.
+    slantMatch := slant ? '*'.
+    spcMatch := spc ? '*'. 
+    pSize isNil ifTrue:[
+        pSizeMatch := '*'
     ] ifFalse:[
-	spcMatch := spc
-    ].
-    pSize isNil ifTrue:[
-	pSizeMatch := '*'
-    ] ifFalse:[
-	pSizeMatch := pSize printString
-    ].
-    encoding isNil ifTrue:[
-	encodingMatch := '*'
-    ] ifFalse:[
-	encodingMatch := encoding
-    ].
+        pSizeMatch := pSize printString
+    ].
+    encodingMatch := encoding ? '*'.
 
     theName := ('-' , foundryMatch,
-		'-' , familyMatch,
-		'-' , weightMatch ,
-		'-' , slantMatch ,
-		'-' , spcMatch ,
-		'-*' ,
-		'-' , pSizeMatch ,
-		'-' , sizeMatch ,
-		'-*-*-*-*' ,
-		'-' , encodingMatch).
+                '-' , familyMatch,
+                '-' , weightMatch ,
+                '-' , slantMatch ,
+                '-' , spcMatch ,
+                '-*' ,
+                '-' , pSizeMatch ,
+                '-' , sizeMatch ,
+                '-*-*-*-*' ,
+                '-' , encodingMatch).
 
 "/  Transcript showCR:theName; endEntry.
 
@@ -8125,27 +8101,28 @@
 
     "
      Display
-	getFontWithFoundry:'*'
-	family:'courier'
-	weight:'medium'
-	slant:'r'
-	spacing:nil
-	pixelSize:nil
-	size:13
-	encoding:#'iso8859-1'.
+        getFontWithFoundry:'*'
+        family:'courier'
+        weight:'medium'
+        slant:'r'
+        spacing:nil
+        pixelSize:nil
+        size:13
+        encoding:#'iso8859-1'.
 
      Display
-	getFontWithFoundry:'*'
-	family:'courier'
-	weight:'medium'
-	slant:'r'
-	spacing:nil
-	pixelSize:nil
-	size:13
-	encoding:#'iso10646-1'
-    "
-
-    "Modified: 10.4.1997 / 19:15:44 / cg"
+        getFontWithFoundry:'*'
+        family:'courier'
+        weight:'medium'
+        slant:'r'
+        spacing:nil
+        pixelSize:nil
+        size:13
+        encoding:#'iso10646-1'
+    "
+
+    "Modified: / 10-04-1997 / 19:15:44 / cg"
+    "Modified: / 03-03-2019 / 23:15:18 / Claus Gittinger"
 !
 
 heightOf:aString from:index1 to:index2 inFont:aFontId