# HG changeset patch # User Michael Beyl # Date 1027456421 -7200 # Node ID d40999d6cd1e397e28012c1cdc9c74a457f47d3f # Parent faf50c1021e06183e09705fc7a9927f403d5e40c refactored diff -r faf50c1021e0 -r d40999d6cd1e BitmapFont.st --- a/BitmapFont.st Tue Jul 23 21:40:47 2002 +0200 +++ b/BitmapFont.st Tue Jul 23 22:33:41 2002 +0200 @@ -377,20 +377,7 @@ !BitmapFont methodsFor:'drawing'! -displayOpaqueString:aString from:index1 to:index2 x:x0 y:y in:aGC - "required protocol for new fonts: - - display part of a string, drawing both fore- and background pixels" - - |x| - - x := x0. - index1 to:index2 do:[:index | - self drawCharacter:(aString at:index) asciiValue in:aGC x:x y:y opaque:true. - x := x + (self widthOfCharacter:(aString at:index) asciiValue) - ] -! - -displayString:aString from:index1 to:index2 x:x0 y:y in:aGC +displayString:aString from:index1 to:index2 x:x0 y:y in:aGC opaque:opaque "required protocol for new fonts: - display part of a string, drawing foreground pixels only" @@ -398,7 +385,7 @@ x := x0. index1 to:index2 do:[:index | - self drawCharacter:(aString at:index) asciiValue in:aGC x:x y:y opaque:false. + self drawCharacter:(aString at:index) asciiValue in:aGC x:x y:y opaque:opaque. x := x + (self widthOfCharacter:(aString at:index) asciiValue) ] ! ! @@ -410,11 +397,7 @@ glyph := characterBitmaps at:(ascii + 1) ifAbsent:nil. glyph isNil ifTrue:[^ self]. - opaque ifTrue:[ - aGC displayOpaqueForm:glyph x:x y:y-ascent - ] ifFalse:[ - aGC displayForm:glyph x:x y:y-ascent - ] + aGC displayForm:glyph x:x y:y-ascent opaque:opaque ! ! !BitmapFont methodsFor:'private - queries'! @@ -566,5 +549,5 @@ !BitmapFont class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview/BitmapFont.st,v 1.4 2002-07-23 17:22:30 mb Exp $' + ^ '$Header: /cvs/stx/stx/libview/BitmapFont.st,v 1.5 2002-07-23 20:31:40 mb Exp $' ! ! diff -r faf50c1021e0 -r d40999d6cd1e CompoundFont.st --- a/CompoundFont.st Tue Jul 23 21:40:47 2002 +0200 +++ b/CompoundFont.st Tue Jul 23 22:33:41 2002 +0200 @@ -28,11 +28,11 @@ "{ Package: 'stx:libview' }" FontDescription subclass:#CompoundFont - instanceVariableNames:'baseFont characterToFontMapping maxAscent maxDescent maxHeight - device' - classVariableNames:'' - poolDictionaries:'' - category:'Graphics-Support' + instanceVariableNames:'baseFont characterToFontMapping maxAscent maxDescent maxHeight + device' + classVariableNames:'' + poolDictionaries:'' + category:'Graphics-Support' ! !CompoundFont class methodsFor:'documentation'! @@ -205,7 +205,7 @@ !CompoundFont methodsFor:'displaying'! -displayOpaqueString:aString from:index1 to:index2 x:x0 y:y0 in:aGC +displayString:aString from:index1 to:index2 x:x0 y:y0 in:aGC opaque:opaque "this is only called for fonts which have a nil fontId, and therefore use the replacementFont. Should never be called for non-replacement fonts." @@ -218,33 +218,9 @@ self substringPartsOf:aString from:index1 to:index2 do:[:s :i1 :i2 :font | - font displayOpaqueString:s from:i1 to:i2 x:x y:y in:aGC. + font displayString:s from:i1 to:i2 x:x y:y in:aGC opaque:opaque. x := x + (font widthOf:aString from:i1 to:i2). ]. - - - -! - -displayString:aString from:index1 to:index2 x:x0 y:y0 in:aGC - "this is only called for fonts which have a nil fontId, - and therefore use the replacementFont. Should never be called - for non-replacement fonts." - - |x y| - - x := x0. - y := y0. - - self - substringPartsOf:aString from:index1 to:index2 - do:[:s :i1 :i2 :font | - font displayString:s from:i1 to:i2 x:x y:y in:aGC. - x := x + (font widthOf:aString from:i1 to:i2). - ]. - - - ! ! !CompoundFont methodsFor:'private'! @@ -389,5 +365,5 @@ !CompoundFont class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview/CompoundFont.st,v 1.4 2002-07-23 19:33:48 mb Exp $' + ^ '$Header: /cvs/stx/stx/libview/CompoundFont.st,v 1.5 2002-07-23 20:32:10 mb Exp $' ! ! diff -r faf50c1021e0 -r d40999d6cd1e Font.st --- a/Font.st Tue Jul 23 21:40:47 2002 +0200 +++ b/Font.st Tue Jul 23 22:33:41 2002 +0200 @@ -308,7 +308,7 @@ !Font methodsFor:'displaying'! -displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aGC +displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:opaque "this is only called for fonts which have a nil fontId, and therefore use the replacementFont. Should never be called for non-replacement fonts." @@ -319,37 +319,13 @@ replacementFont isNil ifTrue:[ fontId notNil ifTrue:[ aGC basicFont:self. - aGC displayOpaqueString:aString from:index1 to:index2 x:x y:y. + aGC displayString:aString from:index1 to:index2 x:x y:y opaque:opaque. ] ifFalse:[ 'Font: [warning]: no replacementFont. should not happen' errorPrintCR. ]. ] ifFalse:[ aGC basicFont:replacementFont. - aGC displayOpaqueString:aString from:index1 to:index2 x:x y:y. - ]. - aGC basicFont:prevFont - - "Modified: 10.1.1997 / 17:51:10 / cg" -! - -displayString:aString from:index1 to:index2 x:x y:y in:aGC - "this is only called for fonts which have a nil fontId, - and therefore use the replacementFont. Should never be called - for non-replacement fonts." - - |prevFont| - - prevFont := aGC font. - replacementFont isNil ifTrue:[ - fontId notNil ifTrue:[ - aGC basicFont:self. - aGC displayString:aString from:index1 to:index2 x:x y:y. - ] ifFalse:[ - 'Font: [warning]: no replacementFont. should not happen' errorPrintCR. - ]. - ] ifFalse:[ - aGC basicFont:replacementFont. - aGC displayString:aString from:index1 to:index2 x:x y:y. + aGC displayString:aString from:index1 to:index2 x:x y:y opaque:opaque. ]. aGC basicFont:prevFont. @@ -1107,6 +1083,6 @@ !Font class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.84 2002-07-18 12:40:59 stefan Exp $' + ^ '$Header: /cvs/stx/stx/libview/Font.st,v 1.85 2002-07-23 20:33:05 mb Exp $' ! ! Font initialize! diff -r faf50c1021e0 -r d40999d6cd1e FontDescription.st --- a/FontDescription.st Tue Jul 23 21:40:47 2002 +0200 +++ b/FontDescription.st Tue Jul 23 22:33:41 2002 +0200 @@ -588,10 +588,10 @@ !FontDescription methodsFor:'displaying'! displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aGC - "display a partial string at some position in aGC." + "display a partial string at some position in aGC. + - display part of a string, drawing both fore- and background pixels" - self subclassResponsibility - + self displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:true ! displayOpaqueString:aString x:x y:y in:aGC @@ -603,8 +603,13 @@ displayString:aString from:index1 to:index2 x:x y:y in:aGC "display a partial string at some position in aGC." + self displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:false +! + +displayString:aString from:index1 to:index2 x:x y:y in:aGC opaque:opaque + "display a partial string at some position in aGC." + self subclassResponsibility - ! displayString:aString x:x y:y in:aGC @@ -955,6 +960,6 @@ !FontDescription class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview/FontDescription.st,v 1.41 2002-07-23 19:37:24 mb Exp $' + ^ '$Header: /cvs/stx/stx/libview/FontDescription.st,v 1.42 2002-07-23 20:32:34 mb Exp $' ! ! FontDescription initialize! diff -r faf50c1021e0 -r d40999d6cd1e GraphicsContext.st --- a/GraphicsContext.st Tue Jul 23 21:40:47 2002 +0200 +++ b/GraphicsContext.st Tue Jul 23 22:33:41 2002 +0200 @@ -1219,6 +1219,16 @@ "draw part of a string with fg at x/y in current font" ^ self subclassResponsibility +! + +displayString:aString from:index1 to:index2 x:x y:y opaque:opaque + "draw part of a string with both fg and bg at x/y in current font" + + opaque ifTrue:[ + self displayOpaqueString:aString from:index1 to:index2 x:x y:y + ] ifFalse:[ + self displayString:aString from:index1 to:index2 x:x y:y + ]. ! ! !GraphicsContext methodsFor:'basic filling'! @@ -1411,6 +1421,19 @@ "Modified: 24.4.1997 / 16:01:43 / cg" ! +displayForm:aFormOrImage x:x y:y opaque:opaque + "draw a form (or image) at x/y; + if the form has depth 1, 1's in the form are + drawn in current paint color, 0's are ignored. + If the form has depth ~~ 1, the current fg color setting is ignored." + + opaque ifTrue:[ + self displayOpaqueForm:aFormOrImage x:x y:y + ] ifFalse:[ + self displayForm:aFormOrImage x:x y:y + ]. +! + displayImage:aFormOrImage at:aPoint "draw an image (or form). Provided for ST-80 compatibilty; @@ -2205,6 +2228,6 @@ !GraphicsContext class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.91 2001-11-06 08:41:46 cg Exp $' + ^ '$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.92 2002-07-23 20:33:41 mb Exp $' ! ! GraphicsContext initialize!