# HG changeset patch # User Claus Gittinger # Date 814467619 -3600 # Node ID 3abcc2ee164180b1de561d97042de24c4afb3b7a # Parent 13a9d4bafa7e89db001c65a2ef972222520b94a5 . diff -r 13a9d4bafa7e -r 3abcc2ee1641 Depth16Image.st --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Depth16Image.st Mon Oct 23 18:00:19 1995 +0100 @@ -0,0 +1,123 @@ +" + COPYRIGHT (c) 1995 by Claus Gittinger + All Rights Reserved + + This software is furnished under a license and may be used + only in accordance with the terms of that license and with the + inclusion of the above copyright notice. This software may not + be provided or otherwise made available to, or used by, any + other person. No title to or ownership of the software is + hereby transferred. +" + +Image subclass:#Depth16Image + instanceVariableNames:'' + classVariableNames:'' + poolDictionaries:'' + category:'Graphics-Images' +! + +Depth16Image comment:' +COPYRIGHT (c) 1995 by Claus Gittinger + All Rights Reserved + +$Header: /cvs/stx/stx/libview/Depth16Image.st,v 1.1 1995-10-23 16:58:37 cg Exp $ +'! + +!Depth16Image class methodsFor:'documentation'! + +copyright +" + COPYRIGHT (c) 1995 by Claus Gittinger + All Rights Reserved + + This software is furnished under a license and may be used + only in accordance with the terms of that license and with the + inclusion of the above copyright notice. This software may not + be provided or otherwise made available to, or used by, any + other person. No title to or ownership of the software is + hereby transferred. +" +! + +version +" +$Header: /cvs/stx/stx/libview/Depth16Image.st,v 1.1 1995-10-23 16:58:37 cg Exp $ +" +! + +documentation +" + this class represents 16 bit images. + Only the minimum protocol is implemented here; much more is + needed for higher performance operations on depth16 images. + (however, 16bit images are seldom used, so falling back into the + slow general methods from Image should not hurt too much ..) +" +! ! + +!Depth16Image class methodsFor:'queries'! + +imageDepth + ^ 16 +! ! + +!Depth16Image methodsFor:'queries'! + +bitsPerPixel + "return the number of bits per pixel" + + ^ 16 +! + +bitsPerRow + "return the number of bits in one scanline of the image" + + ^ width * 16 +! + +bitsPerSample + "return the number of bits per sample. + The return value is an array of bits-per-plane." + + ^ #(16) +! + +bytesPerRow + "return the number of bytes in one scanline of the image" + + ^ width * 2. +! + +samplesPerPixel + "return the number of samples per pixel in the image." + + ^ 1 +! ! + +!Depth16Image methodsFor:'accessing'! + +valueAtX:x y:y + "retrieve a pixel at x/y; return a pixelValue. + Pixels start at x=0 , y=0 for upper left pixel, end at + x = width-1, y=height-1 for lower right pixel" + + |lineIndex "{ Class: SmallInteger }"| + + lineIndex := (width * 2 * y) + 1. + + "left pixel in high bits" + ^ bytes wordAt:(lineIndex + (x * 2)) MSB:true. +! + +atX:x y:y putValue:aPixelValue + "set the pixel at x/y to aPixelValue. + Pixels start at x=0 , y=0 for upper left pixel, end at + x = width-1, y=height-1 for lower right pixel" + + |lineIndex "{ Class: SmallInteger }"| + + lineIndex := (width * 2 * y) + 1. + + bytes wordAt:(lineIndex + (x * 2)) put:aPixelValue MSB:true +! ! diff -r 13a9d4bafa7e -r 3abcc2ee1641 Depth1Image.st --- a/Depth1Image.st Thu Sep 21 13:40:25 1995 +0200 +++ b/Depth1Image.st Mon Oct 23 18:00:19 1995 +0100 @@ -21,7 +21,7 @@ COPYRIGHT (c) 1993 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libview/Depth1Image.st,v 1.12 1995-03-18 05:10:16 claus Exp $ +$Header: /cvs/stx/stx/libview/Depth1Image.st,v 1.13 1995-10-23 16:58:41 cg Exp $ '! !Depth1Image class methodsFor:'documentation'! @@ -42,7 +42,7 @@ version " -$Header: /cvs/stx/stx/libview/Depth1Image.st,v 1.12 1995-03-18 05:10:16 claus Exp $ +$Header: /cvs/stx/stx/libview/Depth1Image.st,v 1.13 1995-10-23 16:58:41 cg Exp $ " ! @@ -452,6 +452,14 @@ f := Form width:width height:height fromArray:bytes. f colorMap:colorMap. ^ f +! + +paletteImageAsTrueColorFormOn:aDevice + "since all devices must support monochrome images, and + a 2-entry colormap is implemented by ST/X's drawForm methods, + we can do this on all color devices as a palette image." + + ^ self paletteImageAsPseudoFormOn:aDevice ! ! !Depth1Image methodsFor:'magnification'! diff -r 13a9d4bafa7e -r 3abcc2ee1641 DevDraw.st --- a/DevDraw.st Thu Sep 21 13:40:25 1995 +0200 +++ b/DevDraw.st Mon Oct 23 18:00:19 1995 +0100 @@ -23,7 +23,7 @@ COPYRIGHT (c) 1992 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libview/Attic/DevDraw.st,v 1.27 1995-09-07 12:29:07 claus Exp $ +$Header: /cvs/stx/stx/libview/Attic/DevDraw.st,v 1.28 1995-10-23 16:58:49 cg Exp $ '! !DeviceDrawable class methodsFor:'documentation'! @@ -44,7 +44,7 @@ version " -$Header: /cvs/stx/stx/libview/Attic/DevDraw.st,v 1.27 1995-09-07 12:29:07 claus Exp $ +$Header: /cvs/stx/stx/libview/Attic/DevDraw.st,v 1.28 1995-10-23 16:58:49 cg Exp $ " ! @@ -1967,6 +1967,25 @@ height:h with:gcId ] +! + +copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY + "copy bits from a smalltalk byteArray. + The bits found there are supposed to be in the devices native format (i.e. + translated to allocated color indices on pseudoColor devices and padded as required. + The byteOrder is MSB and will be converted as appropriate by the underlying devices + method to whatever the device needs." + + device + drawBits:aByteArray bitsPerPixel:bpp depth:depth + width:srcW height:srcH + x:srcX y:srcY + into:drawableId + x:dstX y:dstY + width:(self width) height:(self height) + with:gcId. + + "Created: 21.10.1995 / 00:04:22 / cg" ! ! !DeviceDrawable methodsFor:'filling'! diff -r 13a9d4bafa7e -r 3abcc2ee1641 DevWorkst.st --- a/DevWorkst.st Thu Sep 21 13:40:25 1995 +0200 +++ b/DevWorkst.st Mon Oct 23 18:00:19 1995 +0100 @@ -14,6 +14,9 @@ instanceVariableNames:'displayId visualType monitorType depth ncells bitsPerRGB + bitsRed bitsGreen bitsBlue + redMask greenMask blueMask + redShift greenShift blueShift hasColors hasGreyscales width height widthMM heightMM resolutionHor resolutionVer idToViewMapping knownViews knownIds knownBitmaps knownBitmapIds @@ -36,7 +39,7 @@ COPYRIGHT (c) 1993 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libview/Attic/DevWorkst.st,v 1.45 1995-09-19 14:58:06 claus Exp $ +$Header: /cvs/stx/stx/libview/Attic/DevWorkst.st,v 1.46 1995-10-23 16:58:55 cg Exp $ '! !DeviceWorkstation class methodsFor:'documentation'! @@ -57,7 +60,7 @@ version " -$Header: /cvs/stx/stx/libview/Attic/DevWorkst.st,v 1.45 1995-09-19 14:58:06 claus Exp $ +$Header: /cvs/stx/stx/libview/Attic/DevWorkst.st,v 1.46 1995-10-23 16:58:55 cg Exp $ " ! @@ -74,14 +77,24 @@ visualType one of #StaticGray, #PseudoColor, ... #TrueColor monitorType one of #monochrome, #color, #unknown - depth bits per color - ncells number of colors (i.e. colormap size; not always == 2^depth) - bitsPerRGB number of valid bits per rgb component + depth bits per color + ncells number of colors (i.e. colormap size; not always == 2^depth) + bitsPerRGB number of valid bits per rgb component (actual number taken in A/D converter; not all devices report the true value) + bitsRed number of red bits (only valid for TrueColor displays) + bitsGreen number of green bits (only valid for TrueColor displays) + bitsBlue number of blue bits (only valid for TrueColor displays) + redMask shifted red mask (only useful for TrueColor displays) + greenMask shifted green mask (only useful for TrueColor displays) + blueMask shifted blue mask (only useful for TrueColor displays) + shiftRed number of bits to shift red bits (only valid for TrueColor displays) + shiftGreen number of bits to shift green bits (only valid for TrueColor displays) + shiftBlue number of bits to shift blue bits (only valid for TrueColor displays) + hasColors true, if display supports colors hasGreyscales true, if display supports grey-scales (i.e is not b/w display) - width number of horizontal pixels - height number of vertical pixels + width number of horizontal pixels + height number of vertical pixels heightMM screen height in millimeter widthMM screen width in millimeter resolutionHor pixels per horizontal millimeter @@ -964,17 +977,116 @@ ! bitsPerRGB - "return the number of valid bits per rgb component. + "return the number of valid bits per rgb component; Currently, assume that r/g/b all have the same precision, which is a stupid assumption (there may be some, where less resolution is available in the blue component). - Therefore, this may be changed to return a 3-element vector." + Therefore, this may be changed to return a 3-element vector. + In the meantime, use bitsRed/bitsGreen/bitsBlue to get this information." ^ bitsPerRGB " Display bitsPerRGB " + + "Modified: 21.10.1995 / 00:46:27 / cg" +! + +bitsRed + "return the number of valid bits in the red component." + + bitsRed isNil ifTrue:[ + "/ not a truecolor display + ^ bitsPerRGB + ]. + ^ bitsRed + + " + Display bitsRed + " + + "Created: 21.10.1995 / 00:44:55 / cg" +! + +bitsGreen + "return the number of valid bits in the red component." + + bitsGreen isNil ifTrue:[ + "/ not a truecolor display + ^ bitsPerRGB + ]. + ^ bitsGreen + + " + Display bitsGreen + " + + "Created: 21.10.1995 / 00:45:11 / cg" +! + +bitsBlue + "return the number of valid bits in the red component." + + bitsBlue isNil ifTrue:[ + "/ not a truecolor display + ^ bitsPerRGB + ]. + ^ bitsBlue + + " + Display bitsBlue + " + + "Created: 21.10.1995 / 00:45:27 / cg" +! + +shiftBlue + "return the count by which the blue bits are to be shifted + when forming a color index. + This only makes sense with trueColor displays; therefore, + nil is returned on all others." + + ^ blueShift + + " + Display shiftBlue + " + + "Created: 21.10.1995 / 00:45:27 / cg" + "Modified: 21.10.1995 / 00:47:58 / cg" +! + +shiftRed + "return the count by which the red bits are to be shifted + when forming a color index. + This only makes sense with trueColor displays; therefore, + nil is returned on all others." + + ^ redShift + + " + Display shiftRed + " + + "Created: 21.10.1995 / 00:45:27 / cg" + "Modified: 21.10.1995 / 00:48:10 / cg" +! + +shiftGreen + "return the count by which the red bits are to be shifted + when forming a color index. + This only makes sense with trueColor displays; therefore, + nil is returned on all others." + + ^ greenShift + + " + Display shiftGreen + " + + "Created: 21.10.1995 / 00:45:27 / cg" + "Modified: 21.10.1995 / 00:48:28 / cg" ! visualType:aSymbol @@ -1152,6 +1264,33 @@ " ! +hasExtension:extensionString + "query for an X extension. The method here is provide for XWorkstation + protocol compatibility only." + + ^ false + + " + Display hasExtension:'XVideo' + Display hasExtension:'Input' + Display hasExtension:'GLX' + Display hasExtension:'X3D-PEX' + Display hasExtension:'XInputExtension' + Display hasExtension:'SHAPE' + Display hasExtension:'MIT-SHM' + Display hasExtension:'SGIFullScreenStereo' + " +! + +supportedImageFormats + "return an array with supported image formats; each array entry + is another array, consisting of depth and bitsPerPixel values. + Here, we return a single format only; every graphics device must + support b&w single bit images." + + ^ #( 1 1) "/ depth=1 bitsPerPixel=1 +! + isSlow "return true, if this is a relatively slow device - used to turn off things like popup-shadows" diff -r 13a9d4bafa7e -r 3abcc2ee1641 DeviceWorkstation.st --- a/DeviceWorkstation.st Thu Sep 21 13:40:25 1995 +0200 +++ b/DeviceWorkstation.st Mon Oct 23 18:00:19 1995 +0100 @@ -14,6 +14,9 @@ instanceVariableNames:'displayId visualType monitorType depth ncells bitsPerRGB + bitsRed bitsGreen bitsBlue + redMask greenMask blueMask + redShift greenShift blueShift hasColors hasGreyscales width height widthMM heightMM resolutionHor resolutionVer idToViewMapping knownViews knownIds knownBitmaps knownBitmapIds @@ -36,7 +39,7 @@ COPYRIGHT (c) 1993 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.45 1995-09-19 14:58:06 claus Exp $ +$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.46 1995-10-23 16:58:55 cg Exp $ '! !DeviceWorkstation class methodsFor:'documentation'! @@ -57,7 +60,7 @@ version " -$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.45 1995-09-19 14:58:06 claus Exp $ +$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.46 1995-10-23 16:58:55 cg Exp $ " ! @@ -74,14 +77,24 @@ visualType one of #StaticGray, #PseudoColor, ... #TrueColor monitorType one of #monochrome, #color, #unknown - depth bits per color - ncells number of colors (i.e. colormap size; not always == 2^depth) - bitsPerRGB number of valid bits per rgb component + depth bits per color + ncells number of colors (i.e. colormap size; not always == 2^depth) + bitsPerRGB number of valid bits per rgb component (actual number taken in A/D converter; not all devices report the true value) + bitsRed number of red bits (only valid for TrueColor displays) + bitsGreen number of green bits (only valid for TrueColor displays) + bitsBlue number of blue bits (only valid for TrueColor displays) + redMask shifted red mask (only useful for TrueColor displays) + greenMask shifted green mask (only useful for TrueColor displays) + blueMask shifted blue mask (only useful for TrueColor displays) + shiftRed number of bits to shift red bits (only valid for TrueColor displays) + shiftGreen number of bits to shift green bits (only valid for TrueColor displays) + shiftBlue number of bits to shift blue bits (only valid for TrueColor displays) + hasColors true, if display supports colors hasGreyscales true, if display supports grey-scales (i.e is not b/w display) - width number of horizontal pixels - height number of vertical pixels + width number of horizontal pixels + height number of vertical pixels heightMM screen height in millimeter widthMM screen width in millimeter resolutionHor pixels per horizontal millimeter @@ -964,17 +977,116 @@ ! bitsPerRGB - "return the number of valid bits per rgb component. + "return the number of valid bits per rgb component; Currently, assume that r/g/b all have the same precision, which is a stupid assumption (there may be some, where less resolution is available in the blue component). - Therefore, this may be changed to return a 3-element vector." + Therefore, this may be changed to return a 3-element vector. + In the meantime, use bitsRed/bitsGreen/bitsBlue to get this information." ^ bitsPerRGB " Display bitsPerRGB " + + "Modified: 21.10.1995 / 00:46:27 / cg" +! + +bitsRed + "return the number of valid bits in the red component." + + bitsRed isNil ifTrue:[ + "/ not a truecolor display + ^ bitsPerRGB + ]. + ^ bitsRed + + " + Display bitsRed + " + + "Created: 21.10.1995 / 00:44:55 / cg" +! + +bitsGreen + "return the number of valid bits in the red component." + + bitsGreen isNil ifTrue:[ + "/ not a truecolor display + ^ bitsPerRGB + ]. + ^ bitsGreen + + " + Display bitsGreen + " + + "Created: 21.10.1995 / 00:45:11 / cg" +! + +bitsBlue + "return the number of valid bits in the red component." + + bitsBlue isNil ifTrue:[ + "/ not a truecolor display + ^ bitsPerRGB + ]. + ^ bitsBlue + + " + Display bitsBlue + " + + "Created: 21.10.1995 / 00:45:27 / cg" +! + +shiftBlue + "return the count by which the blue bits are to be shifted + when forming a color index. + This only makes sense with trueColor displays; therefore, + nil is returned on all others." + + ^ blueShift + + " + Display shiftBlue + " + + "Created: 21.10.1995 / 00:45:27 / cg" + "Modified: 21.10.1995 / 00:47:58 / cg" +! + +shiftRed + "return the count by which the red bits are to be shifted + when forming a color index. + This only makes sense with trueColor displays; therefore, + nil is returned on all others." + + ^ redShift + + " + Display shiftRed + " + + "Created: 21.10.1995 / 00:45:27 / cg" + "Modified: 21.10.1995 / 00:48:10 / cg" +! + +shiftGreen + "return the count by which the red bits are to be shifted + when forming a color index. + This only makes sense with trueColor displays; therefore, + nil is returned on all others." + + ^ greenShift + + " + Display shiftGreen + " + + "Created: 21.10.1995 / 00:45:27 / cg" + "Modified: 21.10.1995 / 00:48:28 / cg" ! visualType:aSymbol @@ -1152,6 +1264,33 @@ " ! +hasExtension:extensionString + "query for an X extension. The method here is provide for XWorkstation + protocol compatibility only." + + ^ false + + " + Display hasExtension:'XVideo' + Display hasExtension:'Input' + Display hasExtension:'GLX' + Display hasExtension:'X3D-PEX' + Display hasExtension:'XInputExtension' + Display hasExtension:'SHAPE' + Display hasExtension:'MIT-SHM' + Display hasExtension:'SGIFullScreenStereo' + " +! + +supportedImageFormats + "return an array with supported image formats; each array entry + is another array, consisting of depth and bitsPerPixel values. + Here, we return a single format only; every graphics device must + support b&w single bit images." + + ^ #( 1 1) "/ depth=1 bitsPerPixel=1 +! + isSlow "return true, if this is a relatively slow device - used to turn off things like popup-shadows" diff -r 13a9d4bafa7e -r 3abcc2ee1641 Image.st --- a/Image.st Thu Sep 21 13:40:25 1995 +0200 +++ b/Image.st Mon Oct 23 18:00:19 1995 +0100 @@ -29,7 +29,7 @@ COPYRIGHT (c) 1991 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libview/Image.st,v 1.41 1995-09-21 11:39:49 claus Exp $ +$Header: /cvs/stx/stx/libview/Image.st,v 1.42 1995-10-23 16:59:09 cg Exp $ '! !Image class methodsFor:'documentation'! @@ -50,7 +50,7 @@ version " -$Header: /cvs/stx/stx/libview/Image.st,v 1.41 1995-09-21 11:39:49 claus Exp $ +$Header: /cvs/stx/stx/libview/Image.st,v 1.42 1995-10-23 16:59:09 cg Exp $ " ! @@ -161,6 +161,7 @@ depth == 2 ifTrue:[^ Depth2Image]. depth == 4 ifTrue:[^ Depth4Image]. depth == 8 ifTrue:[^ Depth8Image]. + depth == 16 ifTrue:[^ Depth16Image]. depth == 24 ifTrue:[^ Depth24Image]. ^ self ! ! @@ -1771,7 +1772,7 @@ ^ self rgbImageAsGreyFormOn:aDevice ]. (visual == #TrueColor) ifTrue:[ - ^ self rgbImageAsTrueFormOn:aDevice + ^ self rgbImageAsTrueColorFormOn:aDevice ]. ^ self rgbImageAsPseudoFormOn:aDevice ! @@ -1857,6 +1858,263 @@ "return a pseudocolor form from the rgb-picture" ^ self subclassResponsibility +! + +rgbImageAsTrueColorFormOn:aDevice + "return a truecolor form from the rgb-picture." + + |bestFormat usedDeviceDepth usedDeviceBitsPerPixel depth + myDepth form imageBits destIndex srcIndex + rightShiftR rightShiftG rightShiftB shiftRed shiftGreen shiftBlue ok| + + bestFormat := self bestSupportedImageFormatFor:aDevice. + usedDeviceDepth := bestFormat at:1. + usedDeviceBitsPerPixel := bestFormat at:2. + + rightShiftR := (8 - aDevice bitsRed). + rightShiftG := (8 - aDevice bitsGreen). + rightShiftB := (8 - aDevice bitsBlue). + + shiftRed := aDevice shiftRed. + shiftGreen := aDevice shiftGreen. + shiftBlue := aDevice shiftBlue. + + myDepth := self bitsPerPixel. + myDepth == usedDeviceBitsPerPixel ifTrue:[ + "/ + "/ first, the trivial case, where the depths match + "/ + imageBits := bytes. + ] ifFalse:[ + "/ + "/ for now, only a few formats are supported + "/ + ((myDepth == 24) and:[usedDeviceBitsPerPixel == 16]) ifTrue:[ + imageBits := ByteArray uninitializedNew:(width * height * 2). + + "/ now, walk over the image and compose 16bit values from the r/g/b triples + + ok := false. +%{ +#ifdef NOTDEF + if (__isSmallInteger(_INST(height)) + && __isSmallInteger(_INST(width)) + && __isSmallInteger(rightShiftR) + && __isSmallInteger(rightShiftG) + && __isSmallInteger(rightShiftB) + && __isSmallInteger(shiftRed) + && __isSmallInteger(shiftGreen) + && __isSmallInteger(shiftBlue) + && __isByteArray(_INST(bytes)) + && __isByteArray(imageBits)) { + int rShRed = __intVal(rightShiftR), + rShGreen = __intVal(rightShiftG), + rShBlue = __intVal(rightShiftB), + lShRed = __intVal(shiftRed), + lShGreen = __intVal(shiftGreen), + lShBlue = __intVal(shiftBlue); + int x, y; + + unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element; + char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element; + + for (y=__intVal(_INST(height)); y > 0; y--) { + for (x=__intVal(_INST(width)); x > 0; x--) { + unsigned r, g, b, v; + + r = srcPtr[0] >> rShRed; + g = srcPtr[1] >> rShGreen; + b = srcPtr[2] >> rShBlue; + v = r << lShRed; + v |= (g << lShGreen); + v |= (b << lShBlue); +#ifdef MSBFIRST + ((short *)dstPtr)[0] = v; +#else + dstPtr[0] = (v>>8) & 0xFF; + dstPtr[1] = (v) & 0xFF; +#endif + dstPtr += 2; + srcPtr += 3; + } + } + ok = true; + } +#endif +%}. + ok ifFalse:[ + "/ this fallback is only executed if type is not + "/ what the primitive expects; for example, if the bytes-instvar + "/ is not a ByteArray + + rightShiftR := rightShiftR negated. + rightShiftG := rightShiftG negated. + rightShiftB := rightShiftB negated. + + destIndex := 1. + srcIndex := 1. + + 0 to:height-1 do:[:y | + 0 to:width-1 do:[:x | + |r g b v| + + r := bytes at:srcIndex. + g := bytes at:(srcIndex + 1). + b := bytes at:(srcIndex + 2). + + r := r bitShift:rightShiftR. + g := g bitShift:rightShiftG. + b := b bitShift:rightShiftB. + + v := r bitShift:shiftRed. + v := v bitOr:(g bitShift:shiftGreen). + v := v bitOr:(b bitShift:shiftBlue). + + imageBits wordAt:destIndex put:v MSB:true. + destIndex := destIndex + 2. + srcIndex := srcIndex + 3. + ] + ] + ] + ] ifFalse:[ + ((myDepth == 24) and:[usedDeviceBitsPerPixel == 32]) ifTrue:[ + imageBits := ByteArray uninitializedNew:(width * height * 4). + + "/ now, walk over the image and compose 32bit values from the r/g/b triples + + ok := false. +%{ +#ifdef NOTDEF + if (__isSmallInteger(_INST(height)) + && __isSmallInteger(_INST(width)) + && __isSmallInteger(rightShiftR) + && __isSmallInteger(rightShiftG) + && __isSmallInteger(rightShiftB) + && __isSmallInteger(shiftRed) + && __isSmallInteger(shiftGreen) + && __isSmallInteger(shiftBlue) + && __isByteArray(_INST(bytes)) + && __isByteArray(imageBits)) { + int rShRed = __intVal(rightShiftR), + rShGreen = __intVal(rightShiftG), + rShBlue = __intVal(rightShiftB), + lShRed = __intVal(shiftRed), + lShGreen = __intVal(shiftGreen), + lShBlue = __intVal(shiftBlue); + int x, y; + + unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element; + char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element; + + if ((rShRed == 0) + && (rShGreen == 0) + && (rShBlue == 0)) { + for (y=__intVal(_INST(height)); y > 0; y--) { + for (x=__intVal(_INST(width)); x > 0; x--) { + unsigned v; + + v = srcPtr[0] << lShRed; + v |= (srcPtr[1] << lShGreen); + v |= (srcPtr[2] << lShBlue); +#ifdef MSBFIRST + ((int *)dstPtr)[0] = v; +#else + dstPtr[0] = (v>>24) & 0xFF; + dstPtr[1] = (v>>16) & 0xFF; + dstPtr[2] = (v>>8) & 0xFF; + dstPtr[3] = (v) & 0xFF; +#endif + dstPtr += 4; + srcPtr += 3; + } + } + } else { + for (y=__intVal(_INST(height)); y > 0; y--) { + for (x=__intVal(_INST(width)); x > 0; x--) { + unsigned r, g, b, v; + + r = srcPtr[0] >> rShRed; + g = srcPtr[1] >> rShGreen; + b = srcPtr[2] >> rShBlue; + v = r << lShRed; + v |= (g << lShGreen); + v |= (b << lShBlue); +#ifdef MSBFIRST + ((int *)dstPtr)[0] = v; +#else + dstPtr[0] = (v>>24) & 0xFF; + dstPtr[1] = (v>>16) & 0xFF; + dstPtr[2] = (v>>8) & 0xFF; + dstPtr[3] = (v) & 0xFF; +#endif + dstPtr += 4; + srcPtr += 3; + } + } + } + ok = true; + } +#endif +%}. + ok ifFalse:[ + "/ this fallback is only executed if type is not + "/ what the primitive expects; for example, if the bytes-instvar + "/ is not a ByteArray + + rightShiftR := rightShiftR negated. + rightShiftG := rightShiftG negated. + rightShiftB := rightShiftB negated. + + destIndex := 1. + srcIndex := 1. + + 0 to:height-1 do:[:y | + 0 to:width-1 do:[:x | + |r g b v| + + r := bytes at:srcIndex. + g := bytes at:(srcIndex + 1). + b := bytes at:(srcIndex + 2). + + r := r bitShift:rightShiftR. + g := g bitShift:rightShiftG. + b := b bitShift:rightShiftB. + + v := r bitShift:shiftRed. + v := v bitOr:(g bitShift:shiftGreen). + v := v bitOr:(b bitShift:shiftBlue). + + imageBits doubleWordAt:destIndex put:v MSB:true. + destIndex := destIndex + 4. + srcIndex := srcIndex + 3. + ] + ] + ] + ]. + ] + ]. + + imageBits isNil ifTrue:[ + 'IMAGE: unimplemented trueColor depth in rgbImageAsTrueColorFormOn:' errorPrintNL. + ^ self rgbImageAsMonoFormOn:aDevice + ]. + + form := Form width:width height:height depth:usedDeviceDepth on:aDevice. + form isNil ifTrue:[ + 'IMAGE: display bitmap creation failed' errorPrintNL. + ^ nil + ]. + form initGC. + + form + copyBitsFrom:imageBits bitsPerPixel:usedDeviceBitsPerPixel depth:usedDeviceDepth + width:width height:height + x:0 y:0 toX:0 y:0. + + ^ form + + "Created: 21.10.1995 / 02:15:18 / cg" + "Modified: 21.10.1995 / 19:30:11 / cg" ! ! !Image methodsFor:'converting palette images'! @@ -1864,7 +2122,9 @@ paletteImageAsFormOn:aDevice "return a device-form for the palette-image receiver" - (aDevice visualType == #StaticGray) ifTrue:[ + |type| + + ((type := aDevice visualType) == #StaticGray) ifTrue:[ (aDevice depth == 8) ifTrue:[ ^ self paletteImageAsGreyFormOn:aDevice ]. @@ -1879,7 +2139,14 @@ ^ self paletteImageAsMonoFormOn:aDevice ]. - ^ self paletteImageAsPseudoFormOn:aDevice + (type == #TrueColor) ifTrue:[ + ^ self paletteImageAsTrueColorFormOn:aDevice + ]. + (type == #PseudoColor) ifTrue:[ + ^ self paletteImageAsPseudoFormOn:aDevice + ]. + "/ dump fallback: every device should implement b&w images ... + ^ self paletteImageAsMonoFormOn:aDevice ! paletteImageAsMonoFormOn:aDevice @@ -1930,6 +2197,203 @@ "return a dithered grey-deviceForm from the palette image." ^ self subclassResponsibility +! + +paletteImageAsTrueColorFormOn:aDevice + "return a true-color device-form for the palette-image receiver." + + |depth myDepth nColors colorValues + scaleRed scaleGreen scaleBlue redShift greenShift blueShift + form imageBits bestFormat usedDeviceDepth usedDeviceBitsPerPixel destIndex ok| + + "/ this is a slow fallback method; this ought to be + "/ redefined in DepthxImage for more performance. + + depth := aDevice depth. + myDepth := self bitsPerPixel. + myDepth > 12 ifTrue:[ + 'IMAGE: depth > 12 not supported' errorPrintNL. + ^ nil + ]. + + "/ gather r/g/b values for all colors in the map ... + + nColors := colorMap size. + + "/ precompute scales to map from 0..100 into devices range + "/ (this may be different for the individual components) + + scaleRed := ((1 bitShift:aDevice bitsRed) - 1) / 100. + scaleGreen := ((1 bitShift:aDevice bitsGreen) - 1) / 100. + scaleBlue := ((1 bitShift:aDevice bitsBlue) - 1) / 100. + redShift := aDevice shiftRed. + greenShift := aDevice shiftGreen. + blueShift := aDevice shiftBlue. + + colorValues := Array uninitializedNew:nColors. + + 1 to:nColors do:[:index | + |clr rv gv bv v| + + clr := colorMap at:index. + clr notNil ifTrue:[ + rv := (clr red * scaleRed) rounded. + gv := (clr green * scaleGreen) rounded. + bv := (clr blue * scaleBlue) rounded. + + v := rv bitShift:redShift. + v := v bitOr:(gv bitShift:greenShift). + v := v bitOr:(bv bitShift:blueShift). + colorValues at:index put:v. +"/ clr print. ' ' print. +"/ rv print. ' ' print. gv print. ' ' print. bv print. ' ' print. +"/ ' -> ' print. v printNL. + + ] + ]. + + bestFormat := self bestSupportedImageFormatFor:aDevice. + usedDeviceDepth := bestFormat at:1. + usedDeviceBitsPerPixel := bestFormat at:2. + + "/ for now, only support some depths + + usedDeviceBitsPerPixel == 16 ifTrue:[ + imageBits := ByteArray uninitializedNew:(width * height * 2). + + "/ now, walk over the image and replace + "/ colorMap indices by color values in the bits array + + ok := false. +%{ +#ifdef NOTDEF + if (__isSmallInteger(_INST(height)) + && __isSmallInteger(_INST(width)) + && __isArray(colorValues) + && __isByteArray(_INST(bytes)) + && (myDepth == __MKSMALLINT(8)) + && __isByteArray(imageBits)) { + int x, y; + + unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element; + char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element; + OBJ *ap = __ArrayInstPtr(colorValues)->a_element; + + for (y=__intVal(_INST(height)); y > 0; y--) { + for (x=__intVal(_INST(width)); x > 0; x--) { + unsigned idx, v; + OBJ clr; + + idx = *srcPtr++; + clr = ap[idx]; + v = __intVal(clr); +#ifdef MSBFIRST + ((short *)dstPtr)[0] = v; +#else + dstPtr[0] = (v>>8) & 0xFF; + dstPtr[1] = (v) & 0xFF; +#endif + dstPtr += 2; + } + } + ok = true; + } +#endif +%}. + ok ifFalse:[ + "/ this fallback is only executed if type is not + "/ what the primitive expects; for example, if the bytes-instvar + "/ is not a ByteArray + destIndex := 1. + 0 to:height-1 do:[:y | + 0 to:width-1 do:[:x | + |colorIndex| + + colorIndex := self valueAtX:x y:y. + imageBits wordAt:destIndex put:(colorValues at:colorIndex + 1) MSB:true. + destIndex := destIndex + 2. + ] + ] + ] + ] ifFalse:[ + usedDeviceBitsPerPixel == 32 ifTrue:[ + imageBits := ByteArray uninitializedNew:(width * height * 4). + + "/ now, walk over the image and replace + "/ colorMap indices by color values in the bits array + + ok := false. +%{ +#ifdef NOTDEF + if (__isSmallInteger(_INST(height)) + && __isSmallInteger(_INST(width)) + && __isArray(colorValues) + && __isByteArray(_INST(bytes)) + && (myDepth == __MKSMALLINT(8)) + && __isByteArray(imageBits)) { + int x, y; + + unsigned char *srcPtr = _ByteArrayInstPtr(_INST(bytes))->ba_element; + char *dstPtr = _ByteArrayInstPtr(imageBits)->ba_element; + OBJ *ap = __ArrayInstPtr(colorValues)->a_element; + + for (y=__intVal(_INST(height)); y > 0; y--) { + for (x=__intVal(_INST(width)); x > 0; x--) { + unsigned idx, v; + OBJ clr; + + idx = *srcPtr++; + clr = ap[idx]; + v = __intVal(clr); +#ifdef MSBFIRST + ((short *)dstPtr)[0] = v; +#else + dstPtr[0] = (v>>24) & 0xFF; + dstPtr[1] = (v>>16) & 0xFF; + dstPtr[2] = (v>>8) & 0xFF; + dstPtr[3] = (v) & 0xFF; +#endif + dstPtr += 4; + } + } + ok = true; + } +#endif +%}. + ok ifFalse:[ + destIndex := 1. + 0 to:height-1 do:[:y | + 0 to:width-1 do:[:x | + |colorIndex| + + colorIndex := self valueAtX:x y:y. + imageBits doubleWordAt:destIndex put:(colorValues at:colorIndex + 1) MSB:true. + destIndex := destIndex + 4. + ] + ] + ] + ] + ]. + + imageBits isNil ifTrue:[ + 'IMAGE: unimplemented trueColor depth in paletteImageAsTrueColorFormOn:' errorPrintNL. + ^ self paletteImageAsMonoFormOn:aDevice + ]. + + form := + form := Form width:width height:height depth:usedDeviceDepth on:aDevice. + form isNil ifTrue:[^ nil]. + form initGC. + + form + copyBitsFrom:imageBits bitsPerPixel:usedDeviceBitsPerPixel depth:usedDeviceDepth + width:width height:height + x:0 y:0 toX:0 y:0. + + ^ form + + "Created: 20.10.1995 / 22:05:10 / cg" + "Modified: 21.10.1995 / 19:30:26 / cg" ! ! !Image methodsFor:'converting greyscale images'! @@ -2001,6 +2465,10 @@ ^ self greyImageAsPseudoFormOn:aDevice ]. + (aDevice visualType == #TrueColor) ifTrue:[ + ^ self greyImageAsTrueColorFormOn:aDevice + ]. + self error:'cannot convert this format'. ^ nil ! @@ -2213,6 +2681,118 @@ x:0 y:0 into:(f id) x:0 y:0 width:width height:height with:(f gcId). ^ f +! + +greyImageAsTrueColorFormOn:aDevice + "return a true-color device-form for the grey-image receiver. + TODO: the pixel loops ought to be implemented as inline primitive code ..." + + |depth myDepth nColors colorValues + scaleDown scaleRed scaleGreen scaleBlue redShift blueShift greenShift + form imageBitsdestIndex + bestFormat usedDeviceDepth usedDeviceBitsPerPixel imageBits destIndex| + + "/ this is a slow fallback method; this ought to be + "/ redefined in DepthxImage for more performance. + + depth := aDevice depth. + myDepth := self depth. + myDepth > 12 ifTrue:[ + self error:'unsupported trueColor depth in greyImageAsTrueColorFormOn:'. + ^ nil + ]. + + "/ compute scale to map from my pixels into devices range + + scaleDown := 1 bitShift:myDepth. + scaleRed := (1 bitShift:aDevice bitsRed). + scaleGreen := (1 bitShift:aDevice bitsGreen). + scaleBlue := (1 bitShift:aDevice bitsBlue). + redShift := aDevice shiftRed. + greenShift := aDevice shiftGreen. + blueShift := aDevice shiftBlue. + + nColors := (1 bitShift:myDepth). + colorValues := Array new:nColors. + 1 to:nColors do:[:i | + |v gv bv rv nv| + + "/ scale down to 0..1 + v := (i-1) / scaleDown. + rv := (v * scaleRed) rounded. + gv := (v * scaleGreen) rounded. + bv := (v * scaleBlue) rounded. + nv := rv bitShift:redShift. + nv := nv bitOr:(gv bitShift:greenShift). + nv := nv bitOr:(bv bitShift:blueShift). + colorValues at:i put:nv + ]. + photometric == #whiteIs0 ifTrue:[ + "/ reverse the order; 0 is brightest + colorValues reverse + ]. + + bestFormat := self bestSupportedImageFormatFor:aDevice. + usedDeviceDepth := bestFormat at:1. + usedDeviceBitsPerPixel := bestFormat at:2. + + "/ for now, only support some depths + + usedDeviceBitsPerPixel == 16 ifTrue:[ + imageBits := ByteArray uninitializedNew:(width * height * 2). + + "/ now, walk over the image and replace + "/ colorMap indices by color values in the bits array + + destIndex := 1. + 0 to:height-1 do:[:y | + 0 to:width-1 do:[:x | + |greyValue| + + greyValue := self valueAtX:x y:y. + imageBits wordAt:destIndex put:(colorValues at:greyValue + 1) MSB:true. + destIndex := destIndex + 2. + ] + ] + ] ifFalse:[ + usedDeviceBitsPerPixel == 32 ifTrue:[ + imageBits := ByteArray uninitializedNew:(width * height * 4). + + "/ now, walk over the image and replace + "/ colorMap indices by color values in the bits array + + destIndex := 1. + 0 to:height-1 do:[:y | + 0 to:width-1 do:[:x | + |greyValue| + + greyValue := self valueAtX:x y:y. + imageBits doubleWordAt:destIndex put:(colorValues at:greyValue + 1) MSB:true. + destIndex := destIndex + 4. + ] + ] + ] + ]. + + imageBits isNil ifTrue:[ + 'IMAGE: unimplemented trueColor depth on greyImageAsTrueColorFormOn:' errorPrintNL. + ^ self paletteImageAsMonoFormOn:aDevice + ]. + + form := + form := Form width:width height:height depth:usedDeviceDepth on:aDevice. + form isNil ifTrue:[^ nil]. + form initGC. + + form + copyBitsFrom:imageBits bitsPerPixel:usedDeviceBitsPerPixel depth:usedDeviceDepth + width:width height:height + x:0 y:0 toX:0 y:0. + + ^ form + + "Created: 20.10.1995 / 22:05:10 / cg" + "Modified: 21.10.1995 / 19:30:37 / cg" ! ! !Image methodsFor:'image manipulations'! @@ -2700,6 +3280,59 @@ can only magnify 1,2,4,8 and 24 bit-per-pixel images. But this is done fast." ^ self subclassResponsibility +! + +bestSupportedImageFormatFor:aDevice + "scan through the image formats as supported by aDevice, + and return the best to use when the receiver is to be represented + on it. The best format is the one with the same number or more bits per + pixel. Here, the smallest format found is taken." + + |bestDeviceDepth bestDeviceBitsPerPixel myDepth maxDepth maxBitsPerPixel| + + myDepth := self bitsPerPixel. + maxBitsPerPixel := 0. + + aDevice supportedImageFormats do:[:entry | + |deviceImageDepth deviceImageBitsPerPixel| + + deviceImageDepth := entry at:1. + deviceImageBitsPerPixel := entry at:2. + deviceImageBitsPerPixel > maxBitsPerPixel ifTrue:[ + maxBitsPerPixel := deviceImageBitsPerPixel. + maxDepth := deviceImageDepth. + ]. + deviceImageDepth >= myDepth ifTrue:[ + deviceImageDepth == myDepth ifTrue:[ + "/ take the better one ... + (bestDeviceDepth isNil + or:[(bestDeviceBitsPerPixel ~~ bestDeviceDepth) + and:[deviceImageDepth == deviceImageBitsPerPixel]]) ifTrue:[ + bestDeviceDepth := deviceImageDepth. + bestDeviceBitsPerPixel := deviceImageBitsPerPixel. + ] + ] ifFalse:[ + "/ take the next-larger depth + (bestDeviceDepth isNil + or:[deviceImageBitsPerPixel < bestDeviceBitsPerPixel]) ifTrue:[ + bestDeviceDepth := deviceImageDepth. + bestDeviceBitsPerPixel := deviceImageBitsPerPixel. + ] + ] + ]. + ]. + bestDeviceDepth isNil ifTrue:[ + maxBitsPerPixel == 0 ifTrue:[ + bestDeviceDepth := bestDeviceBitsPerPixel := aDevice depth. + ] ifFalse:[ + bestDeviceDepth := maxDepth. + bestDeviceBitsPerPixel := maxBitsPerPixel + ] + ]. + ^ Array with:bestDeviceDepth with:bestDeviceBitsPerPixel + + "Created: 21.10.1995 / 02:17:48 / cg" + "Modified: 21.10.1995 / 03:52:45 / cg" ! ! !Image methodsFor: 'binary storage'! diff -r 13a9d4bafa7e -r 3abcc2ee1641 Make.proto --- a/Make.proto Thu Sep 21 13:40:25 1995 +0200 +++ b/Make.proto Mon Oct 23 18:00:19 1995 +0100 @@ -1,4 +1,4 @@ -# $Header: /cvs/stx/stx/libview/Make.proto,v 1.42 1995-09-12 10:47:30 claus Exp $ +# $Header: /cvs/stx/stx/libview/Make.proto,v 1.43 1995-10-23 16:59:57 cg Exp $ # # -------------- no need to change anything below ---------- @@ -15,7 +15,7 @@ RCSSOURCES=*.st Make.proto styles/*.style resources/*.rs -all:: abbrev.stc objs $(NOTINLIBOBJS) classList.stc $(OBJTARGET) $(LIBVIEW_MORE) GENLIBLIST +all:: abbrev.stc objs $(NOTINLIBOBJS) classList.stc $(OBJTARGET) $(LIBVIEW_EXTRA_TARGETS) GENLIBLIST # # although all files are compiled here, @@ -83,10 +83,11 @@ WGroup.$(O) \ KeybdFwd.$(O) \ KeybdMap.$(O) \ - ImageRdr.$(O) \ + ImageRdr.$(O) \ RsrcPack.$(O) \ ViewStyle.$(O) \ - $(MOREOBJS) + $(MOREOBJS) \ + Depth16Image.$(O) smalllib: @-rm classList.stc @@ -153,6 +154,10 @@ SimpleView.$(O): $(MAKE) $(BIG_STFILE_RULE) BIG_FILE=SimpleView CC=$(CC) +# +# on my 320H, do not compile DeviceWorkstation with -O2; +# compiler is running out of space ... +# AIX: $(MAKE) DevWorkst.o $(MAKE) OPT=-O2 @@ -191,6 +196,7 @@ Depth2Image.o: Depth2Image.st $(STCHDR) ../include/Image.H ../include/Object.H Depth4Image.o: Depth4Image.st $(STCHDR) ../include/Image.H ../include/Object.H Depth8Image.o: Depth8Image.st $(STCHDR) ../include/Image.H ../include/Object.H +Depth16Image.o: Depth16Image.st $(STCHDR) ../include/Image.H ../include/Object.H DevDraw.o: DevDraw.st $(STCHDR) ../include/DMedium.H ../include/GC.H ../include/Object.H DevFormH.o: DevFormH.st $(STCHDR) ../include/DevHandle.H ../include/Object.H DevHandle.o: DevHandle.st $(STCHDR) ../include/Object.H diff -r 13a9d4bafa7e -r 3abcc2ee1641 NXWorkst.st --- a/NXWorkst.st Thu Sep 21 13:40:25 1995 +0200 +++ b/NXWorkst.st Mon Oct 23 18:00:19 1995 +0100 @@ -30,16 +30,24 @@ All non-monochrome stuff is untested (I only have a monochroome station) -$Header: /cvs/stx/stx/libview/Attic/NXWorkst.st,v 1.11 1995-07-23 02:27:49 claus Exp $ +$Header: /cvs/stx/stx/libview/Attic/NXWorkst.st,v 1.12 1995-10-23 16:59:17 cg Exp $ written spring 92 by claus '! +!NeXTWorkstation primitiveDefinitions! + %{ #include #include #include +%} +! ! + +!NeXTWorkstation primitiveFunctions! + +%{ /* * cannot include objc stuff - too many name conflicts */ @@ -62,6 +70,7 @@ } %} +! ! !NeXTWorkstation class methodsFor:'initialization'! diff -r 13a9d4bafa7e -r 3abcc2ee1641 NeXTWorkstation.st --- a/NeXTWorkstation.st Thu Sep 21 13:40:25 1995 +0200 +++ b/NeXTWorkstation.st Mon Oct 23 18:00:19 1995 +0100 @@ -30,16 +30,24 @@ All non-monochrome stuff is untested (I only have a monochroome station) -$Header: /cvs/stx/stx/libview/NeXTWorkstation.st,v 1.11 1995-07-23 02:27:49 claus Exp $ +$Header: /cvs/stx/stx/libview/NeXTWorkstation.st,v 1.12 1995-10-23 16:59:17 cg Exp $ written spring 92 by claus '! +!NeXTWorkstation primitiveDefinitions! + %{ #include #include #include +%} +! ! + +!NeXTWorkstation primitiveFunctions! + +%{ /* * cannot include objc stuff - too many name conflicts */ @@ -62,6 +70,7 @@ } %} +! ! !NeXTWorkstation class methodsFor:'initialization'! diff -r 13a9d4bafa7e -r 3abcc2ee1641 SimpleView.st --- a/SimpleView.st Thu Sep 21 13:40:25 1995 +0200 +++ b/SimpleView.st Mon Oct 23 18:00:19 1995 +0100 @@ -44,7 +44,7 @@ COPYRIGHT (c) 1989 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.22 1995-09-21 11:40:25 claus Exp $ +$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.23 1995-10-23 16:59:24 cg Exp $ '! !SimpleView class methodsFor:'documentation'! @@ -65,7 +65,7 @@ version " -$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.22 1995-09-21 11:40:25 claus Exp $ +$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.23 1995-10-23 16:59:24 cg Exp $ " ! @@ -1172,6 +1172,47 @@ ] ! +beInvisible + self hidden:true. + realized ifTrue:[ + self unrealize + ] + + "Created: 22.9.1995 / 15:29:01 / claus" +! + +beVisible + self hidden:false. + realized ifFalse:[ + self realize + ] + + " + |top topFrame check list| + + top := StandardSystemView new. + top extent:150@400. + topFrame := VerticalPanelView origin:0.0@0.0 corner:1.0@0.4 in:top. + topFrame horizontalLayout:#leftSpace. + + topFrame add:(check := CheckBox label:'hidden'). + check pressAction:[list beInvisible]. + check releaseAction:[list beVisible]. + + list := ScrollableView for:SelectionInListView. + list origin:0.0@0.4 corner:1.0@1.0. + list list:#('foo' 'bar' 'baz'). + top add:list. + + check turnOn. + list beInvisible. + + top open + " + + "Created: 22.9.1995 / 15:50:33 / claus" +! + hidden:aBoolean "if the argument is true, the receiver view will not be realized automatically when superview is realized" @@ -1372,6 +1413,14 @@ "set the window group." windowGroup := aGroup +! + +aspect:aspectSymbol + "ST-80 style updating: If a views aspectSymbol is nonNil, + it will respond to changes of this aspect from the model. + Alias for aspectMessage: for ST-80 compatibility." + + self aspectMessage:aspectSymbol ! ! !SimpleView methodsFor:'event handling'! @@ -1489,6 +1538,16 @@ ] ! +subViewChangedSize + "some subview has changed its size; we are not interrested + in that here, but some geometry managers redefine this, to reorganize + components if that happens." + + ^ self + + "Created: 22.9.1995 / 14:44:59 / claus" +! + configureX:x y:y width:newWidth height:newHeight "my size has changed by window manager action" @@ -1728,6 +1787,9 @@ ] ]. self changed:#sizeOfView with:how. + superView notNil ifTrue:[ + superView subViewChangedSize + ] ! reparented diff -r 13a9d4bafa7e -r 3abcc2ee1641 StandardSystemView.st --- a/StandardSystemView.st Thu Sep 21 13:40:25 1995 +0200 +++ b/StandardSystemView.st Mon Oct 23 18:00:19 1995 +0100 @@ -23,7 +23,7 @@ COPYRIGHT (c) 1989 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.33 1995-09-10 19:35:53 claus Exp $ +$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.34 1995-10-23 16:59:29 cg Exp $ '! !StandardSystemView class methodsFor:'documentation'! @@ -44,7 +44,7 @@ version " -$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.33 1995-09-10 19:35:53 claus Exp $ +$Header: /cvs/stx/stx/libview/StandardSystemView.st,v 1.34 1995-10-23 16:59:29 cg Exp $ " ! @@ -464,6 +464,20 @@ deviceIcon := deviceIcon on:device ]. ^ deviceIcon +! + +setWindowGroupFromApplication + |win| + + windowGroup isNil ifTrue:[ + application notNil ifTrue:[ + (win := application window) notNil ifTrue:[ + windowGroup := win windowGroup. + ] + ] + ]. + + "Created: 22.9.1995 / 17:40:36 / claus" ! ! !StandardSystemView methodsFor:'realization'! @@ -844,6 +858,20 @@ This is new protocol for ST-80 compatibility and not yet fully supported" application := anApplicationModel +! + +bePartner + self setWindowGroupFromApplication. + super bePartner. + + "Created: 22.9.1995 / 17:40:15 / claus" +! + +beSlave + self setWindowGroupFromApplication. + super beSlave. + + "Created: 22.9.1995 / 17:40:15 / claus" ! ! !StandardSystemView methodsFor:'event handling'! diff -r 13a9d4bafa7e -r 3abcc2ee1641 StdSysV.st --- a/StdSysV.st Thu Sep 21 13:40:25 1995 +0200 +++ b/StdSysV.st Mon Oct 23 18:00:19 1995 +0100 @@ -23,7 +23,7 @@ COPYRIGHT (c) 1989 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libview/Attic/StdSysV.st,v 1.33 1995-09-10 19:35:53 claus Exp $ +$Header: /cvs/stx/stx/libview/Attic/StdSysV.st,v 1.34 1995-10-23 16:59:29 cg Exp $ '! !StandardSystemView class methodsFor:'documentation'! @@ -44,7 +44,7 @@ version " -$Header: /cvs/stx/stx/libview/Attic/StdSysV.st,v 1.33 1995-09-10 19:35:53 claus Exp $ +$Header: /cvs/stx/stx/libview/Attic/StdSysV.st,v 1.34 1995-10-23 16:59:29 cg Exp $ " ! @@ -464,6 +464,20 @@ deviceIcon := deviceIcon on:device ]. ^ deviceIcon +! + +setWindowGroupFromApplication + |win| + + windowGroup isNil ifTrue:[ + application notNil ifTrue:[ + (win := application window) notNil ifTrue:[ + windowGroup := win windowGroup. + ] + ] + ]. + + "Created: 22.9.1995 / 17:40:36 / claus" ! ! !StandardSystemView methodsFor:'realization'! @@ -844,6 +858,20 @@ This is new protocol for ST-80 compatibility and not yet fully supported" application := anApplicationModel +! + +bePartner + self setWindowGroupFromApplication. + super bePartner. + + "Created: 22.9.1995 / 17:40:15 / claus" +! + +beSlave + self setWindowGroupFromApplication. + super beSlave. + + "Created: 22.9.1995 / 17:40:15 / claus" ! ! !StandardSystemView methodsFor:'event handling'! diff -r 13a9d4bafa7e -r 3abcc2ee1641 View.st --- a/View.st Thu Sep 21 13:40:25 1995 +0200 +++ b/View.st Mon Oct 23 18:00:19 1995 +0100 @@ -23,7 +23,7 @@ COPYRIGHT (c) 1995 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libview/View.st,v 1.45 1995-08-24 03:05:35 claus Exp $ +$Header: /cvs/stx/stx/libview/View.st,v 1.46 1995-10-23 16:59:31 cg Exp $ '! !View class methodsFor:'documentation'! @@ -44,7 +44,7 @@ version " -$Header: /cvs/stx/stx/libview/View.st,v 1.45 1995-08-24 03:05:35 claus Exp $ +$Header: /cvs/stx/stx/libview/View.st,v 1.46 1995-10-23 16:59:31 cg Exp $ " ! @@ -325,14 +325,6 @@ self changeMessage:changeSymbol ! -aspect:aspectSymbol - "ST-80 style updating: If a views aspectSymbol is nonNil, - it will respond to changes of this aspect from the model. - Alias for aspectMessage: for ST-80 compatibility." - - self aspectMessage:aspectSymbol -! - aspect "Return the aspect used with changes from/to the model" diff -r 13a9d4bafa7e -r 3abcc2ee1641 XWorkstat.st --- a/XWorkstat.st Thu Sep 21 13:40:25 1995 +0200 +++ b/XWorkstat.st Mon Oct 23 18:00:19 1995 +0100 @@ -16,7 +16,7 @@ hasDPSExtension hasMbufExtension hasXVideoExtension hasSaveUnder hasPEXExtension hasImageExtension hasInputExtension ignoreBackingStore - blackpixel whitepixel redMask greenMask blueMask + blackpixel whitepixel protocolsAtom deleteWindowAtom saveYourselfAtom quitAppAtom primaryAtom secondaryAtom cutBuffer0Atom @@ -36,7 +36,7 @@ COPYRIGHT (c) 1989 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.61 1995-09-19 14:59:18 claus Exp $ +$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.62 1995-10-23 16:59:47 cg Exp $ '! !XWorkstation class methodsFor:'documentation'! @@ -57,7 +57,7 @@ version " -$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.61 1995-09-19 14:59:18 claus Exp $ +$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.62 1995-10-23 16:59:47 cg Exp $ " ! @@ -524,6 +524,7 @@ int faxEventBase, faxErrorBase; char *type, *nm; int dummy; + int mask, shift, nBits; if (ISCONNECTED) { BEGIN_INTERRUPTSBLOCKED @@ -664,6 +665,52 @@ _INST(redMask) = _MKSMALLINT(visual->red_mask); _INST(greenMask) = _MKSMALLINT(visual->green_mask); _INST(blueMask) = _MKSMALLINT(visual->blue_mask); + switch (visual->class) { + case TrueColor: + /* extract number of bits and shift counts */ + mask = visual->red_mask; + shift = 0; + while (mask && ((mask & 1) == 0)) { + mask >>= 1; + shift++; + } + _INST(redShift) = __MKSMALLINT(shift); + nBits = 0; + while (mask) { + mask >>= 1; + nBits++; + } + _INST(bitsRed) = __MKSMALLINT(nBits); + + mask = visual->green_mask; + shift = 0; + while (mask && ((mask & 1) == 0)) { + mask >>= 1; + shift++; + } + _INST(greenShift) = __MKSMALLINT(shift); + nBits = 0; + while (mask) { + mask >>= 1; + nBits++; + } + _INST(bitsGreen) = __MKSMALLINT(nBits); + + mask = visual->blue_mask; + shift = 0; + while (mask && ((mask & 1) == 0)) { + mask >>= 1; + shift++; + } + _INST(blueShift) = __MKSMALLINT(shift); + nBits = 0; + while (mask) { + mask >>= 1; + nBits++; + } + _INST(bitsBlue) = __MKSMALLINT(nBits); + break; + } #ifndef XA_PRIMARY _INST(primaryAtom) = MKOBJ( XInternAtom(dpy, "PRIMARY", True) ); @@ -3089,21 +3136,20 @@ any font to be aquired (even those not conforming to standard naming conventions, such as cursor, fixed or k14)" -%{ /* NOCONTEXT */ +%{ /* UNLIMITEDSTACK */ + /* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ XFontStruct *newFont; if (ISCONNECTED) { if (__isString(aFontName) || __isSymbol(aFontName)) { BEGIN_INTERRUPTSBLOCKED - newFont = XLoadQueryFont(myDpy, (char *)_stringVal(aFontName)); + newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); END_INTERRUPTSBLOCKED RETURN ( newFont ? MKOBJ(newFont) : nil ); } } -%} -. - self primitiveFailed. +%}. ^ nil ! @@ -3807,6 +3853,12 @@ unsigned long color; int screen = _intVal(_INST(screen)); +#ifdef LATER + if (_INST(visualType) == @symbol(TrueColor)) { + /* no need to do anything on TrueColor displays ... */ + RETURN (self); + } +#endif if (__isSmallInteger(colorIndex) && ISCONNECTED) { color = (long) _intVal(colorIndex); BEGIN_INTERRUPTSBLOCKED @@ -5342,7 +5394,7 @@ %{ GC gc = _GCVal(aGCId); Window win = _WindowVal(aDrawableId); - extern OBJ Point; + extern OBJ Point, __AT_(); OBJ point, x, y; int i, num; XPoint *points; @@ -5361,7 +5413,7 @@ points = qPoints; for (i=0; ired_mask); _INST(greenMask) = _MKSMALLINT(visual->green_mask); _INST(blueMask) = _MKSMALLINT(visual->blue_mask); + switch (visual->class) { + case TrueColor: + /* extract number of bits and shift counts */ + mask = visual->red_mask; + shift = 0; + while (mask && ((mask & 1) == 0)) { + mask >>= 1; + shift++; + } + _INST(redShift) = __MKSMALLINT(shift); + nBits = 0; + while (mask) { + mask >>= 1; + nBits++; + } + _INST(bitsRed) = __MKSMALLINT(nBits); + + mask = visual->green_mask; + shift = 0; + while (mask && ((mask & 1) == 0)) { + mask >>= 1; + shift++; + } + _INST(greenShift) = __MKSMALLINT(shift); + nBits = 0; + while (mask) { + mask >>= 1; + nBits++; + } + _INST(bitsGreen) = __MKSMALLINT(nBits); + + mask = visual->blue_mask; + shift = 0; + while (mask && ((mask & 1) == 0)) { + mask >>= 1; + shift++; + } + _INST(blueShift) = __MKSMALLINT(shift); + nBits = 0; + while (mask) { + mask >>= 1; + nBits++; + } + _INST(bitsBlue) = __MKSMALLINT(nBits); + break; + } #ifndef XA_PRIMARY _INST(primaryAtom) = MKOBJ( XInternAtom(dpy, "PRIMARY", True) ); @@ -3089,21 +3136,20 @@ any font to be aquired (even those not conforming to standard naming conventions, such as cursor, fixed or k14)" -%{ /* NOCONTEXT */ +%{ /* UNLIMITEDSTACK */ + /* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */ XFontStruct *newFont; if (ISCONNECTED) { if (__isString(aFontName) || __isSymbol(aFontName)) { BEGIN_INTERRUPTSBLOCKED - newFont = XLoadQueryFont(myDpy, (char *)_stringVal(aFontName)); + newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName)); END_INTERRUPTSBLOCKED RETURN ( newFont ? MKOBJ(newFont) : nil ); } } -%} -. - self primitiveFailed. +%}. ^ nil ! @@ -3807,6 +3853,12 @@ unsigned long color; int screen = _intVal(_INST(screen)); +#ifdef LATER + if (_INST(visualType) == @symbol(TrueColor)) { + /* no need to do anything on TrueColor displays ... */ + RETURN (self); + } +#endif if (__isSmallInteger(colorIndex) && ISCONNECTED) { color = (long) _intVal(colorIndex); BEGIN_INTERRUPTSBLOCKED @@ -5342,7 +5394,7 @@ %{ GC gc = _GCVal(aGCId); Window win = _WindowVal(aDrawableId); - extern OBJ Point; + extern OBJ Point, __AT_(); OBJ point, x, y; int i, num; XPoint *points; @@ -5361,7 +5413,7 @@ points = qPoints; for (i=0; i