cca@pur-phy (Charles C. Allen) (01/21/89)
"Someone asked for experiences and opinions on Smalltalk/V Mac. I haven't had it long enough to do any real projects, so I can't really offer much. What I can offer are a few simple bug fixes I've incorporated. This file should be in fileIn format once you strip off the news header. Please look at the changes carefully before doing the fileIn. I'm somewhat of a Smalltalk novice, and could have screwed something up. I've been using these fixes for a couple of weeks now with no problem. Charles Allen cca@newton.physics.purdue.edu" "The first fix wins the triviality award. This message used to be allign:at:showFrom. Allign ain't in any of my dictionaries...." ! CharacterScanner methods ! align: aString at: aPoint showFrom: anInteger "Private -" self display: aString from: anInteger at: aPoint x + (font distanceOf: anInteger - 1 in: aString) @ aPoint y! ! "The following is the only sender (in the standard image) of the above misspelled message." ! StringModel methods ! display: aRectangle "Display the text contained in aRectangle." | sourceY dest lastY sourceX minY font | font := charScanner font. sourceX := aRectangle origin x. sourceY := aRectangle origin y. lastY := aRectangle corner y. font fixedWidth ifTrue: [ dest := (0 - (topCorner x - 1 * font width)) @ (sourceY - topCorner y * font height) ] ifFalse: [ dest := (0 - (font distanceOf: topCorner x - 1 in: (lines at: topCorner y))) @ (sourceY - topCorner y * font height) ]. lines size >= sourceY ifTrue: [ "display first line" charScanner align: (lines at: sourceY) at: dest showFrom: sourceX. (sourceY = lastY) ifTrue: [^ self]]. "single line" minY := lastY min: lines size. sourceY + 1 to: minY do: [ :i | dest y: (dest y + font height). charScanner display: (lines at: i) from: 1 at: dest]. minY < lastY ifTrue: [ minY := minY max: sourceY - 1. "for case sourceY > minY" charScanner blankRestFrom: (minY - topCorner y + 1 * font height)]! ! "The system uses (aString size * aFont width) in several places. This doesn't cut it when using proportional fonts. These references should be changed to (aFont stringWidth: aString). The following Pen method is one used in the examples, so I went and changed it." ! Pen methods ! centerText: aString font: aFont "Write aString whose center is at the destination origin using aFont." CharacterScanner new initialize: self clipRect font: aFont dest: self destForm; setForeColor: halftone backColor: Form white; display: aString at: self location - ((aFont stringWidth: aString) @ aFont height // 2).! ! "The CharacterScanner>>copyCharsNonPrim method is just plain wrong. This one works." !CharacterScanner methods ! copyCharsNonPrim "Private - Copy the bit pattern of the source string to the destination form. Hide the cursor in the transfer area." | theChar end saveWidth | end := destX + (font stringWidth: textString). saveWidth := width. textPos to: textEnd do: [ :position | theChar := textString at: position. width := font charWidth: theChar. sourceX := font sourceXPositionOf: theChar. self copyBits. destX := destX + width. destX > end ifTrue: [width := saveWidth. ^ self]] "Original method end := destX + width - font width. saveWidth := width. width := font width. textPos to: textEnd do: [ :position | sourceX := font sourceXPositionOf: (textString at: position). self copyBits. destX := destX + font width. destX > end ifTrue: [width := saveWidth. ^ self]]. "! ! "The Font>>sourceXPositionOf: method was not using the xTable to determine the position. Another of the fixed-pitch font leftovers..." !Font methods ! sourceXPositionOf: aChar "Answer the bit position in the glyphs Form of the character aChar." ^ xTable at: (aChar asciiValue - startChar + 1) "Original method ^ self width * (aChar asciiValue - startChar) "! ! "There are other bugs in CharacterScanner I'll encourage others to find :-). I haven't had time to go through things carefully yet. Until I get them fixed, I'm sticking to a fixed-width font for my text and listing fonts."