This text is not finished - expect more to be documented
here in the future.
Demos and coding examples
Many demos and coding examples are found in the
directories "doc/coding"
and "clients/Demos"
.
Some of these files are meant to be filed in, others
(especially in "doc/coding"
only contain
code fragments, which are meant to be evaluated using
doIt. Have a look at those files using
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 archive
are stored there.
Among others, interresting in "doc/coding"
are:
Array-literalStore
demonstrates that storing into array literals is BAD BAD BAD
BOSS-examples
some code fragments to demonstrate binary store
and load of objects (code fragments)
BOSS-errors
some 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.
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. Even have instances which
understand messages.
Class-dynamic
simple demonstration of dynamically changing the
class of an object.
Class-multipleInheritance
a very simple implementation of multiple inheritance
Class-subclassing
each possibility to define a subclass
Context-advanced
some special tricks possible with contexts
(some of these tricks already found their way into
the standard classes; see Blocks whileXX implementation)
Also includes demonstrations of unwinding and unwind-
protect-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)
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 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 one 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
Symbol-withInstvar
yes you can do it (although you should not)
View-ButtonDemoXX
using Buttons (tutorial examples)
View-ExampleXX
various views, views-in-views etc.
with growing complexity (tutorial examples).
(start with example1x, example2, and so on)
View-FrameXX
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-PanelXX
more views showing use of panels
(variableVertical & variableHorizontal)
View-drawing-arc
shows how arcs are drawn
View-drawing-arc2
more on drawing arcs
View-drawing-arc3
more on drawing arcs (varying lineWidth)
View-drawing-arc4
more on drawing arcs (varying lineWidth and color)
View-drawing-filledarc
shows filled arcs
View-drawing-filledarc2
filled arcs as in pie charts (i.e. arcs, lines & filled arcs)
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-example1
a simple horizontal slider
View-Slider-example2
a simple, thin horizontal slider
View-Slider-example3
a thin horizontal slider showing its value
View-Slider-example4
<>
same, but value is shown under sliders knob
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.)
libfii_example
source for the example in the
online documentation 'How to compile ...'
Utilities found in "clients/Demos"
are:
Array-literalStore
demonstrates that storing into array literals is BAD BAD BAD
ClassTreeGraphView.st
SHows a graphical representation of the class tree.
Uses TreeGraphView (see below)
WindowTreeView.st
shows the hierarchy of smalltalk views
another use of TreeGraphView (below)
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 oReillys 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 oReillys
motif book and written as a
challenge of how simple it is in ST/X)
ColorDraw2.st
a subclass of the above - adds brushes
of varying line-widths.
(needs ColorDraw to be filed in first)
ColorDraw3.st
a subclass of the above; adds scrollbars
and redraw features.
(needs 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
(example1 to example4 draw into the root window,
example5 creates its own window)
GreyScaleDemo.st
like ColorScales, but only shows grey values.
HelloView.st
one of the smallest Hello-world programs around.
If the goody: 'goodies/Form-SUNForm.chg' has been
filedIn, it also demonstrates how to define icons
from other-than-X bitmaps (sun-icon format).
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)
Copyright © Claus Gittinger Development & Consulting, all rights reserved
(cg@ssw.de)