.. index:: single: DUIM libraries; tour of single: libraries; DUIM, tour of single: overview of; DUIM libraries single: tour of; DUIM libraries ***************************** A Tour of the DUIM Libraries ***************************** .. index:: single: DUIM; introduction single: introduction to; DUIM Introduction ------------ This chapter provides an overview of the gadgets and functionality that are provided by DUIM. Of necessity, it covers a lot of ground in as short a space as possible, and does not attempt to place any information in the more general context of application development. To gain an understanding of how different pieces of DUIM functionality can be glued together to create a working application, you should follow the extended example given in this manual in :doc:`design` through :doc:`callbacks`. If you need more complete information on any particular aspect of DUIM, you should refer to the DUIM Reference Manual. The most important DUIM classes are as follows: - ```` A window in your application. - ```` A unique piece of any window. - ```` Sheets that are window controls. - ```` Sheets that control the arrangement of other sheets in the sheet hierarchy. All of these are subclasses of :drm:``, except ```` which is a subclass of ````. As with any other Dylan class, use ``make`` to create an instance of a DUIM class. This chapter introduces you to the most important and useful of all these elements. - `A tour of gadgets`_ describes many of the gadgets available in DUIM. A wide variety of different gadgets are available in DUIM, to enable you to create applications that utilize all of the controls for the target operating system. - `A tour of layouts`_ describes layouts. These are classes that allow you to group together other sheets hierarchically (typically gadgets and other layouts) in order to put together the elements in any window. - `A tour of sheets`_ introduces you to the more general concept of sheets. If you intend defining your own sheet classes (for instance, to design your own controls), then you will need to understand how to handle sheets on a more general level than is needed to use gadgets or layouts. - `A tour of frames`_ introduces the different kinds of frame available. There are two basic types of frame: normal windows and dialog boxes. This section also describes how to create your own classes of frame. You can use the Dylan Playground to run the examples in this chapter. *Reminder:* to interactively run the segments of example code presented in this chapter, you must pass them to ``contain`` (see :ref:`using-contain-to-run-examples-interactively` for details). .. index:: single: gadgets; tour single: introduction to; gadgets single: overview of; gadgets single: tour of; gadgets A tour of gadgets ----------------- The DUIM-Gadgets library provides you with all the controls you can use to create an interface. Objects like buttons, menus, boxes, and other common interface elements are defined as subclasses of the base class ````. .. index:: single: gadgets; general properties single: general properties of gadgets single: properties; gadgets, general General properties of gadgets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Each class of gadget has a set of associated slots that help define the properties for that class. Different classes of gadget have different sets of slots. This section describes some of the more important slots available. The following slots are common across most (though not necessarily all) gadget classes. ``gadget-label`` This slot holds the label that is associated with a gadget. For an item on a menu or a button, for example, this label appears on the gadget itself. For a gadget such as a text field or a border, the label may be displayed next to the gadget. A label is usually a text string, but can often be an icon, such as is often found on the buttons of an application's toolbar. If a gadget does not have a label, ``gadget-label`` returns ``#f``. ``gadget-enabled?`` This slot specifies whether or not the gadget is active—that is, whether the user of your application can interact with the gadget. All gadgets have a ``gadget-enabled?`` slot. The ``gadget-enabled?`` slot returns either ``#t`` or ``#f``. When a gadget is disabled, it is usually grayed out on the screen, and cannot be interacted with in any way. ``gadget-value`` This slot holds the value of the gadget. Most gadgets can have a value of some kind; these are general instances of the ```` class. However, gadgets such as borders that are placed around elements have no associated value. Generally speaking, you can think of the gadget value as a value that the user of your application has assigned to the gadget. The ``gadget-value-type`` depends on the class of gadget involved. For a text field, the gadget value is the string typed into the text field. For a gadget with several items (see ``gadget-items`` below), such as a list, the gadget value is the selected item. For a radio button, the gadget value is a boolean that denotes whether the button is selected or not. If a gadget does not have any values, ``gadget-value`` returns ``#f``. All of the slots described above can also be specified as init-keyword values when creating an instance of a gadget. In all cases, the init-keyword name is the same as the slot name, but without the preceding "gadget-". Thus, a gadget can be enabled or disabled when it is first created by specifying the ``enabled?:`` init-keyword appropriately. Gadgets can also have a variety of associated callbacks. A callback is a function that is invoked when a particular event occurs that is associated with a given gadget, such as pressing a button. It is the primary technique you use to make your applications "do something". Like gadget properties, different classes of gadget can have different callback types available. For an introduction to callbacks, see `Assigning callbacks to gadgets`_. .. index:: single: button gadgets single: gadgets; button Button gadgets ~~~~~~~~~~~~~~ Broadly speaking, these are gadgets whose value can be changed, or for which some user-defined functionality can be invoked, by clicking on the gadget. Button gadgets encompass obvious controls such as push buttons, radio buttons, and check boxes, and, less obviously, menu items. .. index:: single: buttons; standard single: option buttons single: standard buttons Standard buttons ~~~~~~~~~~~~~~~~ .. index:: single: buttons; command single: buttons; option single: command buttons DUIM provides three standard button gadget classes: - ```` Sometimes referred to as *command button* in Microsoft documentation. - ```` Sometimes referred to as *option button* in Microsoft documentation. - ```` Sometimes referred to as *check box* in Microsoft documentation. .. _three-buttons: .. figure:: images/tour-3.png :align: center A push button, a radio button, and a check button The chapters covering the task list manager application (chapters :doc:`design` to :doc:`commands`) introduced you to the ```` class. This is the default type of button (that is, creating an instance of ``