Progress
Programming
Handbook


Static Widgets

You can describe and instantiate a static widget in one or two statements, depending on the widget type.

Describing a Static Widget

You can describe a static widget in several ways, depending on the widget:

Instantiating a Static Widget

Progress automatically instantiates any static widget whose unique identity is known when you describe or use it. Thus:

Name references to some widgets specify a unique widget. These include static frame, dialog box, menu, or menu-item of menu widgets. Progress creates only one such widget in a procedure at a time. Thus, Progress can instantiate the widget when you first describe it.

However, to instantiate the description for any other static widget type, including a field-level, browse, submenu, or menu-item of a submenu widget, you must instantiate a static widget that contains it. The reason for this is that when you describe a widget that requires a container, you are only specifying the qualifying attributes of the widget. You can only establish a unique identity (widget handle) for a contained widget by associating it with an instantiated container widget. For example, this code fragment describes an editor widget associated with the variable xvar, and creates an instance of the editor in frame a.

DEFINE VARIABLE xvar AS CHARACTER VIEW-AS EDITOR SIZE 40 BY 10.

ENABLE xvar WITH FRAME a. 

Also, the widget description for a static field-level, submenu, or submenu menu-item widget might specify more than one instance of that widget. When you include a reference to a field-level widget in the descriptions of more than one frame or dialog box, you instantiate a different, but identical, field-level widget for each frame or dialog box in which it appears.

This code fragment describes a button, b1, and creates two instances of it—one in frame x and one in frame y.

DEFINE BUTTON b1.

ENABLE b1 WITH FRAME x.
ENABLE b1 WITH FRAME y. 

Similarly, when you include a reference to a submenu widget in the descriptions of more than one instantiated menu or submenu, you instantiate a different, but identical, submenu widget for each menu and submenu in which it appears.

This code fragment describes a submenu, sub1, and creates two instances of it—one in menu m1 and one in menu m2.

DEFINE SUB-MENU sub1
    MENU-ITEM sub-item1
    MENU-ITEM sub-item2.
    
DEFINE MENU m1
    MENU-ITEM item1
    SUB-MENU sub1.
    
DEFINE MENU m2
    MENU-ITEM item1
    SUB-MENU sub1. 

Thus:

Working with Static Widgets

The VIEW–AS phrase for describing static data-representation widgets has the following general syntax:

SYNTAX
VIEW-AS widget-type [ options ] 

The widgettype parameter is the name of the widget type, such as FILL–IN, TOGGLE–BOX, or SLIDER. The options parameter is a set of options that further describe the widget.

The DEFINE statement for describing other static widgets (buttons, images, rectangles, menus, submenus, and frames) has the following general syntax:

SYNTAX
DEFINE widget-type name [ options ] 

The name parameter specifies a name for the widget, much like a variable name for data-representation widgets.

Again, frames and dialog boxes are described using the Frame phrase in many statements. Some of these statements, such as the FORM, I/O, and block header statements can describe a named or unnamed frame and apply scoping to the frame. The DEFINE FRAME statement, however, describes a named, unscoped frame. For more information on frame scoping, see Frames."

NOTE: The VIEW–AS DIALOG–BOX option is a special case of VIEW–AS applied to the Frame phrase only.

For example, this code fragment describes an editor widget and a frame. It instantiates the frame and editor widget in the frame description.

DEFINE VARIABLE e AS CHARACTER VIEW-AS EDITOR INNER-LINES 5
                  INNER-CHARS 30.

DEFINE FRAME main-frame
      e
      WITH NO-LABELS. 

You can also specify triggers for all static widgets when they are defined using the Trigger phrase, except the browse, frame, menu, and submenu widgets. For more information, see the "User-interface Triggers" section.

Referencing Static Widgets

In general, you can reference static widgets using either the widget name or a widget-handle variable to which its handle has been assigned. For more information on widget handles, see the "Widget Handles" section. The widget name for data-representation widgets is the field or variable name. For frames, it is the frame name; and for all other static widgets, it is the name used in the DEFINE widgettype statement.

The following widgets also require that you qualify name references with the widgettype:

For example, this code fragment shows name references to menu and menu-item widgets:

DEFINE MENU medit1
  MENU-ITEM icut LABEL "Cut"
  MENU-ITEM icopy LABLE "Copy"
  MENU-ITEM ipaste LABLE "Paste".

DEFINE MENU medit2 LIKE MENU medit1.

ON CHOOSE OF MENU-ITEM icopy IN MENU medit2 RUN copy2. 

This code fragment shows name references to field-level and frame widgets, including the browse widget, custbrow; the fill-in field, order.order–num; and the frame, x:

DEFINE QUERY q FOR customer.
DEFINE BROWSE custbrow QUERY q DISPLAY cust-num name WITH SIZE 25 by10.
DEFINE FRAME x custbrow order.order-num.

ON VALUE-CHANGED OF custbrow IN FRAME x DO: END.
ON RETURN OF order.order-num IN FRAME x DO: END. 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095