8.9 Widgets


8.9.1 Widget Look

The flexibility of the HAVi widget framework is further enhanced by separating the look component from the component for feel . This allows easy construction of many styles of presentation associated with each of the abstract Component Behaviors defined previously.

Content can be associated with each state of a widget. For each widget state, textual, graphical, and user defined content can be associated with the widget. The HLook interface defines the mechanism by which the content for the particular state of the widget can be rendered.

The HLook . showLook() is used to provide the rendering of the content for the widget. This method should be called in response to a paint method call of the associated lightweight component. showLook() is similar to the lightweight component's paint method, however because this method is separated from the widget class, there is no need to subclass the widget to change its look. The showLook() method is responsible for repainting the entire component, including its background, subject to the clipRect of the Graphics object passed to it. The showLook() method should not modify the clipRect of the Graphics object that is passed to it.

When a widget is constructed , it is provided with a default look. This default HLook should be one of the standard set of looks listed earlier. For example, the HGraphicButton is created with the HGraphicLook by default. The default look that is used when the widget is constructed can be changed by calling the static method setDefaultLook() that is provided on all widget types. Any widget of that type created after the call should be created with the new HLook that was passed in as the parameter to setDefaultLook() . The look of an individual widget can be modified by using the method HVisible.setLook() .

The pluggable look mechanism is flexible enough so that the application developer can create new HLook s. For example, a combined HGraphicLook and HTextLook , where the Text may overlay the graphic, or be shown in place of the graphic, while the graphic is being loaded.

An HLook may also provide some form of border decoration, for example, drawing a rectangle around the widget when it has focus. To allow for predictable layout and presentation the HLook interface provides methods that are used to indicate the size of such a border area.

To support layout managers the HLook interface also defines the getMaximumSize() , getMinimumSize() , getPreferredSize() methods, which allow the associated HVisible to query the HLook for its maximum, minimum, and preferred sizes.

8.9.2 Widget Behavior

Content is associated with the widget through the following methods on HVisible : setTextContent() , setGraphicContent() , setAnimateContent() , and setContent() . Hence, multiple content (text, graphics, animations, and user-defined content) can be associated with a widget. The way multiple content is rendered is dependent on the HLook associated with the widget. The default looks provided by the platform may not render all the content types.

Different content can be associated with the different states of the widget. For example, an HGraphicButton might have three different images to represent its three different states to the user, using the setGraphicContent() . The same content can be applied to all states of the widget by using the HState constant ALL_STATES when calling setTextContent() , setGraphicContent() , setAnimateContent() , and setContent() .

By default, content associated with a widget is not modified to fit the dimensions of the widget. If the widget size is smaller than the content, the content should be drawn from the top left hand corner of the widget and cropped to the size of the widget. If the widget is larger than the content, the widget should be filled with the background color of the component. The content should then be drawn from the top left hand corner of the widget. Mechanisms are also available that allow graphic content to be resized to match the widget dimensions.

8.9.3 Resident Widgets

Using these component behaviors ( HVisible , HNavigable , HActionable , and HSwitchable ) a set of resident widgets is provided. Implementations of the HAVi widget set should be implemented (and behave) as lightweight components , namely they do not include an associated peer class.

8.9.3.1 Simple Widgets

The set of resident widgets (see Table 8.8) includes both visible and navigable versions of the HText , HIcon , and HAnimation classes:

  • Applications providing simple display-only non-navigable text, image, or animations may employ the static versions of these classes.

  • Applications wishing to provide additional feedback (e.g., graphic or audio tooltips).

Table 8.8. Simple Test, Graphics, and Animate Widgets

Widget Type

Description

Static

Navigable

Animation

Simple Sequence of Images

HStaticAnimation

HAnimation

Text

Text label

HStaticText

HText

Graphics

An Image

HSaticIcon

HIcon

8.9.3.2 Buttons

The HAVi set of resident widgets includes both textual and graphical versions of a push button: HTextButton and HGraphicButton . These buttons implement the HActionable interface that defines their behavior.

The HToggleButton is used to represent a graphical control that has a boolean state that can be toggled on and off by the user (e.g., checkbox or radio button). The HToggleButton implements the HSwitchable interface that defines its behavior. A HToggleButton widget does not have an associated text label as part of the widget. If a text label is required, a separate HStaticText widget should be created.

A set of HToggleButtons can be associated with an HToggleGroup . An HToggleGroup should ensure that a maximum of one HToggleButton is chosen at any time (i.e., a group of radio buttons).

8.9.3.3 Range Widgets

The HAVi set of resident widgets includes a group of controls to represent a particular integer value in a range of values (e.g., slider control, scroll bar). The HStaticRange widget is a nonnavigable widget, HRange widget is navigable (implements the HNavigable interface), and the HRangeValue is navigable and its value can be modified by user interaction (implements the HValue interface).

8.9.3.4 List Widgets

An HListGroup is an HContainer that manages a dynamic set of vertically or horizontally scrollable HListElements , allowing either single or multiple HListElements to be chosen by the user. The HListGroup should automatically scroll the HListElements when the user navigates to an element that is currently not visible within the list group.

8.9.3.5 Text Entry Widgets

The HSinglelineEntry component allows a user to enter a single line text string. A typical rendering is as a text entry field (e.g., with an associated on-screen keyboard). The HMultilineEntry widget extends the HSinglelineEntry widget and allows text to be entered over multiple lines. Both these widgets implement the HValue interface resulting in the widgets firing HValueChangeEvents whenever the content changes.



ITV Handbook. Technologies and Standards
ITV Handbook: Technologies and Standards
ISBN: 0131003127
EAN: 2147483647
Year: 2003
Pages: 170

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net