Windows Virtual Shields for Arduino
Graphics.h
Go to the documentation of this file.
1 /*
2  Copyright(c) Microsoft Open Technologies, Inc. All rights reserved.
3 
4  The MIT License(MIT)
5 
6  Permission is hereby granted, free of charge, to any person obtaining a copy
7  of this software and associated documentation files(the "Software"), to deal
8  in the Software without restriction, including without limitation the rights
9  to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10  copies of the Software, and to permit persons to whom the Software is
11  furnished to do so, subject to the following conditions :
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  THE SOFTWARE.
23 */
24 
25 #ifndef Graphics_h
26 #define Graphics_h
27 
28 #include "Text.h"
29 #include "Sensor.h"
30 
31 const PROGMEM char HorizontalAlignment[] = "HorizontalAlignment";
32 const PROGMEM char Foreground[] = "Foreground";
33 
35 {
41 };
42 
43 class Graphics : public Text
44 {
45 public:
47 
48  int drawAt(UINT x, UINT y, String text, ARGB argb = 0);
49 
50  int drawImage(UINT x, UINT y, String url, String tag = (const char*)0, UINT width = 0, UINT height = 0);
51 
52  int addButton(UINT x, UINT y, String text, String tag = (const char*) 0);
53 
54  int fillRectangle(UINT x, UINT y, UINT width, UINT height,
55  ARGB argb, String tag = (const char*) 0);
56 
57  int line(UINT x1, UINT y1, UINT x2, UINT y2, ARGB color, UINT weight = 1);
58  int input(UINT x, UINT y, bool multiline = false, String text = (const char*) 0, UINT width = 0, UINT height = 0);
59 
60  int orientation(int autoRotationPreferences = -1);
61 
62  int enableTouch(bool enable);
63 
64  bool isButtonClicked(String tag, ShieldEvent* shieldEvent = 0);
65  bool isButtonClicked(int id, ShieldEvent* shieldEvent = 0);
66  bool isTouchEvent(ShieldEvent* shieldEvent = 0);
67  bool isPressed(int id, ShieldEvent* shieldEvent = 0);
68  bool isPressed(String tag, ShieldEvent* shieldEvent = 0);
69  bool isReleased(int id, ShieldEvent* shieldEvent = 0);
70  bool isReleased(String tag, ShieldEvent* shieldEvent = 0);
71 
72  void onJsonReceived(JsonObject& root, ShieldEvent* shieldEvent) override;
73 
74 private:
75  const char* area;
76 };
77 
78 #endif
Definition: Text.h:35
const PROGMEM char Foreground[]
Definition: Graphics.h:32
void onJsonReceived(JsonObject &root, ShieldEvent *shieldEvent) override
Event called when a valid json message was received. Consumes the proper values for this sensor...
Definition: Graphics.cpp:287
bool isReleased(int id, ShieldEvent *shieldEvent=0)
Determines whether the specified identifier is released.
Definition: Graphics.cpp:208
Definition: VirtualShield.h:50
Definition: Graphics.h:37
VirtualShield & shield
Definition: Sensor.h:55
int fillRectangle(UINT x, UINT y, UINT width, UINT height, ARGB argb, String tag=(const char *) 0)
Fills a rectangle.
Definition: Graphics.cpp:129
int addButton(UINT x, UINT y, String text, String tag=(const char *) 0)
Adds a button.
Definition: Graphics.cpp:153
const PROGMEM char HorizontalAlignment[]
Definition: Graphics.h:31
unsigned int UINT
Definition: SensorModels.h:28
Definition: Graphics.h:38
Graphics(const VirtualShield &shield)
Initializes a new instance of the Screen class.
Definition: Graphics.cpp:54
int drawAt(UINT x, UINT y, String text, ARGB argb=0)
Draws graphical text at a location.
Definition: Graphics.cpp:74
Definition: Graphics.h:43
int line(UINT x1, UINT y1, UINT x2, UINT y2, ARGB color, UINT weight=1)
Definition: Graphics.cpp:57
bool isPressed(int id, ShieldEvent *shieldEvent=0)
Determines whether the specified identifier is pressed.
Definition: Graphics.cpp:176
int orientation(int autoRotationPreferences=-1)
Definition: Graphics.cpp:139
bool isButtonClicked(String tag, ShieldEvent *shieldEvent=0)
Determines whether a tag was clicked or tapped.
Definition: Graphics.cpp:240
Definition: SensorModels.h:56
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.
Definition: Graphics.cpp:109
Definition: Graphics.h:39
int enableTouch(bool enable)
Enables the touch input on the screen.
Definition: Graphics.cpp:164
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.
Definition: Graphics.cpp:90
Definition: ShieldEvent.h:35
Definition: Orientation.h:34
bool isTouchEvent(ShieldEvent *shieldEvent=0)
Determines whether the specified shield event is a touch input event.
Definition: Graphics.cpp:271
Definition: Graphics.h:40
Definition: Graphics.h:36