Migrating Tool Settings

Place Line

The following example is the "Place Line" command. It has three sets of a ToggleButton followed by a Text field. The third set is hidden by default. We will not change the actual layout of this command's settings.

Before Image

PlaceLineTS.png

After Image

CONSGEOM_600_PlaceLine.png

To migrate the settings to the Layout Manager, we start with a VStackLayout as its main layout and put a GridLayout within it with three rows. The GridLayout is not used as the main layout because we need to push the items up from the bottom when the Tool Settings dialog is docked, and we do that with a STRETCH(1) item at the end of a VStackLayout. The items on the row are surrounded by the GridRow and EndRow items. Each item is automatically assigned a sequential column number. Each row contains a ToggleButton, Label and Text field. The ToggleButton actually contains the label string. But for layout purposes, a Label item is added and specifies the "LABEL_LINKPREV" itemArg value in order to link to the previous item (the ToggleButton). Using this technique, the label string is pulled over to the Label item and the two items are "linked" for the focus model. This allows the ToggleButton to keep the label in its resource definition in case it is used outside a layout, but also allows the Label item to "link" to it and specify an independent column and size policy for layout purposes. In this case, the default "left alignment" is applied to the Label item. The "LABEL_LINKNEXT" itemArg value would pull the label string from the following item. The items in the third row are hidden by default; therefore, that row's height is 0. A STRETCH(1) is inserted as the last item in the VStackLayout to prevent unnecessary row height expansion when the Tool Settings dialog is docked.

This example uses the following principle and common techniques:

Before

(.unparsed)
#define W10 10*XC
CmdItemListRsc CMD_PLACE_LINE_CONSTRAINED =
{
{
{{X1, Y1, 0, 0}, ToggleButton, TOGGLEID_Length, ON, 0, "", ""},
{{X15, Y1, W10, 0}, Text, TEXTID_Length, ON, 0, "", ""},
{{X1, Y2, 0, 0}, ToggleButton, TOGGLEID_Angle, ON, 0, "", ""},
{{X15, Y2, W10, 0}, Text, TEXTID_Angle, ON, 0, "", ""},
{{X1, Y3, 0, 0}, ToggleButton, TOGGLEID_SolutionChoice, ON|HIDDEN, 0, "", ""},
{{X15, Y3, W10, 0}, OptionButton, OPTIONBUTTONID_SolutionChoice, ON|HIDDEN, 0, "", ""},
{{X1, Y3, W10, 0}, Label, 0, ON, 0, "", ""},
}
};

Before

From MicroStation

(.unparsed)
// Use for all 3 column Grids in Tool Settings
{
{0, 0, 0, 0}, // Margins - Left, Top, Right, Bottom
GRID_HSPACING, GRID_VSPACING, // HSpacing, VSpacing
{ // Column Definitions
{0, "ts3_column0"}, // Stretch, SharedSizeGroup
{0, "ts3_column1"},
{0, "ts3_column2"},
{1, "ts3_stretch"}, // Extra column with a Stretch Factor of 1 to prevent unwanted row expansion
}
};

From PPModules\2dModeling\Apps\consgeom\transkit\consgeom.r

(.unparsed)
#define W10 10*XC
CmdItemListRsc ItemList_LineConstrained =
{{
GRID_ROW(0, "")
{{AUTO_XY, 0, 0}, ToggleButton, TOGGLEID_Length, ON, 0, "", ""},
{{AUTO_XY, W10, 0}, Label, 0, ON, LABEL_LINKPREV | ALIGN_RIGHT, "", ""},
{{AUTO_XY, W10, 0}, Text, TEXTID_Length, ON, 0, "", ""},
GRID_ROW(0, "")
{{AUTO_XY, 0, 0}, ToggleButton, TOGGLEID_Angle, ON, 0, "", ""},
{{AUTO_XY, W10, 0}, Label, 0, ON, LABEL_LINKPREV| ALIGN_RIGHT, "", ""},
{{AUTO_XY, W10, 0}, Text, TEXTID_Angle, ON, 0, "", ""},
GRID_ROW(0, "")
{{AUTO_XY, 0, 0}, ToggleButton, TOGGLEID_SolutionChoice, ON|HIDDEN, 0, "", ""},
{{AUTO_XY, W10, 0}, Label, LABELID_SolutionChoice, ON|HIDDEN, LABEL_LINKPREV| ALIGN_RIGHT, "", ""},
{{AUTO_XY, W10, 0}, OptionButton, OPTIONBUTTONID_SolutionChoice, ON|HIDDEN, 0, "", ""},
}};

Change Attributes

The following example is the "Change Attributes" command.

Before Image

ChangeAttributesTS.png

After Image

CHANGEATTRIBS_3800_ChangeAttributes.png

These settings basically have 3 sections:

  1. The "Use Active Attributes" section
  2. Several "Toggle Label: Editor" rows
  3. more Toggles, one with an editor, and two without

The sections are separated by a Separator item, which spans across the width of the dialog. The basic layout of the command's settings will remain unchanged.

To migrate the settings to the Layout Manager, we start with a VStackLayout as its main layout. For the first section, we use an HStackLayout. We use the HSTACKLAYOUTID_DialogButtons from ustation.rsc. To layout the label of the ToggleButton properly, a Label item is added and specifies the "LABEL_LINKPREV" itemArg value in order to link to the previous item (the ToggleButton). Using this technique, the label string is pulled over to the Label item and the two items are "linked" for the focus model. A SPACING(XC) is used before the IconCmdX to add spacing between the items. A STRETCH(1) is inserted as the last item in the HStackLayout to prevent unnecessary horizontal expansion. The first Separator is then added directly to the VStackLayout.

