[squeak-dev] The Trunk: Morphic-ar.164.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] The Trunk: Morphic-ar.164.mcz

commits-2
Andreas Raab uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-ar.164.mcz

==================== Summary ====================

Name: Morphic-ar.164
Author: ar
Time: 30 August 2009, 5:15:48 am
UUID: b12dfe19-bea4-7a48-9de3-0fd4d8667090
Ancestors: Morphic-laza.163

First pass on FreeTypePlus integration:
- Integrate overrides/extensions
- Fold modal dialog support from Polymorph
- Add FontChooserTool as a font chooser dialog
- Use dialog in standard font choice places

=============== Diff against Morphic-laza.163 ===============

Item was added:
+ ----- Method: SystemWindow>>bringBehind: (in category 'polymorph') -----
+ bringBehind: aMorph
+ "Make the receiver be directly behind the given morph.
+ Take into account any modal owner and propagate."
+
+ |outerMorph|
+ outerMorph := self topRendererOrSelf.
+ outerMorph owner ifNil: [^ self "avoid spurious activate when drop in trash"].
+ outerMorph owner addMorph: outerMorph after: aMorph topRendererOrSelf.
+ self modalOwner ifNotNilDo: [:mo | mo bringBehind: self]!

Item was added:
+ ----- Method: SystemWindow>>modalChild (in category 'polymorph') -----
+ modalChild
+ "Answer the modal child of the receiver, if any."
+
+ ^self valueOfProperty: #modalChild!

Item was changed:
  ----- Method: TextMorphEditor>>changeTextFont (in category 'attributes') -----
  changeTextFont
+ "Present a dialog which allows the user to select a font, and if one is chosen, apply it to the current selection. If there is no selection, or the selection is empty, apply it to the whole morph."
+ | curFont startIndex chooser newFont |
- "Present a menu of available fonts, and if one is chosen, apply it to the current selection.
- If there is no selection, or the selection is empty, apply it to the whole morph."
- | curFont newFont attr startIndex stopIndex |
  startIndex := self startIndex.
- stopIndex := self stopIndex-1 min: paragraph text size.
  curFont := (paragraph text fontAt: startIndex withStyle: paragraph textStyle).
+ morph openModal: (
+ Cursor wait showWhile: [
+ (chooser := FontChooserTool default
+ withTitle: 'Change the selected text''s font to...' translated
+ for: self
+ setSelector: #changeSelectionFontTo:
+ getSelector: curFont) open]).
+ newFont := chooser result.
+ newFont ifNotNil:[self changeSelectionFontTo: newFont].!
- newFont := StrikeFont fromUser: curFont allowKeyboard: false.
- newFont ifNil:[^self].
- attr := TextFontReference toFont: newFont.
- stopIndex >= startIndex
- ifTrue: [ paragraph text addAttribute: attr from: startIndex to: stopIndex ]
- ifFalse: [ paragraph text addAttribute: attr from: 1 to: paragraph text size. ].
-
- paragraph composeAll.
- self recomputeInterval.
- !

Item was added:
+ ----- Method: FontChooserTool>>fontStyleList (in category 'style list') -----
+ fontStyleList
+ "names of simulated styles are enclosed in parenthesis"
+ ^#('Regular' 'Bold' 'Italic' 'Bold Italic')!

Item was added:
+ ----- Method: GrafPort>>lastFontForegroundColor (in category 'accessing') -----
+ lastFontForegroundColor
+ ^lastFontForegroundColor!

Item was added:
+ ----- Method: SystemWindow>>activateWindow (in category 'top window') -----
+ activateWindow
+ "Bring me to the front and make me able to respond to mouse and keyboard.
+ Was #activate (sw 5/18/2001 23:20)"
+
+ | oldTop outerMorph sketchEditor pal |
+ outerMorph := self topRendererOrSelf.
+ outerMorph owner ifNil: [^ self "avoid spurious activate when drop in trash"].
+ oldTop := TopWindow.
+ oldTop = self ifTrue: [^self].
+ TopWindow := self.
+ oldTop ifNotNil: [oldTop passivate].
+ outerMorph owner firstSubmorph == outerMorph
+ ifFalse: ["Bring me (with any flex) to the top if not already"
+ outerMorph owner addMorphFront: outerMorph].
+ self submorphsDo: [:m | m unlock].
+ labelArea ifNotNil:
+ [labelArea submorphsDo: [:m | m unlock].
+ self setStripeColorsFrom: self paneColorToUse].
+ self isCollapsed ifFalse:
+ [model modelWakeUpIn: self.
+ self positionSubmorphs.
+ labelArea ifNil: [self adjustBorderUponActivationWhenLabeless]].
+
+ (sketchEditor := self extantSketchEditor) ifNotNil:
+ [sketchEditor comeToFront.
+ (pal := self world findA: PaintBoxMorph) ifNotNil:
+ [pal comeToFront]].
+ !

