3797 "Created: / 30-10-2018 / 21:06:49 / Claus Gittinger" |
3797 "Created: / 30-10-2018 / 21:06:49 / Claus Gittinger" |
3798 ! ! |
3798 ! ! |
3799 |
3799 |
3800 !XWorkstation methodsFor:'drawing'! |
3800 !XWorkstation methodsFor:'drawing'! |
3801 |
3801 |
|
3802 _displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
|
3803 "draw a line. If the coordinates are not integers, an error is triggered." |
|
3804 |
|
3805 <context: #return> |
|
3806 |
|
3807 operationsUntilFlush notNil ifTrue:[ |
|
3808 operationsUntilFlush <= 0 ifTrue:[ |
|
3809 self flush. |
|
3810 ] ifFalse:[ |
|
3811 operationsUntilFlush := operationsUntilFlush - 1. |
|
3812 ]. |
|
3813 ]. |
|
3814 %{ |
|
3815 |
|
3816 GC gc; |
|
3817 Window win; |
|
3818 |
|
3819 if (ISCONNECTED |
|
3820 && __isExternalAddress(aGCId) |
|
3821 && __isExternalAddress(aDrawableId) |
|
3822 && __bothSmallInteger(x0, y0) |
|
3823 && __bothSmallInteger(x1, y1)) { |
|
3824 Display *dpy = myDpy; |
|
3825 int ix0, iy0, ix1, iy1; |
|
3826 gc = __GCVal(aGCId); |
|
3827 win = __WindowVal(aDrawableId); |
|
3828 |
|
3829 ix0 = __intVal(x0); |
|
3830 iy0 = __intVal(y0); |
|
3831 ix1 = __intVal(x1); |
|
3832 iy1 = __intVal(y1); |
|
3833 |
|
3834 /* attention: coordinates in X are shorts and wrap; clamp here. */ |
|
3835 if (ix0 > 0x7FFF) ix0 = 0x7FFF; |
|
3836 else if (ix0 < -0x8000) ix0 = -0x8000; |
|
3837 if (iy0 > 0x7FFF) iy0 = 0x7FFF; |
|
3838 else if (iy0 < -0x8000) iy0 = -0x8000; |
|
3839 if (ix1 > 0x7FFF) ix1 = 0x7FFF; |
|
3840 else if (ix1 < -0x8000) ix1 = -0x8000; |
|
3841 if (iy1 > 0x7FFF) iy1 = 0x7FFF; |
|
3842 else if (iy1 < -0x8000) iy1 = -0x8000; |
|
3843 |
|
3844 ENTER_XLIB(); |
|
3845 if ((ix0 == ix1) && (iy0 == iy1)) { |
|
3846 /* little bit shorter X-lib message (better with slow connections...) */ |
|
3847 XDrawPoint(dpy, win, gc, ix0, iy0); |
|
3848 } else { |
|
3849 XDrawLine(dpy, win, gc, ix0, iy0, ix1, iy1); |
|
3850 } |
|
3851 LEAVE_XLIB(); |
|
3852 RETURN ( self ); |
|
3853 } |
|
3854 %}. |
|
3855 "badGC, badDrawable or coordinates not integer" |
|
3856 self primitiveFailedOrClosedConnection |
|
3857 ! |
|
3858 |
|
3859 _fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
3860 "fill a rectangle. |
|
3861 If any coordinate is not integer, an error is triggered." |
|
3862 |
|
3863 <context: #return> |
|
3864 |
|
3865 operationsUntilFlush notNil ifTrue:[ |
|
3866 operationsUntilFlush <= 0 ifTrue:[ |
|
3867 self flush. |
|
3868 ] ifFalse:[ |
|
3869 operationsUntilFlush := operationsUntilFlush - 1. |
|
3870 ]. |
|
3871 ]. |
|
3872 %{ |
|
3873 |
|
3874 int w, h; |
|
3875 |
|
3876 if (ISCONNECTED |
|
3877 && __isExternalAddress(aGCId) |
|
3878 && __isExternalAddress(aDrawableId) |
|
3879 && __bothSmallInteger(x, y) |
|
3880 && __bothSmallInteger(width, height)) { |
|
3881 w = __intVal(width); |
|
3882 h = __intVal(height); |
|
3883 /* |
|
3884 * need this check here: some servers simply dump core with bad args |
|
3885 */ |
|
3886 if ((w >= 0) && (h >= 0)) { |
|
3887 ENTER_XLIB(); |
|
3888 XFillRectangle(myDpy, |
|
3889 __DrawableVal(aDrawableId), __GCVal(aGCId), |
|
3890 __intVal(x), __intVal(y), w, h); |
|
3891 LEAVE_XLIB(); |
|
3892 } |
|
3893 RETURN ( self ); |
|
3894 } |
|
3895 %}. |
|
3896 "badGC, badDrawable or coordinates not integer" |
|
3897 self primitiveFailedOrClosedConnection |
|
3898 ! |
|
3899 |
3802 clearRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
3900 clearRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
3803 "clear (fill with background) a rectangle. If any coordinate is not integer, an error is triggered." |
3901 "clear (fill with background) a rectangle. If any coordinate is not integer, an error is triggered." |
3804 |
3902 |
3805 <context: #return> |
3903 <context: #return> |
3806 |
3904 |
4148 RETURN ( self ); |
4246 RETURN ( self ); |
4149 } |
4247 } |
4150 } |
4248 } |
4151 %}. |
4249 %}. |
4152 self _displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
4250 self _displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
4153 ! |
|
4154 |
|
4155 _displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId |
|
4156 "draw a line. If the coordinates are not integers, an error is triggered." |
|
4157 |
|
4158 <context: #return> |
|
4159 |
|
4160 operationsUntilFlush notNil ifTrue:[ |
|
4161 operationsUntilFlush <= 0 ifTrue:[ |
|
4162 self flush. |
|
4163 ] ifFalse:[ |
|
4164 operationsUntilFlush := operationsUntilFlush - 1. |
|
4165 ]. |
|
4166 ]. |
|
4167 %{ |
|
4168 |
|
4169 GC gc; |
|
4170 Window win; |
|
4171 |
|
4172 if (ISCONNECTED |
|
4173 && __isExternalAddress(aGCId) |
|
4174 && __isExternalAddress(aDrawableId) |
|
4175 && __bothSmallInteger(x0, y0) |
|
4176 && __bothSmallInteger(x1, y1)) { |
|
4177 Display *dpy = myDpy; |
|
4178 int ix0, iy0, ix1, iy1; |
|
4179 gc = __GCVal(aGCId); |
|
4180 win = __WindowVal(aDrawableId); |
|
4181 |
|
4182 ix0 = __intVal(x0); |
|
4183 iy0 = __intVal(y0); |
|
4184 ix1 = __intVal(x1); |
|
4185 iy1 = __intVal(y1); |
|
4186 |
|
4187 /* attention: coordinates in X are shorts and wrap; clamp here. */ |
|
4188 if (ix0 > 0x7FFF) ix0 = 0x7FFF; |
|
4189 else if (ix0 < -0x8000) ix0 = -0x8000; |
|
4190 if (iy0 > 0x7FFF) iy0 = 0x7FFF; |
|
4191 else if (iy0 < -0x8000) iy0 = -0x8000; |
|
4192 if (ix1 > 0x7FFF) ix1 = 0x7FFF; |
|
4193 else if (ix1 < -0x8000) ix1 = -0x8000; |
|
4194 if (iy1 > 0x7FFF) iy1 = 0x7FFF; |
|
4195 else if (iy1 < -0x8000) iy1 = -0x8000; |
|
4196 |
|
4197 ENTER_XLIB(); |
|
4198 if ((ix0 == ix1) && (iy0 == iy1)) { |
|
4199 /* little bit shorter X-lib message (better with slow connections...) */ |
|
4200 XDrawPoint(dpy, win, gc, ix0, iy0); |
|
4201 } else { |
|
4202 XDrawLine(dpy, win, gc, ix0, iy0, ix1, iy1); |
|
4203 } |
|
4204 LEAVE_XLIB(); |
|
4205 RETURN ( self ); |
|
4206 } |
|
4207 %}. |
|
4208 "badGC, badDrawable or coordinates not integer" |
|
4209 self primitiveFailedOrClosedConnection |
|
4210 ! |
4251 ! |
4211 |
4252 |
4212 displayLinesFromX:startX step:stepX yValues:yValues scaleY:scaleY transY:transY in:aDrawableId with:aGCId |
4253 displayLinesFromX:startX step:stepX yValues:yValues scaleY:scaleY transY:transY in:aDrawableId with:aGCId |
4213 "draw a polygon starting at x; the y values derives from the collection yValues. |
4254 "draw a polygon starting at x; the y values derives from the collection yValues. |
4214 The associated x is a multiple of step. Each y value will be scaled and translated |
4255 The associated x is a multiple of step. Each y value will be scaled and translated |
5195 RETURN ( self ); |
5236 RETURN ( self ); |
5196 } |
5237 } |
5197 } |
5238 } |
5198 %}. |
5239 %}. |
5199 self _fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
5240 self _fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
5200 ! |
|
5201 |
|
5202 _fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId |
|
5203 "fill a rectangle. |
|
5204 If any coordinate is not integer, an error is triggered." |
|
5205 |
|
5206 <context: #return> |
|
5207 |
|
5208 operationsUntilFlush notNil ifTrue:[ |
|
5209 operationsUntilFlush <= 0 ifTrue:[ |
|
5210 self flush. |
|
5211 ] ifFalse:[ |
|
5212 operationsUntilFlush := operationsUntilFlush - 1. |
|
5213 ]. |
|
5214 ]. |
|
5215 %{ |
|
5216 |
|
5217 int w, h; |
|
5218 |
|
5219 if (ISCONNECTED |
|
5220 && __isExternalAddress(aGCId) |
|
5221 && __isExternalAddress(aDrawableId) |
|
5222 && __bothSmallInteger(x, y) |
|
5223 && __bothSmallInteger(width, height)) { |
|
5224 w = __intVal(width); |
|
5225 h = __intVal(height); |
|
5226 /* |
|
5227 * need this check here: some servers simply dump core with bad args |
|
5228 */ |
|
5229 if ((w >= 0) && (h >= 0)) { |
|
5230 ENTER_XLIB(); |
|
5231 XFillRectangle(myDpy, |
|
5232 __DrawableVal(aDrawableId), __GCVal(aGCId), |
|
5233 __intVal(x), __intVal(y), w, h); |
|
5234 LEAVE_XLIB(); |
|
5235 } |
|
5236 RETURN ( self ); |
|
5237 } |
|
5238 %}. |
|
5239 "badGC, badDrawable or coordinates not integer" |
|
5240 self primitiveFailedOrClosedConnection |
|
5241 ! |
5241 ! |
5242 |
5242 |
5243 primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
5243 primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth |
5244 msb:msb masks:maskArray padding:bitPadding |
5244 msb:msb masks:maskArray padding:bitPadding |
5245 extent:imageExtent sourceOrigin:srcOrg |
5245 extent:imageExtent sourceOrigin:srcOrg |
8035 "Modified: 4.7.1996 / 11:38:47 / stefan" |
8035 "Modified: 4.7.1996 / 11:38:47 / stefan" |
8036 "Modified: 10.4.1997 / 19:20:06 / cg" |
8036 "Modified: 10.4.1997 / 19:20:06 / cg" |
8037 ! |
8037 ! |
8038 |
8038 |
8039 getFontWithFoundry:foundry family:family weight:weight |
8039 getFontWithFoundry:foundry family:family weight:weight |
8040 slant:slant spacing:spc pixelSize:pSize size:size |
8040 slant:slant spacing:spc pixelSize:pSize size:size |
8041 encoding:encoding |
8041 encoding:encoding |
8042 |
8042 |
8043 "get the specified font, if not available, return nil. |
8043 "get the specified font, if not available, return nil. |
8044 Individual attributes can be left empty (i.e. '') or nil to match any. |
8044 Individual attributes can be left empty (i.e. '') or nil to match any. |
8045 |
8045 |
8046 foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
8046 foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
8057 foundryMatch familyMatch weightMatch slantMatch spcMatch |
8057 foundryMatch familyMatch weightMatch slantMatch spcMatch |
8058 pSizeMatch encodingMatch| |
8058 pSizeMatch encodingMatch| |
8059 |
8059 |
8060 "this works only on 'Release >= 3' - X-servers" |
8060 "this works only on 'Release >= 3' - X-servers" |
8061 "name is: |
8061 "name is: |
8062 -foundry-family -weight -slant- |
8062 -foundry-family -weight -slant- |
8063 sony helvetica bold r |
8063 sony helvetica bold r |
8064 adobe courier medium i |
8064 adobe courier medium i |
8065 msic fixed o |
8065 msic fixed o |
8066 ... ... |
8066 ... ... |
8067 " |
8067 " |
8068 |
8068 |
8069 size isNil ifTrue:[ |
8069 size isNil ifTrue:[ |
8070 sizeMatch := '*' |
8070 sizeMatch := '*' |
8071 ] ifFalse:[ |
8071 ] ifFalse:[ |
8072 sizeMatch := size printString , '0' |
8072 sizeMatch := size printString , '0' |
8073 ]. |
8073 ]. |
8074 foundry isNil ifTrue:[ |
8074 foundryMatch := foundry ? '*'. |
8075 foundryMatch := '*' |
8075 familyMatch := family ? '*'. |
|
8076 weightMatch := weight ? '*'. |
|
8077 slantMatch := slant ? '*'. |
|
8078 spcMatch := spc ? '*'. |
|
8079 pSize isNil ifTrue:[ |
|
8080 pSizeMatch := '*' |
8076 ] ifFalse:[ |
8081 ] ifFalse:[ |
8077 foundryMatch := foundry |
8082 pSizeMatch := pSize printString |
8078 ]. |
8083 ]. |
8079 family isNil ifTrue:[ |
8084 encodingMatch := encoding ? '*'. |
8080 familyMatch := '*' |
|
8081 ] ifFalse:[ |
|
8082 familyMatch := family |
|
8083 ]. |
|
8084 weight isNil ifTrue:[ |
|
8085 weightMatch := '*' |
|
8086 ] ifFalse:[ |
|
8087 weightMatch := weight |
|
8088 ]. |
|
8089 slant isNil ifTrue:[ |
|
8090 slantMatch := '*' |
|
8091 ] ifFalse:[ |
|
8092 slantMatch := slant |
|
8093 ]. |
|
8094 spc isNil ifTrue:[ |
|
8095 spcMatch := '*' |
|
8096 ] ifFalse:[ |
|
8097 spcMatch := spc |
|
8098 ]. |
|
8099 pSize isNil ifTrue:[ |
|
8100 pSizeMatch := '*' |
|
8101 ] ifFalse:[ |
|
8102 pSizeMatch := pSize printString |
|
8103 ]. |
|
8104 encoding isNil ifTrue:[ |
|
8105 encodingMatch := '*' |
|
8106 ] ifFalse:[ |
|
8107 encodingMatch := encoding |
|
8108 ]. |
|
8109 |
8085 |
8110 theName := ('-' , foundryMatch, |
8086 theName := ('-' , foundryMatch, |
8111 '-' , familyMatch, |
8087 '-' , familyMatch, |
8112 '-' , weightMatch , |
8088 '-' , weightMatch , |
8113 '-' , slantMatch , |
8089 '-' , slantMatch , |
8114 '-' , spcMatch , |
8090 '-' , spcMatch , |
8115 '-*' , |
8091 '-*' , |
8116 '-' , pSizeMatch , |
8092 '-' , pSizeMatch , |
8117 '-' , sizeMatch , |
8093 '-' , sizeMatch , |
8118 '-*-*-*-*' , |
8094 '-*-*-*-*' , |
8119 '-' , encodingMatch). |
8095 '-' , encodingMatch). |
8120 |
8096 |
8121 "/ Transcript showCR:theName; endEntry. |
8097 "/ Transcript showCR:theName; endEntry. |
8122 |
8098 |
8123 ^ self createFontFor:theName. |
8099 ^ self createFontFor:theName. |
8124 |
8100 |
8125 |
8101 |
8126 " |
8102 " |
8127 Display |
8103 Display |
8128 getFontWithFoundry:'*' |
8104 getFontWithFoundry:'*' |
8129 family:'courier' |
8105 family:'courier' |
8130 weight:'medium' |
8106 weight:'medium' |
8131 slant:'r' |
8107 slant:'r' |
8132 spacing:nil |
8108 spacing:nil |
8133 pixelSize:nil |
8109 pixelSize:nil |
8134 size:13 |
8110 size:13 |
8135 encoding:#'iso8859-1'. |
8111 encoding:#'iso8859-1'. |
8136 |
8112 |
8137 Display |
8113 Display |
8138 getFontWithFoundry:'*' |
8114 getFontWithFoundry:'*' |
8139 family:'courier' |
8115 family:'courier' |
8140 weight:'medium' |
8116 weight:'medium' |
8141 slant:'r' |
8117 slant:'r' |
8142 spacing:nil |
8118 spacing:nil |
8143 pixelSize:nil |
8119 pixelSize:nil |
8144 size:13 |
8120 size:13 |
8145 encoding:#'iso10646-1' |
8121 encoding:#'iso10646-1' |
8146 " |
8122 " |
8147 |
8123 |
8148 "Modified: 10.4.1997 / 19:15:44 / cg" |
8124 "Modified: / 10-04-1997 / 19:15:44 / cg" |
|
8125 "Modified: / 03-03-2019 / 23:15:18 / Claus Gittinger" |
8149 ! |
8126 ! |
8150 |
8127 |
8151 heightOf:aString from:index1 to:index2 inFont:aFontId |
8128 heightOf:aString from:index1 to:index2 inFont:aFontId |
8152 |resultArray| |
8129 |resultArray| |
8153 |
8130 |