
Larry Wall, the creator of the language PERL likes to say that: "there are many ways to do the same thing using PERL".
We can say that there are many more using Squeak-Croquet.
In the last lesson we have made an application, a project, using some visual resources. Old programers don't like this kind of thing. They like "to code" everything.
At this lesson we will use a more traditional approach for the creation of a window inside the Squeak-Croquet desktop. We will use this type of window in the next (yes, the next!) lesson to put a 3D croquet world inside.
The OOP (Object Oriented Programming) paradigma has the idea of Class: a group of functions and variables (or methods, properties, messages or many other names) that can be used when we create an object-reference (or object, or prefix, or instance or many other names)of the Class. The usual name for the creation of this object is: instantialization.
We will present for you now a not complete but "selected reference" of 3 Classes of the Squeak-Croquet API (Application Program Interface):
SystemWyndow
addMorph: aMorph fullFrame: frame
aMorph can be a Croquet world.
frame can be an object of the
Class: LayoutFrame, by example.
fullScreen to "fullscreennize" the window.
openInWorldExtent: w@h set values for width and height.
setLabel: string
setWindowColor: color color can be an object of the Class:
Color
LayoutFrame
rightFraction:n n is a number between 0.1 and 1 defining
the limit of the object inside the window
lefttFraction:n n is a number between 0 and 0.99 defining
the limit of the object inside the window
topFraction:n n is a number between 0 and 0.99 defining
the limit of the object inside the window
bottomFraction:n n is a number between 0.1 and 1 defining
the limit of the object inside the window
Color Don't need to be created an object-reference.
We use: Color r:n g:n b:n
where n is between 0 and 1;
or we use the directly: Color:name-of-the-color
black
blue
brown
cyan
darkGray
gray
green
lightBlue
lightBrown
lightCyan
lightGray
lightGreen
lightMagenta
lightOrange
lightRed
lightYellow
magenta
orange
paleBlue
paleBuff
paleGreen
paleMagenta
paleOrange
palePeach
paleRed
paleTan
paleYellow
red
tan
veryDarkGray
veryLightGray
veryPaleRed
veryVeryDarkGray
veryVeryLightGray
white
yellow
Lets go to an exercice creating a "project" that is only an empty window on the desktop. Like we said, in the next lesson we will put a 3D Croquet world inside it.
After to open a new "morphic project" (we saw how to do this at previous lesson), in the "green window" click "Tools" and drag and drop a "Workspace". You can resize it using the yellow button of the "halo" - this is valid for any Squeak window. You can move it using the brown button.
Type this code inside the Workspace:
|win| win := SystemWindow new. "Creating a window" win setLabel: 'PRIVATE'. win setWindowColor: Color blue. win openInWorldExtent: 400@200.
CODE COMMENTS:
Here you learn:
I imagine that you understood that after the two-points we have the parameter of a function.
After created the program we need to do an "accept" rightclicking over the Workspace and clicking also : "do it" after drag the pointer over all the lines of the program.
Our empty window appears! (I hope...)
If you like to save the project - don't need... - the method is the same of the previous lesson.
PREVIOUS LESSON NEXT LESSON T. CONTENTS HOMEPAGE
