![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
The first step toward connected display
elements is to rewrite createViews
such that both a
MeterGraphPane
and a ListBox
are included. Now, both require
framingRatio:
messages, because both occupy only a fraction of the
top pane to which they are connected by addSubpane:
messages.
Similarly, both require when:perform:
messages so that they can send
appropriate callback messages to the view manager in response to the
getContents
events that occur when the meter pane and the list box
are created.
Also, you soon need to be able to refer to the meter by name; accordingly,
you send the graph pane the paneName:
message, with a string
argument, 'CalorieMeter'
.
CalorieViewManager method definition instance createViews | theTopPane theListBox theMeterPane | "Set up all panes" self addView: (theTopPane := TopPane new). theListBox := ListBox new. theMeterPane := MeterGraphPane new. "Set up the top pane" theTopPane owner: self; labelWithoutPrefix: 'Demonstration Window'; noSmalltalkMenuBar; addSubpane: theListBox; addSubpane: theMeterPane; framingRatio: (1/4 @ (1/3) rightBottom: 3/4 @ (2/3)). "Set up the list-box pane" theListBox owner: self; when: #getContents perform: #initializeListBox:; when: #select perform: #itemSelected:; framingRatio: (2/3 @ 0 rightBottom: 1 @ 1). "Set up the meter pane" theMeterPane owner: self; paneName: 'CalorieMeter'; noScrollBars; when: #getContents perform: #initializeMeter:; when: #display perform: #callDrawMeter:; framingRatio: (0 @ 0 rightBottom: 2/3 @ 1).