29.11.2014 Views

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

Smalltalk and Object Orientation: an Introduction - Free

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CheckButtonView class <strong><strong>an</strong>d</strong> its subclasses. This class has five subclasses including<br />

MacCheckButtonView, Win3CheckButtonView <strong><strong>an</strong>d</strong> MotifCheckButtonView. In this<br />

case when a user requests that a CheckButtonView is created, one of its subclasses will be used<br />

depending on the user interface look requested by the user. For example, either <strong>an</strong> Apple Macintosh,<br />

Windows 3 or X/Motif style button will be displayed. Here different views c<strong>an</strong> be used, without <strong>an</strong>y<br />

modification of the model or the associated controller.<br />

Figure 26.4: Part of the View class hierarchy<br />

26.2.2.3 Controllers<br />

Controllers h<strong><strong>an</strong>d</strong>le the user interaction with the application. They work in t<strong><strong>an</strong>d</strong>em with the view so that<br />

when a user clicks on a button (displayed by a view) the controller c<strong>an</strong> decide what to do. For example,<br />

the controller c<strong>an</strong> ask the view to confirm that the cursor was within the active area of the button <strong><strong>an</strong>d</strong><br />

then call the method associated with that button. That is, when the button is “pressed”, the controller<br />

will ensure that the appropriate method is evaluated.<br />

As was said e arlier, all views have <strong>an</strong> associated controller (even if it is <strong>an</strong> inst<strong>an</strong>ce of the<br />

NoController class). Therefore, in m<strong>an</strong>y situations there are controller classes available which<br />

mirror the view classes. For example, there is a MenuButtonController (to go w ith the<br />

MenuButtonView), there is a ScrollBarController (to go with the ScrollBar view) <strong><strong>an</strong>d</strong><br />

there are various ButtonControllers. The<br />

St<strong><strong>an</strong>d</strong>ardSystemController <strong><strong>an</strong>d</strong> the<br />

ApplicationSt<strong><strong>an</strong>d</strong>ardSystemController are used with the top most application view while<br />

m<strong>an</strong>y of the other controllers are used to h<strong><strong>an</strong>d</strong>le input <strong><strong>an</strong>d</strong> output for small subviews (such as buttons).<br />

216

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!