Sun Microsystems Logo
Products and Services
 
Support and Training
 
 

Previous Previous     Contents     Index     Next Next
Chapter 7

Common Desktop Environment Motif Widgets

The Common Desktop Environment provides Motif 2.1 libraries (with bug fixes) and enhancements. In addition, the Common Desktop Environment provides four custom widgets you can use to provide certain OPEN LOOK™ and Microsoft® Windows functionality. This chapter describes these Motif custom widgets.

The widget library, libDtWidget, contains four widgets that combine or enhance functionality of existing Motif 2.1 widgets:

  • DtMenuButton provides menu-cascading functionality outside of the menu bar.

  • DtEditor incorporates such single text editor functions as cut and paste.

  • DtSpinBox combines a text field and arrow buttons in a control that can increment or decrement numeric or text values. It pre-dates the Motif widget XmSpinBox.

  • DtComboBox combines a text field and a list box in a control that displays one of the valid choices for the text field. It pre-dates the Motif widget XmComboBox.

These widgets provide common functionality across all Common Desktop Environment applications. None of these widgets support subclassing.

The Custom Widgets library depends directly on the following libraries:

  • Xm library for the Motif superclass support

  • Xt library for creation and manipulation of widgets

  • X11 Library for the base X Window System

  • DtSvc for desktop support utilized by DtEditor

Menu Button Widget (DtMenuButton)

Use the DtMenuButton widget to provide menu-cascading functionality outside of a menu pane.

DtMenuButton widget is a command widget that complements the menu cascading functionality of an XmCascadeButton widget. As a complement to XmCascadeButton widget, it can only be instantiated outside a MenuBar, Pulldown, or Popup (use XmCascadeButton widget inside a MenuPane.)Figure 7-1 shows examples of a DtMenuButton widget.

Figure 7-1 Examples of menu button widget (DtMenuButton)

Library and Header Files

The DtMenuButton widget is in the libDtWidget library. The header file is Dt/MenuButton.h.

Demo Program

A demo containing an example of the DtMenuButton widget is in /usr/dt/examples/dtwidget/controls.c.

Convenience Functions

DtCreateMenuButton() is a convenience function that creates a Common Desktop Environment widget.

DtMenuButton widget is a subclass of XmLabel class. Visually, DtMenuButton widget has a label string and a menu glyph. The menu glyph always appears on the right end of the widget and, by default, is a downward pointing arrow.

DtMenuButton widget has an implicitly created submenu attached to it. The submenu is a pop-up menu and has this DtMenuButton widget as its parent. The name of the implicitly created submenu is obtained by prefixing submenu_ to the name of this DtMenuButton widget. You can obtain the widget ID of the submenu by setting an XtGetValues on DtNsubMenuId resource of this DtMenuButton widget. The implicitly created submenu must not be destroyed by the user of this widget.

The submenu can be popped up by pressing the menu post button (see XmNmenuPost resource of XmRowColumn) anywhere on the DtMenuButton widget or by pressing the Motif Cancel key (usually Escape).

Classes

DtMenuButtonWidget inherits behavior and resources from Core, XmPrimitive, and XmLabel classes.

The class pointer is dtMenuButtonWidgetClass.

The class name is DtMenuButtonWidget.

DtMenuButtonWidget does not support subclassing.

Resources

DtMenuButtonWidget provides the following resources. Table 7-1 shows the class, type, default, and access for these resources.

  • DtNcascadingCallback specifies the list of callbacks that are called before the attached submenu is displayed.

  • DtNcascadePixmap specifies the pixmap that is displayed as the menu glyph. If no pixmap is specified, a downward pointing arrow is displayed.

  • DtNsubMenuId specifies the widget ID of the pop-up menu pane to be associated with this DtMenuButton widget. You must create the pop-up menu pane with this DtMenuButton as its parent. You cannot specify this resource when the widget is created because the submenu is automatically destroyed by this widget when the resource is set.

See the DtMenuButtonWidget(3X) man page for more information.

The codes in the access column show if you can:

  • Set the resource at creation time (C)

  • Set by using XtSetValues (S)

  • Retrieve by using XtGetValues (G)

Table 7-1 DtMenuButtonWidget Resources

Name

Class

Type

Default

Access

DtNcascadingCallback

DtCCallback

XtCallbackList

NULL

C

DtNcascadePixmap

DtCPixmap

Pixmap

XmUNSPECIFIED_PIXMAP

CSG

DtNsubMenuId

DtCMenuWidget

Widget

NULL

SG

Previous Previous     Contents     Index     Next Next
 

Updated: 2003-09-29, 21:43