This text is not finished - expect more to be documented
here in the future.
Many demos and coding examples are found in the
directories
"doc/coding"
and
"clients/Demos"
.
The demos are provided for you to get some starting point for your
own applications.
Some of these files are to be filed in, others
(especially in "doc/coding"
) only contain
code fragments, and are to be evaluated using
doIt.
Have a look at those files with the fileBrowser.
Another source of information and examples is the
"goodies"
subdirectory. Ported goodies and classes from public domain
or freeware archives (mainly the Manchester Smalltalk Archive)
are stored there.
Finally, many classes provide an "examples" method in
their "documentation" category. This usually consists of code pieces which
are to be evaluated with doIt.
Among others, interesting in "doc/coding"
are:
Array-literalStore
demonstrates that storing into array literals is BAD BAD BAD
and that ST/X's compiler can be configured to help
detecting these bad stored.
BOSS-examples
some code fragments to demonstrate binary store
and load of objects
BOSS-errors
code fragments to demonstrate possible errors
when using binary store (i.e. loading obsolete instances).
Also, mechanisms to detect and correct these situations are described
by example.
BOSS-special
demonstrates how instance variables can be ommitted from
a binary store (i.e. only storing parts of an object).
Block-examples
demonstrates, that blocks have true local state
(i.e. are closures, and can be recursive)
Block-unwind
shows how valueOnUnwind:
and valueNowOrOnUnwind:
are used
Class-anonymous
demonstrates how classes (a Behavior or light weight class)
can be created on-the-fly.
Of course, they can have instances which understand messages.
Class-dynamic
simple demonstration of dynamically changing the
class of an object.
(this is more of theoretical interest)
Class-multipleInheritance
a very simple demo implementation of multiple inheritance
(experimental - you should not use or depend on MI in Smalltalk)
Class-subclassing
various possibilities to define a subclass
(also demonstrates that variableSubclasses can have named instance variables)
Context-advanced
some special tricks possible with contexts
(some of these tricks already found their way into
the standard classes; see the implementation of while*
in
the Block class).
Also includes demonstrations of unwinding and
unwindProtect-actions (valueOnUnwindDo:
)
File-IO.st
code fragments to show simple I/O with text & binary files
FileIn-errors
demonstrates how errors during fileIn are handled
(i.e. use of abort, debug & continue)
Font-BitmapFont
how to create your own bitmap fonts
(is someone willing to write & publish a TrueType font class ?)
MVC-xxx
various examples of using widgets
with a model
Model-Simple1
shows how models can be used (i.e. kind of
MVC; however, in ST/X the view and controller
functionality is combined in the view for many widgets).
This example shows how buttons can use models.
Model-Simple2
a selectionInListView with a model
Model-Simple3
buttons and a popUpList with a model
Model-Label.st
a label and a model
Process-examples
simple process examples showing fork
, newProcess
etc.
Process-delay
shows use of Delay
and process forking
Process-diningTable
the standard philosopher example using Semaphores
Requires Process-philosopher
to be loeaded also.
(load both, start with: "(DiningTable new:5) dinner")
Process-philosopher2
example on how to prevent the (possible) deadlock in Philosopher
Process-sharedQueue
shows use of processes and shared queues
Registry-example
shows use of a registry to track object reclamation by
the garbage collector (i.e. finalization).
Signal-handling
examples on how Signal
, Exception
and SignalSet
are used (study this file carefully - its nice)
Signal-floatSignals
floating point errors and handling
Signal-stackoverflow
examples on how stack overflow can be handled
Socket-connection
use of Sockets (code fragments)
Socket-objectcopy
how objects can be sent via a socket connection using
binaryStore (code fragments)
Special-hereSend
local sends - an ST/X special feature
View-ButtonDemo*
using Buttons (tutorial examples)
View-Example*
various views, views-in-views etc.
with growing complexity (tutorial examples).
(start with example1x, example2, and so on)
View-Frame*
more views showing use of frames (tutorial examples)
View-HelloWorld
hello world in Smalltalk
(no language without its hello-world program ... :-)
This example creates a new View subclass, i.e. it
does not use existing widgets, but defines a
new 'hello-world' widget.
View-HelloWorld2
same, but using the existing Label widget.
View-16bit-strings
example, how 16bit strings are drawn in a view
View-16bit-labels
demonstrates that labels can handle 16bit strings.
View-16bit-buttons
and buttons too
View-Panel*
more views showing use of panels
(variableVertical & variableHorizontal)
View-drawing-arc*
shows how various arcs (different lineWidths, colors etc.) are drawn
View-drawing-filledarc*
shows how various filled arcs (different colors etc.) are drawn
View-PopUpMenu-simple
how to define a very simple popup-menu
View-PopUpMenu-check
how to define a popup-menu with check-marks
View-PopUpMenu-submenus
how to define a more complex popup-menu (with submenus)
View-Slider-example*
various horizontal sliders (different sizes, with/without numeric value)
View-border-round
a round-bordered view
View-border-funny
a very funny shaped view - transparent, using an image
as border (you never saw this before in Smalltalk !)
View-transformations*
various demos for how transformations can be used
when drawing (metric units, scaling etc.)
libfoo_example
source for the example in the
online documentation 'How to compile ...'
Utilities found in "clients/Demos"
are:
ClassTreeGraphView.st
shows a graphical representation of the class tree.
Uses & requires TreeGraphView.
WindowTreeView.st
shows the hierarchy of Smalltalk views
another use of TreeGraphView
View demos found in "clients/Demos"
:
BDemo1.st
shows the use of buttons
and labels
BDemo2.st
also, but nicer button size
BDemo3.st
puts 2 buttons with action
in a panel for better geometry.
CalcView.st
a simple calculator
Calendar.st
a simple calendar program
(mimics example in o'Reillys motif book)
CommanderDemo.st
draws geometric designs using
Commander and Pen.
(autoloads Commander & Pen classes)
ColorDraw.st
a simple Paint demo
(inspired by example in o'Reillys
motif book and written as a
challenge of how simple it is in Smalltalk)
ColorDraw2.st
a subclass of the above - adds brushes
of varying line-widths.
(requires ColorDraw.st
to be filed in first)
ColorDraw3.st
a subclass of the above; adds scrollbars
and redraw features.
(requires both of the above and FormDrawView.st
to be filed in)
ColorScales.st
shows color handling - on b&w displays and
low color resolution displays (VGA), this
demonstrates how colors are automatically dithered.
DirTreeV.st
graphical display of a directory tree.
(a demo of how to use the ObjectView class)
FormDrawView.st
helper for ColorDrawDemo3; provides a saved canvas area.
Fractal.st
draws fractal mountains.
A free goody, slightly modified for ST/X.
("Fractal example1"
to "Fractal example4"
draw into the root window,
while
"Fractal example5"
creates its own window)
GreyScaleDemo.st
like ColorScales, but only shows grey values.
HelloView.st
one of the smallest Hello-world programs around.
PenDemo.st
draws geometric designs using a Pen.
(autoloads Pen class) Also a good example for
PanelView, which makes the button-layout
(try resizing the view), and both Button and Toggle
usage (see label-change in the nib-toggle).
SliderDemo.st
shows use of Sliders and color handling
SliderDemo2.st
a subclass of the above with colored sliders
(needs above to be filed-in first)
TreeView.st
shows use of ObjectView; an abstract Tree Viewer.
ClassTreeView
displays a graphical view of the whole class
hierarchy; allows some limited interaction
by selections and a pop-up menu.
TreeGraphView.st
even better: adds connecting lines. Is also
abstract
- Example1 to Example11 help in a step-by-step introduction to view
programming. They provide examples of increased complexity, starting
with a very simple (useless) view, ending in a simple editor application.
Example1.st
simple view with a subview
Example2.st
simple view with two subviews; shows how sizes
can be computed.
Example3.st
simple view with two subviews; subview sizes are
specified relative to superviews size.
Example4.st
simple view with two subviews; the relative size
ratios can be changed (VariableVerticalPanel)
Example5.st
same, but one of the views shows read-only text
Example6.st
same, but TextView is scrollable
Example7.st
same, but TextView shows contents of a file
Example8.st
a simple view showing the use of PullDownMenu,
Notifiers and Confirmers
Example9.st
a setup for a scrollable view, with a PullDownMenu
Example10.st
an editable textview, with scrollbar and useful
functions in the PullDownMenu.
Example11.st
same, but all message texts have been internationalized
by using resources.
- Frame1 to Frame6 show examples of frame views:
Frame1.st
a simple frame
Frame2.st
also simple, but uses different font
Frame3.st
a frame around a TextView
Frame4.st
more complex, two Lists in frames, which are themselfes
in a Horizontal panel.
Frame5.st
two frames, one houses a list which provides a selection
possibility, the other houses a TextView reacting on
selections in the list. All of this in a variable panel.
Frame6.st
same setup, different function. This shows files and
their contents
- PathDemo1 to PathDemo8 demonstrate the use of the Path subclasses:
(they will autoload some Path stuff)
PathDemo1.st
shows different instances of class Line.
(varying capStyles, varying lineStyles and colors)
PathDemo2.st
shows LinearFit usage (varying line styles)
PathDemo3.st
shows Spline usage (varying line styles)
PathDemo4.st
shows Arc and Circle usage
PathDemo5.st
shows Curve usage
PathDemo6.st
shows Arrows (varying directions, varying styles)
PathDemo7.st
shows splines, press LeftButton for points, last point
with RightButton.
PathDemo8.st
shows Ellipse usage
- ViewDemo1 to ... will follow
ViewDemo1.st
shows how to define a view-background pattern
(needs 'goodies/Form-Patterns.chg to be loaded)
3D graphic demos found in "clients/GLDemos"
:
Demo1.st
shows how to setup a GL view, a viewing transformation
and draws a simple rectangle.
Demo2.st
shows how to setup a GL view, a viewing transformation
and draws a simple figure. Starts a background process
to animate a rotating rectangle. (rotates around z axis)
Demo3.st
like Demo2, but rotating around y axis
Demo4.st
like Demo3, but sets up double buffering for smoother display
Demo5.st
like Demo4, including double buffering. All rotations combined.
Demo6.st
draws axes, handles mouse input to change the eye position.
GLObjectDemo.st
Abstract class providing a framework for animated (rotating) objects.
GLCubeDemo.st
, GLTetraDemo.st
,
GLWireCubeDemo.st
, GLWireSphereDemo.st
and GLPlanetDemo.st
Concrete subclasses animating various 3D objects.
GLOctaHedronDemo.st
A rotating octaHedron with color interpolation between edges.
Requires a true GL implementation
(i.e. does not work on VOGL-based systems)
GLSphereDemo1.st
and GLSphereDemo2.st
A light source rotating around a sphere. Requires a true GL implementation
(i.e. does not work on VOGL-based systems)
GLCubeDemo2.st
A cube and a light source.
Requires a true GL implementation
(i.e. does not work on VOGL-based systems)
GLBrickCubeDemo.st
A textured cube.
Requires a true GL implementation
(i.e. does not work on VOGL-based systems)
GLXYGraph.st
Draws a graph of a function(x,y).
Includes a panel to control rotation and translation.
(a nice demo, combining ST/X widgets and GL drawing. Also
shows how partner views are setup)
RubicsCubeView.st
Draws and interacts with a rubics cube.
This example especially demonstrates how to pick & select objects
in 3D space (using the backBuffer & pixelRead facilities).
Misc goodies are found in "goodies"
:
- Collections-*
Various PD and Freeware collection classes and addons.
- distributions
Classes for random number generation with various
distributions (normal-, bernoulli, exponential etc.)
This is an adaption of the corresponding classes from a PD
package.
- persistency
Classes to access DBM / NDBM / DB-1.6 index-sequential database files.
These classes provide a dictionary-like interface to those databases,
allowing the storage and retrieval of either unstructured strings, or
of arbitrary objects.
- rdoit
A mechanism to execute Smalltalk expressions via shell commands.
On the Smalltalk side, a Smalltalk-thread reads incoming requests
from a unix-domain socket, executes them and sends the results printString
back through the socket. On the Unix side, a little C program connects
to that socket and sends its command line argument as request through the
socket, printing the returned string.
Thus, you can now open browsers, applications etc. via shell scripts
(or windowManagers popup funtions, or makefiles) by:
rdoit "Transcript showCR:'hello there'"
See the "README"
file there.
- tgen
A compiler construction kit. This is the PD TGen package, with slight
modifications for ST/X.
Copyright © 1996 Claus Gittinger Development & Consulting, all rights reserved
<cg at exept.de>
Doc $Header: /cvs/stx/stx/doc/online/english/demos/TOP.html,v 1.31 2021/03/13 18:24:48 cg Exp $