Up Previous Next Title Page Index Contents

1.7 Dialog Editor

See also the Menu Reference, Section 3.7.

The Object, Relationship, Role and Graph Tools allow you to open a Dialog Editor to modify the layout of the dialog used to edit the properties of an instance of that type. To edit the dialog layout:
1)Open a pop-up menu from the Properties field with the right mouse button.
2)Select Edit Dialog (Figure 1-22).

Figure 1-22. Object Tool.

As a result a dialog opens as illustrated in Figure 1-23. It shows the layout and contents of a dialog for a Process object. In other words, it shows the appearance of a dialog that a CASE tool user uses when creating or editing a Process in a Data Flow Diagram.

Each widget in the dialog is determined by the data type and widget type of its property type (a string is a single line field, text is a text box, list is a list box etc.). The labels are the local names of the properties in this object type.

Figure 1-23. A dialog for Process.

Location of dialog components

The location of any field or label can be changed by selecting the item and dragging it to the desired location with the mouse. Several items can be selected to be moved as one unit by keeping the shift button down while selecting the items from the window. When moving the selection, it is possible to constrain the movement to happen only either vertically or horizontally by holding shift as you begin the move: the axis along which movement is restricted is taken from the direction you first move the selection in.

Setting resize factors for dialog components

If the location of dialog components is changed you usually must also set resizing information for dialog components. This is needed to specify how individual property fields, labels and buttons are resized when the whole dialog is resized. For this purpose MetaEdit+ offers the Properties tool for each dialog component.

To open a Properties tool for a dialog component, select a component and press Esc-P. This opens a window containing a notebook. Select the Position page from the notebook.

Figure 1-24. Properties tool for dialog elements.

The Position page has a proportion field and offset field for each side of a component, Left, Top, Right and Bottom. For components whose width and height is calculated automatically, i.e. text labels, fields show the origin’s X and Y co-ordinates, and the position of the origin point within the component: normally 0 and 0, for the top left corner, but could be 1 and 1 to make the bottom right corner the origin.

The Proportion value for a dialog component’s side controls how much that side moves relative to the window size. Values can be between 0 and 1: 0 is the left or top of the window and 1 is the right or bottom of the window. Thus setting it to 0 causes the dialog component’s side to remain a fixed distance from the top or left side of the dialog, and setting it to 0.5 will make the side remain a fixed distance from the middle of the dialog.

Offset sets the desired distance to offset the component’s side from the value given by the proportion. It may be positive or negative. For example, a left proportion value of 0.5 and offset value 50 means that the dialog element is located 50 pixels left from the middle of the window. Thus the pixel position of the side is equal to the window’s extent in that direction (width or height) multiplied by the proportion value, plus the offset value. For one complete example, see the Tutorial chapter on the Symbol Editor (Figure 2-9).

The most common use for the Properties tool is for customised dialogs where you want dialog components to expand or shrink in concert with the window. This is done by setting the component’s right proportion to be different from its left proportion, and/or by setting its bottom proportion to be different from the top proportion. The latter is useful for dialog elements like list and text fields which can use the additional space once the dialog is resized: input fields and other single-line fields normally have the same proportion value for top and bottom sides.

By default, MetaEdit+ creates dialogs where all fields have a left proportion of 0 and a right proportion of 1: thus making dialogs wider makes each field grow to fill the extra width. Similarly, top and bottom proportions of fields higher than a single line are set to different values. Thus making dialogs higher makes each field with more than a single line grow to fill the extra height; the extra height is shared equally among these fields. Each label is given the same top proportion as that of its field, so it moves with that field. Finally, the buttons are always centred at the bottom of the dialog.

