'From Squeak3.2 of 11 July 2002 [latest update: #4956] on 30 September 2002 at 11:05:16 pm'! "Change Set: PatternLoader-sbw Date: 30 September 2002 Author: Stephan B Wessels Provides a previewer for images that can be loaded as the desktop. Opens up from the Appearance menu, via 'set desktop image...'. New capability from previous version of this change set includes a few options for how the desktop image is placed."! !FileList2 methodsFor: 'as yet unclassified' stamp: 'sbw 1/30/2002 00:55'! fileListIndex: anInteger super fileListIndex: anInteger. self changed: #imageDimensionContents. self updateImageMorph! ! !FileList2 methodsFor: 'as yet unclassified' stamp: 'sbw 3/8/2002 11:45'! imageDimensionContents | fName frm ext dpth strm label | label _ 'Dimensions: '. listIndex = 0 ifFalse: [fName _ self fullName. fName isNil ifFalse: [frm _ Form fromFileNamed: fName. frm isNil ifFalse: [ext _ frm extent. dpth _ frm depth. strm _ ReadWriteStream on: ''. strm nextPutAll: ' ' , ext x printString; nextPutAll: ' x ' , ext y printString; nextPutAll: ' x ' , dpth printString. ^ label, strm contents]]]. ^ label! ! !FileList2 methodsFor: 'as yet unclassified' stamp: 'sbw 3/8/2002 10:59'! imageMorph | win | win _ self topView. win isNil ifTrue: [^ nil]. ^ win submorphNamed: #image! ! !FileList2 methodsFor: 'as yet unclassified' stamp: 'sbw 3/8/2002 10:44'! morphicImageDimensionsPane | pane | pane _ PluggableTextMorph on: self text: #imageDimensionContents accept: nil readSelection: nil menu: nil. pane hideScrollBarIndefinitely; color: Color white. ^ pane! ! !FileList2 methodsFor: 'as yet unclassified' stamp: 'sbw 3/8/2002 11:09'! morphicImagePreviewPane | alignMorph | alignMorph _ AlignmentMorph newColumn beSticky. alignMorph borderWidth: 0; color: Color white; clipSubmorphs: true; layoutPolicy: ProportionalLayout new. alignMorph addMorphBack: (ImageMorph new name: #image; image: self whiteFormPreviewPane; yourself). ^alignMorph! ! !FileList2 methodsFor: 'as yet unclassified' stamp: 'sbw 9/28/2002 11:47'! openAsBackgroundWithOptions | choices actions response theForm | theForm _ Form fromFileNamed: self fullName. Smalltalk isMorphic ifFalse: [^ theForm setAsBackground]. choices _ #('Tile the image' 'Scale the image full' 'Scale the image keep aspect' 'Center the image' ). actions _ #(#tile #scale #aspect #center ). response _ (SelectionMenu labelList: choices selections: actions) startUpWithCaption: 'Set in background with option...'. response = #tile ifTrue: [^ theForm setAsBackground]. response = #scale ifTrue: [^ (theForm scaledToSize: self currentWorld extent) setAsBackground]. response = #aspect ifTrue: [^ self openImageCenteredOnBackground: (theForm scaledToSize: self currentWorld extent)]. response = #center ifTrue: [^ self openImageCenteredOnBackground: theForm]! ! !FileList2 methodsFor: 'as yet unclassified' stamp: 'sbw 9/28/2002 11:47'! openImageCenteredOnBackground: image | sketch previous | sketch _ SketchMorph withForm: image. sketch setToAdhereToEdge: #center; name: 'worldBackgroundImage'; lock. previous _ self currentWorld submorphNamed: 'worldBackgroundImage'. previous isNil ifFalse: [previous delete]. sketch openInWorld. sketch goBehind! ! !FileList2 methodsFor: 'as yet unclassified' stamp: 'sbw 3/8/2002 11:56'! optionalButtonRow | row | row _ super optionalButtonRow. Preferences alternativeWindowLook ifTrue: [row color: Color transparent. row submorphsDo: [:m | m borderWidth: 2; borderColor: #raised]]. ^row! ! !FileList2 methodsFor: 'as yet unclassified' stamp: 'sbw 1/30/2002 00:55'! preview ^Form fromFileNamed: self fullName! ! !FileList2 methodsFor: 'as yet unclassified' stamp: 'sbw 1/30/2002 10:29'! setSelectedDirectoryTo: aFileDirectoryWrapper currentDirectorySelected _ aFileDirectoryWrapper. self directory: aFileDirectoryWrapper withoutListWrapper. brevityState _ #FileList. "self addPath: path." self changed: #fileList. self changed: #contents. self changed: #getSelectedDirectory. self changed: #imageDimensionContents. self updateImageMorph! ! !FileList2 methodsFor: 'as yet unclassified' stamp: 'sbw 3/8/2002 11:43'! updateImageMorph | morph form preview limits ratio ext fName | morph _ self imageMorph. morph isNil ifTrue: [^ nil]. listIndex = 0 ifTrue: [preview _ self whiteFormPreviewPane] ifFalse: [fName _ self fullName. fName isNil ifFalse: [form _ self preview. limits _ morph owner extent - (2*(self class previewWhiteSpace@self class previewWhiteSpace)). (form width <= limits x and: [form height <= limits y]) ifTrue: [preview _ form] ifFalse: [form width > form height ifTrue: [ratio _ limits x / form width] ifFalse: [ratio _ limits y / form height]. ext _ (form extent * ratio) rounded. preview _ form scaledToSize: ext]]]. morph newForm: preview. morph layoutChanged! ! !FileList2 methodsFor: 'as yet unclassified' stamp: 'sbw 3/8/2002 11:07'! whiteFormPreviewPane | whiteForm extent iMorph | extent _ 1 @ 1. self topView isNil ifFalse: [iMorph _ self imageMorph. iMorph isNil ifFalse: [extent _ iMorph extent]]. whiteForm _ Form extent: extent depth: 32. whiteForm fill: whiteForm boundingBox fillColor: self defaultBackgroundColor. ^ whiteForm! ! !FileList2 class methodsFor: 'morphic ui' stamp: 'sbw 3/8/2002 11:41'! buildPreviewerPane: aFileList | alignMorph listHeight dimHeight space | listHeight _ 70. dimHeight _ 16. space _ self previewWhiteSpace. alignMorph _ AlignmentMorph newColumn beSticky. alignMorph borderWidth: 0; color: Color white; clipSubmorphs: true; layoutPolicy: ProportionalLayout new. alignMorph addMorph: aFileList morphicFileListPane fullFrame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 0) offsets: (16 @ 0 corner: 0 @ listHeight)). alignMorph addMorph: aFileList morphicImageDimensionsPane fullFrame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 0) offsets: (16 @ (listHeight + space) corner: 0 @ (listHeight + space + dimHeight))). alignMorph addMorph: aFileList morphicImagePreviewPane fullFrame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 1) offsets: (space @ (listHeight + space + dimHeight + space) corner: space negated @ space negated)). ^ alignMorph! ! !FileList2 class methodsFor: 'morphic ui' stamp: 'sbw 3/8/2002 11:57'! morphicViewImageViewerWithPreview | dir aFileList window firstLine fixedSize | dir _ FileDirectory default. aFileList _ self new directory: dir. aFileList optionalButtonSpecs: self specsForImageViewPreviewer. aFileList fileSelectionBlock: [:entry :myPattern | entry isDirectory ifTrue: [false] ifFalse: [#('bmp' 'gif' 'jpg' 'form' 'png' 'jpeg' ) includes: (aFileList getSuffix: entry name asLowercase)]] fixTemps. window _ (SystemWindow labelled: 'Select image for desktop') model: aFileList. fixedSize _ 27. firstLine _ 0.4. "morph, frame, offsets" self addFullPanesTo: window from: {{aFileList optionalButtonRow. 0 @ 0 corner: 1 @ 0. 0 @ 0 corner: 0 @ fixedSize}. {aFileList morphicDirectoryTreePane. 0 @ 0 corner: firstLine @ 1. 0 @ fixedSize corner: 0 @ 0}. {self buildPreviewerPane: aFileList. firstLine @ 0 corner: 1 @ 1. 0 @ fixedSize corner: 0 @ 0}}. aFileList postOpen. ^ window! ! !FileList2 class methodsFor: 'morphic ui' stamp: 'sbw 3/8/2002 11:41'! previewWhiteSpace ^3! ! !FileList2 class methodsFor: 'morphic ui' stamp: 'sbw 9/28/2002 10:39'! specsForImageViewPreviewer ^ #(#('Name' #sortByName #sortingByName 'sort entries by name') #('Date' #sortByDate #sortingByDate 'sort entries by date') #('Size' #sortBySize #sortingBySize 'sort entries by size') #('Import' #importImage #none 'read image into ImageImports') #('Bgnd...' #openAsBackgroundWithOptions #none 'open image as background (with options)') )! ! !FileList2 class methodsFor: 'instance creation' stamp: 'sbw 1/30/2002 01:04'! openMorphicViewWithPreviewInWorld "FileList2 openMorphicViewWithPreviewInWorld" ^ self morphicViewImageViewerWithPreview openInWorld! ! !TheWorldMenu methodsFor: 'construction' stamp: 'sbw 9/25/2002 21:11'! appearanceMenu "Build the appearance menu for the world." | screenCtrl | screenCtrl _ ScreenController new. ^ self fillIn: (self menu: 'appearance...') from: {{'preferences...'. {Preferences. #openFactoredPanel}. 'Opens a "Preferences Panel" which allows you to alter many settings'}. {'choose theme...'. {Preferences. #offerThemesMenu}. 'Presents you with a menu of themes; each item''s balloon-help will tell you about the theme. If you choose a theme, many different preferences that come along with that theme are set at the same time; you can subsequently change any settings by using a Preferences Panel'}. nil. {'window colors...'. {Preferences. #windowSpecificationPanel}. 'Lets you specify colors for standard system windows.'}. {'system fonts...'. {self. #standardFontDo}. 'Choose the standard fonts to use for code, lists, menus, window titles, etc.'}. {'text highlight color...'. {Preferences. #chooseTextHighlightColor}. 'Choose which color should be used for text highlighting in Morphic.'}. {'insertion point color...'. {Preferences. #chooseInsertionPointColor}. 'Choose which color to use for the text insertion point in Morphic.'}. {'keyboard focus color'. {Preferences. #chooseKeyboardFocusColor}. 'Choose which color to use for highlighting which pane has the keyboard focus'}. nil. {#menuColorString. {Preferences. #toggleMenuColorPolicy}. 'Governs whether menu colors should be derived from the desktop color.'}. {#roundedCornersString. {Preferences. #toggleRoundedCorners}. 'Governs whether morphic windows and menus should have rounded corners.'}. nil. {'full screen on'. {screenCtrl. #fullScreenOn}. 'puts you in full-screen mode, if not already there.'}. {'full screen off'. {screenCtrl. #fullScreenOff}. 'if in full-screen mode, takes you out of it.'}. nil. {'set display depth...'. {self. #setDisplayDepth}. 'choose how many bits per pixel.'}. {'set desktop color...'. {self. #changeBackgroundColor}. 'choose a uniform color to use as desktop background.'}. {'set gradient color...'. {self. #setGradientColor}. 'choose second color to use as gradient for desktop background.'}. {'use texture background'. {#myWorld. #setStandardTexture}. 'apply a graph-paper-like texture background to the desktop.'}. {'set desktop image...'. {FileList2. #openMorphicViewWithPreviewInWorld}. 'open up an image browser to choose a new desktop background'}. nil. {'clear turtle trails from desktop'. {#myWorld. #clearTurtleTrails}. 'remove any pigment laid down on the desktop by objects moving with their pens down.'}}! !