Windows Virtual Shields for Arduino
Public Member Functions | List of all members
Graphics Class Reference

#include <Graphics.h>

Inherits Text.

Public Member Functions

 Graphics (const VirtualShield &shield)
 Initializes a new instance of the Screen class. More...
 
int drawAt (UINT x, UINT y, String text, ARGB argb=0)
 Draws graphical text at a location. More...
 
int drawImage (UINT x, UINT y, String url, String tag=(const char *) 0, UINT width=0, UINT height=0)
 Draws the image at a location. More...
 
int addButton (UINT x, UINT y, String text, String tag=(const char *) 0)
 Adds a button. More...
 
int fillRectangle (UINT x, UINT y, UINT width, UINT height, ARGB argb, String tag=(const char *) 0)
 Fills a rectangle. More...
 
int line (UINT x1, UINT y1, UINT x2, UINT y2, ARGB color, UINT weight=1)
 
int input (UINT x, UINT y, bool multiline=false, String text=(const char *) 0, UINT width=0, UINT height=0)
 Draws the image at a location. More...
 
int orientation (int autoRotationPreferences=-1)
 
int enableTouch (bool enable)
 Enables the touch input on the screen. More...
 
bool isButtonClicked (String tag, ShieldEvent *shieldEvent=0)
 Determines whether a tag was clicked or tapped. More...
 
bool isButtonClicked (int id, ShieldEvent *shieldEvent=0)
 Determines whether a tag was clicked or tapped. More...
 
bool isTouchEvent (ShieldEvent *shieldEvent=0)
 Determines whether the specified shield event is a touch input event. More...
 
bool isPressed (int id, ShieldEvent *shieldEvent=0)
 Determines whether the specified identifier is pressed. More...
 
bool isPressed (String tag, ShieldEvent *shieldEvent=0)
 Determines whether the specified tag is pressed. More...
 
bool isReleased (int id, ShieldEvent *shieldEvent=0)
 Determines whether the specified identifier is released. More...
 
bool isReleased (String tag, ShieldEvent *shieldEvent=0)
 Determines whether the specified tag is released. More...
 
void onJsonReceived (JsonObject &root, ShieldEvent *shieldEvent) override
 Event called when a valid json message was received. Consumes the proper values for this sensor. More...
 
- Public Member Functions inherited from Text
 Text (const VirtualShield &shield)
 Initializes a new instance of the Screen class. More...
 
int clear (ARGB argb=0)
 Clears the screen of all elements. More...
 
int clearLine (UINT line)
 Clears the line. More...
 
int clearId (UINT id)
 Clears the element associated with the id. More...
 
int print (String text, ARGB argb=0)
 Prints the specified text. More...
 
int printAt (UINT line, String text, Attr extraAttributes[]=0, int extraAttributeCount=0)
 Prints the specified text at the specified line. More...
 
int printAt (UINT line, EPtr text, Attr extraAttributes[]=0, int extraAttributeCount=0)
 Prints the specified text at the specified line. More...
 
int printAt (UINT line, double value, ARGB argb=0)
 Prints the specified double at the specified line. More...
 
void onJsonReceived (JsonObject &root, ShieldEvent *shieldEvent) override
 Event called when a valid json message was received. Consumes the proper values for this sensor. More...
 
- Public Member Functions inherited from Sensor
 Sensor (const VirtualShield &shield, const char sensorType)
 Initializes a new instance of the Sensor class. More...
 
int start (double delta=0, long interval=0)
 Starts the sensor, triggered when longer than the interval and larger than the delta. More...
 
virtual int stop ()
 Stops this sensor. More...
 
int get ()
 Gets a single, current sensor reading. More...
 
int getOnChange (double delta=0)
 Requests a single reading when more than the delta beyond the current reading. More...
 
bool isUpdated ()
 Determines whether this sensor has an updated value. Resets to false after this call. More...
 
int writeAll (const char *serviceName, EPtr values[], int count, Attr extraAttributes[]=0, int extraAttributeCount=0)
 Writes all EPtr values to the communication channel. More...
 
int sensorAction (SensorAction sensorAction, double delta=0, long interval=0) const
 Sends the specific action to start/stop/get/onChange the sensor using a delta and interval. More...
 
virtual bool isEvent (const char *tag, const char *action, ShieldEvent *shieldEvent)
 Determines whether the specified shieldEvent matches the tag and action. More...
 
virtual bool isEvent (int id, const char *action, ShieldEvent *shieldEvent)
 Determines whether the specified shieldEvent matches the id and action. More...
 
void setOnEvent (void(*onEvent)(ShieldEvent *shieldEvent))
 
