Form Objects ^TOP^
When constructing your ACCESS Linux Platform user interfaces you'll primarily use those widgets made available to you in Glade. Although GTK+ supports many other widgets, for one reason or another those widgets are not all that useful in applications that run on small handheld devices. In Glade you'll see a mix of GTK+ widgets (some enhanced to work better on ACCESS Linux Platform), and ACCESS widgets which provide functionality not readily available from the GTK+ widget set.
Widgets are user interface elements that the user can manipulate or view (a scrollbar or button, for example). Not all widgets are visible, however. For instance, some widgets are used to contain other widgets, and can control the positioning and spacing for those contained widgets. Some widgets are "compound widgets"; widgets that are made up of more than one other widget. The ACCESS Date Selector widget is just one such compound widget: it contains a Calendar widget, arrow buttons, and a table, among other things.
From a programmer's technical perspective, in GTK+ a widget is any instance of a class that inherits from the GtkWidget base class.
GTK+ Widgets ^TOP^
Table 5.1 lists those GTK+ widgets that are particularly well-suited for use in ACCESS Linux Platform applications.
Table 5.1 Useful GTK+ widgetsÂ
Widget
|
Description
|
Window
|
Main application or form area. Window dimensions are provided by the Window Manager. All applications use the Window widget as the application canvas.
|
Dialog Box
|
A dialog window with a title bar. Used as a foreground window, often to display options or preference details.
|
Horizontal Box
|
Also referred to as "H Box," this layout widget is used to display content in columns. For example, in a dialog it could be used to place an icon to the left of a block of text.
|
Vertical Box
|
Also referred to as "V Box," this layout widget is used to display content in rows. For instance, it could be used to place a button region below a Text View.
|
Table
|
A layout widget that displays its content in a grid format. It is used in the week and month views of the Calendar application to display days of the month.
|
Notebook
|
The Notebook widget presents tabs that allow the user to switch between multiple associated forms. In the Calendar application's Day View, the Notebook widget allows the user to select between the days of the week.
|
Menu Bar
|
A menu bar that can display menu items. You would only use this widget in an application that doesn't have an ACCESS Title Bar (otherwise, you should use an ACCESS Menu Bar widget instead).
|
Tool Bar
|
A palette of tools as you might find in an application such as Adobe Photoshop or Microsoft Word.
|
Horizontal Button Box
|
Displays a horizontal row of buttons. This widget is usually much better than placing individual buttons into a Horizontal Box widget. The command button region at the bottom of a form is generally done using a Horizontal Button Box.
|
Vertical Button Box
|
Displays a vertical row of buttons.
|
Layout
|
A generic container widget that supports scrolling natively (you can add it to a Scrolled Window widget).
|
Event Box
|
Gives functionality to widgets that normally have no interaction. Wrapping an image in an Event Box allows an action event to be assigned to it. You could use this to allow an image to be selectable, for instance.
|
Viewport
|
Allows widgets that do not natively support scrolling to be placed inside of a Scrolled Window widget. If you put an Image widget inside a Viewport, for example, and then put the Viewport inside a Scrolled Window widget, the image will be scrollable.
|
Scrolled Window
|
Presents scrolling controls for content that is too large to fit in the window. Widgets that do not have native scrolling (the Image widget, for example) can be placed inside a Viewport widget which in turn can be placed inside of a Scrolled Window widget to enable scrolling. Whenever you have content that must have the ability to scroll, use a Scrolled Window widget. Note that Text View, Tree View, Icon View, and Layout widgets can all be directly added to a Scrolled Window widget.
|
Alignment
|
Controls the alignment and size of the widgets within the area allocated to it. The Alignment widget has four settings: xscale, yscale, xalign, and yalign, all of which can have a value ranging from 0 to 1. These are used to specify how much the child widget should expand to fill the allocated space.
|
Button
|
A button that generates an event when selected.
|
Check Button
|
Check Buttons allow the user to select options. When the check mark is present, the option is on. When it is absent, the option is off. Calendar uses a check box to allow the user to specify whether or not an alarm should sound at the time of an event.
|
Radio Button
|
Allows the user to select one (and only one) of a number of associated items. The Calendar application uses radio buttons when deleting a repeating event: it presents options for Current, Future, or All—only one of which may be selected.
|
Image
|
Displays an image. You specify the image's height and width, as well as the image data to be displayed. By itself, the user cannot interact with an Image widget. Image widgets are used throughout ACCESS Linux Platform to display icons and other images.
|
Label
|
Displays descriptive text that cannot be edited or interacted with. This widget is used to apply labels to buttons or to describe the name of a field. It can also be used to display non-editable blocks of text.
|
Text Entry
|
Allows the entry and editing of a single line of text. You use it whenever screen real estate is constrained and no scrolling is desired. Text Entry widgets are frequently used in areas where the user can assign a name to an object; for example, to assign a name to an alarm in the Clock application.
|
Text View
|
Displays multiple lines of editable or non-editable text. The Memo application uses a Text View widget for text editing. The Messaging application uses one to show the text of a received message.
|
Vertical Scrollbar
|
An element that both indicates that there is off-screen content and allows access to that content.
|
Combo Box
|
Has both a text entry area as well as a drop-down menu. If an item is selected from the drop-down list, it is displayed in the text entry area. This widget is used for category lists, filters, sorts, etc.
|
Progress Bar
|
Shows that an operation is active and indicates how much longer the operation might take. The Audio Player application, for instance, shows the playback position within an audio track. The Browser uses this widget to show the status of a file download.
|
Tree View
|
Displays a list of actionable items. A Tree View can have multiple columns. This widget is frequently used whenever selecting an item in a list "opens" or "acts upon" the item. The Contacts application uses it to display a list of contacts and their contact numbers.
|
Icon View
|
A grid of "actionable" icons or images, optionally with labels. The Launcher uses an Icon View widget to display the application icons and names.The Picture Viewer uses one to display image thumbnails.
|
Calendar
|
Displays the days of the month in a grid format. The Date Selector widget uses the Calendar widget to display the days of the currently-selected month.
|
Popup Menu
|
Contextual menu used to display a list of items to the user. This widget is frequently used to present a list of actions when a button is pressed. For example, in the Contacts application when the user selects the picture field a Popup Menu is used to present a list of options: Remove, Take Picture, and Choose.
|
Horizontal Separator
|
A graphic element used to separate regions or elements on a form or in a dialog. This widget is commonly used to separate "header" options from options that change based upon the header selection.
|
Arrow
|
A simple arrow graphic. This widget is used in combination with a button to become an interactive element (when used with a button, the button widget becomes transparent). The Messaging application uses Arrow widgets, in combination with buttons, to allow the user to navigate between messages when they are open.
|
Drawing Area
|
A canvas for drawing objects onto the screen. The Calendar's week view uses a Drawing Area: the hour table cells each have a rectangle drawn into them to give a color to the cell that can change depending upon whether or not an event has been set for that time slot.
|
Custom Widget
|
A container used to hold widgets that do not show in the Glade palette. For instance, if you place this widget in a Window and give it an ID for the ACCESS Media Selector widget, the ACCESS Media Selector is then displayed.
|
For much more detail on these widgets, see the GTK+ documentation at http://developer.gimp.org/api/2.0/gtk/ch02.html.
NOTE: Although they may appear in Glade, the Frame and Fixed widgets are not recommended for use in ACCESS Linux Platform applications. The Frame container draws an outline around itself with a break in the outline for a title. For a small-screen device, this excess decoration makes little sense. The "Fixed" container is also discouraged since it uses precise pixel coordinates to determine the layout. It does not permit variations in screen orientation or size.
ACCESS Widgets ^TOP^
The list of widgets added to Glade for ACCESS Linux Platform applications is much smaller than the set of GTK+ widgets. The following widgets were created specifically to improve the user experience in ACCESS Linux Platform applications:
ACCESS Menu Bar
The ACCESS Menu Bar widget displays a menu of options. It replaces the ACCESS Title Bar when activated, to save on-screen real-estate. This widget can only be used when an ACCESS Title Bar is present.
Most ACCESS Linux Platform applications use this widget in lieu of the GTK+ Menu Bar widget.
ACCESS Title Bar
This is a horizontal box that inherits a specific decoration based upon theming. The ACCESS Title Bar can contain many of the control and display widgets. Usually, it is divided into two regions: the left side displays the application name, while the right side contains a category drop-down menu. The ACCESS Title Bar works closely with the ACCESS Menu Bar: the menu bar replaces, or overlies, the title bar when the menu is active. When the user makes a selection from the menu, the title bar is once again displayed.
ACCESS Progress Dialog
This is a compound widget composed of a Dialog widget and a Progress Bar widget. It is a simple way to present the user with the status of a long-running operation such as a file download.
ACCESS Date Selector
This is a compound widget that allows the user to select a complete date: a year, month, and day of the month. Use this widget when you need the user to specify a date.
ACCESS Time Selector
A compound widget that contains three ACCESS Spin Button widgets and an AM/PM toggle button, you use this when you need the user to specify a time value. The Calendar application uses this, as does the Date and Time preferences panel.
ACCESS Repeat Button
This button sends out signals at periodic intervals for as long as the button is selected.
ACCESS Spin Button
A compound widget composed of two arrows, a button, and a label, you use spin buttons to allow the user to select from a set of well-ordered values. For instance, individual spin buttons are used by the ACCESS Time Selector widget to specify each of the digits comprising the minutes value, and another is used to specify the hours.
Status Bar Manager and Status Gadgets ^TOP^
The Status Bar is a strip across the screen consisting of a series of gadgets (small icons that indicate various types of device status, such as battery level, signal strength, or message waiting). The Status Bar occupies a reserved portion of the screen: application windows cannot normally use that screen area. On a wireless handheld device, these gadgets may optionally activate a more comprehensive slip when tapped. Slips pop up in a separate window immediately adjacent the status bar. Only one slip can be showing at a time. If a request to launch a different slip is received, any currently showing slip is closed first.
On devices with limited screen space (for instance, a square screen device), the Status Bar will normally be collapsed to a small button which, when tapped, expands into a full Status Bar that overlays application windows, rather than occupying its own exclusive screen space. When the Status Bar loses focus, or the user again taps the button that activates the Status Bar, the Status Bar collapses back down to that button.
When writing GTK+ applications that present dialogs, you should be aware that you should set all of your dialogs to be transient. Quoting from the GTK documentation for the gtk_window_set_transient_for() function:
- Dialog windows should be set transient for the main application window they were spawned from. This allows window managers to e.g. keep the dialog on top of the main window, or center the dialog over the main window.
Glade doesn't make your windows transient for you, so you have to call the following before you show a dialog for the first time:
gtk_window_set_transient_for (GTK_WINDOW(myDialog), GTK_WINDOW(myMainWindow));
If you don't make your dialogs transient, they are likely to stay on top of the stack of windows, even if a background application displays some UI. The dialog will obscure the background application. This is especially important for applications that support smart text in dialogs; when the user selects the smart text, an exchange request occurs that launches the application currently registered to handle that type of request. Your application's dialog is likely to obscure any UI displayed by the application handling the request.
When displaying a dialog, use alp_max_dialog_run() rather than gtk_dialog_run(). alp_max_dialog_run() calls through to gtk_dialog_run(), but maintains a stack of active dialogs which can later be dismissed by calling alp_max_dialog_cancel_all(). This is especially useful when an application may call into libraries which display their own dialogs. Applications need to dismiss all dialogs when they receive an exit request or are relaunched with ALP_APP_BACKGROUNDED, and this API provides the infrastructure for doing so.
IMPORTANT: When
alp_max_dialog_cancel_all() is called, it cancels all dialogs in the active stack by calling
gtk_dialog_response(GTK_RESPONSE_NONE) for them. Because of this, you need to make sure that you handle the case where your dialog returns with
GTK_RESPONSE_NONE. Do not assume that because your dialog exited, one of the dialog buttons (such as OK or Cancel) was pressed.