Code Updates for Squeakbook
Still in development! The updates below focus on changes from Squeak 2.7 to Squeak 3.0 and above. There are, of course, actual BUGS in the book as well. See the *Errata page>http://coweb.cc.gatech.edu/cs2340/9* for those.
The most significant change between Squeak 2.7/2.8 and Squeak 3.0 (and beyond) are the changes to AlignmentMorphs. All Morphs can now align the way that AlignmentMorphs did (and in new, more powerful ways) -- but with all new messages.
The positive side of this is that most of the front of the book remains exactly the same!
No code changes. Line example still works.
Page 36: There is now a class above Object in the class hierarchy. It's class ProtoObject. A ProtoObject is the raw minimal object behavior, mostly for proxy objects (objects meant to wrap something else). For the most part, you'll never deal with ProtoObject.
Page 55: Transcript show: 3.2 is no longer an easy way to bring up a debugger for testing. That now does string conversions for you. If you have an undefined variable, like a, a + 3.2 does a fine job of bringing up a debugger.
No changes are necessary. Amazingly, Joe works just fine.
No changes needed.
Probably the biggest changes are that MVC has all but disappeared from use in Squeak, and that the look-and-feel of many of the pieces discussed in this chapter has changed.
In terms of working example code, everything works until openAsMorph2 (p. 160). It has to change due to AlignmentMorph changes. The new code is (file):
openAsMorph2 | win component filler clock | "Create the clock" clock := Clock new. clock setTime: (Time now printString). clock start. "Create a window for it" win := SystemWindow labelled: 'Clock'. win model: self. "Set up the text view and the various pieces" filler := AlignmentMorph newRow. filler listCentering: #center. win addMorph: filler frame: (0@0 extent: firstname.lastname@example.org). component := PluggableTextMorph on: clock text: #display accept: nil. filler addMorph: component. component := PluggableButtonMorph new model: clock; action: #addHour; label: 'Hours +'; borderWidth: 1. win addMorph: component frame: (email@example.com extent: firstname.lastname@example.org). component := PluggableButtonMorph new model: clock; action: #subtractHour; label: 'Hours -'; borderWidth: 1. win addMorph: component frame: (email@example.com extent: firstname.lastname@example.org). component := PluggableButtonMorph new model: clock; action: #addMinute; label: 'Minutes +'; borderWidth: 1. win addMorph: component frame: (email@example.com extent: firstname.lastname@example.org). component := PluggableButtonMorph new model: clock; action: #subtractMinute; label: 'Minutes -'; borderWidth: 1. win addMorph: component frame: (email@example.com extent: firstname.lastname@example.org). component := PluggableButtonMorph new model: clock; action: #stop; label: 'STOP'; borderWidth: 1. win addMorph: component frame: (email@example.com extent: firstname.lastname@example.org). win openInWorld. ^win
No code in this chapter, so no changes.
All the multimedia examples in the book except for one do work. Of course, they've been superceded by even newer multimedia examples: BookMorphs tend to be used inside of Projects which can be saved to disk themselves, SqueakMovies tend to be passed over in favor of MPEG movies, etc.
The one example that does not work anymore is the process of setting an active texture in Wonderland. (Many more Wonderland examples can be found in the Wonderland PPT slides.) The easiest way to set a texture is to simply execute setTextureFromUser, e.g., bunny head setTextureFromUser. The user is prompted for a section of screen which will be used as a texture. To make an activeTexture:
The audio notes code breaks exactly where the analysis of the code predicted it would (p. 234). The various morphic components that make up the Audio Notes window were restructured, so the textMorphString method indexes the wrong subcomponents. A working version in 3.2 is:
textMorphString "I wonder if there's a better way." ^(((self dependents at: 3) submorphs at: 2) submorphs at: 1) contents string
MAT seems to work just fine in Squeak 3.2.
One change is needed to the PlayBench class to deal with AlignmentMorph changes:
new | me | me := super new "Accept submorphs vertically" listDirection: #topToBottom; "was in 2.7/8: orientation: #vertical;" hResizing: #spaceFill; vResizing: #spaceFill. ^me setUp "Set up the pieces"