Contents

Class PluggableListView


Inheritance:

Object  »
  View  »
    ListView  »
      PluggableListView

A pluggable list view gets its content from the model. This allows the same kind of view to be used in different situations, thus avoiding a proliferation of gratuitous view and controller classes.

A pluggable list view is set up with a data provider - its model - and several message selectors that the view can use to communicate with its model.

Instance Variables:

Important Class Methods:

The class protocol of PluggableListView includes method for three frequent use cases. Each of these methods creates a properly initialized instance.

For the creation of initialized instances, the class protocol provides a set of three dedicated class methods. Method on:list:selected:changeSelected:menu:keystroke is the most general of these, two others are shortened variants that provide reasonable default values for some parameters of the general method.

Important Instance Methods:

Important Hints:

Any of the above selectors can be nil, meaning that the model does not supply behavior for the given action, and the default behavior should be used. However, if getListSel is nil, the default behavior just provides an empty list, which makes for a rather dull list view!

The model informs a pluggable view of changes by sending #changed: to itself with getListSel or getSelectionSel as a parameter. The view informs the model of selection changes by sending setSelectionSel to it with the newly selected item as a parameter, and invokes menu and keyboard actions on the model via getMenuSel and keyActionSel.

Pluggability allows a single model object to have pluggable list views on multiple aspects of itself. For example, an object representing one personal music library might be organized as a three-level hierarchy: the types of music, the titles within a given type, and the songs on a given title. Pluggability allows one to easily build a multipane browser for this object with separate list views for the music type, title, and song.

AutoDeselect is a feature, normally set to true, that will tell the model that there is no selection if you click on an item that is currently selected. If autoDeselect is false, then the model will simply be told to select the same item again.

Update Behavior:

This is a pluggable view. Update methods compare a message argument with stored selectors, and ignore messages with unknown selectors.

A PluggableListView uses one font to display all items of its list. It is possible to use text adornments to emphasize some items. The following piece of code demonstrates this possibility:

textAttributesList
    " answer a list of four items. The first and second
      item use text adornments. " 
  ^Array with: 'bold' asText allBold
         with: ('italic' asText addAttribute: (TextColor color: Color red))
         with: 'underlined' asText
         with: 'struck out' asText 

   "colored items require a ColorSystemView as top view "

Note that you should use a ColorSystemView as top view of your window when you use colored text.

Example of Use


Contents