Progress
Programming
Handbook
Images
An image widget is a container in which you can display an image from a bitmap file. You create a static image widget at compile time with the DEFINE IMAGE statement.
The DEFINE IMAGE statement creates an image widget and optionally makes an association between the widget and an operating system image file. The DEFINE IMAGE statement takes an Image phrase, which has the following options:
- FILE — A character expression that specifies the name of the image file to associate with the image widget.
- FROM — Two integer values that specify position of the upper-left corner of the image within the image file. Use X and Y to specify pixel offsets and ROW and COLUMN to specify character offsets.
- IMAGE–SIZE | IMAGE–SIZE–CHARS — Two integer values, separated by the keyword BY, that specify the width and height of the image in character units.
- IMAGE–SIZE–PIXELS — Two integer values, separated by the keyword BY, that specify the width and height of the image in pixel units.
- STRETCH–TO–FIT — This option/attribute forces the image to expand or contract to fit within the image widget’s boundaries.
- RETAIN–SHAPE — This option/attribute is used only when the STRETCH–TO–FIT option/attribute is TRUE. It indicates that the image should retain its aspect ratio.
- TRANSPARENT — This option/attribute indicates that the image’s background color should become transparent.
When you use one of the image-size options in conjunction with the FILE options, Progress simply makes a compile-time association between the image file and the image widget; the image file does not have to exist at this point.
If you leave out the file extension when referencing an image file from within a procedure, Progress looks through your PROPATH for files that have the .bmp extension and then for files that have the .ico extension. You must supply the file extension if you reference an image file that does not have the the .bmp or .ico extension.
NOTE: Progress supports the display of many image file formats, including JPEG (.jpg) and Graphics Interchange Format (.gif). See the Progress Language Reference for a complete list of supported image file formats.Omit the FILE option if you want to create an image widget that is not associated with an image file at compile time, but instead want to make the association at run time.
Use the FILE option without one of the image-size options if you do not know the size of the image and want Progress to determine the size at compile time. If you do this, Progress uses the entire image. Also note that the image file must exist at compile time or a compiler error will occur.
The following code fragment uses the DEFINE IMAGE statement to create an image widget. The FILE option makes an association between the image widget and the
pro
bitmap file. The FROM and the IMAGE–SIZE–PIXELS options instruct Progress to read a 64x64 pixel portion of the file beginning at pixel location 5, 5. The code fragment then displays the image.
To associate an image file with an image widget at run time, use the LOAD–IMAGE method. You can do this either to change an existing association or to create an association if you did not use the FILE option when defining the image widget. The LOAD–IMAGE method returns a logical value and has the following parameters:
filename
A character-string expression of a full or relative pathname of a file that contains an image.
x-offset
An integer that specifies the pixel along the x-axis at which to begin reading from the image file.
y-offset
An integer that specifies the pixel along the y-axis at which to begin reading from the image file.
width
An integer that specifies the number of pixels along the x-axis to read from the image file.
height
An integer that specifies the number of pixels along the y-axis to read from the image file.
NOTE: When you use the LOAD–IMAGE method, Progress uses pixels as the unit of measurement for the x-offset, y-offset, width, and height; you cannot specify character units.The following code fragment creates a dynamic image widget and lets you choose an image file to load into the widget:
Because images are supported only for Windows, this procedure determines whether you are running in a character interface. If so, it displays a message and returns. Otherwise, you can choose the Get Image button and select an image to load.
For example, if you load the
admin.bmp
image shipped with Progress, the following screen appears:
NOTE: Each time you load a new image, the procedure adjusts the size of the frame to ensure the image widget still fits in the frame.Converting Original Color Specifications for Images to System 3-D Colors
The CONVERT-3D-COLORS option enables colors that are associated with an image to be converted to system 3-D colors when the image is loaded. The color conversion process is based on mapping white, grey, and black colors to their original red-green-blue color values. Subsequently, these original color values are converted to the new corresponding system colors. During a session, if Windows notifies Progress that the system colors are changed, all images that have the CONVERT-3D-COLORS option are reloaded and converted to the new system colors.
For detailed information on color conversion for 3–D colors, see the DEFINE IMAGE Statement reference entry in the Progress Language Reference .
Transparency
If you set the TRANSPARENT attribute of an image to TRUE, portions of one image can show through another image. The background color of an image which is TRANSPARENT becomes transparent, allowing any image beneath it to show through. This feature does not apply to icon images since they can be drawn with transparent backgrounds.
The TRANSPARENT attribute overrides the CONVERT–3D–COLORS attribute. If both TRANSPARENT and CONVERT–3D–COLORS are set to TRUE, the latter will be ignored.
Specifying Tooltip Information for Images
On Windows, you can optionally specify ToolTips, a brief text message string that automatically displays when the mouse pointer pauses over a widget for which a ToolTip value is defined. Although ToolTips can be set up for a variety of field-level widgets, including buttons, images and rectangles discussed in this chapter, they are most commonly defined for button widgets. For more information on ToolTips and other Windows interface design options, see Interface Design."
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |