'From Squeak3.3alpha of 12 January 2002 [latest update: #4790] on 5 March 2002 at 3:22:25 pm'! "Change Set: prefSym-sw Date: 5 March 2002 Author: Scott Wallace Fixes a problem with string-valued preference categories"! !Preference methodsFor: 'initialization' stamp: 'sw 3/5/2002 14:12'! name: aName defaultValue: aValue helpString: aString localToProject: projectBoolean categoryList: aList changeInformee: informee changeSelector: aChangeSelector "Initialize the preference from the given values. There is an extra tolerence here for the symbols #true, #false, and #nil, which are interpreted, when appropriate, as meaning true, false, and nil" name _ aName asSymbol. defaultValue _ aValue == true or: [aValue = #true]. value _ defaultValue. helpString _ aString. localToProject _ projectBoolean == true or: [projectBoolean = #true]. categoryList _ (aList ifNil: [OrderedCollection with: #unclassified]) collect: [:elem | elem asSymbol]. changeInformee _ (informee == nil or: [informee == #nil]) ifTrue: [nil] ifFalse: [(informee isKindOf: Symbol) ifTrue: [Smalltalk at: informee] ifFalse: [informee]]. changeSelector _ aChangeSelector! ! !Preferences class methodsFor: 'preferences panel' stamp: 'sw 3/5/2002 15:21'! 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 | controlPage addMorphBack: (aPreference representativeButtonWithColor: cc inPanel: aPanel)]. controlPage setNameTo: aCat asString. aCat = #? ifTrue: [aPanel addHelpItemsTo: controlPage]. aCat = #halos ifTrue: [aPanel addHaloControlsTo: 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']. maxEntriesPerCategory _ maxEntriesPerCategory max: prefObjects size]. tabbedPalette selectTabNamed: '?'. tabsMorph rowsNoWiderThan: aPasteUpMorph width. aPasteUpMorph on: #mouseDown send: #yourself to: #(). anExtent _ aPasteUpMorph width @ (25 + tabsMorph height + (20 * maxEntriesPerCategory)). aPasteUpMorph extent: anExtent. aPasteUpMorph color: aColor. aPasteUpMorph addMorphBack: tabbedPalette.! ! !Preferences class methodsFor: 'preferences panel' stamp: 'sw 3/5/2002 13:58'! listOfCategories "Answer a list of category names for the preferences panel" | categoryNames | categoryNames _ Set new. DictionaryOfPreferences do: [:aPreference | categoryNames addAll: (aPreference categoryList collect: [:n | n asSymbol])]. categoryNames _ categoryNames asSortedArray. ^ {#?}, categoryNames asSortedArray, {#'search results'} "Preferences listOfCategories" ! ! "Postscript:" Preferences allPreferenceObjects do: [:pr | pr categoryList ifNotNil: [pr categoryList: (pr categoryList collect: [:cat | cat asSymbol])]]. !