To lay out a dialog’s components to resize with the window as you wish, you should first get the layout right for a given size of the window:
1)Drag from the top left corner to nearly the bottom right corner to select all the labels and fields, but not the buttons.
2)Press Esc-f. This changes all of the components to have a fixed position, i.e. sets their proportion fields to zero, but without changing their visible positions. Having fixed positions makes getting the basic layout right easier.
3)Resize the whole dialog to be twice as wide (assuming you want to place the fields in two columns). Move the desired fields and their labels into the space on the right to make two columns. Resize the dialog again to be the right height (the buttons will follow the bottom edge of the dialog). Now you should have the dialog elements in their intended location for this size of dialog: adjust their positions if necessary.

Now that you have the layout right in this size, you can set the proportion values for the components so that they will move and resize appropriately when the window is resized:
1)Select a dialog component, open its Properties tool with Esc-P and select the Position page.
2)Clear all the offset values by clicking the small buttons on the right hand side of the offset fields. This means that when you make a setting in the proportion field, the value in the offset is automatically adjusted so that the component side remains in the same position as it is currently. Thus you can safely adjust the proportion values, without the component moving around the dialog away from its undesired position.
3)If the component is in the left column, set its left proportion to 0, and its right proportion to 0.5. Similarly, if it is in the right column set its left proportion to 0.5 and its right proportion to 1.
4)Set the bottom proportion (B) to a value that is larger than the top proportion (T). If you have four fields that could be relative above each other, set the first one’s top proportion to 0 and its bottom proportion to 0.25, and the second one’s top proportion to 0.25 and bottom proportion to 0.5 etc.
5)If you beforehand moved the dialog element to its intended location, the offsets are calculated automatically once you press the Apply or OK button. Alternatively, you may set the exact pixel distance from the imaginary proportion line by hand.

The resulting setting is shown immediately in the dialog, and you can test it by resizing the dialog window: the component should behave as expected, but other components which have not yet been set will not move.

You may continue in this way to select and position other dialog elements. You can also set a position for a side or sides of each of a set of dialog elements by selecting them all first (either by dragging an area or by clicking with shift held down), then opening the Properties tool with Esc-P. Note that the selected group must contain either only fields, or only labels, not both. If you are laying out the dialog in two columns, you can set the left and right proportions for all labels in the left column, then again for all fields in the left column, and similarly for the right column. You can then continue to set the top and bottom proportions for each individual field and label with non-zero top or bottom proportions.

There is a simpler dialog version of the Position page of the Properties tool, which may be opened with Esc-L, but only for a single element at a time.

Aligning dialog components

Sometimes several components need to be aligned or distributed relative to each other. These operations can be performed by selecting first the components and then the appropriate commands from the pop-up menu.

To align a group of widgets, select them keeping the shift key pressed and select Align... from the pop-up menu. In the Align dialog (see Figure 1-25) select the on vertical line option to align widgets in a column. To align widgets side by side, select on horizontal line. Select first selection to align widgets with the first widget that was selected. Select merged box to align the widgets on a line halfway between the most extreme positions within the group of widgets. To align the edges of the widgets select either left edges, or right edges, or centers.

Figure 1-25. Alignment dialog.

Distributing dialog components

After making modifications it is often necessary to equalise spaces between a group of widgets. This can be done by selecting Distribute... from the pop-up menu. In the distribute dialog (Figure 1-26), select left to right for widgets that are to be evenly spaced horizontally. Select top to bottom for an even vertical spacing. The type of spacing can be set either as equal between centers or edges, which distribute all elements between the outermost two, or as constant spacing between edges. If you choose constant spacing, you have to specify the constant, the number of pixels between each pair of widgets. The widgets are then spaced using that constant, starting from the top or leftmost widget.

Figure 1-26. Spacing dialog.

Equalising dimensions

Series of widgets can be forced to adopt the same width, height or both by choosing Equalize... from the pop-up menu. The size can be equalised using the first of the selected objects as the size for others, or then you can set the minimum or maximum of the sizes to be used for all. If you want the size to be a certain number of pixels, that can be set in the ‘constant’ box.

Figure 1-27. Equalize dialog.

