Interfaces are the GUI Windows upon which controls are placed for user or MakerPlot-J use. They are called Interfaces as they are used to create the Human-Machine Interface (HMI) through which data can be monitored, devices controlled, user operations performed, serial data sent or received, logging performed or many other operations.
There are two categories of Interfaces:
Main Interface
The Main Interface is the main Window of MPJ and often referred to as simply Main. As with controls, the Main Interface has properties, instructions and Event Code that can be processed. Many of MPJ's operations are performed by the it. Unlike Controls or Child Interfaces, the name of the interface object is NOT used when addressing it.
For example, to change the background color for the Main Interface: !backColor=RED
With controls and Child Interfaces, the name those objects must be stated when accessing it: !intGraphs.backColor=RED !txtPower = BLUE
Main Interface Items
For a list of available properties, values, controls, instructions, and variables accessible through the Main Interface, use the Debug/CLI (F4) or the Code Editor (Use F3 after clicking the Main Interface to open the Interface Editor and double-click the Event Code Text Box) and type !, or in the case of constant drawings, @.
The Debug/CLI or Code Editor will be populated with available options.
Using MPJ code, properties may be read or changed, instructions ran, controls and variables accessed.
Through Main, many of the software instructions and values can be accessed, such as writing to files, fileWrite, or accessing the system Time, [systemTime].
!snapScreen test.png
!fileOpen snapshots/test.png ? [systemTime]
Main Interface Events
When using the Code Editor, typing < will list the available Events that can be accessed to perform operations, such as if the Main's background is clicked.
Note that on click, a release is also generated causing that event code to run also.
Please see Event Code and Triggered Event Code for more information on writing Event Code.
Drawing on the Main Interface
Drawing may be performed on the Main Interface through the use of the Drawing Instructions.
The Main Interface has a coordinate system of 0,0 in upper-left to 100,100 in lower-right for drawing lines, arcs, images, etc.
!drawLine 0,0,100,100,RED
Constant Drawings (@) will be saved as part of the Interface File and redrawn when opened.
Please see Drawing Instructions for more information.
Placing Controls on Main
The easiest means to place controls on the Main Interface is graphically:
•Enter Edit Mode (F9)
•Open the Control's Palette (F2)
•Click a Control of choice
•Click or draw on Main to place a control
•Answer any questions asked concerning the control's creation, such as control name or initial value. As with most GUI environments, good practice dictates to use a prefix with the name identifying its type: txtPower, txt for a textbox for example. MPJ will suggest the standard prefix when creating.
Controls may be placed through instructions as well from code entered in the Debug/CLI Window, from an Interface File, from a Macro File (.txt typically) or Event Code, or from serial data from a connected microcontroller. As with drawing, the coordinate system is 0,0 in upper-left to 100,100 in lower-right.
Controls on the Interface will resize with the interface unless the property resizeControls is disabled.
!makeTextBox name, left, top, width, height, text
!makeTextBox txtData, 80, 20, 10, 5, Data
Please see Controls for more information on using controls.
Child Interfaces
Child Interfaces are interfaces created through the Main Interface. They can be created using menu options:
•Enter Edit Mode (F9)
•CTRL-I or use the Interfaces Menu
•Provide a name for the Interface, typically starting with int, intTest
•Provide a Title for the Interface Window
The can also be created through code:
!makeInt name, title, screen left position, screen top position, screen width, screen height
!makeInterface intPower, Power, 500,200,400,200
The first 9 Child Interfaces created can be accessed from the Main Interface using CTRL-1 to CTRL-9. From a Child Interface, the Main Interface can be accessed using CTRL-0. All Child Interfaces can be accessed through Main --> Interfaces menu.
A Child Interface created CANNOT be deleted directly in MPJ. By editing an Interface File as a text file, the creation code be deleted.
Drawing on Child Interfaces
Drawing on a Child Interface is done in the same manner, using the same coordinate system as for Main, but the drawing instructions will be prefixed by the name of the interface:
!intPower.drawLine 0,0,100,100,RED
Constant Drawings (@) will be saved as part of the Interface File and redrawn when opened.
Please see Drawing Instructions for more information.
Placing Controls On Child Interfaces
Placing controls is performed in the same manner as Main, but in code the instruction must be prefixed with the name of the control:
!intPower.makeTextBox txtPower, 80, 20, 10, 5, Data
NOTE: All controls created are global to Main. When accessing controls, do NOT prefix with the Child's name:
!txtPower.backColor=WHITE
A control name must be unique to the application. If desired for clarity and uniqueness, include the interface name in the control's name, such as:
!intPower.makeTextBox intPowertxtData, 80, 20, 10, 5, Data
Controls on the Interface will resize with the interface unless the property resizeControls is disabled.
Please see Controls for more information on using controls.
|