View on GitHub

UI-with-Classes

Collection of 4D classes dedicated to user interface management, designed to structure the UI and make code more readable, maintainable, and reusable.

coordinates

The coordinates class provides an interface for manipulating the coordinates of a widget or window, for example.

This class is available from the cs class store, or cs.ui class store if you use the UI component.


📌 Important

To simplify the distinction between form objects and object type, this documentation uses the term widget for all form objects, whether static (a line, a rectangle…) or not (a button, a subform…).


cs.coordinates.new()

cs.coordinates.new( widget : Object ) : cs.coordinates
cs.coordinates.new ( name : Text ) : cs.coordinates
cs.coordinates.new ( left : Integer; top : Integer; right : Integer; bottom : Integer ) : cs.coordinates
cs.coordinates.new ( ) : cs.coordinates

Parameter Type   Description
widget Object A widget class object like cs.static, cs.input, cs.button
name Text A name of a widget
left
top
right
bottom
Integer Coordinates in pixels, in the form coordinate system*.
result cs.coordinates New cs.coordinates

* Origin is top left corner of current form

Description

cs.coordinates.new() creates & returns a new instance of the class.

Summary

Properties

Properties Description Type Writable
.left
.top
.right
.bottom
Coordinates, in pixels, in the form coordinate system Integer
.height
.width
Height & width, in pixels, calculated from the current coordinates Integer x
.rect Dimension object from the current coordinates cs.rect x
.dimensions Dimension object from the current coordinates cs.dimensions x
.name Name of the widget registered when using the constructor Text x
.screenCoordinates Converted current coordinates into the screen coordinate system (origin is top left corner of main screen) {left,top,right,bottom} x
.windowCoordinates Converted current coordinates into the window coordinate system (origin is top left corner of current window) {left,top,right,bottom} x

Functions

Functions Action
.apply ({name}) Sets the coordinates of a widget

.apply()

.apply ({name})

Parameter Type   Description
name Text form object name

Description

Sets the coordinates of a widget.

If the name parameter is omitted, the method uses the name registered by the constructor.
If no name is available, an assert is triggered.

Example

var $coordinates:=cs.coordinates.new("Input")
$coordinates.left+=10
$coordinates.top+=10
$coordinates.apply()