Smalltalk and Object Orientation: an Introduction - Free
Smalltalk and Object Orientation: an Introduction - Free
Smalltalk and Object Orientation: an Introduction - Free
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
27. Graphical User Interface Construction Tools<br />
27.1 <strong>Introduction</strong><br />
This chapter provides a brief introduction to the VisualWorks window building facilities. The<br />
VisualWorks user interface builder is a tool which allows the developer to interactively construct a<br />
window using <strong>an</strong> object oriented drawing tool (à la MacDraw, xfig or AutoSketch). This drawi ng tool<br />
c<strong>an</strong> then generate the <strong>Smalltalk</strong> source code required to actually create <strong>an</strong> inst<strong>an</strong>ce of the window<br />
designed by the user. This <strong>Smalltalk</strong> window definition c<strong>an</strong> then be easily <strong><strong>an</strong>d</strong> simply linked to a user’s<br />
application. Thus making it particularly easy to construct graphical interfaces to <strong>Smalltalk</strong> applications.<br />
This chapter is intended to provide a description of some of the features of the User Interface<br />
Painting tools. It is not intended to be a complete introduction to either the User Interface Buil der or to<br />
the inst<strong>an</strong>ce structure of VisualWorks windows.<br />
In the remainder of this chapter we first consider what a window building tool is <strong><strong>an</strong>d</strong> then what<br />
window construction tools are available in VisualWorks (which are very similar to those tools in other<br />
<strong>Smalltalk</strong> development environments). We then consider the use of associated classes such as<br />
ApplicationModel <strong><strong>an</strong>d</strong> ValueHolder as well as how to construct windows using the availab le<br />
tools.<br />
27.2 What is a user interface builder?<br />
A user interface builder is a tool which allows a developer to construct a window by drawing it rather<br />
th<strong>an</strong> by defining it programatically. This is a very great adv<strong>an</strong>tage as the construction of windows in<br />
m<strong>an</strong>y windowing systems is unnecessarily complex <strong><strong>an</strong>d</strong> difficult to underst<strong><strong>an</strong>d</strong>. It often takes a great<br />
deal of source code just to create a window, give it a label, place <strong>an</strong> input field, <strong>an</strong> output field <strong><strong>an</strong>d</strong> a<br />
button on that window. In m<strong>an</strong>y situations the resulting “program” is difficult to maintain <strong><strong>an</strong>d</strong> may be<br />
error prone. The result is that it is difficult to build <strong><strong>an</strong>d</strong> modify windows, whereas windowing systems<br />
by their very nature are intended to be easy to use.<br />
One approach to this problem was the construction of w indow construction toolkit. TCL/TK is <strong>an</strong><br />
example of such a toolkit [Ousterhout 1994]. It allows the user to specify the structure of a window in a<br />
simple scripting l<strong>an</strong>guage. The resulting window c<strong>an</strong> then be integrated with a program written in<br />
<strong>an</strong>other l<strong>an</strong>guage such as C. The problem with this approach is that firstly the developer must learn the<br />
TCL scripting l<strong>an</strong>guage, secondly they must integrate the windowing system with their C programs (not<br />
always a straight forward task) <strong><strong>an</strong>d</strong> thirdly when a bug is encou ntered they must search through two<br />
separate systems to identify where the fault occurred. In addition this approach still relies on the<br />
developer laying out the window programatically.<br />
Another approach is to use a window drawing tool. The motivation for s uch tools was to allow users<br />
to construct their windows graphically, enabling them to easily <strong><strong>an</strong>d</strong> quickly modify the window layout<br />
<strong><strong>an</strong>d</strong> then to compile the graphic window into source code. The source code could then be compiled to<br />
construct the window. In th e early days of these systems it was necessary to integrate your application<br />
code with the source code generated by the window construction tool. Having done this, if you ever<br />
modified the window, you would overwrite <strong>an</strong>y application code. Obviously this wa s not acceptable,<br />
<strong><strong>an</strong>d</strong> was caused because the window construction tools were not closely integrated with a development<br />
environment.<br />
The age of the visual tool overcame this hurdle. L<strong>an</strong>guages such as VisualBasic, Visual C++,<br />
Sym<strong>an</strong>tec’s Visual Cafe <strong><strong>an</strong>d</strong> of course VisualWorks, allow a developer to draw a window on the screen,<br />
compile it, add their own application code <strong><strong>an</strong>d</strong> modify the window without <strong>an</strong>y loss of information.<br />
These tools have greatly simplified the construction of graphical interfaces <strong><strong>an</strong>d</strong> enabled a far wider<br />
r<strong>an</strong>ge of applications to benefit from sophisticated windowing environments.<br />
223