'From Squeak3.1alpha of 5 February 2001 [latest update: #4268] on 21 August 2001 at 11:45:29 am'! "Change Set: moreTextProps Date: 21 August 2001 Author: Bob Arning Additions to text properties panel for new TextMorph - added toggle for auto-fit - added toggle for wrapping - added control to change margins - will change slot to that of last used global color change - pre-empted 'text color...' item from red halo menu to open properties panel for greater functionality"! GenericPropertiesMorph subclass: #TextPropertiesMorph instanceVariableNames: 'activeTextMorph applyToWholeText lastGlobalColor ' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Experimental'! !TextMorph methodsFor: 'accessing' stamp: 'RAA 8/21/2001 11:18'! isWrapped ^wrapFlag! ! !TextMorph methodsFor: 'accessing' stamp: 'RAA 8/21/2001 11:41'! margins ^margins! ! !TextMorph methodsFor: 'menu' stamp: 'RAA 8/21/2001 11:08'! changeTextColor "Change the color of the receiver -- triggered, e.g. from a menu" self openATextPropertySheet. ">>>>> ColorPickerMorph new choseModalityFromPreference; sourceHand: self activeHand; target: self; selector: #textColor:; originalColor: self textColor; putUpFor: self near: self fullBoundsInWorld <<<<"! ! !TextPropertiesMorph methodsFor: 'as yet unclassified' stamp: 'RAA 8/21/2001 11:26'! adjustTargetMargin: aFractionalPoint | n | n _ (aFractionalPoint * 4) rounded. myTarget margins: n. self showSliderFeedback: n. ! ! !TextPropertiesMorph methodsFor: 'as yet unclassified' stamp: 'RAA 8/21/2001 11:07'! changeTargetColorTo: aColor self applyToWholeText ifTrue: [ lastGlobalColor _ aColor ]. self changeSelectionAttributeTo: (TextColor color: aColor)! ! !TextPropertiesMorph methodsFor: 'as yet unclassified' stamp: 'RAA 8/21/2001 11:06'! doAccept myTarget text: self activeTextMorph contents textStyle: self activeTextMorph textStyle; releaseCachedState; changed. lastGlobalColor ifNotNil: [myTarget textColor: lastGlobalColor]. super doAccept.! ! !TextPropertiesMorph methodsFor: 'as yet unclassified' stamp: 'RAA 8/21/2001 11:41'! initialize super initialize. applyToWholeText _ true. myTarget ifNil: [myTarget _ TextMorph new openInWorld]. self color: (Color r: 0.355 g: 0.742 b: 0.839). self borderColor: self color darker. activeTextMorph _ TextMorph new extent: 300@100; contents: myTarget contents wrappedTo: 300; text: myTarget contents textStyle: myTarget textStyle; releaseCachedState. thingsToRevert at: #wrapFlag: put: myTarget isWrapped; at: #autoFit: put: myTarget isAutoFit; at: #margins: put: myTarget margins. self rebuild. ! ! !TextPropertiesMorph methodsFor: 'as yet unclassified' stamp: 'RAA 8/21/2001 11:12'! paneForAutoFitToggle ^self inARow: { self directToggleButtonFor: self getter: #targetHasAutoFit setter: #toggleTargetAutoFit help: 'Turn auto-fit on or off'. self lockedString: ' Auto-Fit'. } ! ! !TextPropertiesMorph methodsFor: 'as yet unclassified' stamp: 'RAA 8/21/2001 11:24'! paneForMargins ^(self inARow: { self buildFakeSlider: 'Margins' selector: #adjustTargetMargin: help: 'Drag in here to change the margins of the text' }) hResizing: #shrinkWrap ! ! !TextPropertiesMorph methodsFor: 'as yet unclassified' stamp: 'RAA 8/21/2001 11:17'! paneForWrappingToggle ^self inARow: { self directToggleButtonFor: self getter: #targetHasWrapping setter: #toggleTargetWrapping help: 'Turn line wrapping on or off'. self lockedString: ' Wrapping'. } ! ! !TextPropertiesMorph methodsFor: 'as yet unclassified' stamp: 'RAA 8/21/2001 11:27'! rebuild | buttonColor c | self removeAllMorphs. self addAColumn: { self lockedString: 'Text Properties for ',myTarget name. }. self addAColumn: { self paneForApplyToWholeText. }. c _ self addAColumn: { self activeTextMorph. }. c wrapCentering: #topLeft; color: Color white; borderWidth: 2; borderColor: color darker. self addAColumn: { self paneForTextColorPicker. }. self addARow: { self paneForAutoFitToggle. }. self addARow: { self paneForWrappingToggle. }. self addARow: { self paneForMargins. }. buttonColor _ color lighter. self addARow: { self inAColumn: { self addARow: { self buttonNamed: 'Size' action: #offerFontMenu color: buttonColor help: 'font changing'. self buttonNamed: 'Style' action: #changeStyle color: buttonColor help: 'font changing'. self buttonNamed: 'N' action: #changeToNormalText color: buttonColor help: 'normal text'. self buttonNamed: 'B' action: #toggleBold color: buttonColor help: 'bold text'. self buttonNamed: 'I' action: #toggleItalic color: buttonColor help: 'italic text'. self buttonNamed: 'n' action: #toggleNarrow color: buttonColor help: 'narrow text'. self buttonNamed: 'U' action: #toggleUnderlined color: buttonColor help: 'underlined text'. self buttonNamed: 'S' action: #toggleStruckOut color: buttonColor help: 'struck out text'. self buttonNamed: 'Kern-' action: #kernMinus color: buttonColor help: 'decrease kern'. self buttonNamed: 'Kern+' action: #kernPlus color: buttonColor help: 'increase kern'. }. }. }. self addARow: { self inAColumn: { self addARow: { self buttonNamed: 'Accept' action: #doAccept color: buttonColor help: 'keep changes made and close panel'. self buttonNamed: 'Cancel' action: #doCancel color: buttonColor help: 'cancel changes made and close panel'. }. }. }. ! ! !TextPropertiesMorph methodsFor: 'as yet unclassified' stamp: 'RAA 8/21/2001 11:14'! targetHasAutoFit ^myTarget isAutoFit ! ! !TextPropertiesMorph methodsFor: 'as yet unclassified' stamp: 'RAA 8/21/2001 11:19'! targetHasWrapping ^myTarget isWrapped ! ! !TextPropertiesMorph methodsFor: 'as yet unclassified' stamp: 'RAA 8/21/2001 11:14'! toggleTargetAutoFit ^myTarget autoFitOnOff ! ! !TextPropertiesMorph methodsFor: 'as yet unclassified' stamp: 'RAA 8/21/2001 11:16'! toggleTargetWrapping ^myTarget wrapOnOff ! !