Order of fields

When a user opens a property dialog for an instance, the cursor is initially in a certain field (by default, the first property of that type). By pressing Tab, the user can advance through all the fields, and finally to the OK, Cancel and Info... buttons. This tab order of the fields can be set by keeping the shift key pressed and selecting the widgets, in the order in which the tabbing should advance the focus, and selecting Tab Order from the pop-up menu.

Dialog size

By default each dialog has a fixed size in which it opens in modelling tools. This size is determined automatically after ordering the property fields and related labels below each other (cf. Figure 1-23).

If the opening size of the default dialog is not suitable you may change it by simply resizing the window with the mouse, and closing it, accepting changes. You may also set the minimum and maximum sizes for the property dialog, by scaling the window to the required size and then selecting either Set Minimum Size or Set Maximum Size. Normally, the minimum size is set to be the smallest size at which all components are visible, and components with more than one line of text are showing roughly two lines. The maximum size is not normally set. After setting minimum or maximum sizes, remember to return the window to an appropriate default size before saving your changes.

Scroll bars

If the window’s height is such that it might not fit into some displays, the system automatically turns on the vertical scroll bar. If the scroll bar is not needed it can be turned off by selecting Toggle Vertical Scroll Bar from the pop-up menu.

In some cases you might also want to use horizontal scroll bar: for example to hide some rarely needed design information and to make the size of property dialogs smaller. To turn it on or off, select Toggle Horizontal Scroll Bar from the window’s pop-up menu.

Removing, cutting and pasting components

In some circumstances, for example when using subclasses of existing types, there may be a need to delete a field from the dialog. The field can be deleted by selecting the field and pressing the delete button from keyboard. Note that the users can not give values for a property whose input field has been removed, but the property is still stored, with its current value (or default empty value for new objects).

The most recently deleted selection can be added back into the window with CTRL-J. This allows even multiple selections to be cut and pasted between dialog editors. Be aware however that property entry fields are specific to a given type. They can only be copied for a given property in a given non-property type if they are defined in the same type (this type or a common supertype), and that property in that type does not change between the cut and paste. Labels and buttons can be cut from any dialog editor, and pasted into any other dialog editor, regardless of which type the dialog represents.

Cutting and pasting dialog elements is most useful when building a custom dialog that extends an existing custom dialog with new properties. This can happen when subtyping an existing type and adding a new property, or adding a new property to an existing type.
1)Select Edit Dialog from the property list pop-up menu (cf. Figure 1-22) of the existing supertype, or the type before the property addition.
2)Select all the elements in the dialog by clicking and dragging to define an area totally enclosing them all.
3)Leave this dialog editor open while you perform your change to the existing type or create a subtype, making sure you generate a new default dialog for that type.
4)Select Edit Dialog from the property list pop-up menu of the new or changed type.
5)Select all the components of the new default dialog, except the labels and widgets for the new properties.
6)Press DELETE to cut these elements of the new default dialog.
7)Resize the second dialog editor to the right size and shape to accommodate the old custom layout plus the new properties. Move the new properties to their desired place.
8)In the first dialog editor, press DELETE to cut the corresponding elements. This overwrites the contents of the cut buffer from step 6) above.
9)In the second dialog editor, press CTRL-J to paste the elements from the buffer. Finalise the layout, and close this dialog editor, installing this new definition.
10)Close the first dialog editor; do not agree to install the definition.

Care should be taken in this procedure, especially in making sure that the cut property fields are defined in the same type. If incorrect property fields are present in a dialog, that dialog will not be able to open, preventing editing and creation of instances of that type. In this case, you should rebuild the default dialog for the type.

Closing a Dialog Editor

The new window specification can be saved by closing the window and answering yes to the dialog (Figure 1-28) that asks whether or not the changes should be saved.

Figure 1-28. ‘Save changes to the dialog definition’ dialog.


Up Previous Next Title Page Index Contents