03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

� if the Set interval button is selected, the Set time button should be deselected, and the<br />

remainder of the dialog should change appropriately (in this case, the time editors are<br />

replaced by a choice list for selecting time intervals);<br />

� if the user sets two Check for new messages at values to be the same, as in Figure<br />

12.3, then the second value should be dimmed when the user moves away from the line<br />

on the dialog or presses Done. It makes no sense to schedule two downloads to take<br />

place at the same time.<br />

12.2.2 Some Basic Abstractions<br />

On the basis of this list of user requirements, you can see some abstractions beginning to<br />

take shape:<br />

� The highlight (or in text editors, the cursor) is actually a visual indication of focus. The<br />

control that currently has focus receives the majority of key events; it therefore ought to<br />

know whether it has focus or not, and draw any necessary highlight accordingly. (Not all<br />

key events go to the control with focus: in dialogs, pressing the hardware Confirm key<br />

causes the default button – usually Done – to be pressed, rather than going to the<br />

highlighted control.)<br />

� A control needs to be able to refuse interactions such as pointer events. Invisible or<br />

dimmed controls should certainly refuse interactions. A control should know whether it<br />

is dimmed and thereby draw itself in a suitable way.<br />

� A control needs to be able to say whether it is in a valid state, and to respond to<br />

queries about its state.<br />

� If a control's state changes, it needs to be able to report that to an observer such as<br />

the dialog, so that the dialog can handle any knock-on effects. (For example, if the<br />

checkbox changes to indicate no scheduled downloads, the dialog must make it<br />

impossible to select the other controls.)<br />

These are the user requirements. Throughout the rest of this chapter, I'll be describing how<br />

the GUI framework makes it possible for you meet them.<br />

12.2.3 Programmer Requirements<br />

If ease of use matters to end users, it certainly matters to programmers, who will have some<br />

requirements on the way all the ideas raised above should hang together:<br />

� It should be possible to invent new dialogs with rich functionality and to implement the<br />

validation rules with sufficient ease that programmers will want to use these facilities to<br />

deliver helpful and usable dialogs.<br />

� It should be possible to use any control in such dialogs – not only the stock controls<br />

provided by Uikon and UIQ but also any new control that you invent and wish to include<br />

in a dialog. (Not all controls are designed to be included in dialogs. I don't see any need<br />

to include my fleet view in a dialog.)<br />

� Given the number of different ideas here, it should be possible to write code that<br />

supports only the things you require for a particular control, without having to worry<br />

about implementing things that are unnecessary. Furthermore, you need to be confident<br />

that you've decided to include only those things that need including and to exclude only<br />

those things that need excluding.<br />

12.2.4 Compound Controls<br />

I began to introduce the idea of compound controls in relation to drawing. It turns out that<br />

compounding also makes it very much easier to implement general-purpose containers such<br />

as dialogs. Returning once again to our e-mail account dialog, the visible controls on it, from<br />

the top, are as follows:

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

Saved successfully!

Ooh no, something went wrong!