'From Squeak3.4 of 1 March 2003 [latest update: #5170] on 23 April 2003 at 12:54:46 pm'! !MultiString methodsFor: 'converting' stamp: 'sumim 4/23/2003 12:36'! asString | newString | self isOctetString ifFalse: [^ self]. newString _ String new: self size. 1 to: self size do: [ :i | newString basicAt: i put: (self basicAt: i)]. ^ newString ! ! !StrikeFont class methodsFor: 'instance creation' stamp: 'sumim 4/23/2003 12:28'! fromUserForMulti: priorFont "Present a menu of available fonts, and if one is chosen, return it." | fontList fontMenu style active ptMenu label spec font | "self halt." fontList _ StrikeFont familyNames remove: 'DefaultTextStyle' ifAbsent: []; asOrderedCollection. fontMenu _ MenuMorph new defaultTarget: self. fontList do: [:fontName | ((style _ TextStyle named: fontName) defaultFont class name copyLast: 3) = 'Set' ifTrue: [ active _ priorFont familyName sameAs: fontName. ptMenu _ MenuMorph new defaultTarget: self. style pointSizes do: [:pt | (active and:[pt = priorFont pointSize]) ifTrue:[label _ ''] ifFalse:[label _ '']. label _ label, pt printString, ' pt'. ptMenu add: label target: fontMenu selector: #modalSelection: argument: {fontName. pt}]. (style fontArray first isKindOf: TTCFont) ifTrue: [ ptMenu add: 'new size' target: style selector: #addNewFontSizeDialog: argument: {fontName. fontMenu}. ]. active ifTrue:[label _ ''] ifFalse:[label _ '']. label _ label, fontName. fontMenu add: label subMenu: ptMenu]]. spec _ fontMenu invokeModal: false. "don't allow keyboard control" spec ifNil: [^ nil]. style _ TextStyle named: spec first. style ifNil: [^ self]. font _ style fonts detect: [:any | any pointSize = spec last] ifNone: [nil]. ^ font! ! !String methodsFor: 'converting' stamp: 'sumim 4/23/2003 12:36'! asString ^ self! ! !TextMorphEditor methodsFor: 'attributes' stamp: 'sumim 4/23/2003 12:52'! changeStyle "Let user change styles for the current text pane." | aList reply style theStyle menuList menu | self flag: #arNote. "Move this up once we get rid of MVC" aList _ StrikeFont familyNames remove: 'DefaultTextStyle' ifAbsent: []; asOrderedCollection. ((paragraph text instVarNamed: 'string' put: paragraph text string asString) isKindOf: MultiString) ifTrue: [ aList removeAllSuchThat: [ :familyName | (style _ TextStyle named: familyName) ifNotNil: [ (style defaultFont class name copyLast: 3) ~= 'Set'] ifNil: [false]]]. theStyle _ paragraph textStyle. menuList _ aList collect:[:styleName| "Hack!! use defaultFont for comparison - we have no name that we could use for compare and the style changes with alignment so they're no longer equal." (TextConstants at: styleName) defaultFont == theStyle defaultFont ifTrue:['', styleName] ifFalse:['',styleName]]. theStyle = TextStyle default ifTrue:[menuList addFirst: 'DefaultTextStyle'] ifFalse:[menuList addFirst: 'DefaultTextStyle']. aList addFirst: 'DefaultTextStyle'. menu _ SelectionMenu labelList: menuList lines: #(1) selections: aList. reply _ menu startUp. reply ~~ nil ifTrue: [(style _ TextStyle named: reply) ifNil: [self beep. ^ true]. paragraph textStyle: style copy. paragraph composeAll. self recomputeSelection. self mvcRedisplay]. ^ true! ! !TextMorphEditor methodsFor: 'attributes' stamp: 'sumim 4/23/2003 12:49'! changeTextFont "Present a menu of available fonts, and if one is chosen, apply it to the current selection." | curFont newFont attr | curFont _ (paragraph text fontAt: startBlock stringIndex withStyle: paragraph textStyle). newFont _ ((paragraph text instVarNamed: 'string' put: paragraph text string asString) isKindOf: MultiString) ifTrue: [StrikeFont fromUserForMulti: curFont] ifFalse: [StrikeFont fromUser: curFont]. newFont ifNil:[^self]. attr _ TextFontReference toFont: newFont. paragraph text addAttribute: attr from: startBlock stringIndex to: (stopBlock stringIndex-1 min: paragraph text size). paragraph composeAll. self recomputeInterval. morph changed.! !