'From Squeak3.2alpha of 2 October 2001 [latest update: #4482] on 13 November 2001 at 9:19:55 pm'! "Change Set: makeThumbnailTweak2 Date: 13 November 2001 Author: Dan Ingalls Amends the earlier changeSet makeThumbnailTweak so as to properly include the offset of a form being used to build a thumnail image. Also fixes a problem with overly bold labels on flapTabs (a side-effect of #4460 keepTextFont). In the postscript, all shared flaps will be reinitialized to take advantage of the changes. "! !FlapTab methodsFor: 'textual tabs' stamp: 'di 11/13/2001 20:41'! assumeString: aString font: aFont orientation: anOrientation color: aColor | aTextMorph workString pad | pad _ (anOrientation == #vertical) ifTrue: [Character cr] ifFalse: [Character space]. workString _ String streamContents: [:s | aString do: [:c | s nextPut: c] separatedBy: [s nextPut: pad]]. (anOrientation == #vertical) ifFalse: [workString _ ' ' , workString , ' ']. aTextMorph _ (TextMorph new beAllFont: aFont) contents: workString asText. self removeAllMorphs. self addMorph: aTextMorph centered. aTextMorph lock. anOrientation == #horizontal ifTrue: [self borderWidth: 0] ifFalse: [self borderWidth: 3; borderColor: #raised]. self fitContents. aColor ifNotNil: [self color: aColor]. aTextMorph position: self position. self layoutChanged! ! !FlapTab methodsFor: 'miscellaneous' stamp: 'di 11/13/2001 21:18'! balloonTextForFlapsMenu "Answer the balloon text to show on a menu item in the flaps menu that governs the visibility of the receiver in the current project" | id | id _ self flapID. #( ('Squeak' 'A flap with various generally-useful controls for updating the system, navigating among projects, etc.') ('Tools' 'A quick way to get browsers, change sorters, file lists, etc.') ('Widgets' 'A variety of controls and media tools') ('Supplies' 'A source for many basic types of objects') ('Stack Tools' 'Tools for building stacks. Caution!! Powerful but young and underdocumented') ('Scripting' 'Tools useful when doing tile scripting'.) ('Painting' 'A flap housing the paint palette. Click on the closed tab to make make a new painting')) do: [:pair | id = pair first ifTrue: [^ pair second]. "Make this work for IDs assigned as, eg, Stack Tools2'..." ((id beginsWith: pair first) and: [(id copyFrom: pair first size+1 to: id size) allSatisfy: [:c | c isDigit]]) ifTrue: [^ pair second]]. ^ self balloonText! ! !Flaps class methodsFor: 'predefined flaps' stamp: 'di 11/13/2001 20:02'! stackToolsFlapTab "Answer the tab that represents the shared tools flap, or nil if none." ^ self globalFlapTabWithID: 'Stack Tools'! ! !Flaps class methodsFor: 'replacement' stamp: 'di 11/13/2001 20:01'! replaceStackToolsFlap "if there is a global tools flap, replace it with an updated one." | aFlapTab | aFlapTab _ self stackToolsFlapTab ifNil: [^ self]. self removeFlapTab: aFlapTab keepInList: false. self addGlobalFlap: self newStackToolsFlap. self currentWorld ifNotNil: [self currentWorld addGlobalFlaps] "Flaps replaceStackToolsFlap"! ! !Thumbnail methodsFor: 'thumnail creation' stamp: 'di 11/13/2001 19:53'! makeThumbnailFromForm: aForm "Make a thumbnail from the form provided, obeying my min and max width and height preferences" | scaleX scaleY margin opaque | scaleY _ minimumHeight / aForm height. "keep height invariant" scaleX _ ((aForm width * scaleY) <= maximumWidth) ifTrue: [scaleY] "the usual case; same scale factor, to preserve aspect ratio" ifFalse: [scaleY _ maximumWidth / aForm width]. "self form: (aForm magnify: aForm boundingBox by: (scaleX @ scaleY) smoothing: 2)." "Note: A problem with magnify:by: fails to reproduce borders properly. The following code does a better job..." margin _ 1.0 / (scaleX@scaleY) // 2 max: 0@0. "Extra margin around border" opaque _ (Form extent: aForm extent + margin depth: aForm depth) "fillWhite". aForm displayOn: opaque at: aForm offset negated rule: Form paint. "Opaque form shrinks better" self form: (opaque magnify: opaque boundingBox by: (scaleX @ scaleY) smoothing: 2). self extent: originalForm extent! ! "Postscript: Recreate shared flaps if it's OK with the user." PartsBin clearThumbnailCache. Preferences okToReinitializeFlaps ifTrue: [Flaps replaceSuppliesFlap]. Preferences okToReinitializeFlaps ifTrue: [Flaps replaceToolsFlap]. Preferences okToReinitializeFlaps ifTrue: [Flaps replaceWidgetsFlap]. Preferences okToReinitializeFlaps ifTrue: [Flaps replaceStackToolsFlap]. !