Progress
ADM 2 Guide
Customizing the Visual Class
The example in this section illustrates customizing the visual class. The customization defines a special property that you can set to specify the background color for SmartObjects that inherit from this class (that is, all visual SmartObjects), thus standardizing the look of your Progress 4GL applications.
The following sections note which custom class files you need to provide, and describe how to modify them to create the new functionality.
Copying the Visual Custom Class Files
You customize an existing class by modifying the custom class files built into that class. For this example, you will modify a selected set of the visual custom class files. Note that you work on a copy of the required files in your working directory rather than in their installed location.
To prepare for customization, follow this step;
Modifying the Visual Custom Class Files
You use the following new code to customize the visual class with the new functionality: a BgColor property, setBgColor and getBgColor functions, and an override procedure for the standard ADM initializeObject method. Adding this functionality requires changes to the
visualcustom.i
primary include file, thevispropcustom.i
property file, thevisualcustom.p
super procedure file, and thevisualdefscustom.i
custom instance definition file, which you will copy and open as required.Follow these steps in the AppBuilder to add the new functionality:
- Define the BgColor property in the
vispropcustom.i
custom property file in your working directory) To do this, open the file, go to its main block, and add the code shown in bold typeface:
When you finish making these changes, click on the Save button (the diskette icon) on the AppBuilder main window to save your changes, then close the property file window.
- Create new setBgColor and getBgColor functions in the
visualcustom.p
super procedure file. These functions allows you to set and get the new Bgcolor property publicly. To create the new function, open the file, then add the code shown in bold typeface:
- Create an override procedure for the initializeObject method in the
visualcustom.p
custom super procedure file in your working directory. This procedure gets the current value of the new BgColor property and sets the background color of container frame accordingly. To create the new override procedure, add the code shown in bold typeface:
When you finish making the changes in Steps 2 and 3, click on the Save button (the diskette icon) on the AppBuilder main window to save your changes, then close the super procedure file window. The AppBuilder now creates a .r version of the super procedure in the
src\adm2
directory under your working directory.- Edit the
visualcustom.i
primary include file and uncomment the line that starts the custom super procedure. When you finish making this change, click on the Save button (the diskette icon) on the AppBuilder main window to save your change, then close the primary include file window.- Add the BgColor property to the list of instance properties and specify a filename for the instance property dialog in the
visualdefscustom.i
custom instance definition file in your working directory. To add the property and filename, open the file, then add the code shown in bold typeface:
Note that you have specified
adm2/support/visuald.w
—that is, the filevisuald.w
in theadm2\support
directory under your working directory—as the instance property dialog box file. (Progress code is not sensitive to whether you use forward or reverse slashes in pathnames.) You will add support for this dialog box in the next step.When you finish making these changes, click on the Save button (the diskette icon) on the AppBuilder main window to save your changes, then close the property file window.
- Provide support for your new property in the instance property dialog box. In this example, the simplest approach is to copy the instance property dialog box for the visual class,
visuald.w
, from the%DLC%\src\adm2\support
directory to thesrc\adm2\support
directory under your working directory, then modify the copy as needed.Alternatively, you can either modify the original
visuald.w
instance property dialog box in the%DLC%\src\adm2\support
directory or create a completely new instance property dialog box that includes support for the new property (as well as for all other properties required by the class).Regardless of which technique you use, you must be sure that the instance property dialog box filename matches the name that you specified in the custom instance definition file in your working directory. (See Step 5 .)
NOTE: If you do not move the .r file into the- Enable the new super procedure file by moving the .r file from the
src\adm2
directory under your working directory into theadm
2 directory under your working directory.adm
2 directory under your working directory, you will not be able to use the new super procedure.The customized class, with its new property, is now ready for use. Before you work with it, you should restart the AppBuilder to re-establish the super procedure stack.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |