Morph Workspace: select this complete example and Do it. | morph | morph := Morph new color: (Color r: 0.20 g: 0.48 b: 0.78); extent: 220@110; position: 100@100; yourself. morph openInWorld. morph Working with it: Change color:, position:, or extent:. addMorph: embeds a child; delete removes this Morph from its owner. ---------------------------------------- BorderedMorph Workspace: select this complete example and Do it. | morph | morph := BorderedMorph new color: (Color r: 0.95 g: 0.96 b: 0.98); borderWidth: 3; borderColor: (Color r: 0.20 g: 0.48 b: 0.78); cornerStyle: #rounded; extent: 240@120; yourself. morph openInWorld. morph Working with it: Adjust borderWidth: and borderColor:. Combine it with a StringMorph label or a TableLayout. ---------------------------------------- RectangleMorph Workspace: select this complete example and Do it. | morph | morph := RectangleMorph new color: (Color r: 0.85 g: 0.34 b: 0.25); borderWidth: 0; extent: 230@100; yourself. morph openInWorld. morph Working with it: Send extent: to resize it. Rounded corners are a styling choice, not a separate rectangle class. ---------------------------------------- EllipseMorph Workspace: select this complete example and Do it. | morph | morph := EllipseMorph new color: (Color r: 0.10 g: 0.61 b: 0.54); borderWidth: 3; borderColor: (Color r: 0.03 g: 0.35 b: 0.30); extent: 240@120; yourself. morph openInWorld. morph Working with it: Change extent: to alter the oval proportions. containsPoint: tests the visible elliptical area. ---------------------------------------- CircleMorph Workspace: select this complete example and Do it. | morph | morph := CircleMorph new color: (Color r: 0.85 g: 0.56 b: 0.11); borderWidth: 0; extent: 180@140; yourself. morph openInWorld. morph Working with it: Compare extent: 180@140 with the resulting extent of 140@140. ---------------------------------------- PolygonMorph Workspace: select this complete example and Do it. | morph | morph := PolygonMorph vertices: {0@120. 110@0. 220@120} color: (Color r: 0.56 g: 0.35 b: 0.82) borderWidth: 2 borderColor: Color darkGray. morph openInWorld. morph Working with it: Use setVertices: to replace the Points. Native halo handles let you explore the shape interactively. ---------------------------------------- LineMorph Workspace: select this complete example and Do it. | morph | morph := LineMorph from: 0@0 to: 260@100 color: (Color r: 0.20 g: 0.48 b: 0.78) width: 5. morph openInWorld. morph Working with it: Create another line with different from: and to: Points. borderWidth: changes the stroke width. ---------------------------------------- CurveMorph Workspace: select this complete example and Do it. | morph | morph := CurveMorph new color: (Color r: 0.82 g: 0.40 b: 0.58); borderWidth: 2; borderColor: Color darkGray; extent: 240@140; yourself. morph openInWorld. morph Working with it: Edit its vertices with Morphic handles. In source, initialize sends beSmoothCurve to select the curve behavior. ---------------------------------------- CurvierMorph Workspace: select this complete example and Do it. | morph | morph := CurvierMorph new color: (Color r: 0.24 g: 0.63 b: 0.72); borderWidth: 2; borderColor: Color darkGray; extent: 230@140; yourself. morph openInWorld. morph Working with it: Compare its default curve with CurveMorph. Browse the class and its superclass to explore vertex editing. ---------------------------------------- MixedCurveMorph Workspace: select this complete example and Do it. | morph | morph := MixedCurveMorph new color: (Color r: 0.63 g: 0.42 b: 0.83); borderWidth: 2; borderColor: Color darkGray; extent: 230@130; yourself. morph openInWorld. morph Working with it: Use vertex handles to explore mixed curve segments. The native class contains its own clamp and slope logic. ---------------------------------------- StringMorph Workspace: select this complete example and Do it. | morph | morph := StringMorph contents: 'Hello, Morphic!' font: (TextStyle default fontOfSize: 24). morph color: (Color r: 0.15 g: 0.25 b: 0.38). morph openInWorld. morph Working with it: Change contents: to update the text. Set font: or color: to change its appearance. ---------------------------------------- TextMorph Workspace: select this complete example and Do it. | morph | morph := TextMorph new contents: 'A TextMorph can wrap text across several lines. Select it to edit this native Squeak text.'; beAllFont: (TextStyle default fontOfSize: 18); wrapFlag: true; extent: 330@100; color: Color darkGray; yourself. morph openInWorld. morph Working with it: Use contents:, beAllFont:, wrapFlag:, or textColor:. Read-only behavior can be requested with readOnly: true. ---------------------------------------- UpdatingStringMorph PREREQUISITE: file in MorphicReferenceModel.st first. Workspace: select this complete example and Do it. | morph model | model := MorphicReferenceModel new. morph := UpdatingStringMorph on: model selector: #status. morph useStringFormat; font: (TextStyle default fontOfSize: 22). morph step. morph openInWorld. morph Working with it: Send press to the model, then step to the Morph to refresh its label. ---------------------------------------- ImageMorph Workspace: select this complete example and Do it. | morph form pen | form := Form extent: 180@120 depth: 32. form fillColor: (Color r: 0.94 g: 0.97 b: 1). pen := Pen newOnForm: form. pen defaultNib: 4; color: (Color r: 0.20 g: 0.48 b: 0.78). pen place: 50@20; north; turn: 90; down. 4 timesRepeat: [pen go: 80; turn: 90]. pen up. morph := ImageMorph new image: form. morph openInWorld. morph Working with it: Replace the bitmap with image: anotherForm. The Form stores pixels; ImageMorph puts them in the Morphic object tree. ---------------------------------------- SketchMorph Workspace: select this complete example and Do it. | morph form pen | form := Form extent: 180@120 depth: 32. form fillColor: (Color r: 0.94 g: 0.97 b: 1). pen := Pen newOnForm: form. pen defaultNib: 4; color: (Color r: 0.20 g: 0.48 b: 0.78). pen place: 50@20; north; turn: 90; down. 4 timesRepeat: [pen go: 80; turn: 90]. pen up. morph := SketchMorph withForm: form. morph openInWorld. morph Working with it: Try flipHorizontal or flipVertical, or open the native painting tools through its menu. ---------------------------------------- ThumbnailImageMorph Workspace: select this complete example and Do it. | morph target label | target := BorderedMorph new color: Color lightBlue; extent: 260@150; yourself. label := StringMorph contents: 'Original object'. target addMorph: label. label center: target center. morph := ThumbnailImageMorph new. morph extent: 150@100; target: target. morph openInWorld. morph Working with it: Send target: again after the target changes to refresh the captured preview. This is a snapshot rather than a live owner relationship. ---------------------------------------- AnimatedImageMorph Workspace: select this complete example and Do it. | morph frames | frames := {Color blue. Color orange} collect: [:color | AnimatedImageFrame new form: ((Form extent: 180@120 depth: 32) fillColor: color); delay: 200; disposal: #leaveCurrent; yourself]. morph := AnimatedImageMorph new. morph fromFrames: frames. morph image: (Form extent: 180@120 depth: 32). morph step. morph openInWorld. morph Working with it: step advances one frame. setStepping: true starts playback; false stops it. Supply the backing Form explicitly: reset references an unavailable maxImagesExtent method in this image. ---------------------------------------- MovieMorph Workspace: select this complete example and Do it. | morph frames | frames := {Color blue. Color orange} collect: [:color | SketchMorph withForm: ((Form extent: 180@120 depth: 32) fillColor: color)]. morph := MovieMorph new. morph insertFrames: frames; setFrame: 1. morph openInWorld. morph Working with it: setFrame: selects a frame. playLoop plus startStepping runs the sequence; stopPlaying stops it. ---------------------------------------- AlignmentMorph Workspace: select this complete example and Do it. | morph | morph := AlignmentMorph newRow. morph color: Color transparent; cellGap: 12. #('Model' 'View' 'Messages') do: [:name | | chip label | chip := BorderedMorph new color: (Color r: 0.20 g: 0.48 b: 0.78); extent: 110@50; hResizing: #rigid; vResizing: #rigid; yourself. label := StringMorph contents: name. label color: Color white. chip addMorph: label. label center: chip center. morph addMorphBack: chip]. morph fullBounds. morph openInWorld. morph Working with it: Use AlignmentMorph newColumn for vertical layout. Morph + TableLayout is another way to arrange the same children. ---------------------------------------- TransformMorph Workspace: select this complete example and Do it. | morph child label | morph := TransformMorph new color: Color transparent; extent: 320@180; yourself. child := BorderedMorph new color: Color lightBlue; extent: 170@80; position: 15@15; yourself. label := StringMorph contents: 'Scaled content'. child addMorph: label. label center: child center. morph addMorph: child. morph scale: 1.4. morph openInWorld. morph Working with it: Change scale: or angle:. Submorph coordinates are transformed by the container. ---------------------------------------- TransformationMorph Workspace: select this complete example and Do it. | morph child label | child := BorderedMorph new color: Color lightBlue; extent: 220@100; yourself. label := StringMorph contents: 'Rotated 20 degrees'. child addMorph: label. label center: child center. morph := TransformationMorph new. morph asFlexOf: child; rotationDegrees: 20. morph openInWorld. morph Working with it: rotationDegrees: uses degrees here. This differs from TransformMorph angle:, which uses radians. ---------------------------------------- PasteUpMorph Workspace: select this complete example and Do it. | morph ellipse | morph := PasteUpMorph new color: (Color r: 0.93 g: 0.96 b: 1); extent: 320@170; yourself. ellipse := EllipseMorph new color: Color blue; extent: 70@70; position: 30@45; yourself. morph addMorph: ellipse. morph openInWorld. morph Working with it: Add children with addMorph:. World is itself a PasteUpMorph, but this example makes an ordinary separate playfield. ---------------------------------------- ScrollPane Workspace: select this complete example and Do it. | morph text | morph := ScrollPane new extent: 330@170; yourself. text := TextMorph new contents: (String streamContents: [:stream | 1 to: 18 do: [:i | stream nextPutAll: 'Line '; print: i; cr]]); beAllFont: (TextStyle default fontOfSize: 16); yourself. morph scroller addMorph: text. morph openInWorld. morph Working with it: The viewport stays fixed while its scroller moves. Use scrollbars or mouse-wheel input to explore the longer text. ---------------------------------------- SystemWindow Workspace: select this complete example and Do it. | morph panel label | morph := SystemWindow new. morph setLabel: 'My Morphic window'; extent: 380@200. panel := Morph new color: (Color r: 0.95 g: 0.97 b: 1). label := StringMorph contents: 'A real SystemWindow'. label position: 22@40. panel addMorph: label. morph addMorph: panel frame: (0@0 corner: 1@1). morph openInWorld. morph extent: 380@200. morph Working with it: setLabel: changes the title. Set extent: after openInWorld: opening applies the image’s window-placement policy. Add panes with fractional frames. ---------------------------------------- SimpleButtonMorph Workspace: select this complete example and Do it. | morph label | label := StringMorph contents: 'Ready'. morph := SimpleButtonMorph new label: 'Click to update'; target: [label contents: 'Clicked!']; actionSelector: #value; extent: 200@44; yourself. morph setProperty: #demoLabel toValue: label. label openInWorld; position: 100@170. morph openInWorld. morph Working with it: Click the button in Squeak. It runs the block and changes the separate label’s contents. ---------------------------------------- SimpleSwitchMorph Workspace: select this complete example and Do it. | morph states | states := OrderedCollection new. morph := SimpleSwitchMorph new label: 'Enabled'; onColor: Color lightGreen; offColor: Color lightGray; target: [:state | states add: state]; actionSelector: #value:; extent: 170@44; yourself. morph turnOn; setProperty: #demoStates toValue: states. morph openInWorld. morph Working with it: turnOn and turnOff change its state. Its native mouse handling toggles the state and dispatches the action. ---------------------------------------- IconicButton Workspace: select this complete example and Do it. | morph form pen | form := Form extent: 42@42 depth: 32. form fillColor: Color white. pen := Pen newOnForm: form. pen defaultNib: 5; color: Color blue. pen place: 9@21; down; goto: 33@21; up. pen place: 21@9; down; goto: 21@33; up. morph := IconicButton new. morph labelGraphic: form; target: [Transcript show: 'Icon clicked'; cr]; actionSelector: #value. morph openInWorld. morph Working with it: Replace the icon with labelGraphic:. Connect target: and actionSelector: just as with SimpleButtonMorph. ---------------------------------------- PluggableButtonMorph PREREQUISITE: file in MorphicReferenceModel.st first. Workspace: select this complete example and Do it. | morph model | model := MorphicReferenceModel new. morph := PluggableButtonMorph on: model getState: nil action: #press. morph label: 'Press the model'; extent: 220@44; wantsGradient: false. morph openInWorld. morph Working with it: Clicking sends press to the model. performAction triggers the same action in the verification run. ---------------------------------------- Slider PREREQUISITE: file in MorphicReferenceModel.st first. Workspace: select this complete example and Do it. | morph model | model := MorphicReferenceModel new. morph := Slider on: model getValue: #amount setValue: #amount: min: 0 max: 1 quantum: 0.05. morph extent: 300@28. morph openInWorld. morph Working with it: Dragging changes the model amount. setValue: follows the model setter; value: only sets the slider’s own value. ---------------------------------------- PluggableTextMorph PREREQUISITE: file in MorphicReferenceModel.st first. Workspace: select this complete example and Do it. | morph model | model := MorphicReferenceModel new. morph := PluggableTextMorph on: model text: #text accept: #acceptText:. morph extent: 330@85; acceptOnCR: true; hideScrollBarsIndefinitely. morph openInWorld. morph Working with it: Edit the text and accept it using the text menu or Return in this example. setText: changes the visible editor; accepting sends the setter. ---------------------------------------- PluggableListMorph PREREQUISITE: file in MorphicReferenceModel.st first. Workspace: select this complete example and Do it. | morph model | model := MorphicReferenceModel new. morph := PluggableListMorph on: model list: #items selected: #selectionIndex changeSelected: #selectionIndex:. morph extent: 300@125. morph openInWorld. morph Working with it: Select another row to change selectionIndex. Keep selection state in the model and notify changes with changed:. ---------------------------------------- PluggableCheckBoxMorph PREREQUISITE: file in MorphicReferenceModel.st first. Workspace: select this complete example and Do it. | morph model | model := MorphicReferenceModel new. morph := PluggableCheckBoxMorph on: model getState: #enabled action: #toggleEnabled label: #checkLabel. morph layoutPolicy: TableLayout new; hResizing: #shrinkWrap; vResizing: #shrinkWrap. morph installButton. morph allMorphsDo: [:each | (each isKindOf: UpdatingThreePhaseButtonMorph) ifTrue: [each step]]. morph openInWorld. morph Working with it: installButton builds the native checkbox content in this image. Click it to send toggleEnabled. The model announces changed: #enabled. ---------------------------------------- MenuMorph Workspace: select this complete example and Do it. | morph actions | actions := OrderedCollection new. morph := MenuMorph new. morph addTitle: 'Object actions'. morph add: 'Inspect example' target: [actions add: #inspect] selector: #value. morph add: 'Duplicate example' target: [actions add: #duplicate] selector: #value. morph setProperty: #demoActions toValue: actions. morph openInWorld. morph Working with it: Use popup behavior in a live application, or openInWorld to study the menu’s own object tree as here. ---------------------------------------- ProgressBarMorph Workspace: select this complete example and Do it. | morph model | model := ValueHolder new contents: 0.65. morph := ProgressBarMorph new value: model; progressColor: (Color r: 0.10 g: 0.61 b: 0.54); color: Color lightGray; extent: 300@28; yourself. morph update: #contents. morph openInWorld. morph Working with it: Send contents: to the ValueHolder to change progress. It notifies its dependents so the Morph can redraw. ---------------------------------------- DoCommandOnceMorph Workspace: select this complete example and Do it. | morph log | log := OrderedCollection new. morph := DoCommandOnceMorph new. morph addText: 'Run once'; actionBlock: [log add: #finished]. morph setProperty: #demoLog toValue: log. morph openInWorld. morph Working with it: step executes the block once. It is a specialized command host rather than a general push button. ---------------------------------------- HaloMorph Workspace: select this complete example and Do it. | morph target halo | morph := Morph new color: Color transparent; extent: 350@220; yourself. target := EllipseMorph new color: Color lightBlue; extent: 140@100; yourself. morph addMorph: target. target center: morph center. morph openInWorld. halo := target addHalo. morph addMorph: halo. morph Working with it: In normal use, send addHalo to the object you want to edit. This specimen keeps the halo and target together for its screenshot.