Progress
Programming
Handbook


Button Images

In a graphical interface, you can specify one, two, or three images to be displayed in a button. The primary image for a button is called the up image. It is displayed when the button is in the up or unpressed state. You can also specify a down image to be displayed when the button is in the down or pressed state. Progress displays the down image only momentarily when you press the button. Typically, the down image is similar to the up image but with a different color or shading. If you specify an up image but not a down image, Progress continues to display the up image when you press the button. Finally, you can specify an insensitive image to be displayed in place of the up image when the button is disabled.

NOTE: In a graphical interface the label is ignored and the image is used instead. In a character interface, the image is ignored and the label is used. Specifying both a label and an image makes your code portable between graphical and character interfaces.

For a button, you can use any image that is supported for the image widget. See the section "Images" later in this chapter.

NO–FOCUS Option

In addition to the types of images that a button can display, you can specify an attribute to indicate that a button with an image will not accept focus. The purpose of providing the NOFOCUS attribute is to simulate in Progress the standard Windows toolbar button behavior; it is supported on Windows only. Therefore, a button for which the NOFOCUS attribute is defined will not take focus when the mouse is clicked on it, and it will not accept keyboard input. Also, Progress will not generate ENTRY or LEAVE events for the button.

The status of the NOFOCUS option of a button is a factor in determining the thickness of a button’s border when no button size is defined. See the section "Specifying Button Size" later in this chapter.

For more information on the NOFOCUS attribute, see the DEFINE BUTTON Statement reference entry and the NOFOCUS Attribute reference entry in the Progress Language Reference .

Pre-defined Built-in Button Images

Frequently, you want to use an arrow as an image on a button. Therefore, Progress provides the following predefined built-in button images:

The p-arrows.p procedure allows you to scroll forward and backward through the customer records until you choose the QUIT button. The example enables three buttons and uses built-in images for two of them:

p-arrows.p
DEFINE BUTTON next-but LABEL "Next" IMAGE-UP FILE "BTN-DOWN-ARROW"
                      SIZE-CHARS 6 BY 1.
DEFINE BUTTON prev-but LABEL "Prev" IMAGE-UP FILE "BTN-UP-ARROW"
                      SIZE-CHARS 6 BY 1.
DEFINE BUTTON quit-but LABEL "Quit".
DEFINE VARIABLE title-string AS CHARACTER INITIAL "Customer Browser".

FORM
    next-but prev-but quit-but
    WITH FRAME button-frame.
FORM
    customer.cust-num customer.name
    WITH FRAME name-frame.
ON CHOOSE OF next-but DO:
    FIND NEXT customer NO-ERROR.
    IF NOT AVAILABLE(customer)
    THEN DO:
        MESSAGE "This is the last customer."
                  VIEW-AS ALERT-BOX ERROR BUTTONS OK
                  TITLE title-string.
        FIND LAST customer.
    END.
    DISPLAY customer.cust-num customer.name
                WITH FRAME name-frame.
END.
ON CHOOSE OF prev-but DO:
    FIND PREV customer NO-ERROR.
    IF NOT AVAILABLE(customer) THEN DO:
        MESSAGE "This is the first customer."
                VIEW-AS ALERT-BOX ERROR BUTTONS OK 
                TITLE title-string.
        FIND FIRST customer.
    END.
    DISPLAY customer.cust-num customer.name
            WITH FRAME name-frame.
END.

ENABLE next-but prev-but quit-but WITH FRAME button-frame.
FIND FIRST customer NO-LOCK.
DISPLAY customer.cust-num customer.name
      WITH FRAME name-frame.

WAIT-FOR CHOOSE OF quit-but OR WINDOW-CLOSE OF CURRENT-WINDOW. 

When you run this procedure in a graphical environment, arrow images appear on nextbut and prevbut. In a character environment, the labels NEXT and PREV appear instead. The SIZECHARS option on nextbut and prevbut ensure that they are the same size as quitbut.

Specifying Button Size

When you assign an image to a button, you can specify two sizes: the size of the button and the size of the image. To size the image, use the IMAGE–SIZE, IMAGE–SIZE–CHARS, or IMAGE–SIZE–PIXELS option of the Image phrase. See the section "Images" later in this chapter.

To size the button, you can specify the outside dimensions of the button widget using the sizephrase. If no size is specified, Progress calculates a default size for the button. This calculation adds the button’s border thickness (that is, the combination of 3D shadows and highlights, and the focus rectangle) to the up image size defined by the IMAGE | IMAGEUP imagephrase option. However, the thickness of the border depends on whether the button has dual images (up and down images) and whether it is a NOFOCUS button. For detailed information on how button image and the NOFOCUS status of a button determine the button’s border thickness, see the section on the DEFINE BUTTON statement in the Progress Language Reference .

You can also change the images for a button at run time by using the LOADIMAGEUP, LOADIMAGEDOWN, and LOADIMAGEINSENSITIVE methods.

The following code example lets you enter the name of an image file. When you enter a name and press GO, the contents of the image file are loaded as the up image for the button. If you do not enter the image file extension, Progress will only search for .bmp or .ico files. You must include the file extension if you wish to use a different type of image file:

p-but2.p
DEFINE BUTTON quit-button LABEL "Quit".
DEFINE VARIABLE image-file AS CHARACTER FORMAT "x(60)" LABEL "Image File".
DEFINE VARIABLE status-ok AS LOGICAL.

FORM
   image-file SKIP
   quit-button SKIP(13)
   WITH FRAME choices-frame SIDE-LABELS.
   
ON GO OF image-file OR RETURN OF image-file
   DO:
      ASSIGN image-file.
      status-ok = quit-button:LOAD-IMAGE-UP(image-file).
      IF status-ok = NO
      THEN MESSAGE "Cannot load this image." VIEW-AS ALERT-BOX
                                             MESSAGE BUTTONS OK.
      STATUS INPUT "Enter another filename or press the button to quit.".
   END.

ENABLE image-file quit-button WITH FRAME choices-frame.
STATUS INPUT "Enter filename of image for Quit button.".

WAIT-FOR CHOOSE OF quit-button OR WINDOW-CLOSE OF CURRENT-WINDOW. 

If you run this example on Windows and load the Progress adeicon\next.bmp file, the following screen appears:

NOTE: The adeicon\next.bmp file resides in the Progress distribution in the library gui\adeicon.pl. For more information on unloading files from libraries, see the preface.

The size of the button changes depending on the size of the image you load. If the image is very large, the button might not fit in the frame. When this happens, Progress displays a warning message.

Preserving Original Color Specifications for Button Images

In a graphical interface such as Windows, you can specify colors for the various areas of a button. To ensure that colors associated with the button’s images (that is, up, down, and insensitive) are not converted to the system 3D colors, you can use the NOCONVERT3DCOLORS option. By default, Progress converts shades of grey in an image to the corresponding system 3D color. Using this option allows you to override the default behavior to preserve your original color selections for the image on a button.

For detailed information on color conversions for 3D colors, see the DEFINE BUTTON Statement reference entry in the Progress Language Reference .


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