'From etoys2.2 of 24 September 2007 [latest update: #1771] on 9 November 2007 at 11:48:38 pm'! "Change Set: noKomika-sw Date: 9 November 2007 Author: Scott Wallace Eliminate remaining uses of Komika font in the etoys UI. Adds an eToyTitleFont item to the font-configuration menu. Makes the font-configuration menu be an UpdatingMenuMorph."! !GenericPropertiesMorph methodsFor: 'initialization' stamp: 'sw 11/9/2007 23:11'! buttonNamed: aString action: aSymbol color: aColor help: helpString "Answer a button with the string provided as label, with the receiver as target, and with the given action; give it the color specified, and associate the given help-sting with it." | f col | f _ SimpleButtonMorph new target: self; labelString: aString font: Preferences standardEToysButtonFont; color: aColor; actionSelector: aSymbol; setBalloonText: helpString. col _ (self inAColumn: {f}) hResizing: #shrinkWrap. ^ col! ! !GenericPropertiesMorph methodsFor: 'olpc' stamp: 'sw 11/9/2007 19:04'! lockedString: s "Answer a StringMorph with the given string as contents, rendered in a font appropriate for deployment within the receiver." ^ (StringMorph contents: s font: Preferences standardEToysFont) lock! ! !PlaybackInvoker methodsFor: 'appearance' stamp: 'sw 11/9/2007 23:16'! showString: aString "Make the receiver show the given string." | str rec | str := StringMorph contents: aString font: Preferences standardEToysButtonFont. rec := RectangleMorph new extent: (str extent + (10@10)); color: (Color r: 0.677 g: 0.935 b: 0.484); borderWidth: 1; yourself. rec addMorphBack: str. rec useRoundedCorners. str center: rec center. self form: rec imageForm ! ! !Preferences class methodsFor: 'fonts' stamp: 'sw 11/9/2007 17:39'! chooseEToysTitleFont "Present a menu with the possible fonts for etoy titles" self chooseFontWithPrompt: 'Choose the etoy title font' translated andSendTo: self withSelector: #setEToysTitleFontTo: highlight: self standardEToysTitleFont! ! !Preferences class methodsFor: 'fonts' stamp: 'sw 11/9/2007 23:46'! printStandardSystemFonts "Open a window showing the details of the current settings of the standard system fonts. Consider also: TheWorldMenu new adaptToWorld: ActiveWorld; standardFontDo " | string | string := String streamContents: [ :s | #(standardDefaultTextFont standardListFont standardFlapFont standardEToysFont standardEToysButtonFont standardEToysCodeFont standardEToysTitleFont standardMenuFont windowTitleFont standardBalloonHelpFont standardCodeFont standardButtonFont) do: [:selector | | font | font _ Preferences perform: selector. s nextPutAll: selector; space; nextPutAll: font familyName; space; nextPutAll: (AbstractFont emphasisStringFor: font emphasis); nextPutAll: ' points: '; print: font pointSize; nextPutAll: ' height: '; print: font height; cr ]]. (StringHolder new) contents: string; openLabel: 'Current system font settings' translated. ! ! !Preferences class methodsFor: 'fonts' stamp: 'sw 11/9/2007 23:34'! restoreDefaultFonts "Since this is called from menus, we can take the opportunity to prompt for missing font styles." " Preferences restoreDefaultFonts " Preferences setDefaultFonts: #( (setListFontTo: BitstreamVeraSans 15) (setFlapsFontTo: BitstreamVeraSansBold 15) (setEToysButtonFontTo: BitstreamVeraSans 15) (setEToysFontTo: BitstreamVeraSansBold 15) (setEToysCodeFontTo: BitstreamVeraSans 24) (setEToysTitleFontTo: BitstreamVeraSans 32) (setPaintBoxButtonFontTo: BitstreamVeraSans 9) (setMenuFontTo: BitstreamVeraSans 15) (setWindowTitleFontTo: BitstreamVeraSans 15) (setBalloonHelpFontTo: BitstreamVeraSans 15) ). ! ! !Preferences class methodsFor: 'fonts' stamp: 'sw 11/9/2007 17:42'! setEToysTitleFontTo: aFont "change the title font used in eToys environment" Parameters at: #eToysTitleFont put: aFont! ! !Preferences class methodsFor: '*green' stamp: 'sw 11/9/2007 17:56'! fontConfigurationMenu "Answer a menu that lets the user set system fonts" | aMenu | aMenu := UpdatingMenuMorph new defaultTarget: self. aMenu updater: self updateSelector: #rebuildFontConfigurationMenu:. aMenu updateMenu. ^ aMenu! ! !Preferences class methodsFor: '*green' stamp: 'sw 11/9/2007 22:07'! rebuildFontConfigurationMenu: aMenu "Rebuild the font-configuration menu." aMenu addTitle: 'Standard System Fonts' translated. aMenu addStayUpIcons. aMenu add: 'default text font...' translated action: #chooseSystemFont. aMenu balloonTextForLastItem: 'Choose the default font to be used for code and in workspaces, transcripts, etc.' translated. aMenu lastItem font: Preferences standardDefaultTextFont. aMenu add: 'list font...' translated action: #chooseListFont. aMenu lastItem font: Preferences standardListFont. aMenu balloonTextForLastItem: 'Choose the font to be used in list panes' translated. aMenu add: 'flaps font...' translated action: #chooseFlapsFont. aMenu lastItem font: Preferences standardFlapFont. aMenu balloonTextForLastItem: 'Choose the font to be used on textual flap tabs' translated. aMenu add: 'etoy tile font...' translated action: #chooseEToysFont. aMenu lastItem font: Preferences standardEToysFont. aMenu balloonTextForLastItem: 'Choose the font to be used on etoy tiles' translated. aMenu add: 'etoy button font...' translated action: #chooseEToysButtonFont. aMenu lastItem font: Preferences standardEToysButtonFont. aMenu balloonTextForLastItem: 'Choose the font to be used on etoy buttons' translated. aMenu add: 'etoy code font...' translated action: #chooseEToysCodeFont. aMenu lastItem font: Preferences standardEToysCodeFont. aMenu balloonTextForLastItem: 'Choose the font to be used for textual code in etoys' translated. aMenu add: 'etoy title font...' translated action: #chooseEToysTitleFont. aMenu lastItem font: Preferences standardEToysTitleFont. aMenu balloonTextForLastItem: 'Choose the font to be used titles in etoys' translated. " aMenu add: 'halo label font...' translated action: #chooseHaloLabelFont. aMenu lastItem font: Preferences standardHaloLabelFont. aMenu balloonTextForLastItem: 'Choose the font to be used on labels in halo' translated. aMenu add: 'object name font...' translated action: #chooseObjectNameFont. aMenu lastItem font: Preferences standardObjectNameFont. aMenu balloonTextForLastItem: 'Choose the font to be used for object names' translated." aMenu add: 'menu font...' translated action: #chooseMenuFont. aMenu lastItem font: Preferences standardMenuFont. aMenu balloonTextForLastItem: 'Choose the font to be used in menus' translated. aMenu add: 'window-title font...' translated action: #chooseWindowTitleFont. aMenu lastItem font: Preferences windowTitleFont emphasis: 1. aMenu balloonTextForLastItem: 'Choose the font to be used in window titles.' translated. aMenu add: 'balloon-help font...' translated action: #chooseBalloonHelpFont. aMenu lastItem font: Preferences standardBalloonHelpFont. aMenu balloonTextForLastItem: 'choose the font to be used when presenting balloon help.' translated. aMenu add: 'button font...' translated action: #chooseButtonFont. aMenu lastItem font: Preferences standardButtonFont. aMenu balloonTextForLastItem: 'Choose the font to be used for (some) buttons.' translated. aMenu add: 'code font...' translated action: #chooseCodeFont. aMenu lastItem font: Preferences standardCodeFont. aMenu balloonTextForLastItem: 'Choose the font to be used in code panes.' translated. aMenu addLine. aMenu add: 'restore default font choices' translated action: #restoreDefaultFonts. aMenu balloonTextForLastItem: 'Use the standard system font defaults' translated. aMenu add: 'show current font choices' translated action: #printStandardSystemFonts. aMenu balloonTextForLastItem: 'Open a window showing the current font settings' translated. aMenu addLine. aMenu add: 'refresh this menu' translated target: aMenu action: #updateMenu. aMenu balloonTextForLastItem: 'If any font settings have changed since you pinned this menu up, this will allow the menu to rebuilt to reflect current font choices.' translated. ^ aMenu! ! !StandardScriptingSystem methodsFor: 'font & color choices' stamp: 'sw 11/9/2007 23:33'! installOLPCFontsAndPreferences "Assures that some of the standard olpc font and scrolling choices are installed. This is for private use by developers who may have changed some font and scrolling preferences, for the benefit of development work." Preferences restoreDefaultFonts. Preferences enable: #inboardScrollbars. Preferences enable: #scrollBarsOnRight. Preferences enable: #mouseOverHalos. Preferences enable: #biggerHandles. Preferences disable: #escapeKeyProducesMenu. Preferences setParameter: #fontForBlueFileListTitle to: ((StrikeFont familyName: 'Accujen' size: 30) emphasized: 1). Preferences setParameter: #fontForBlueFileListButtons to: ((StrikeFont familyName: 'Accujen' size: 22) emphasized: 1). false ifTrue: [ScriptingSystem installOLPCFontsAndPreferences] "to have a sender" " ScriptingSystem installOLPCFontsAndPreferences. "! ! !StandardScriptingSystem methodsFor: 'help in a flap' stamp: 'sw 11/9/2007 18:22'! openInfoFlapWithLabel: aTitle helpContents: aString edge: anEdge "Open an info flap with the given label, contents, and edge" | aPlug outer leftStrip rightStrip titleRow aDismissButton aFlapTab | Preferences enable: #scrollBarsOnRight. Preferences enable: #inboardScrollbars. Preferences enable: #scrollBarsNarrow. aFlapTab := FlapTab new. aFlapTab assureExtension visible: false. aFlapTab referentMargin: (0 @ ActiveWorld sugarAllowance). outer := AlignmentMorph newRow. outer assureExtension visible: false. outer clipSubmorphs: true. outer beTransparent. outer vResizing: #spaceFill; hResizing: #spaceFill. outer layoutInset: 0; cellInset: 0; borderWidth: 0. outer setProperty: #morphicLayerNumber toValue: 26. leftStrip := Morph new beTransparent. leftStrip layoutInset: 0; cellInset: 0; borderWidth: 0. leftStrip width: 20. leftStrip hResizing: #rigid; vResizing: #spaceFill. outer addMorphBack: leftStrip. rightStrip := AlignmentMorph newColumn. rightStrip beTransparent. rightStrip layoutInset: 0; cellInset: 0; borderWidth: 0. outer addMorphBack: rightStrip. outer clipSubmorphs: true. titleRow := AlignmentMorph newRow. titleRow borderColor: Color veryVeryLightGray; borderWidth: 1. titleRow hResizing: #spaceFill; vResizing: #shrinkWrap. titleRow beTransparent. aDismissButton := aFlapTab tanOButton. aDismissButton actionSelector: #dismissViaHalo. titleRow addMorphFront: aDismissButton. titleRow addTransparentSpacerOfSize: 8 @ 0. titleRow addMorphBack: (StringMorph contents: aTitle font: Preferences standardEToysTitleFont). rightStrip addMorph: titleRow. aPlug := PluggableTextMorph new. aPlug width: 540. aPlug setText: aString. aPlug textMorph beAllFont: Preferences standardEToysFont. aPlug retractable: false; scrollBarOnLeft: false. aPlug hideHScrollBarIndefinitely: true. aPlug borderColor: ScriptingSystem borderColor. aPlug setNameTo: aTitle. aPlug hResizing: #spaceFill. aPlug vResizing: #spaceFill. rightStrip addMorphBack: aPlug. aFlapTab referent ifNotNil: [aFlapTab referent delete]. aFlapTab referent: outer. aFlapTab setName: aTitle edge: anEdge color: (Color r: 0.677 g: 0.935 b: 0.484). aFlapTab submorphs first beAllFont: Preferences standardEToysFont. ActiveWorld addMorphFront: aFlapTab. aFlapTab adaptToWorld: ActiveWorld. aFlapTab computeEdgeFraction. anEdge == #left ifTrue: [aFlapTab position: (outer left @ outer top). outer extent: (540 @ ActiveWorld height)]. anEdge == #right ifTrue: [aFlapTab position: ((ActiveWorld right - aFlapTab width) @ ActiveWorld top). outer extent: (540 @ ActiveWorld height)]. outer beFlap: true. outer color: Color green veryMuchLighter. aPlug textMorph lock. aFlapTab referent hide. aFlapTab openFully. outer beSticky. leftStrip beSticky. rightStrip beSticky. ActiveWorld doOneCycle. aPlug width: 540. aPlug setText: aString. "hmm, again" aPlug color: outer color. aPlug borderWidth: 0. aPlug textMorph contents: aString wrappedTo: 520. aFlapTab applyThickness: 560. aFlapTab fitOnScreen. aFlapTab referent show. ^ aFlapTab! ! "Postscript:" Preferences setEToysTitleFontTo: (StrikeFont familyName: 'BitstreamVeraSans' size: 32). !