Sample Widget
In general, custom widgets should be created in the Idea Studio. The parameters for GUITransform statements, while documented, are not meant to be coded by hand. After creating, you may then open the source code to make modifications as required.
The following example shows the code for the Meter19 widget (Antique Bolted). It has been modified slightly so that you can copy this example to your workstation as a .SRC file, then import it into the Idea Studio.
Notes:
- \Root refers to the tag to which an instance of this widget is linked.
- In the statement that draws the Radial Legend , Scope(VTSDB, "0h!22-c639", TRUE) refers to one of the VTScada Font tags.
{================================== Meter19 ==================================} { Draws a meter that mimics an antique gauge } {=============================================================================} (0, 174, 174, 0) { bounding box } ( NumMajorDivisions Long { Number of Major Divisions in the Scale }; NumMinorDivisions Long { Number of Minor Divisions in the Scale }; UseTagScaling Status { Flag - True to use the Tag's Scaling Values }; MinScaleValue Double { The Value at Minimum }; MaxScaleValue Double { The Value at Maximum }; ShowUnits Status { Flag - True to show the units on the meter }; NeedleColor Text { Color of the Needle }; TextColor Text { Color of the text and scale }; BackgroundColor Text { Color of the text and scale }; DisableTrend Status { Flag to disable trend windows }; DisableNavigation Status { Flag to disable navigator (context) menu }; DisableTooltip Status { Flag to disable tool tips }; ) [ Constant DrawLabel = "Meter19Label"; { Replace "Meter19Label" with an application property of your own creation } Constant #HelpID = 21363 { HelpID 21363 }; { Create a user-defined help entry and use that value } Panel Module; Constant PanelWd = 400 { Default panel width }; Constant PanelHt = 500 { Default panel height }; Constant #UseTagScaling = 2; Constant #MinScaleValue = 3; Constant #MaxScaleValue = 4; Constant #DisableTrend = 9; Constant #DisableNavigation = 10; Constant #DisableTooltip = 11; { Initial set of tags, to which this meter can be linked } Shared AnalogInput (POINTS); Shared AnalogStatus (POINTS); ] Main [ If Watch(1); [ DisableTrend = PickValid(DisableTrend, 0); DisableNavigation = PickValid(DisableNavigation, 0); DisableTooltip = PickValid(DisableTooltip, 0); ] \Common(GetModuleRefBox(Self, 0), GetModuleRefBox(Self, 1), GetModuleRefBox(Self, 2), GetModuleRefBox(Self, 3), DisableTrend, DisableNavigation, DisableTooltip); GUITransform(0, 174, 174, 0, 1, 1, 1, 1, 1 { Scaling }, 0, 0 { Movement }, 1, 0 { Visibility, Reserved }, 0, 0, 0 { Selectability }, Scope(Code, "Library", TRUE)\Bitmap(\ImageParmSet("Bitmaps\Meter Parts\Backgrounds\Case2_Background.png", BackgroundColor, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0), -1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, "<FFFFFFFF>", 0, 1)); GUITransform(9, 181, 165, 25, 1, 1, 1, 1, 1 { Scaling }, 0, 0 { Movement }, 1, 0 { Visibility, Reserved }, 0, 0, 0 { Selectability }, Scope(Code, "MeterParts", TRUE)\RadialLegend(\Root, 300, 60, PickValid(NumMajorDivisions + 1, 0), Scope(VTSDB, "0h!22-c639", TRUE), TextColor, 0, 1, UseTagScaling, MinScaleValue, MaxScaleValue, 1)); GUITransform(19, 168, 156, 38, 1, 1, 1, 1, 1 { Scaling }, 0, 0 { Movement }, 1, 0 { Visibility, Reserved }, 0, 0, 0 { Selectability }, Scope(Code, "MeterParts", TRUE)\SimpleRadialScale(NumMajorDivisions, NumMinorDivisions, 0.07, 0.03, PickValid(Abs(GetXFormRefBox(Self, 1) - GetXFormRefBox(Self, 3)) * 0.008, 0), PickValid(Abs(GetXFormRefBox(Self, 1) - GetXFormRefBox(Self, 3)) * 0.008, 0), 300, 60, 2, 8, TextColor, TextColor)); GUIText(0, 83, 174, 63, 1, 1, 1, 1, 1 { Scaling }, 0, 0 { Movement }, PickValid(True(ShowUnits), 0), TRUE { Visibility, Font Scaling }, 0, 0, 0 { Selectability }, Brush("<00000000>", 0, 1), Pen(PickValid(TextColor, 0), 1, 1), Scope(VTSDB, "LabelFont", TRUE)\Value, 3, 4, "%s", \Root.Units); GUITransform(17, 169, 157, 37, 1, 1, 1, 1, 1 { Scaling }, 0, 0 { Movement }, 1, 0 { Visibility, Reserved }, 0, 0, 0 { Selectability }, Scope(Code, "MeterParts", TRUE)\RadialIndicator(\Root, \ImageParmSet("Bitmaps\Meter Parts\Indicators\Radial\Needle13_White.png", NeedleColor, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0), -13, 0, 300, 60, 0, 1, 1, 1, 1, 0, 0, UseTagScaling, MinScaleValue, MaxScaleValue, 1, "<FFFFFFFF>")); GUITransform(0, 174, 174, 0, 1, 1, 1, 1, 1 { Scaling }, 0, 0 { Movement }, 0.68, 0 { Visibility, Reserved }, 0, 0, 0 { Selectability }, Scope(Code, "Library", TRUE)\Bitmap(\ImageParmSet("Bitmaps\Meter Parts\Glass\Glass22.png", "<FFFFFFFF>", 0, 1, 0, 0.75, 1, 1, 0, 1, 0, 0), -1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, "<FFFFFFFF>", 0, 1)); GUITransform(0, 174, 174, 0, 1, 1, 1, 1, 1 { Scaling }, 0, 0 { Movement }, 1, 0 { Visibility, Reserved }, 0, 0, 0 { Selectability }, Scope(Code, "Library", TRUE)\Bitmap(\ImageParmSet("Bitmaps\Meter Parts\Bezels\Case2.png", \ParameterSet(), \ParameterSet(), \ParameterSet(), \ParameterSet(), \ParameterSet(), \ParameterSet(), \ParameterSet(), \ParameterSet(), \ParameterSet(), \ParameterSet(), \ParameterSet()))); GUITransform(72, 102, 102, 72, 1, 1, 1, 1, 1 { Scaling }, 0, 0 { Movement }, 1, 0 { Visibility, Reserved }, 0, 0, 0 { Selectability }, Variable("Code\Library")\TagIconMarker(\Root)); ] < {=============================== Meter19\Panel ===============================} {=============================================================================} Panel (0, PanelHt, PanelWd, 0) ( Parms { Array of Parameters }; PtrWaitClose { Pointer to Flag - True to wait to close dlg }; ParmDefs { Array of page parameter definition structs }; DialogRoot { The calling dialog window }; ) [ PageInst { Page instance }; ContPageInfo { Container page information }; Height { Current height of the panel }; PEObj { Array of ParameterEdit object values }; PEBot { Array of ParameterEdit Bottom coordinates }; SubWaitClose { Wait-to-close variables for ParameterEdits }; TitleWd { Width of ParameterEdit titles }; ColorModules { Used for the "Color" ParameterEdits }; ColorParms { Used for the "Color" ParameterEdits }; ColorValue { Used to retain the Revision on the parameters }; OldColorValue { Used to retain the Revision on the parameters }; ] Init [ If 1 Main; [ { Get info about the parms of the container page } PageInst = \GetUserSession()\GraphicEditor\GetSelectedTabItem(); ContPageInfo = \GetParamInfo(PageInst); PEObj = New(7); PEBot = New(7); SubWaitClose = New(7); ColorModules = New(5); ColorParms = New(5); ColorModules[0] = "ParmEditColor"; ColorParms[0] = New(1); ColorParms[0][0] = TRUE; ColorModules[1] = "ParmEditTagValue"; ColorParms[1] = New(2); ColorParms[1][0] = "Numeric"; ColorParms[1][1] = 0; { No Scaling } ColorModules[2] = "ParmEditParmValue"; ColorParms[2] = New(5); ColorParms[2][0] = ContPageInfo; ColorParms[2][1] = \#VTypeShort; ColorParms[2][2] = \#VTypeText; ColorParms[2][3] = Invalid; ColorParms[2][4] = 0; ColorModules[3] = "ParmEditTagProperty"; ColorParms[3] = New(5); ColorParms[3][0] = ContPageInfo; ColorParms[3][1] = \#VTypeShort; ColorParms[3][2] = \#VTypeText; ColorParms[3][3] = Invalid; ColorParms[3][4] = 0; ColorModules[4] = "ParmEditExprNoNormalize"; ColorParms[4] = New(2); ColorParms[4][0] = 1 + 2; ColorParms[4][1] = ContPageInfo; ColorValue = New(3); OldColorValue = New(3); ColorValue[0] = OldColorValue[0] = Parms\NeedleColor; ColorValue[1] = OldColorValue[1] = Parms\TextColor; ColorValue[2] = OldColorValue[2] = Parms\BackgroundColor; MetaData(ColorValue[0], "Revision") = 0; MetaData(ColorValue[2], "Revision") = 0; MetaData(ColorValue[3], "Revision") = 0; ] ] Main [ { Let the caller know when its not ok to close. Or is used so we can maintain the 2nd bit of the WaitClose flag that is set when an expression has some compiler errors in it. It is used for an error dialog. } *PtrWaitClose = Or(PickValid(SubWaitClose[0], 0), PickValid(SubWaitClose[1], 0), PickValid(SubWaitClose[2], 0), PickValid(SubWaitClose[3], 0), PickValid(SubWaitClose[4], 0), PickValid(SubWaitClose[5], 0), PickValid(SubWaitClose[6], 0)); Height = PEBot[6] + 5*\Space + \TitleSpace + 3*\CheckHt; If Watch(1, Height); [ \SetPanelRefBox(Self, 0, Height, PanelWd, 0); ] TitleWd = Max(TextAttribs(GetPhrase("NumMajorDivisionsLabel"), \_DialogFont, 0), TextAttribs(GetPhrase("NumMinorDivisionsLabel"), \_DialogFont, 0), TextAttribs(GetPhrase("UseTagScalingLabel"), \_DialogFont, 0), TextAttribs(GetPhrase("ShowUnitsLabel"), \_DialogFont, 0), TextAttribs(GetPhrase("NeedleLabel"), \_DialogFont, 0), TextAttribs(GetPhrase("TextLabel"), \_DialogFont, 0), TextAttribs(GetPhrase("BackgroundLabel"), \_DialogFont, 0), TextAttribs(GetPhrase("MinimumValueLabel"), \_DialogFont, 0), TextAttribs(GetPhrase("MaximumValueLabel"), \_DialogFont, 0)); System.Bevel(0, PEBot[2] + \Space, PanelWd, 0, \GetPhrase("OptionsLabel)"); { Number of Major divisions } PEObj[0] = \NumericParameterEdit(\Space, \Space + \TitleSpace + 2*\EditHt, PanelWd - \Space, \Space + \TitleSpace, Parms\NumMajorDivisions, ParmDefs\NumMajorDivisions, FALSE, \GetPhrase("NumMajorDivisionsLabel"), &(SubWaitClose[0]), DialogRoot, 1, 100, Invalid, TitleWd, TRUE, 1 {FID}, \#VTypeLong, TRUE); PEBot[0] = \Space + \TitleSpace + PickValid(PEObj[0]\Height, 2*\EditHt); { Number of Minor divisions } PEObj[1] = \NumericParameterEdit(\Space, PEBot[0] + \Space + 2*\EditHt, PanelWd - \Space, PEBot[0] + \Space, Parms\NumMinorDivisions, ParmDefs\NumMinorDivisions, FALSE, \\GetPhrase("NumMinorDivisionsLabel"), &(SubWaitClose[1]), DialogRoot, 1, 100, Invalid, TitleWd, TRUE, 2 {FID}, \#VTypeLong, TRUE); PEBot[1] = PEBot[0] + \Space + PickValid(PEObj[1]\Height, 2*\EditHt); { Show Units } PEObj[2] = \NumericParameterEdit(\Space, PEBot[1] + \Space + 2*\EditHt, PanelWd - \Space, PEBot[1] + \Space, Parms\ShowUnits, ParmDefs\ShowUnits, FALSE, \\GetPhrase("ShowUnitsLabel"), &(SubWaitClose[2]), DialogRoot, 0, 1, Invalid, TitleWd, TRUE, 3 {FID}, \#VTypeStatus); PEBot[2] = PEBot[1] + \Space + PickValid(PEObj[2]\Height, 2*\EditHt); System.Bevel(0, PEBot[5] + \Space, PanelWd, PEBot[2] + 2*\Space, \ColorizationLabel); { Needle color } GUITransform(0, 1, 1, 0, 1 - \Space, PEBot[2] + 3*\Space + \TitleSpace + 2*\EditHt, PanelWd - \Space, 1 - (PEBot[2] + 3*\Space + \TitleSpace), 1, 0, 0, 1, 0, 0, 0, 0, PEObj[3] = \ParameterEdit(ColorValue[0], ParmDefs\NeedleColor, TRUE, \\GetPhrase("NeedleLabel"), ColorModules, Code, ColorParms, TitleWd, Invalid, &(SubWaitClose[3]), DialogRoot, 4 {FID})); If ColorValue[0] != OldColorValue[0] || Valid(ColorValue[0]) != Valid(OldColorValue[0]); [ OldColorValue[0] = Parms\NeedleColor = RootValue(ColorValue[0]); ] PEBot[3] = PEBot[2] + 3*\Space + \TitleSpace + PickValid(PEObj[3]\Height, 2*\EditHt); { Text Color } GUITransform(0, 1, 1, 0, 1 - \Space, PEBot[3] + \Space + 2*\EditHt, PanelWd - \Space, 1 - (PEBot[3] + \Space), 1, 0, 0, 1, 0, 0, 0, 0, PEObj[4] = \ParameterEdit(ColorValue[1], ParmDefs\TextColor, TRUE, \\GetPhrase("TextLabel"), ColorModules, Code, ColorParms, TitleWd, Invalid, &(SubWaitClose[4]), DialogRoot, 5 {FID})); If ColorValue[1] != OldColorValue[1] || Valid(ColorValue[1]) != Valid(OldColorValue[1]); [ OldColorValue[1] = Parms\TextColor = RootValue(ColorValue[1]); ] PEBot[4] = PEBot[3] + \Space + PickValid(PEObj[4]\Height, 2*\EditHt); { Background color } GUITransform(0, 1, 1, 0, 1 - \Space, PEBot[4] + \Space + 2*\EditHt, PanelWd - \Space, 1 - (PEBot[4] + \Space), 1, 0, 0, 1, 0, 0, 0, 0, PEObj[5] = \ParameterEdit(ColorValue[2], ParmDefs\BackgroundColor, TRUE, \\GetPhrase("BackgroundLabel"), ColorModules, Code, ColorParms, TitleWd, Invalid, &(SubWaitClose[5]), DialogRoot, 6 {FID})); If ColorValue[2] != OldColorValue[2] || Valid(ColorValue[2]) != Valid(OldColorValue[2]); [ OldColorValue[2] = Parms\BackgroundColor = RootValue(ColorValue[2]); ] PEBot[5] = PEBot[4] + \Space + PickValid(PEObj[5]\Height, 2*\EditHt); { Scaling limits } GUITransform(0, 1, 1, 0, 1 - 0, PEBot[5] + 2*\Space + \TScalingFldsHt, PanelWd, 1 - (PEBot[5] + 2*\Space), 1 { No scaling }, 0, 0, 1, 0 { No movement; visible; reserved }, 0, 0, 0 { Not selectable }, PEObj[6] = \TagScalingFields(Parms, #UseTagScaling, #MinScaleValue, #MaxScaleValue, \Root, &(SubWaitClose[6]), 7 { ID + 2 end }, ParmDefs, DialogRoot, TitleWd)); PEBot[6] = PEBot[5] + 2*\Space + PickValid(PEObj[6]\Height, 2*\EditHt); { Disable Options } System.Bevel(0, PEBot[6] + 5*\Space + \TitleSpace + 3*\CheckHt, PanelWd, PEBot[6] + \Space, \\GetPhrase("DisableOptionsLabel")); { Disable Trends Check Box } GUITransform(0, 1, 1, 0, 1 - (\Space + \BvlWd), PEBot[6] + 2*\Space + \TitleSpace + \CheckHt, PanelWd, 1 - (PEBot[6] + 2*\Space + \TitleSpace), 1, 0, 0, 1, 0 { No movement; visible; reserved }, 0, 0, 0 { Not selectable }, \DialogLibrary.PCheckBox(#DisableTrend, \\GetPhrase("DisableTrendLabel"), 1 { box on left }, 3 { left, centered }, 11 { ID })); { Disable Navigation Check Box } GUITransform(0, 1, 1, 0, 1 - (\Space + \BvlWd), PEBot[6] + 3*\Space + \TitleSpace + 2*\CheckHt, PanelWd, 1 - (PEBot[6] + 3*\Space + \TitleSpace + \CheckHt), 1, 0, 0, 1, 0 { No movement; visible; reserved }, 0, 0, 0 { Not selectable }, \DialogLibrary.PCheckBox(#DisableNavigation, \\GetPhrase("DisableNavigationLabel"), 1 { box on left }, 3 { left, centered }, 12 { ID })); { Disable Tooltip Check Box } GUITransform(0, 1, 1, 0, 1 - (\Space + \BvlWd), PEBot[6] + 4*\Space + \TitleSpace + 3*\CheckHt, PanelWd, 1 - (PEBot[6] + 4*\Space + \TitleSpace + 2*\CheckHt), 1, 0, 0, 1, 0 { No movement; visible; reserved }, 0, 0, 0 { Not selectable }, \DialogLibrary.PCheckBox(#DisableTooltip, \\GetPhrase("DisableTooltipLabel"), 1 { box on left }, 3 { left, centered }, 13 { ID })); ] { End of Meter19\Panel } > { End of Meter19 }