2.3 Scroll Pane

Compared to the LinearLayoutMorph class, the PluggableScrollPane class doesn’t have many subclasses. We found ones for all sorts of lists of items or text editors with the need to scroll contents.

This class doesn’t need to be subclassed to be useful. Each time you want to present a morph with a large extent, embed it in a scroll pane:

PluggableScrollPane new ::
   scroller: Sample02Bezier new;
   color: Color white;
   openInWorld

Example 2.1: Bezier curves on a scroller

ch02-scrollPane

Figure 2.4: A scroll pane encapsulating Bézier curves with scroll bars

Among its few subclasses, FlowLayoutMorph extends the behavior of the layout morph but doesn’t inherit from it. It presents a collection of morphs in a strip spanning several rows. It is flanked with a vertical scroll bar if needed, inherited from the behavior of the PluggableScrollPane.

Its use is simple:

FlowLayoutMoprh class>>example1
| flow cells |
flow := self new openInWorld.
cells := OrderedCollection new.
50 timesRepeat: [ cells add: (
   ColoredBoxMorph new :: 
      morphExtent: (5 to: 80) atRandom asPoint;
      color: Color random)].
flow cells: cells

When resizing the morph, particularly its width, the flow of morphs is updated simultaneously.

ch02-flowLayoutMorph

Figure 2.5: Flow of boxes of various sizes