86 CHAPTER 7. GRAPHICAL USER INTERFACE DESIGN IN SCHEME
yellow
(color 255 255 0)
white
(color 255 255 255)
black
(color 0 0 0)
blue
(color 0 0 255)
lightblue
(color 200 200 255)
darkblue
(color 0 0 150)
You can set the background of a label (or any other component) just by including
the color as one of the arguments of the label. Continuing with our running
example, we can make the label yellow as follows:
(define w
(window "Hello"
(label "Hello again" (HelveticaBold 60) yellow)))
(.pack w)
(.show w)
7.7
Tabular Layouts
So far we have considered windows containing a single label. We now look at
four procedures for specifying the layout of multiple components in a window.
Although these layouts can be applied to any component, we will stick with
labels for simplicity.
The first two layouts we discuss are the row and column layouts. The row
procedure arranges its arguments horizontally across the window. The col
procedures arranges its arguments vertically. For example, the following code
produces a window with labels red , green , yellow , and blue having the
same color as their label, laid out horizontally across the window:
(define w
(window "Hello"
(row
(label "red" red)
(label "green" green)
(label "yellow" yellow)
(label "blue" blue)
)))
(.pack w)
(.show w)
By swapping col for row , the labels would be arranged vertically.
The row and col procedures also take additional arguments which specify
what should happen when the window is resized. One possibility is to have the
components in the row stay the same size even though the window grows. On
the otherhand, one might want the components in the row to expand as the
window expands (the expansion can be horizontal, or vertical, or both). To
specify this expansion property one adds one of the following to the row or col
argument lists: