84 CHAPTER 7. GRAPHICAL USER INTERFACE DESIGN IN SCHEME
Feel free to write variations of the programs we show here. This will help you
learn how to think in Scheme. Programming is a skill that is best learned by
doing rather than by reading alone.
7.3
Windows
Window are the most basic component of Graphical User Interfaces. All other
components must appear inside a window and any particular GUI might use
several different windows (e.g. help windows, about windows, file selection
windows, warning windows, editting windows).
The most basic window contains just a title (which is a string that usually
appears in the title bar). The following code creates a window with the title
Hello , sets is size to be 300 pixels wide by 400 pixels high, and makes it appear
on the screen:
(define w (window "Hello"))
(.resize w 300 400)
(.show w)
Note that we have used the define syntax to give the name w to the window.
This name is need when we resize the window and make it visible in the following
two expressions. We will see many more windows below, so we don't dwell any
further on them at this point.
7.4
Labels
A label is a component used to display some text on the GUI. For example, the
following program creates a window with the text Hello in the titlebar and
the phrase Hello again in the inside of the window:
(define w (window "Hello"
(label "Hello again")))
(.resize w 300 400)
(.show w)
The first argument of the label procedure must be the string that will appear
on the label. We will see below that one can also specify the font and the color
of a label by adding more arguments to the label procedure.
7.5
Fonts
There are nine built in fonts that you can use in the JLIB library, and for each
font you can pick any font size (as long as it is a positive whole number). These
fonts are:
(Helvetica 23)
(HelveticaBold 100)
(HelveticaItalic 12)
(TimesRoman 29)
(TimesRomanBold 88)
(TimesRomanItalic 9)
(Courier 33)
(CourierBold 32)
(CourierItalic 33)