DeviceGraphicsContext.st
changeset 832 064890dcfabd
parent 786 af5fecf93126
child 844 17d0f74d7d02
equal deleted inserted replaced
831:ceb4e9f32262 832:064890dcfabd
  1311                            x:pX y:pY 
  1311                            x:pX y:pY 
  1312                           in:drawableId with:gcId.
  1312                           in:drawableId with:gcId.
  1313         ^ self
  1313         ^ self
  1314     ].
  1314     ].
  1315 
  1315 
       
  1316     "/ the very hard case (fg-dither)
       
  1317 
  1316     self displayDeviceOpaqueString:s from:index1 to:index2 in:fontUsed x:pX y:pY.
  1318     self displayDeviceOpaqueString:s from:index1 to:index2 in:fontUsed x:pX y:pY.
  1317 
  1319 
  1318     "Modified: 21.5.1996 / 21:16:08 / cg"
  1320     "Modified: 12.6.1996 / 12:36:33 / cg"
  1319 !
  1321 !
  1320 
  1322 
  1321 displayOpaqueString:aString x:x y:y
  1323 displayOpaqueString:aString x:x y:y
  1322     "draw a string at the coordinate x/y - draw foreground pixels in paint-color,
  1324     "draw a string at the coordinate x/y - draw foreground pixels in paint-color,
  1323      background pixels in bgPaint color. If the transformation involves scaling, 
  1325      background pixels in bgPaint color. If the transformation involves scaling, 
  2477         "
  2479         "
  2478          only fg is dithered; fill with bg first ...
  2480          only fg is dithered; fill with bg first ...
  2479         "
  2481         "
  2480         device setForeground:bgId in:gcId.
  2482         device setForeground:bgId in:gcId.
  2481         device setFunction:#copy in:gcId.
  2483         device setFunction:#copy in:gcId.
       
  2484         device setBitmapMask:nil in:gcId.
  2482         self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
  2485         self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h.
  2483 
  2486 
  2484         "/ draw dithered
  2487         "/ draw fg dithered
  2485         (mask depth == 1) ifTrue:[
  2488         (mask depth == 1) ifTrue:[
  2486             device setBitmapMask:mask id in:gcId
  2489             device setBitmapMask:mask id in:gcId.
       
  2490             device setForeground:foreground colorId background:background colorId in:gcId.
  2487         ] ifFalse:[
  2491         ] ifFalse:[
  2488             device setPixmapMask:mask id in:gcId
  2492             device setPixmapMask:mask id in:gcId
  2489         ].
  2493         ].
  2490 
  2494 
  2491         device setForeground:foreground colorId background:background colorId in:gcId.
       
  2492         device displayString:s
  2495         device displayString:s
  2493                     from:index1 to:index2 
  2496                     from:index1 to:index2 
  2494                        x:pX y:pY
  2497                        x:pX y:pY
  2495                       in:drawableId with:gcId.
  2498                       in:drawableId with:gcId.
  2496         ^ self.
  2499         ^ self.
  2528 "/      "
  2531 "/      "
  2529 "/      foreground := nil.
  2532 "/      foreground := nil.
  2530 "/      background := nil.
  2533 "/      background := nil.
  2531 "/      device setFunction:function in:gcId.
  2534 "/      device setFunction:function in:gcId.
  2532 "/      ^ self
  2535 "/      ^ self
  2533    ].
  2536     ].
  2534     "
  2537 
  2535      hard case, both fg and bg are dithered colors/images
  2538     "
       
  2539      very hard case, both fg and bg are dithered colors/images
  2536     "
  2540     "
  2537     noColor := Color noColor.
  2541     noColor := Color noColor.
  2538 'hard: ' print. aString print. ' ' print. paint print. ' ' print. bgPaint printCR.
  2542 "/ 'hard: ' print. aString print. ' ' print. paint print. ' ' print. bgPaint printCR.
  2539     "
  2543     "
  2540      create temp-forms;
  2544      create temp-forms;
  2541     "
  2545     "
  2542     bgForm := Form width:w height:h depth:deviceDepth on:device.
  2546     bgForm := Form width:w height:h depth:deviceDepth on:device.
  2543     fgForm := Form width:w height:h depth:deviceDepth on:device.
  2547     fgForm := Form width:w height:h depth:deviceDepth on:device.
  2613      flush foreground/background cache
  2617      flush foreground/background cache
  2614     "
  2618     "
  2615     foreground := nil.
  2619     foreground := nil.
  2616     background := nil.
  2620     background := nil.
  2617 
  2621 
  2618     "Modified: 30.5.1996 / 09:22:11 / cg"
  2622     "Modified: 12.6.1996 / 12:50:12 / cg"
  2619 !
  2623 !
  2620 
  2624 
  2621 displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y
  2625 displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y
  2622     "draw a substring at the coordinate x/y - draw foreground pixels in
  2626     "draw a substring at the coordinate x/y - draw foreground pixels in
  2623      paint-color and background pixels in bgPaint-color.
  2627      paint-color and background pixels in bgPaint-color.
  3126 !
  3130 !
  3127 
  3131 
  3128 reinitialize
  3132 reinitialize
  3129     'reinit of ' errorPrint. self classNameWithArticle errorPrint.
  3133     'reinit of ' errorPrint. self classNameWithArticle errorPrint.
  3130     ' failed' errorPrintNL
  3134     ' failed' errorPrintNL
       
  3135 !
       
  3136 
       
  3137 releaseGC
       
  3138     "destroy the associated GC - can be done to be nice to the 
       
  3139      display if you know that you are done with a drawable."
       
  3140 
       
  3141     gcId notNil ifTrue:[
       
  3142         device destroyGC:gcId.
       
  3143         gcId := nil.
       
  3144         Lobby registerChange:self.
       
  3145     ]
       
  3146 
       
  3147     "Created: 11.6.1996 / 22:07:30 / cg"
  3131 ! !
  3148 ! !
  3132 
  3149 
  3133 !DeviceGraphicsContext methodsFor:'instance release'!
  3150 !DeviceGraphicsContext methodsFor:'instance release'!
  3134 
  3151 
  3135 disposed
  3152 disposed
  3152 setGCForPaint
  3169 setGCForPaint
  3153     "private; given a complex color (i.e. a pixmap or dithered color,
  3170     "private; given a complex color (i.e. a pixmap or dithered color,
  3154      setup the GC to draw in this color.
  3171      setup the GC to draw in this color.
  3155      A helper for paint and paint:on:"
  3172      A helper for paint and paint:on:"
  3156 
  3173 
  3157     |dither map pixelId p fg bg vOrg ditherDepth|
  3174     |dither map pixelId p fg bg vOrg ditherDepth deviceDepth|
  3158 
  3175 
  3159     gcId notNil ifTrue:[
  3176     gcId notNil ifTrue:[
  3160         (p := paint) isColor ifTrue:[
  3177         (p := paint) isColor ifTrue:[
  3161             paint := p := p on:device.
  3178             paint := p := p on:device.
  3162             pixelId := p colorId.
  3179             pixelId := p colorId.
  3197                 bg := map at:1.
  3214                 bg := map at:1.
  3198             ].
  3215             ].
  3199             self foreground:fg background:bg.
  3216             self foreground:fg background:bg.
  3200             paint := p
  3217             paint := p
  3201         ] ifFalse:[
  3218         ] ifFalse:[
  3202             (ditherDepth ~~ device depth) ifTrue:[
  3219             deviceDepth := device depth.
       
  3220             (ditherDepth ~~ deviceDepth) ifTrue:[
  3203                 dither := dither asFormOn:device.
  3221                 dither := dither asFormOn:device.
  3204                 (dither isNil or:[ditherDepth ~~ device depth]) ifTrue:[
  3222                 ditherDepth := dither depth.
       
  3223                 (dither isNil or:[ditherDepth ~~ deviceDepth]) ifTrue:[
  3205                     self error:'bad dither'.
  3224                     self error:'bad dither'.
  3206                     ^ self
  3225                     ^ self
  3207                 ]
  3226                 ]
  3208             ]
  3227             ]
  3209         ].
  3228         ].
  3211         vOrg := self viewOrigin.
  3230         vOrg := self viewOrigin.
  3212         self setMaskOriginX:vOrg x negated y:vOrg y negated.
  3231         self setMaskOriginX:vOrg x negated y:vOrg y negated.
  3213     ]
  3232     ]
  3214 
  3233 
  3215     "Created: 16.5.1996 / 15:35:51 / cg"
  3234     "Created: 16.5.1996 / 15:35:51 / cg"
  3216     "Modified: 16.5.1996 / 15:37:31 / cg"
  3235     "Modified: 12.6.1996 / 12:49:07 / cg"
  3217 ! !
  3236 ! !
  3218 
  3237 
  3219 !DeviceGraphicsContext methodsFor:'queries'!
  3238 !DeviceGraphicsContext methodsFor:'queries'!
  3220 
  3239 
  3221 horizontalIntegerPixelPerMillimeter
  3240 horizontalIntegerPixelPerMillimeter
  3275 ! !
  3294 ! !
  3276 
  3295 
  3277 !DeviceGraphicsContext class methodsFor:'documentation'!
  3296 !DeviceGraphicsContext class methodsFor:'documentation'!
  3278 
  3297 
  3279 version
  3298 version
  3280     ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.6 1996-06-04 17:04:41 cg Exp $'
  3299     ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.7 1996-06-12 11:04:34 cg Exp $'
  3281 ! !
  3300 ! !
  3282 DeviceGraphicsContext initialize!
  3301 DeviceGraphicsContext initialize!