The most typical way to set a part's shape attribute is
through the part's settings view. Because shape is a
new attribute, it is not set in any of the settings pages that the part
inherits. One way to add the shape attribute to the settings
view is by adding another page to the settings notebook. First, create
a new visual part called MyShapeSettingsView in
MyEditSamplePartsApp. Make the part look like the
following:
Notice that the view uses a Form part instead of a Window part as its primary part. The Form part has a Drop-down List part. Open the settings of the Drop-down List part and add the circle, rectangle, and triangle choices to its list of initial items.
As you learned in Custom settings view, updateOperation is a special variable that VisualAge uses to connect this settings page to a specific part. Use these steps to add and connect the updateOperation variable:
Because this part will be an entry in the settings notebook, save the part and add the following class method to MyShape:
settingsPageNames "Add a new entry to the properties table." ^(super settingsPageNames addFirst: MyShapeSettingsView; yourself)
Move this method to your edit application, MyEditSamplePartsApp. This method will add the settings that are specific to your part to the first page of the General section of the settings notebook. This is the same approach that is used by VisualAge parts.
Occasionally, you will want to add your own pages as a separate section of the settings notebook. To do this, open the Script Editor on your settings part (MyShapeSettingsView) and add the following two class methods to the part. These methods define the text and style of the notebook tab for this page.
tabDisplayName "Answer the name of the settings page's tab" ^'Shape'
tabType "Make the settings page either a major or minor tab" ^XmMAJOR
Save the part, and add it to the shape part's settings notebook by changing the settingsPageNames class method in MyShape.
settingsPageNames "Add a new page to the settings notebook" ^(super settingsPageNames add: MyShapeSettingsView; yourself)
This method will add a new Shape page to the end of the settings notebook.
You can add help to this new settings page by adding two more class methods to MyShape, which specify the name of the help file and the help topic ID for the page:
abtSettingsViewHelpFile "answer the name of the help file" ^'abtsamp'
abtSettingsViewHelpTopicId "answer the topic id in the help file" ^'5'
Move both of these methods to MyEditSamplePartsApp.
Test your work by opening the settings of a shape part. Select rectangle or triangle from the drop-down list, and the shape part is displayed with the new appearance.