The Properties Panel
If the widget includes parameters, it is strongly recommended that you supply a Panel module. The purpose of this module is to control the layout of the parameter elements in the properties dialog when the widget is being edited.
The Panel module takes two parameters: Parms, which is a pointer to an array containing the widgets parameters and PtrWaitClose, which is used by VTScada when the properties dialog is being closed.
The Panel module will normally also have one internal variable, Trigger. This will be used by VTScada when each field in the panel is edited by the user.
Like the tag configuration dialog, the P* functions are commonly used for the data entry fields.
For example, the entirety of the Analog Status tag's Draw widget panel, as shown in the preceding topic, is as follows:
<
{=============================== Panel ===============================}
Panel
(0, #PanelHt, #PanelWd, 0)
(
Parms;
PtrWaitClose { Pointer to Flag - TRUE to wait to close dlg };
ParmDefs { Array of page parameter definition structures };
DialogRoot { The calling dialog window };
)
[
Trigger { Edit fields trigger };
SubWaitClose { WaitClose flag for the datasource editor };
Height { Height of panel };
PageInst { Page instance };
ContPageInfo { Container page information };
Modules { Array of modules to load in the ParameterEdit };
Parameters { Array of parameters for ParameterEdit modules };
ParmEditObj { Object value of the ParameterEdit control };
PEBottom { Bottom of the ParameterEdit };
FontParm; OldFontParm { Used for ParameterEdit };
]
Init [
If 1 PanelMain;
[
{***** Set defaults *****}
Parms[#Digits] = PickValid(Parms[#Digits], 1);
Parms[#ShowUnits] = PickValid(Parms[#ShowUnits], 1);
Parms[#Border] = PickValid(Parms[#Border], 0);
Parms[#BgndColor] = PickValid(Parms[#BgndColor], \DialogBGColor);
Parms[#DisableTrend] = PickValid(Parms[#DisableTrend], 0);
Parms[#DisableNavigation] = PickValid(Parms[#DisableNavigation], 0);
Parms[#DisableTooltip] = PickValid(Parms[#DisableTooltip], 0);
{ Initialize the wait close flag to not wait }
*PtrWaitClose = FALSE;
{ Get info about the parms of the container page }
PageInst = \GetUserSession()\GraphicEditor\GetSelectedTabItem();
ContPageInfo = GetParamInfo(PageInst);
{ Set up variables for ParameterEdit }
FontParm =
OldFontParm = Parms[#FontParm];
MetaData(FontParm, "Revision") = 0;
{ "Font" ParameterEdit }
Modules = New(3);
Parameters = New(3);
{ Tag option }
Modules[0] = "ParmEditTag";
Parameters[0] = New(1);
Parameters[0][0] = "FontValue";
{ Parameter option }
Modules[1] = "ParmEditParmValue";
Parameters[1] = New(6);
Parameters[1][0] = ContPageInfo;
Parameters[1][1] = \#VTypeObject;
Parameters[1][2] = Invalid;
Parameters[1][3] = New(1);
Parameters[1][3][0] = "FontValue";
Parameters[1][4] = 0; { No Scaling }
Parameters[1][5] = Invalid; { No default value }
{ Expression option }
Modules[2] = "ParmEditExprNoNormalize";
Parameters[2] = New(2);
Parameters[2][0] = 1;
Parameters[2][1] = ContPageInfo;
]
]
PanelMain [
{***** Let the caller know when its ok to close *****}
*PtrWaitClose = PickValid(Trigger, 1) == 0 || PickValid(SubWaitClose, 0) == 1;
Height = 10*Space + 2*TitleSpace + PEBottom + SpinHt + BtnHt + 3*CheckHt + 65;
If Watch(0, Height);
[
SetPanelRefBox(Self, 0, Height, #PanelWd, 0);
]
{***** Font *****}
GUITransform(0, 1, 1, 0,
1 - 0,
2 * (EditHt + Space),
#PanelWd,
1 - 0,
1, 0, 0, 1, 0, 0, 0, 0,
ParmEditObj = \ParameterEdit(FontParm { Parameter Value },
ParmDefs[#FontParm] { Parameter Definition },
1 { Enable Flag },
\GetPhrase("FontLabel") { Title },
Modules { Array of Parm Edit Modules },
Code { Contexts for Edit Modules },
Parameters { Parameters for Edit Modules },
TextAttribs(\GetPhrase("FontLabel"), _DialogFont, 0) { Title Width },
Invalid { Index value },
SubWaitClose { Wait to close },
DialogRoot { Calling dialog window }));
If FontParm != OldFontParm ||
Valid(FontParm) != Valid(OldFontParm);
[
OldFontParm =
Parms[#FontParm] = RootValue(FontParm);
]
PEBottom = PickValid(ParmEditObj\Height, 2 * (EditHt + Space));
{***** Digits *****}
GUITransform(0, 1, 1, 0,
1 - 0,
Space + PEBottom + SpinHt,
170,
1 - (Space + PEBottom),
1, 0, 0, 1, 0, 0, 0, 0,
\DialogLibrary.PSpinBox(#Digits, \GetPhrase("DigitsAfterDecLabel"), 1 { box on left },
0, 9 { limits }, 3 { left, centered }, 0 { autosize },
0 { no edit }, 3 { ID }, Invalid, Invalid, Trigger {Trigger}));
{***** Show units *****}
GUITransform(0, 1, 1, 0,
1 - 180,
Space + PEBottom + CheckHt + 4,
#PanelWd,
1 - (Space + PEBottom + 4),
1, 0, 0, 1, 0, 0, 0, 0,
\DialogLibrary.PCheckBox(#ShowUnits, \GetPhrase("ShowUnitsLabel"), 1 { box on left },
3 { left, centered }, 4 { ID }));
{***** Type of border *****}
GUITransform(0, 1, 1, 0,
1 - 0,
2*Space + PEBottom + SpinHt + 65,
#PanelWd,
1 - (2*Space + PEBottom + SpinHt),
1, 0, 0, 1, 0, 0, 0, 0,
\DialogLibrary.PRadioButtons(#Border, 8 { to 10 - ID },
1 { border }, \GetPhrase("TypeOfBorderLabel"), 1 { btns on left }, 1 { align title },
\GetPhrase("NoButtonLabel"), \GetPhrase("ButtonLabel")));
{***** Colors *****}
System.Bevel(0,
5*Space + TitleSpace + PEBottom + SpinHt + BtnHt + 65,
#PanelWd,
3*Space + PEBottom + SpinHt + 65,
\GetPhrase("ColorsLabel"));
{***** Background color *****}
GUITransform(0, 1, 1, 0,
1 - Space,
4*Space + TitleSpace + PEBottom + SpinHt + BtnHt + 65,
260,
1 - (4*Space + TitleSpace + PEBottom + SpinHt + 65),
1, 0, 0, 1, 0, 0, 0, 0,
\DialogLibrary.PColorSelect(#BgndColor, \GetPhrase("BackgroundLabel"), 1 { btn on left },
1 { standard size }, 1 { centered }, 12 { ID }));
{***** Disable Options *****}
System.Bevel(0,
10*Space + 2*TitleSpace + PEBottom + SpinHt + BtnHt + 3*CheckHt + 65,
#PanelWd,
6*Space + TitleSpace + PEBottom + SpinHt + BtnHt + 65,
\GetPhrase("DisableOptionsLabel"));
{***** Disable Trends Check Box *****}
GUITransform(0, 1, 1, 0,
1 - Space,
7*Space + 2*TitleSpace + PEBottom + SpinHt + BtnHt + CheckHt + 65,
#PanelWd - Space,
1 - (7*Space + 2*TitleSpace + PEBottom + SpinHt + BtnHt + 65),
1, 0, 0, 1, 0, 0, 0, 0,
\DialogLibrary.PCheckBox(#DisableTrend, \GetPhrase("DisableTrendLabel"),
1 { box on left },
3 { left, centered },
13 { ID }));
{***** Disable Navigation Check Box *****}
GUITransform(0, 1, 1, 0,
1 - Space,
8*Space + 2*TitleSpace + PEBottom + SpinHt + BtnHt + 2*CheckHt + 65,
#PanelWd - Space,
1 - (8*Space + 2*TitleSpace + PEBottom + SpinHt + BtnHt + CheckHt + 65),
1, 0, 0, 1, 0, 0, 0, 0,
\DialogLibrary.PCheckBox(#DisableNavigation, \GetPhrase("DisableNavigationLabel"),
1 { box on left },
3 { left, centered },
14 { ID }));
{***** Disable Tooltip Check Box *****}
GUITransform(0, 1, 1, 0,
1 - Space,
9*Space + 2*TitleSpace + PEBottom + SpinHt + BtnHt + 3*CheckHt + 65,
#PanelWd - Space,
1 - (9*Space + 2*TitleSpace + PEBottom + SpinHt + BtnHt + 2*CheckHt + 65),
1, 0, 0, 1, 0, 0, 0, 0,
\DialogLibrary.PCheckBox(#DisableTooltip, \GetPhrase("DisableTooltipLabel"),
1 { box on left },
3 { left, centered },
15 { ID }));
]
{ End of Draw\Panel }