int sendStop (const char *serviceName)
 

Additional Inherited Members

- Public Attributes inherited from Sensor
void(* onEvent )(ShieldEvent *shieldEvent)
 
VirtualShieldshield
 
ShieldEvent recentEvent
 
const char sensorType
 
bool isRunning = false
 
- Protected Attributes inherited from Sensor
bool _isUpdated = false
 

Constructor & Destructor Documentation

Graphics::Graphics ( const VirtualShield shield)

Initializes a new instance of the Screen class.

Parameters
shieldThe shield.

Member Function Documentation

int Graphics::addButton ( UINT  x,
UINT  y,
String  text,
String  tag = (const char*) 0 
)

Adds a button.

Parameters
xThe x.
yThe y.
textThe text.
tagThe tag. Returned back for event recognition.
Returns
The id of the message. Negative if an error.
int Graphics::drawAt ( UINT  x,
UINT  y,
String  text,
ARGB  argb = 0 
)

Draws graphical text at a location.

Parameters
xThe x.
yThe y.
textThe text.
Returns
The id of the message. Negative if an error.
int Graphics::drawImage ( UINT  x,
UINT  y,
String  url,
String  tag = (const char*)0,
UINT  width = 0,
UINT  height = 0 
)

Draws the image at a location.

Parameters
xThe x.
yThe y.
urlThe url (local or remote) of the image to draw.
tagThe tag. Returned back for event recognition.
widthThe width.
heightThe height.
Returns
The id of the message. Negative if an error.
int Graphics::enableTouch ( bool  enable)

Enables the touch input on the screen.

Parameters
enabletrue to enable, false to disable.
Returns
The id of the message. Negative if an error.
int Graphics::fillRectangle ( UINT  x,
UINT  y,
UINT  width,
UINT  height,
ARGB  argb,
String  tag = (const char*) 0 
)

Fills a rectangle.

Parameters
xThe x.
yThe y.
widthThe width.
heightThe height.
rgbaThe rgba.
tagThe tag. Returned back for event recognition.
Returns
The id of the message. Negative if an error.
int Graphics::input ( UINT  x,
UINT  y,
bool  multiline = false,
String  text = (const char*) 0,
UINT  width = 0,
UINT  height = 0 
)

Draws the image at a location.

Parameters
xThe x.
yThe y.
urlThe url (local or remote) of the image to draw.
tagThe tag. Returned back for event recognition.
widthThe width.
heightThe height.
Returns
The id of the message. Negative if an error.
bool Graphics::isButtonClicked ( String  tag,
ShieldEvent shieldEvent = 0 
)

Determines whether a tag was clicked or tapped.

Parameters
tagThe tag.
shieldEventThe shield event.
Returns
true if clicked or tapped
bool Graphics::isButtonClicked ( int  id,
ShieldEvent shieldEvent = 0 
)

Determines whether a tag was clicked or tapped.

Parameters
tagThe tag.
shieldEventThe shield event.
Returns
true if clicked or tapped
bool Graphics::isPressed ( int  id,
ShieldEvent shieldEvent = 0 
)

Determines whether the specified identifier is pressed.

Parameters
idThe identifier.
shieldEventThe shield event.
Returns
true if pressed or tapped
bool Graphics::isPressed ( String  tag,
ShieldEvent shieldEvent = 0 
)

Determines whether the specified tag is pressed.

Parameters
tagThe tag.
shieldEventThe shield event.
Returns
true if pressed or tapped
bool Graphics::isReleased ( int  id,
ShieldEvent shieldEvent = 0 
)

Determines whether the specified identifier is released.

Parameters
idThe identifier.
shieldEventThe shield event.
Returns
true if released or tapped
bool Graphics::isReleased ( String  tag,
ShieldEvent shieldEvent = 0 
)

Determines whether the specified tag is released.

Parameters
tagThe tag.
shieldEventThe shield event.
Returns
true if released or tapped
bool Graphics::isTouchEvent ( ShieldEvent shieldEvent = 0)

Determines whether the specified shield event is a touch input event.

Parameters
shieldEventThe shield event.
Returns
true if this event is a touch input event
int Graphics::line ( UINT  x1,
UINT  y1,
UINT  x2,
UINT  y2,
ARGB  color,
UINT  weight = 1 
)
void Graphics::onJsonReceived ( JsonObject &  root,
ShieldEvent shieldEvent 
)
overridevirtual

Event called when a valid json message was received. Consumes the proper values for this sensor.

Parameters
rootThe root json object.
shieldEventThe shield event.

Reimplemented from Sensor.

int Graphics::orientation ( int  autoRotationPreferences = -1)

The documentation for this class was generated from the following files: