'From etoys3.0 of 24 February 2008 [latest update: #1936] on 28 March 2008 at 11:40:33 pm'! "Change Set: transPrefPanel-KR Date: 28 March 2008 Author: Korakurider translate preference panel"! !BooleanPreferenceView methodsFor: 'user interface' stamp: 'KR 3/28/2008 23:29'! offerPreferenceNameMenu: aPanel with: ignored1 in: ignored2 "the user clicked on a preference name -- put up a menu" | aMenu | ActiveHand showTemporaryCursor: nil. aMenu := MenuMorph new defaultTarget: self preference. aMenu addTitle: self preference name. (Preferences okayToChangeProjectLocalnessOf: self preference name) ifTrue: [aMenu addUpdating: #isProjectLocalString target: self preference action: #toggleProjectLocalness. aMenu balloonTextForLastItem: 'Some preferences are best applied uniformly to all projects, and others are best set by each individual project. If this item is checked, then this preference will be printed in bold and will have a separate value for each project' translated]. aMenu add: 'browse senders' translated target: self systemNavigation selector: #browseAllCallsOn: argument: self preference name. aMenu balloonTextForLastItem: 'This will open a method-list browser on all methods that the send the preference "' translated, self preference name, '".'. aMenu add: 'show category...' translated target: aPanel selector: #findCategoryFromPreference: argument: self preference name. aMenu balloonTextForLastItem: 'Allows you to find out which category, or categories, this preference belongs to.' translated. Smalltalk isMorphic ifTrue: [aMenu add: 'hand me a button for this preference' translated target: self selector: #tearOffButton. aMenu balloonTextForLastItem: 'Will give you a button that governs this preference, which you may deposit wherever you wish' translated]. aMenu add: 'copy this name to clipboard' translated target: self preference selector: #copyName. aMenu balloonTextForLastItem: 'Copy the name of the preference to the text clipboard, so that you can paste into code somewhere' translated. aMenu popUpInWorld! ! !HaloThemePreferenceView methodsFor: 'user interface' stamp: 'KR 3/28/2008 23:22'! haloThemeRadioButtons "Answer a column of butons representing the choices of halo theme" | buttonColumn aRow aRadioButton aStringMorph | buttonColumn := AlignmentMorph newColumn beTransparent. #('iconic' 'classic' 'simple' 'custom') translatedNoop. #( (iconicHaloSpecifications iconic iconicHalosInForce 'circular halos with icons inside') (classicHaloSpecs classic classicHalosInForce 'plain circular halos') (simpleFullHaloSpecifications simple simpleHalosInForce 'fewer, larger halos') (customHaloSpecs custom customHalosInForce 'customizable halos')) translatedNoop do: [:quad | aRow := AlignmentMorph newRow beTransparent. aRow addMorph: (aRadioButton := UpdatingThreePhaseButtonMorph radioButton). aRadioButton target: Preferences. aRadioButton setBalloonText: quad fourth translated. aRadioButton actionSelector: #installHaloTheme:. aRadioButton getSelector: quad third. aRadioButton arguments: (Array with: quad first). aRow addTransparentSpacerOfSize: (4 @ 0). aRow addMorphBack: (aStringMorph := StringMorph contents: quad second asString translated). aStringMorph setBalloonText: quad fourth translated. buttonColumn addMorphBack: aRow]. ^ buttonColumn "(Preferences preferenceAt: #haloTheme) view tearOffButton"! ! !Preferences class methodsFor: 'preferences panel' stamp: 'KR 3/28/2008 23:08'! initializePreferencePanel: aPanel in: aPasteUpMorph "Initialize the given Preferences panel. in the given pasteup, which is the top-level panel installed in the container window. Also used to reset it after some change requires reformulation" | tabbedPalette controlPage aColor aFont maxEntriesPerCategory tabsMorph anExtent prefObjects cc | aPasteUpMorph removeAllMorphs. aFont := StrikeFont familyName: 'NewYork' size: 19. aColor := aPanel defaultBackgroundColor. tabbedPalette := TabbedPalette newSticky. tabbedPalette dropEnabled: false. (tabsMorph := tabbedPalette tabsMorph) color: aColor darker; highlightColor: Color red regularColor: Color brown darker darker. tabbedPalette on: #mouseDown send: #yourself to: #(). maxEntriesPerCategory := 0. self listOfCategories do: [:aCat | controlPage := AlignmentMorph newColumn beSticky color: aColor. controlPage on: #mouseDown send: #yourself to: #(). controlPage dropEnabled: false. Preferences alternativeWindowLook ifTrue: [cc := Color transparent. controlPage color: cc]. controlPage borderColor: aColor; layoutInset: 4. (prefObjects := self preferenceObjectsInCategory: aCat) do: [:aPreference | | button | button _ aPreference representativeButtonWithColor: cc inPanel: aPanel. button ifNotNil: [controlPage addMorphBack: button]]. controlPage setNameTo: aCat asString. aCat = #? ifTrue: [aPanel addHelpItemsTo: controlPage]. tabbedPalette addTabFor: controlPage font: aFont. aCat = 'search results' ifTrue: [(tabbedPalette tabNamed: aCat) setBalloonText: 'Use the ? category to find preferences by keyword; the results of your search will show up here' translated]. maxEntriesPerCategory := maxEntriesPerCategory max: prefObjects size]. tabbedPalette selectTabNamed: '?'. tabsMorph rowsNoWiderThan: aPasteUpMorph width. aPasteUpMorph on: #mouseDown send: #yourself to: #(). anExtent := aPasteUpMorph width @ (490 max: (25 + tabsMorph height + (20 * maxEntriesPerCategory))). aPasteUpMorph extent: anExtent. aPasteUpMorph color: aColor. aPasteUpMorph addMorphBack: tabbedPalette.! ! !Preferences class methodsFor: 'preferences panel' stamp: 'KR 3/28/2008 23:08'! openFactoredPanelWithWidth: aWidth "Open up a preferences panel of the given width" "Preferences openFactoredPanelWithWidth: 325" | window playfield aPanel | aPanel _ PreferencesPanel new. playfield _ PasteUpMorph new width: aWidth. playfield dropEnabled: false. self initializePreferencePanel: aPanel in: playfield. self couldOpenInMorphic ifTrue: [window _ (SystemWindow labelled: 'Preferences' translated) model: aPanel. window on: #keyStroke send: #keyStroke: to: aPanel. window bounds: (100 @ 100 - (0 @ window labelHeight + window borderWidth) extent: playfield extent + (2 * window borderWidth)). window addMorph: playfield frame: (0 @ 0 extent: 1 @ 1). window updatePaneColors. window setProperty: #minimumExtent toValue: playfield extent + (12@15). self currentWorld addMorphFront: window. window center: self currentWorld center. window activateAndForceLabelToShow] ifFalse: [(window _ MVCWiWPasteUpMorph newWorldForProject: nil) addMorph: playfield. MorphWorldView openOn: window label: 'Preferences' translated extent: playfield extent]! ! !PreferencesPanel methodsFor: 'initialization' stamp: 'KR 3/28/2008 23:34'! addModelItemsToWindowMenu: aMenu "aMenu is being constructed to be presented to the user in response to the user's pressing on the menu widget in the title bar of a morphic SystemWindow. Here, the model is given the opportunity to add any model-specific items to the menu, whose default target is the SystemWindow itself." true ifTrue: [^ self]. "The below are provisionally disenfranchised, because their function is now directly available in the ? category" aMenu addLine. aMenu add: 'find preference... (f)' translated target: self action: #findPreference:. aMenu add: 'inspect parameters' translated target: Preferences action: #inspectParameters! ! !PreferencesPanel methodsFor: 'find' stamp: 'KR 3/28/2008 23:18'! addHelpItemsTo: panelPage "Add the items appropriate the the ? page of the receiver" | aButton aTextMorph aMorph firstTextMorph | panelPage hResizing: #shrinkWrap; vResizing: #shrinkWrap. firstTextMorph _ TextMorph new contents: 'Search Preferences for:' translated. firstTextMorph beAllFont: ((TextStyle default fontOfSize: 13) emphasized: 1). panelPage addMorphBack: firstTextMorph lock. panelPage addTransparentSpacerOfSize: 0@10. aMorph _ RectangleMorph new clipSubmorphs: true; beTransparent; borderWidth: 2; borderColor: Color black; extent: 250 @ 36. aMorph vResizing: #rigid; hResizing: #rigid. aTextMorph _ PluggableTextMorph new on: self text: #searchString accept: #setSearchStringTo: readSelection: nil menu: nil. " aTextMorph hResizing: #rigid." aTextMorph borderWidth: 0. aTextMorph font: ((TextStyle default fontOfSize: 21) emphasized: 1); setTextColor: Color red. aMorph addMorphBack: aTextMorph. aTextMorph acceptOnCR: true. aTextMorph position: (aTextMorph position + (6@5)). aMorph clipLayoutCells: true. aTextMorph extent: 240 @ 25. panelPage addMorphBack: aMorph. aTextMorph setBalloonText: 'Type what you want to search for here, then hit the "Search" button, or else hit RETURN or ENTER' translated. aTextMorph setTextMorphToSelectAllOnMouseEnter. aTextMorph hideScrollBarsIndefinitely. panelPage addTransparentSpacerOfSize: 0@10. aButton _ SimpleButtonMorph new target: self; color: Color transparent; actionSelector: #initiateSearch:; arguments: {aTextMorph}; label: 'Search' translated. panelPage addMorphBack: aButton. aButton setBalloonText: 'Type what you want to search for in the box above, then click here (or hit RETURN or ENTER) to start the search; results will appear in the "search results" category.' translated. panelPage addTransparentSpacerOfSize: 0@30. panelPage addMorphBack: (SimpleButtonMorph new color: Color transparent; label: 'Restore all Default Preference Settings' translated; target: Preferences; actionSelector: #chooseInitialSettings; setBalloonText: 'Click here to reset all the preferences to their standard default values.' translated ; yourself). panelPage addTransparentSpacerOfSize: 0@14. panelPage addMorphBack: (SimpleButtonMorph new color: Color transparent; label: 'Save Current Settings as my Personal Preferences' translated; target: Preferences; actionSelector: #savePersonalPreferences; setBalloonText: 'Click here to save the current constellation of Preferences settings as your personal defaults; you can get them all reinstalled with a single gesture by clicking the "Restore my Personal Preferences".' translated; yourself). panelPage addTransparentSpacerOfSize: 0@14. panelPage addMorphBack: (SimpleButtonMorph new color: Color transparent; label: 'Restore my Personal Preferences' translated; target: Preferences; actionSelector: #restorePersonalPreferences; setBalloonText: 'Click here to reset all the preferences to their values in your Personal Preferences.' translated; yourself). panelPage addTransparentSpacerOfSize: 0@30. panelPage addMorphBack: (SimpleButtonMorph new color: Color transparent; label: 'Save Current Settings to Disk' translated; target: Preferences; actionSelector: #storePreferencesToDisk; setBalloonText: 'Click here to save the current constellation of Preferences settings to a file; you can get them all reinstalled with a single gesture by clicking "Restore Settings From Disk".' translated; yourself). panelPage addTransparentSpacerOfSize: 0@14. panelPage addMorphBack: (SimpleButtonMorph new color: Color transparent; label: 'Restore Settings from Disk' translated; target: Preferences; actionSelector: #restorePreferencesFromDisk; setBalloonText: 'Click here to load all the preferences from their saved values on disk.' translated; yourself). panelPage addTransparentSpacerOfSize: 0@30. panelPage addMorphBack: (SimpleButtonMorph new color: Color transparent; label: 'Inspect Parameters' translated; target: Preferences; actionSelector: #inspectParameters; setBalloonText: 'Click here to view all the values stored in the system Parameters dictionary' translated; yourself). panelPage addTransparentSpacerOfSize: 0@10. panelPage addMorphBack: (Preferences themeChoiceButtonOfColor: Color transparent font: TextStyle defaultFont). panelPage addTransparentSpacerOfSize: 0@10. panelPage addMorphBack: (SimpleButtonMorph new color: Color transparent; label: 'Help!!' translated; target: Preferences; actionSelector: #giveHelpWithPreferences; setBalloonText: 'Click here to get some hints on use of this Preferences Panel' translated; yourself). panelPage wrapCentering: #center. ! ! !PreferencesPanel methodsFor: 'find' stamp: 'KR 3/28/2008 23:33'! findPreference: evt "Allow the user to submit a selector fragment; search for that among preference names; put up a list of qualifying preferences; if the user selects one of those, redirect the preferences panel to reveal the chosen preference" self findPreferencesMatching: (FillInTheBlank request: 'Search for preferences containing:' translated initialAnswer: 'color')! ! !PreferencesPanel methodsFor: 'find' stamp: 'KR 3/28/2008 23:33'! searchString "Answer the current searchString, initializing it if need be" | win aMorph | searchString isEmptyOrNil ifTrue: [searchString _ 'Type here, hit Search' translated. (win _ self containingWindow) ifNotNil: [aMorph _ win findDeepSubmorphThat: [:m | m isKindOf: PluggableTextMorph] ifAbsent: [^ searchString]. aMorph setText: searchString. aMorph setTextMorphToSelectAllOnMouseEnter. aMorph selectAll]]. ^ searchString! ! !PreferencesPanel class methodsFor: 'window color' stamp: 'KR 3/28/2008 23:38'! windowColorSpecification "Answer a WindowColorSpec object that declares my preference" ^ WindowColorSpec classSymbol: self name wording: 'Preferences Panel' translated brightColor: #(0.645 1.0 1.0) pastelColor: #(0.886 1.0 1.0) helpMessage: 'A tool for expressing personal preferences for numerous options.' translated! !