Windows, Pages, and Graphics
Coordinates for graphics are always given in the form (Left, Bottom, Right, Top), where numbers are relative to the top left of the container holding the graphic. For example, a box with coordinates (0, 10, 10, 0) has one corner at the upper left of the containing window (0, 0) and the other corner ten pixels down and ten pixels to the right (10,10). While it is standard practice to specify a Right value that is greater than the Left, and a Bottom value that is greater than the Top (coordinates increase down from the top left), VTScada will not mirror the object if you swap the numbers. This is not to say that the order doesn't matter. Stay with the convention of (Left, Bottom, Right, Top) and you will reduce confusion.
The following tools are available to hold your user-interface elements.
Page
The standard container for user-interface elements in a VTScada application. Although created using the Idea Studio, you can exercise extensive control over the appearance and behavior of pages through code.
Widget
Also created using the Idea Studio using exactly the same tools as those used for a page. A widget is very similar to a page except that menu links can be created only to pages, not to widgets. Widgets are meant to be displayed within pages. Additionally, widgets can be linked to tags but pages cannot. Both widgets and pages may have parameters.
Window
A container for graphics. For example, pages are displayed within a window that is launched and maintained by the VTScada display manager. You can create your own windows, over which you exercise complete control.
4BtnDialog
A graphics statement that opens a window containing an OK/Cancel type of dialog. Use this rather than a page or window if your goal is to prompt the operator or request confirmation.
An example of a call to the window function can be found in the AppRoot.src file of every new script application.
Init [ If 1 Main; [ RunningOnVIC = IsVICSession(); ] ] Main [ Window( 0, 0 { Upper left corner }, 800, 600 { View area }, 800, 600 { Virtual area }, Graphics() { Start user graphics }, {65432109876543210} 0b00010000000110011, Concat(WinTitle, RunningOnVIC ? " - %S" : ""), 0, 1); ]
The Window() function specifies the size, location, and attributes of the window when it is created. The seventh parameter (Graphics() in this example) is a call to start another module. Any graphic statements that appear in the called module or in any of its child modules are drawn on the screen created by the Window function.
Icons
If the close icon is enabled on the window (via the Style parameter, 8th bit), care must be taken to ensure that when the user selects it, the action you desire occurs, as by default, clicking the close button stops your application; you may prefer to close the window but keep the application running. To help you specify the action you wish to occur when the close button is clicked, the WindowClose() function is provided.
For example, you may wish to define a "Cancel" button that will close the window, as well as having the close button enabled:
If ZButton(10, 220, 110, 200, "Cancel", 2) || WindowClose(Self()) Done; [ ... winOpen = 0 { Assuming winOpen was used as the 11th parameter of Window function }; ]
When either this cancel button or the close button is selected, the script above will execute, causing the variable that is in the Window function's Enable parameter to become "0", thereby closing the window. Notice that the WindowClose function (as used above), does not actually close the window; rather it checks to see if the user is trying to close the window with the window close button. It returns a true value when this is the case, and the resulting execution of the script closes the window. This example therefore, does not conflict with the caution in the following topic about overloading a PageClose button.
Note that having a WindowClose(Self) call is not always enough. The Window call should always set bit 19. Otherwise, if the user hits the X before the WindowClose has had a chance to run (for example, if the object running in the window has an Init state that is taking time to collect some data), then the window will close as if no WindowClose statement is running. This may cause other problems.