Item was added:
+ ----- Method: TextLine>>justifiedPadFor:font: (in category 'scanning') -----
+ justifiedPadFor: spaceIndex font: aFont
+ "Compute the width of pad for a given space in a line of justified text."
+
+ | pad |
+ internalSpaces = 0 ifTrue: [^0].
+ ^(aFont notNil and:[aFont isSubPixelPositioned])
+ ifTrue:[paddingWidth * 1.0 / internalSpaces]
+ ifFalse:[
+ pad _ paddingWidth // internalSpaces.
+ spaceIndex <= (paddingWidth \\ internalSpaces)
+ ifTrue: [pad + 1]
+ ifFalse: [pad]]
+ !

Item was added:
+ ----- Method: FontChooserTool>>selectedPointSizeIndex (in category 'point size') -----
+ selectedPointSizeIndex
+ ^self pointSizeList indexOf: (pointSize reduce asString padded: #left to: 3 with: $ )!

Item was added:
+ ----- Method: FontChooserTool>>buildWith: (in category 'toolbuilder') -----
+ buildWith: builder
+ "Create the ui for the browser"
+ "ToolBuilder open: self"
+ | windowSpec |
+ windowSpec := self buildWindowWith: builder specs: {
+ (0@0 corner: 0.4@0.4) -> [self buildFontListWith: builder].
+ (0.4@0 corner: 0.8@0.4) -> [self buildStyleListWith: builder].
+ (0.8@0 corner: 1.0@0.4) -> [self buildPointSizeListWith: builder].
+ (0.0@0.4 corner: 1.0@0.88) -> [self buildPreviewPaneWith: builder].
+ (0.0@0.88 corner: 1@1) -> [self buildButtonBarWith: builder].
+ }.
+ windowSpec extent: 400@300.
+ window := builder build: windowSpec.
+ ^window!

Item was added:
+ ----- Method: Morph>>modalUnlockFrom: (in category 'polymorph') -----
+ modalUnlockFrom: aSystemWindow
+ "Unlock the receiver as a modal owner of the given window."
+
+ self unlock!

Item was added:
+ ----- Method: SystemWindow>>rememberedKeyboardFocus (in category 'polymorph') -----
+ rememberedKeyboardFocus
+ "Answer the remembered keyboard focus for the receiver."
+
+ ^self valueOfProperty: #rememberedFocus!

Item was added:
+ ----- Method: FontChooserTool>>open (in category 'toolbuilder') -----
+ open
+ ^ToolBuilder open: self!

Item was added:
+ ----- Method: FontChooserTool>>cancel (in category 'actions') -----
+ cancel
+ result := nil.
+ ToolBuilder default close: window.!

Item was added:
+ ----- Method: FontChooserTool>>buildPointSizeListWith: (in category 'toolbuilder') -----
+ buildPointSizeListWith: builder
+ "Build the font choosers list of point sizes"
+ | listSpec |
+ listSpec := builder pluggableListSpec new.
+ listSpec
+ model: self;
+ list: #pointSizeList;
+ getIndex: #selectedPointSizeIndex;
+ setIndex: #selectedPointSizeIndex:.
+ ^listSpec
+ !

Item was added:
+ ----- Method: FontChooserTool class>>withTitle:for:setSelector:getSelector: (in category 'opening') -----
+ withTitle: titleString for: anObject setSelector: setSelector getSelector: getSelector
+ "
+ (FontChooserTool
+ withTitle: 'Choose the Menu Font'
+ for: Preferences
+ setSelector: #setMenuFontTo:
+ getSelector: #standardMenuFont) open.
+ "
+ | instance |
+ instance := self new.
+ instance
+ title: titleString;
+ target: anObject;
+ setSelector: setSelector;
+ getSelector: getSelector.
+ ^instance!

Item was added:
+ ----- Method: Morph>>openModal: (in category 'polymorph') -----
+ openModal: aSystemWindow
+ "Open the given window locking the receiver until it is dismissed.
+ Answer the system window.
+ Restore the original keyboard focus when closed."
+
+ |area mySysWin keyboardFocus|
+ keyboardFocus _ self activeHand keyboardFocus.
+ mySysWin := self isSystemWindow ifTrue: [self] ifFalse: [self ownerThatIsA: SystemWindow].
+ mySysWin ifNil: [mySysWin := self].
+ mySysWin modalLockTo: aSystemWindow.
+ ( RealEstateAgent respondsTo: #reduceByFlaps: )
+ ifTrue:[
+ area := RealEstateAgent reduceByFlaps: RealEstateAgent maximumUsableArea]
+ ifFalse:[
+ area := RealEstateAgent maximumUsableArea].
+ aSystemWindow extent: aSystemWindow initialExtent.
+ aSystemWindow position = (0@0)
+ ifTrue: [aSystemWindow
+ position: self activeHand position - (aSystemWindow extent // 2)].
+ aSystemWindow
+ bounds: (aSystemWindow bounds translatedToBeWithin: area).
+ [ToolBuilder default runModal: aSystemWindow openAsIs]
+ ensure: [mySysWin modalUnlockFrom: aSystemWindow.
+ self activeHand newKeyboardFocus: keyboardFocus].
+ ^aSystemWindow!

Item was changed:
  ----- Method: TextEditor>>changeTextFont (in category 'attributes') -----
  changeTextFont
+ "Present a dialog which allows the user to select a font, and if one is chosen, apply it to the current selection. If there is no selection, or the selection is empty, apply it to the whole morph."
+ | curFont startIndex chooser newFont |
+ startIndex := self startIndex.
+ curFont := (paragraph text fontAt: startIndex withStyle: paragraph textStyle).
+ morph openModal: (
+ Cursor wait showWhile: [
+ (chooser := FontChooserTool default
+ withTitle: 'Change the selected text''s font to...' translated
+ for: self
+ setSelector: #changeSelectionFontTo:
+ getSelector: curFont) open]).
+ newFont := chooser result.
+ newFont ifNotNil:[self changeSelectionFontTo: newFont].!
- "Present a menu of available fonts, and if one is chosen, apply it to the current selection."
- | curFont newFont attr startIndex |
- startIndex _ self startIndex.
- curFont _ (paragraph text fontAt: startIndex withStyle: paragraph textStyle).
- newFont _ StrikeFont fromUser: curFont.
- newFont ifNil:[^self].
- attr _ TextFontReference toFont: newFont.
- paragraph text addAttribute: attr from: startIndex to: (self stopIndex-1 min: paragraph text size).
- paragraph composeAll.
- self recomputeInterval.
- morph changed.!

Item was added:
+ ----- Method: FontChooserTool class>>default: (in category 'accessing') -----
+ default: aFontChooser
+ "Answer the default font chooser tool"
+ Default := aFontChooser!

Item was added:
+ ----- Method: FontChooserTool>>windowTitle (in category 'initialize') -----
+ windowTitle
+ ^ title translated!

Item was added:
+ ----- Method: FontChooserTool>>selectedFontStyleIndex: (in category 'style list') -----
+ selectedFontStyleIndex: anIndex
+ anIndex = 0 ifTrue: [^self].
+ emphasis := anIndex - 1.
+ self changed: #selectedFontStyleIndex.
+ self changed: #contents.!

Item was added:
+ ----- Method: FontChooserTool>>target (in category 'accessing') -----
+ target
+ "Answer the value of target"
+
+ ^ target!

Item was added:
+ ----- Method: FontChooserTool>>selectedFontIndex (in category 'font list') -----
+ selectedFontIndex
+ | font textStyleName family |
+ selectedFontIndex ifNotNil: [^selectedFontIndex].
+ selectedFontIndex := 0.
+ font := (getSelector isSymbol and:[target notNil])
+ ifTrue:[target perform: getSelector]
+ ifFalse:[getSelector].
+ font ifNotNil:[
+ emphasis := font emphasis.
+ pointSize := font pointSize.
+ textStyleName := font textStyleName.
+ family := self fontList detect:[:f | f = textStyleName] ifNone:[].
+ ].
+ selectedFontIndex := self fontList indexOf: family ifAbsent:[0].
+ self selectedFontIndex: selectedFontIndex.
+ ^selectedFontIndex!

Item was changed:
  ----- Method: BalloonMorph class>>chooseBalloonFont (in category 'utility') -----
  chooseBalloonFont
  "BalloonMorph chooseBalloonFont"
 
+ Preferences
+ chooseFontWithPrompt:  'Ballon Help font...' translated
+ andSendTo: self
+ withSelector: #setBalloonFontTo:
+ highlightSelector: #balloonFont!
- Preferences chooseFontWithPrompt:  'Select the font to be
- used for balloon help' translated
- andSendTo: self withSelector: #setBalloonFontTo: highlight: BalloonFont!

Item was added:
+ ----- Method: FontChooserTool>>setSelector: (in category 'accessing') -----
+ setSelector: anObject
+ "Set the value of setSelector"
+
+ setSelector := anObject!

Item was added:
+ ----- Method: FontChooserTool>>buildButtonBarWith: (in category 'toolbuilder') -----
+ buildButtonBarWith: builder
+ "Build the button bar"
+ | panelSpec buttonSpec |
+ panelSpec := builder pluggablePanelSpec new.
+ panelSpec children: OrderedCollection new.
+
+ buttonSpec := builder pluggableButtonSpec new.
+ buttonSpec
+ model: self;
+ label: ' Apply ' translated;
+ action: #apply;
+ frame: (0.0@0 corner: 0.33@1).
+ panelSpec children addLast: buttonSpec.
+
+
+ buttonSpec := builder pluggableButtonSpec new.
+ buttonSpec
+ model: self;
+ label: '     OK     ' translated;
+ action: #accept;
+ frame: (0.33@0 corner: 0.67@1).
+ panelSpec children addLast: buttonSpec.
+
+ buttonSpec := builder pluggableButtonSpec new.
+ buttonSpec
+ model: self;
+ label: ' Cancel ' translated;
+ action: #cancel;
+ frame: (0.67@0 corner: 1@1).
+ panelSpec children addLast: buttonSpec.
+
+ ^panelSpec!

Item was added:
+ ----- Method: Morph>>modalLockTo: (in category 'polymorph') -----
+ modalLockTo: aSystemWindow
+ "Lock the receiver as a modal owner of the given window."
+
+ self lock!

Item was added:
+ ----- Method: FontChooserTool>>pointSize (in category 'point size') -----
+ pointSize
+ ^pointSize ifNil: [pointSize := 10.0]!

Item was added:
+ ----- Method: FontChooserTool>>buildWindowWith: (in category 'toolbuilder') -----
+ buildWindowWith: builder
+ | windowSpec |
+ windowSpec := builder pluggableWindowSpec new.
+ windowSpec model: self.
+ windowSpec label: #windowTitle.
+ windowSpec children: OrderedCollection new.
+ ^windowSpec!

Item was added:
+ ----- Method: FontChooserTool>>buildStyleListWith: (in category 'toolbuilder') -----
+ buildStyleListWith: builder
+ "Build the font choosers list of font styles"
+ | listSpec |
+ listSpec := builder pluggableListSpec new.
+ listSpec
+ model: self;
+ list: #fontStyleList;
+ getIndex: #selectedFontStyleIndex;
+ setIndex: #selectedFontStyleIndex:.
+ ^listSpec
+ !

Item was added:
+ ----- Method: FontChooserTool>>title: (in category 'accessing') -----
+ title: anObject
+ "Set the value of title"
+
+ title := anObject!

Item was changed:
  ----- Method: PluggableListMorph>>setListFont (in category 'menus') -----
  setListFont
  "set the font for the list"
 
+ Preferences
+ chooseFontWithPrompt: 'Choose the font for this list' translated
+ andSendTo: self
+ withSelector: #font:
+ highlightSelector: #font!
- Preferences chooseFontWithPrompt: 'Choose the font for this list' translated andSendTo: self withSelector: #font: highlight: self listMorph font!

Item was changed:
  ----- Method: SystemWindow>>activate (in category 'top window') -----
  activate
+ "Activate the owner too."
- "Bring me to the front and make me able to respond to mouse and keyboard"
 
+ |mo mc|
+ mo := self modalOwner.
+ mc := self modalChild.
+ mc isNil
+ ifFalse: [mc owner notNil ifTrue: [
+ mc activate.
+ ^mc modalChild isNil ifTrue: [mc flash]]].
+ (self paneMorphs size > 1 and: [self splitters isEmpty])
+ ifTrue: [self addPaneSplitters].
+ self activateWindow.
+ self rememberedKeyboardFocus
+ ifNil: [(self respondsTo: #navigateFocusForward)
+ ifTrue: [self navigateFocusForward]]
+ ifNotNilDo: [:m | m world
+ ifNil: [self rememberKeyboardFocus: nil] "deleted"
+ ifNotNilDo: [:w |
+ m wantsKeyboardFocus
+ ifTrue: [m takeKeyboardFocus]
+ ifFalse: [(self respondsTo: #navigateFocusForward)
+ ifTrue: [self navigateFocusForward]]]].
+ (mo notNil and: [mo isKindOf: SystemWindow])
+ ifTrue: [mo bringBehind: self]!
- | oldTop outerMorph sketchEditor pal |
- outerMorph := self topRendererOrSelf.
- outerMorph owner ifNil: [^ self "avoid spurious activate when drop in trash"].
- oldTop := TopWindow.
- TopWindow := self.
- oldTop ifNotNil: [oldTop passivate].
- outerMorph owner firstSubmorph == outerMorph
- ifFalse: ["Bring me (with any flex) to the top if not already"
- outerMorph owner addMorphFront: outerMorph].
- self submorphsDo: [:m | m unlock].
- labelArea ifNotNil:
- [labelArea submorphsDo: [:m | m unlock].
- self setStripeColorsFrom: self paneColorToUse].
- self isCollapsed ifFalse:
- [model modelWakeUpIn: self.
- self positionSubmorphs.
- labelArea ifNil: [self adjustBorderUponActivationWhenLabeless]].
-
- (sketchEditor := self extantSketchEditor) ifNotNil:
- [sketchEditor comeToFront.
- (pal := self world findA: PaintBoxMorph) ifNotNil:
- [pal comeToFront]].
- !

Item was added:
+ ----- Method: TextEditor>>changeTextFontDialog (in category 'attributes') -----
+ changeTextFontDialog
+ "Present a dialog which allows the user to select a font, and if one is chosen, apply it to the current selection. If there is no selection, or the selection is empty, apply it to the whole morph."
+ | curFont startIndex chooser newFont |
+ startIndex := self startIndex.
+ curFont := (paragraph text fontAt: startIndex withStyle: paragraph textStyle).
+ (curFont isKindOf: LogicalFont)
+ ifTrue:[
+ curFont := curFont copy.
+ ((paragraph text emphasisAt: startIndex) anyMask: 1) ifTrue:[curFont forceBold].
+ ((paragraph text emphasisAt: startIndex) anyMask: 2) ifTrue:[curFont forceItalicOrOblique].
+ curFont clearRealFont].
+ morph openModal: (
+ Cursor wait showWhile: [
+ (chooser := FontChooserTool default
+ withTitle: 'Change the selected text''s font to...' translated
+ for: self
+ setSelector: #changeSelectionFontTo:
+ getSelector: curFont) open]).
+ newFont := chooser result.
+ newFont ifNotNil:[self changeSelectionFontTo: newFont].!

Item was added:
+ ----- Method: FontChooserTool>>selectedPointSize (in category 'point size') -----
+ selectedPointSize
+ ^self selectedFont pointSize!

Item was added:
+ ----- Method: PasteUpMorph>>modalLockTo: (in category 'polymorph') -----
+ modalLockTo: aSystemWindow
+ "Don't lock the world!! Lock the submorphs.
+ The modal window gets opened afterwards so is OK."
+
+ |lockStates|
+ lockStates _ IdentityDictionary new.
+ self submorphsDo: [:m |
+ lockStates at: m put: m isLocked.
+ m lock].
+ self
+ setProperty: #submorphLockStates
+ toValue: lockStates!

Item was added:
+ ----- Method: FontChooserTool>>result (in category 'accessing') -----
+ result
+ ^result!

Item was added:
+ ----- Method: FontChooserTool>>contents (in category 'toolbuilder') -----
+ contents
+ | sample i c f |
+ sample := WriteStream on: ''.
+ f := self selectedFont ifNil:[^Text new].
+ f isSymbolFont ifFalse:[
+ sample
+ nextPutAll: 'the quick brown fox jumps over the lazy dog' ;cr;
+ nextPutAll:  'THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.' ;cr;cr;
+ nextPutAll: '0123456789'; cr; cr;
+ nextPutAll: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
+ yourself.
+ ] ifTrue:[
+ i := 0.
+ 33 to: 255 do:[:ci |
+ sample nextPut: (c:=Character value: ci).
+ i := i + 1.
+ (('@Z`z' includes:c) or:[i = 30])
+ ifTrue:[i :=0. sample cr]].
+ ].
+ sample := sample contents asText.
+ sample addAttribute: (TextFontReference toFont: f).
+ ^sample!

Item was added:
+ ----- Method: FontChooserTool>>selectedPointSizeIndex: (in category 'point size') -----
+ selectedPointSizeIndex: anIndex
+
+ anIndex = 0 ifTrue: [^self].
+ pointSize := (self pointSizeList at: anIndex) withBlanksTrimmed asNumber.
+ self changed: #pointSizeList.
+ self changed: #contents.!

Item was added:
+ ----- Method: FontChooserTool>>selectedFontIndex: (in category 'font list') -----
+ selectedFontIndex: anIndex
+ anIndex = 0 ifTrue: [^self].
+ selectedFontIndex := anIndex.
+ self changed: #selectedFontIndex.
+ self changed: #selectedFontStyleIndex.
+ self changed: #pointSizeList.
+ self changed: #pointSizeIndex.
+ self changed: #contents.!

Item was changed:
  ----- Method: StringMorph>>changeFont (in category 'menu') -----
  changeFont
+ | newFont chooser|
+ chooser := self openModal: (
+ Cursor wait showWhile: [UIManager default
+ chooseFont: 'Choose a Font'
+ for: self
+ setSelector: #font:
+ getSelector: self fontToUse]).
+ newFont := chooser result.
- | newFont |
- newFont := StrikeFont fromUser: self fontToUse.
  newFont ifNotNil:[self font: newFont].!

Item was added:
+ ----- Method: FontChooserTool>>target: (in category 'accessing') -----
+ target: anObject
+ "Set the value of target"
+
+ target := anObject!

Item was added:
+ ----- Method: FontChooserTool>>buildWindowWith:specs: (in category 'toolbuilder') -----
+ buildWindowWith: builder specs: specs
+ | windowSpec rect action widgetSpec |
+ windowSpec := self buildWindowWith: builder.
+ specs do:[:assoc|
+ rect := assoc key.
+ action := assoc value.
+ widgetSpec := action value.
+ widgetSpec ifNotNil:[
+ widgetSpec frame: rect.
+ windowSpec children add: widgetSpec]].
+ ^windowSpec!

Item was added:
+ ----- Method: FontChooserTool class>>openWithWindowTitle:for:setSelector:getSelector: (in category 'opening') -----
+ openWithWindowTitle: titleString for: anObject setSelector: setSelector getSelector: getSelector
+ "
+ FontChooserTool
+ openWithWindowTitle: 'Choose the Menu Font'
+ for: Preferences
+ setSelector: #setMenuFontTo:
+ getSelector: #standardMenuFont.
+ "
+ ^(self withTitle: titleString for: anObject setSelector: setSelector getSelector: getSelector) open!

Item was added:
+ ----- Method: FontChooserTool class>>windowTitle:for:setSelector:getSelector: (in category 'opening') -----
+ windowTitle: titleString for: anObject setSelector: setSelector getSelector: getSelector
+ | instance |
+
+ instance := self new.
+ instance
+ title: titleString;
+ target: anObject;
+ setSelector: setSelector;
+ getSelector: getSelector.
+ ^instance open!

Item was added:
+ ----- Method: SystemWindow>>modalOwner (in category 'polymorph') -----
+ modalOwner
+ "Answer the modal owner of the receiver, if any."
+
+ ^self valueOfProperty: #modalOwner!

Item was added:
+ ----- Method: PasteUpMorph>>modalUnlockFrom: (in category 'polymorph') -----
+ modalUnlockFrom: aSystemWindow
+ "Don't unlock the world!! Unlock the submorphs
+ that were not originally locked."
+
+ |lockStates|
+ lockStates := self
+ valueOfProperty: #submorphLockStates
+ ifAbsent: [^self].
+ self removeProperty: #submorphLockStates.
+ lockStates keysAndValuesDo: [:m :locked |
+ locked ifFalse: [m unlock]]!

Item was added:
+ ----- Method: FontChooserTool>>buildFontListWith: (in category 'toolbuilder') -----
+ buildFontListWith: builder
+ "Build the font choosers list of font names"
+ | listSpec |
+ listSpec := builder pluggableListSpec new.
+ listSpec
+ model: self;
+ list: #fontList;
+ getIndex: #selectedFontIndex;
+ setIndex: #selectedFontIndex:.
+ ^listSpec
+ !

Item was added:
+ ----- Method: FontChooserTool>>getSelector (in category 'accessing') -----
+ getSelector
+ "Answer the value of getSelector"
+
+ ^ getSelector!

Item was added:
+ ----- Method: FontChooserTool>>pointSizeList (in category 'point size') -----
+ pointSizeList
+ ^self selectedFont textStyle pointSizes collect: [:each | each asString padded: #left to: 3 with: $ ]!

Item was added:
+ ----- Method: FontChooserTool>>buildPreviewPaneWith: (in category 'toolbuilder') -----
+ buildPreviewPaneWith: builder
+ "Build the preview panel"
+ | textSpec |
+ textSpec := builder pluggableTextSpec new.
+ textSpec
+ model: self;
+ getText: #contents.
+ ^textSpec!

Item was added:
+ ----- Method: FontChooserTool>>selectedFontStyleIndex (in category 'style list') -----
+ selectedFontStyleIndex
+ "This is a hack"
+ ^emphasis+1!

Item was changed:
  ----- Method: TransformMorph>>drawSubmorphsOn: (in category 'drawing') -----
  drawSubmorphsOn: aCanvas
 
  aCanvas transformBy: transform
  clippingTo: self innerBounds
  during: [:myCanvas |
+ (self angle ~= 0.0 or: [self scale ~= 1.0])
+ ifTrue:[
+ AbstractFont forceNonSubPixelDuring:[
+ submorphs reverseDo:[:m | myCanvas fullDrawMorph: m] ] ]
+ ifFalse:[
+ submorphs reverseDo:[:m | myCanvas fullDrawMorph: m] ] ]
- submorphs reverseDo:[:m | myCanvas fullDrawMorph: m] ]
  smoothing: smoothing!

Item was added:
+ Model subclass: #FontChooserTool
+ instanceVariableNames: 'title selectedFontIndex fontList target getSelector setSelector pointSize emphasis window result'
+ classVariableNames: 'Default'
+ poolDictionaries: ''
+ category: 'Morphic-Support'!
+
+ !FontChooserTool commentStamp: 'ar 8/30/2009 14:28' prior: 0!
+ A ToolBuilder version of FreeTypePlus' FontChooser[Morph].!

Item was added:
+ ----- Method: FontChooserTool class>>open (in category 'opening') -----
+ open
+ "
+ FontChooserTool open.
+ "
+ ^self new open!

Item was added:
+ ----- Method: SystemWindow>>modalUnlockFrom: (in category 'polymorph') -----
+ modalUnlockFrom: aSystemWindow
+ "Unlock the receiver as a modal owner of the given window."
+
+ aSystemWindow removeProperty: #modalOwner.
+ self removeProperty: #modalChild.
+ self activate!

Item was changed:
  ----- Method: GrafPort>>installStrikeFont:foregroundColor:backgroundColor: (in category 'private') -----
  installStrikeFont: aStrikeFont foregroundColor: foregroundColor backgroundColor: backgroundColor
  super installStrikeFont: aStrikeFont foregroundColor: foregroundColor backgroundColor: backgroundColor.
- alpha := foregroundColor privateAlpha.
  aStrikeFont glyphs depth = 1 ifTrue: [
+ alpha := foregroundColor privateAlpha.
  "dynamically switch between blend modes to support translucent text"
  "To handle the transition from TTCFont to StrikeFont, rule 34 must be taken into account."
  alpha = 255 ifTrue:[
  combinationRule = 30 ifTrue: [combinationRule := Form over].
  combinationRule = 31 ifTrue: [combinationRule := Form paint].
  combinationRule = 34 ifTrue: [combinationRule := Form paint].
+ combinationRule = 41 ifTrue: [combinationRule := Form paint]. "41 is  SPRmode"
  ] ifFalse:[
  combinationRule = Form over ifTrue: [combinationRule := 30].
  combinationRule = Form paint ifTrue: [combinationRule := 31].
  combinationRule = 34 ifTrue: [combinationRule := 31].
+ combinationRule = 41 ifTrue: [combinationRule := 31]. "41 is SPR mode"
+ ]
- ].
  ].
  lastFont := aStrikeFont.
  lastFontForegroundColor := foregroundColor.
  lastFontBackgroundColor := backgroundColor.
  !

Item was added:
+ ----- Method: FontChooserTool>>selectedFont (in category 'font list') -----
+ selectedFont
+ | font family |
+ family := self fontList at: self selectedFontIndex ifAbsent:[^TextStyle defaultFont].
+ font := (TextStyle named: family) fontOfPointSize: pointSize.
+ ^font emphasized: emphasis!

Item was added:
+ ----- Method: FontChooserTool>>apply (in category 'actions') -----
+ apply
+ | font |
+ target ifNotNil:[
+ setSelector ifNotNil:[
+ font := self selectedFont.
+ font ifNotNil:[
+ target perform: setSelector with: font]]].!

Item was added:
+ ----- Method: TextEditor>>changeSelectionFontTo: (in category 'attributes') -----
+ changeSelectionFontTo: aFont
+ | attr |
+ aFont ifNil:[^self].
+ attr _ TextFontReference toFont: aFont.
+ paragraph text addAttribute: attr from: self startIndex to: (self stopIndex-1 min: paragraph text size).
+ paragraph composeAll.
+ self recomputeInterval.
+ morph changed.!

Item was added:
+ ----- Method: FontChooserTool class>>default (in category 'accessing') -----
+ default
+ "Answer the default font chooser tool"
+ ^Default ifNil:[self]!

Item was added:
+ ----- Method: FontChooserTool>>pointSize: (in category 'point size') -----
+ pointSize: aNumber
+ pointSize := aNumber.
+ self changed: #pointSize.
+ self changed: #contents.!

Item was added:
+ ----- Method: FontChooserTool>>selectedFontFamily (in category 'font list') -----
+ selectedFontFamily
+ ^self fontList at: self selectedFontIndex ifAbsent:[nil].
+
+ !

Item was added:
+ ----- Method: FontChooserTool>>getSelector: (in category 'accessing') -----
+ getSelector: aSelectorSymbolOrFont
+ "Set the value of getSelector"
+
+ getSelector := aSelectorSymbolOrFont!

Item was added:
+ ----- Method: FontChooserTool>>fontList (in category 'font list') -----
+ fontList
+ "List of available font family names"
+ ^fontList ifNil:[fontList := (TextConstants select: [:each | each isKindOf: TextStyle]) keys asArray sort]!

Item was added:
+ ----- Method: SystemWindow>>modalLockTo: (in category 'polymorph') -----
+ modalLockTo: aSystemWindow
+ "Lock the receiver as a modal owner of the given window."
+
+ aSystemWindow
+ setProperty: #modalOwner toValue: self.
+ self setProperty: #modalChild toValue: aSystemWindow!

Item was added:
+ ----- Method: TextMorphEditor>>changeSelectionFontTo: (in category 'attributes') -----
+ changeSelectionFontTo: aFont
+ | attr |
+ aFont ifNil:[^self].
+ attr _ TextFontReference toFont: aFont.
+ paragraph text addAttribute: attr from: self startIndex to: (self stopIndex-1 min: paragraph text size).
+ paragraph composeAll.
+ self recomputeInterval.
+ morph changed.!

Item was added:
+ ----- Method: FontChooserTool>>initialize (in category 'initialize') -----
+ initialize
+ super initialize.
+ title := 'Choose A Font'.
+ getSelector := TextStyle defaultFont.
+ emphasis := 0.!

Item was added:
+ ----- Method: FontChooserTool>>accept (in category 'actions') -----
+ accept
+ self apply.
+ result := self selectedFont.
+ ToolBuilder default close: window.!

Item was added:
+ ----- Method: FontChooserTool>>window (in category 'accessing') -----
+ window
+ ^window!

Item was added:
+ ----- Method: FontChooserTool>>initialExtent (in category 'initialize') -----
+ initialExtent
+ ^400@300!