next up previous
Next: 3.1.2.0.1 Warning Up: 3.1 GUI Programming Previous: 3.1.1 Model-View-controller Pattern

3.1.2 How to Write a View

Most view components have a small number of distinct states that determine how the view is configured and how it will respond to the next program event. As a result, view component programs typically consist of:

The controller uses the registration methods to attach callbacks to program event sources in the view. The callbacks use the setter methods to change the state of the view in response to program events.

For our click counter example, the view will have the following format:

\includegraphics{gif/Counter.ps}

which we decompose into three possible states:

1.
the Min state where the DEC and 0 buttons are deactivated because the counter has its minimum value of 0.
2.
the Counting state where are three buttons are activated, and
3.
the Max state where the INC button is deactivated because the counter has reached its maximum value.

The listener must take into account the state of the model to update view.



 
next up previous
Next: 3.1.2.0.1 Warning Up: 3.1 GUI Programming Previous: 3.1.1 Model-View-controller Pattern
Corky Cartwright
2000-01-07