The objective of this section is to familiarize you with creating reusable visual parts and using them with VAGen parts. This exercise focuses on the following tasks:
You will build a group box and use the Quick Form function to add labels and fields to it. Figure 100 shows the group box you will define.
First, you will create a new visual part (just as you did in "Creating a new visual part"). In the next section you will add this reusable visual part to your Customer Information window.
To build a Group Box using Quick Form, perform the following steps:
The VisualAge New Part window is displayed.
The Composition Editor is displayed.
Now you can see the entire Window part.
The context menu is displayed.
The Window is deleted.
A Group Box places a rectangular box around a set of parts. It also allows you to move and use them as a single unit.
Complete the following steps to create the Address Group Box.
The parts palette is refreshed to show all parts in the Canvas category.
A default size Group Box is displayed on your free-form surface.
The Group Box corners have selection handles.
The Group Box is resized.
The Group Box label becomes blocked for deletion in text edit mode.
Address is now the label of the Group Box.
To add parts to the Group Box, you will use Quick Form just like you did in Chapter 18, Building a visual part using VisualAge Generator Developer on Smalltalk.
Complete the following steps to add parts to the Address Group Box.
The Add Subpart window is displayed.
The CUSTOMER record part is displayed on the free-form surface.
The context menu is displayed.
A list of data items is displayed.
The Street Label part and a Text part are added to the Group Box. An attribute-to-attribute connection is created, and the data type is set using the CUSSTREET data item definition.
The record and all the connections are now deleted. You do not need the attribute-to-attribute connections in this scenario. Later, you will promote these fields to the public interface so that you can define connections to them in any view where you embed this address box.
Lay out the Label and Text parts in the Group Box as shown in Figure 100. Remember, to size a part, select it with mouse button 1, place the mouse pointer on one of the selection handles, and move the mouse while holding down mouse button 1. For more detailed information about laying out visual parts, see "Arranging visual parts".
If you want to access any information in the ADDRESS Group Box from another view, you must add the appropriate features to the public interface. In this case, the features needed are the attributes for the Text parts. In this section, you will add attributes for all four Text parts (Street, City, State, and Zip) to the public interface.
For more complete information on topics covered in this section, refer to the VisualAge for Smalltalk User's Guide.
To promote part features to the public interface, perform the following steps:
The Promote features from window is displayed.
textCUSSTREETObject is displayed in the Promote feature name field.
Now other parts can reference this Text part by the attribute name. By selecting object, you are adding the actual value of the data that the part represents, including all customized parameters, such as currency symbols or numeric separators. Selecting string would only have added a reference to the input string typed into the field.
The object attribute feature of each of the four Text parts has been added to the public interface. Now these attributes can be accessed by other parts.
You can also do this same task from the Promote tab in Public Interface Editor. Refer to the VisualAge for Smalltalk User's Guide more information on using the Public Interface Editor.
Now you are ready to embed the address box in your tutorial view and add VAGen logic parts.