The next section contains several "Toggle Label: Editor" rows. The layout for this section is a GridLayout, and we use the GRIDLAYOUTID_3ColsToggleLabelSetting standard layout from ustation.rsc. Each "Toggle Label: Editor" set will be on a separate GridRow. This is accomplished using the GRID_ROW and END_ROW helper macros. We again add a Label item with the "LABEL_LINKPREV" itemArg for proper layout and sizing. After the GridLayout, the second Separator is added directly to the VStackLayout.

The final section is another GridLayout using the same GRIDLAYOUTID_3ColsToggleLabelSetting standard layout. The first GridLayout is similar to the ones in the previous section. But the last two have no editor. So we use a colSpan override value of '*' (AKA. the Star value), which indicates the cell will span the columns to the end of the row. The last item added to the main VStackLayout is a STRETCH(1) item to prevent vertical stretching.

Several of the older helper macros dealing with column position and row calculations could be removed after migrating to the Layout Manager.

This example uses the following principle and common techniques:

Before

(.unparsed)
#define CA_CTRL_CX 17
#define CA_CKBX_CX 16
#define CA_UAA_CX (20*XC)
#define CA_MElm_X (22*XC)
#define CA_ROW(x) D_ROW(x)
#define CA_CTRL_X (17*XC)
CmdItemListRsc CMD_CHANGE_ATTRIBUTES =
{{
{{XC, CA_ROW( 1.0), CA_UAA_CX, 0}, ToggleButton, TOGGLEBUTTONID_UseActiveAttributes, ON, 0, "", ""},
{{CA_MElm_X, CA_ROW( 0.8), 0, 0}, IconCmdX, ICONCMDX_MatchElementAttr, ON, 0, "", ""},
{{0, CA_ROW( 2.2), 0, 0}, Separator, 0, ON, 0, "", ""},
{{XC, CA_ROW( 2.7), CA_CKBX_CX*XC, 0}, ToggleButton, TOGGLEBUTTONID_ChangeElmLevel, ON, 0, "", ""},
{{CA_CTRL_X, CA_ROW( 2.7), CA_CTRL_CX*XC, 0}, ComboBox, COMBOBOXID_ElmLevel, DISABLED, 0, "", ""},
{{XC, CA_ROW( 3.7), CA_CKBX_CX*XC, 0}, ToggleButton, TOGGLEBUTTONID_ChangeElmOutlineColor, ON, 0, "", ""},
{{CA_CTRL_X, CA_ROW( 3.7), CA_CTRL_CX*XC, 0}, IconPopup, ICONPOPUPID_ElmOutlineColor, DISABLED, 0, "", ""},
. . .
{{0, CA_ROW(10.8), 0, 0}, Separator, 0, ON, 0, "", ""},
{{XC, CA_ROW(11.2), 0, 0}, ToggleButton, TOGGLEID_UseFence, ON, CMD_CHANGE_ATTRIBUTES,"",""},
{{15*XC, CA_ROW(11.2), 0, 0}, OptionButton, OPTIONBUTTONID_LockFenceMode, ON, 0, "\0", ""},
{{XC, CA_ROW(12.2), 0, 0}, ToggleButton, TOGGLEBUTTONID_MakeCopy, ON, 0, "", ""},
. . .
}};

After

(.unparsed)
#define CA_CTRL_CX 17
#define CA_CKBX_CX 12
CmdItemListRsc ItemList_ChangeAttributes =
{{
GRID_ROW(0, "")
EMPTY_GRID_CELL(0,"")
{{AUTO_XY, 0, 0}, ToggleButton, TOGGLEBUTTONID_UseActiveAttributes, ON, 0, "", ""},
{{AUTO_XY, 0, 0}, IconCmdX, ICONCMDX_MatchElementAttr, ON, 0, "", ""},
{AUTO_XYWH, Separator, 0, ON, SEPARATOR_HTOOLSETTINGS, "", ""},
GRID_ROW(0, "")
{{AUTO_XY, 0, 0}, ToggleButton, TOGGLEBUTTONID_ChangeElmLevel, ON, 0, "", ""},
{{AUTO_XY, CA_CKBX_CX*XC, 0}, Label, 0, ON, LABEL_LINKPREV | ALIGN_RIGHT, "", ""},
{{AUTO_XY, CA_CTRL_CX*XC, 0}, ComboBox, COMBOBOXID_ElmLevel, DISABLED, 0, "", ""},
GRID_ROW(0, "")
{{AUTO_XY, 0, 0}, ToggleButton, TOGGLEBUTTONID_ChangeElmOutlineColor, ON, 0, "", ""},
{{AUTO_XY, CA_CKBX_CX*XC, 0}, Label, 0, ON, LABEL_LINKPREV | ALIGN_RIGHT, "", ""},
{{AUTO_XY, CA_CTRL_CX*XC, 0}, IconPopup, ICONPOPUPID_ElmOutlineColor, DISABLED, 0, "", ""},
. . .
{AUTO_XYWH, Separator, 0, ON, SEPARATOR_HTOOLSETTINGS, "", ""},
GRID_ROW(0, "")
{{AUTO_XY, 0, 0}, ToggleButton, TOGGLEID_UseFence, ON, CMD_CHANGE_ATTRIBUTES, "", ""},
{{AUTO_XY, CA_CKBX_CX*XC, 0}, Label, 0, ON, LABEL_LINKPREV | ALIGN_RIGHT, "", ""},
{{AUTO_XY, CA_CTRL_CX*XC, 0}, OptionButton, OPTIONBUTTONID_LockFenceMode, ON, 0, "\0", ""},
GRID_ROW(0, "")
{{AUTO_XY, 0, 0}, ToggleButton, TOGGLEBUTTONID_MakeCopy, ON, 0, "", "column='2',colSpan='*'"},
. . .
STRETCH (1)
}};
}};

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.