Arduino style GUI

Committer:
jonebuckman
Date:
Wed Feb 27 22:34:06 2019 +0000
Revision:
4:d353b314d244
Parent:
0:90962b684403
Updated writeCommand and writeData.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jonebuckman 0:90962b684403 1 /* NeatGUI Library
jonebuckman 0:90962b684403 2 * Copyright (c) 2013 Neil Thiessen
jonebuckman 0:90962b684403 3 *
jonebuckman 0:90962b684403 4 * Licensed under the Apache License, Version 2.0 (the "License");
jonebuckman 0:90962b684403 5 * you may not use this file except in compliance with the License.
jonebuckman 0:90962b684403 6 * You may obtain a copy of the License at
jonebuckman 0:90962b684403 7 *
jonebuckman 0:90962b684403 8 * http://www.apache.org/licenses/LICENSE-2.0
jonebuckman 0:90962b684403 9 *
jonebuckman 0:90962b684403 10 * Unless required by applicable law or agreed to in writing, software
jonebuckman 0:90962b684403 11 * distributed under the License is distributed on an "AS IS" BASIS,
jonebuckman 0:90962b684403 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jonebuckman 0:90962b684403 13 * See the License for the specific language governing permissions and
jonebuckman 0:90962b684403 14 * limitations under the License.
jonebuckman 0:90962b684403 15 */
jonebuckman 0:90962b684403 16
jonebuckman 0:90962b684403 17 #ifndef CONTROL_H
jonebuckman 0:90962b684403 18 #define CONTROL_H
jonebuckman 0:90962b684403 19
jonebuckman 0:90962b684403 20 #include "mbed.h"
jonebuckman 0:90962b684403 21 #include "Canvas.h"
jonebuckman 0:90962b684403 22
jonebuckman 0:90962b684403 23 /** Control abstract class.
jonebuckman 0:90962b684403 24 * Used as a base class for UI elements.
jonebuckman 0:90962b684403 25 */
jonebuckman 0:90962b684403 26 class Control
jonebuckman 0:90962b684403 27 {
jonebuckman 0:90962b684403 28 public:
jonebuckman 0:90962b684403 29 /** Create a Control object with the specified size and location
jonebuckman 0:90962b684403 30 *
jonebuckman 0:90962b684403 31 * @param x The X coordinate of the control.
jonebuckman 0:90962b684403 32 * @param y The Y coordinate of the control.
jonebuckman 0:90962b684403 33 * @param w The width of the control.
jonebuckman 0:90962b684403 34 * @param h The height of the control.
jonebuckman 0:90962b684403 35 */
jonebuckman 0:90962b684403 36 Control(int x, int y, int w, int h);
jonebuckman 0:90962b684403 37
jonebuckman 0:90962b684403 38 /** Paint the control on the specified canvas and mark as valid again
jonebuckman 0:90962b684403 39 *
jonebuckman 0:90962b684403 40 * @param canvas Pointer to the canvas to paint on.
jonebuckman 0:90962b684403 41 */
jonebuckman 0:90962b684403 42 virtual void paint(Canvas *canvas);
jonebuckman 0:90962b684403 43
jonebuckman 0:90962b684403 44 /** Get the X coordinate of the control
jonebuckman 0:90962b684403 45 *
jonebuckman 0:90962b684403 46 * @returns The X coordinate of the control.
jonebuckman 0:90962b684403 47 */
jonebuckman 0:90962b684403 48 int posX();
jonebuckman 0:90962b684403 49
jonebuckman 0:90962b684403 50 /** Set the X coordinate of the control
jonebuckman 0:90962b684403 51 *
jonebuckman 0:90962b684403 52 * @param x The new X coordinate for the control.
jonebuckman 0:90962b684403 53 */
jonebuckman 0:90962b684403 54 void posX(int x);
jonebuckman 0:90962b684403 55
jonebuckman 0:90962b684403 56 /** Get the Y coordinate of the control
jonebuckman 0:90962b684403 57 *
jonebuckman 0:90962b684403 58 * @returns The Y coordinate of the control.
jonebuckman 0:90962b684403 59 */
jonebuckman 0:90962b684403 60 int posY();
jonebuckman 0:90962b684403 61
jonebuckman 0:90962b684403 62 /** Set the Y coordinate of the control
jonebuckman 0:90962b684403 63 *
jonebuckman 0:90962b684403 64 * @param y The new Y coordinate for the control.
jonebuckman 0:90962b684403 65 */
jonebuckman 0:90962b684403 66 void posY(int y);
jonebuckman 0:90962b684403 67
jonebuckman 0:90962b684403 68 /** Get the width of the control
jonebuckman 0:90962b684403 69 *
jonebuckman 0:90962b684403 70 * @returns The width of the control.
jonebuckman 0:90962b684403 71 */
jonebuckman 0:90962b684403 72 int width();
jonebuckman 0:90962b684403 73
jonebuckman 0:90962b684403 74 /** Set the width of the control
jonebuckman 0:90962b684403 75 *
jonebuckman 0:90962b684403 76 * @param w The new width for the control.
jonebuckman 0:90962b684403 77 */
jonebuckman 0:90962b684403 78 void width(int w);
jonebuckman 0:90962b684403 79
jonebuckman 0:90962b684403 80 /** Get the height of the control
jonebuckman 0:90962b684403 81 *
jonebuckman 0:90962b684403 82 * @returns The height of the control.
jonebuckman 0:90962b684403 83 */
jonebuckman 0:90962b684403 84 int height();
jonebuckman 0:90962b684403 85
jonebuckman 0:90962b684403 86 /** Set the height of the control
jonebuckman 0:90962b684403 87 *
jonebuckman 0:90962b684403 88 * @param h The new height for the control.
jonebuckman 0:90962b684403 89 */
jonebuckman 0:90962b684403 90 void height(int h);
jonebuckman 0:90962b684403 91
jonebuckman 0:90962b684403 92 /** Get the current margin width
jonebuckman 0:90962b684403 93 *
jonebuckman 0:90962b684403 94 * @returns The current margin width.
jonebuckman 0:90962b684403 95 */
jonebuckman 0:90962b684403 96 int margin();
jonebuckman 0:90962b684403 97
jonebuckman 0:90962b684403 98 /** Set the margin width
jonebuckman 0:90962b684403 99 *
jonebuckman 0:90962b684403 100 * @param m The new margin width.
jonebuckman 0:90962b684403 101 */
jonebuckman 0:90962b684403 102 void margin(int m);
jonebuckman 0:90962b684403 103
jonebuckman 0:90962b684403 104 /** Get the current border width
jonebuckman 0:90962b684403 105 *
jonebuckman 0:90962b684403 106 * @returns The current border width.
jonebuckman 0:90962b684403 107 */
jonebuckman 0:90962b684403 108 int border();
jonebuckman 0:90962b684403 109
jonebuckman 0:90962b684403 110 /** Set the border width
jonebuckman 0:90962b684403 111 *
jonebuckman 0:90962b684403 112 * @param b The new border width.
jonebuckman 0:90962b684403 113 */
jonebuckman 0:90962b684403 114 void border(int b);
jonebuckman 0:90962b684403 115
jonebuckman 0:90962b684403 116 /** Get the current padding width
jonebuckman 0:90962b684403 117 *
jonebuckman 0:90962b684403 118 * @returns The current padding width.
jonebuckman 0:90962b684403 119 */
jonebuckman 0:90962b684403 120 int padding();
jonebuckman 0:90962b684403 121
jonebuckman 0:90962b684403 122 /** Set the padding width
jonebuckman 0:90962b684403 123 *
jonebuckman 0:90962b684403 124 * @param p The new padding width.
jonebuckman 0:90962b684403 125 */
jonebuckman 0:90962b684403 126 void padding(int p);
jonebuckman 0:90962b684403 127
jonebuckman 0:90962b684403 128 /** Get the X coordinate of the control's content area
jonebuckman 0:90962b684403 129 *
jonebuckman 0:90962b684403 130 * @returns The X coordinate of the control's content area.
jonebuckman 0:90962b684403 131 */
jonebuckman 0:90962b684403 132 int contentPosX();
jonebuckman 0:90962b684403 133
jonebuckman 0:90962b684403 134 /** Get the Y coordinate of the control's content area
jonebuckman 0:90962b684403 135 *
jonebuckman 0:90962b684403 136 * @returns The Y coordinate of the control's content area.
jonebuckman 0:90962b684403 137 */
jonebuckman 0:90962b684403 138 int contentPosY();
jonebuckman 0:90962b684403 139
jonebuckman 0:90962b684403 140 /** Get the width of the control's content area
jonebuckman 0:90962b684403 141 *
jonebuckman 0:90962b684403 142 * @returns The width of the control's content area.
jonebuckman 0:90962b684403 143 */
jonebuckman 0:90962b684403 144 int contentWidth();
jonebuckman 0:90962b684403 145
jonebuckman 0:90962b684403 146 /** Get the height of the control's content area
jonebuckman 0:90962b684403 147 *
jonebuckman 0:90962b684403 148 * @returns The height of the control's content area.
jonebuckman 0:90962b684403 149 */
jonebuckman 0:90962b684403 150 int contentHeight();
jonebuckman 0:90962b684403 151
jonebuckman 0:90962b684403 152 /** Get the foreground color
jonebuckman 0:90962b684403 153 *
jonebuckman 0:90962b684403 154 * @returns The foreground color as a 32-bit ARGB value.
jonebuckman 0:90962b684403 155 */
jonebuckman 0:90962b684403 156 unsigned int foreColor();
jonebuckman 0:90962b684403 157
jonebuckman 0:90962b684403 158 /** Set the foreground color
jonebuckman 0:90962b684403 159 *
jonebuckman 0:90962b684403 160 * @param c The new foreground color as a 32-bit ARGB value.
jonebuckman 0:90962b684403 161 */
jonebuckman 0:90962b684403 162 void foreColor(unsigned int c);
jonebuckman 0:90962b684403 163
jonebuckman 0:90962b684403 164 /** Get the background color
jonebuckman 0:90962b684403 165 *
jonebuckman 0:90962b684403 166 * @returns The background color as a 32-bit ARGB value.
jonebuckman 0:90962b684403 167 */
jonebuckman 0:90962b684403 168 unsigned int backColor();
jonebuckman 0:90962b684403 169
jonebuckman 0:90962b684403 170 /** Set the background color
jonebuckman 0:90962b684403 171 *
jonebuckman 0:90962b684403 172 * @param c The new background color as a 32-bit ARGB value.
jonebuckman 0:90962b684403 173 */
jonebuckman 0:90962b684403 174 void backColor(unsigned int c);
jonebuckman 0:90962b684403 175
jonebuckman 0:90962b684403 176 /** Get the current text of the control
jonebuckman 0:90962b684403 177 *
jonebuckman 0:90962b684403 178 * @returns The current text of the control.
jonebuckman 0:90962b684403 179 */
jonebuckman 0:90962b684403 180 const char* text();
jonebuckman 0:90962b684403 181
jonebuckman 0:90962b684403 182 /** Set the text of the control
jonebuckman 0:90962b684403 183 *
jonebuckman 0:90962b684403 184 * @param text The new text.
jonebuckman 0:90962b684403 185 */
jonebuckman 0:90962b684403 186 void text(const char* text);
jonebuckman 0:90962b684403 187
jonebuckman 0:90962b684403 188 /** Get the current font of the control
jonebuckman 0:90962b684403 189 *
jonebuckman 0:90962b684403 190 * @returns The current font of the control.
jonebuckman 0:90962b684403 191 */
jonebuckman 0:90962b684403 192 Font* font();
jonebuckman 0:90962b684403 193
jonebuckman 0:90962b684403 194 /** Set the font of the control
jonebuckman 0:90962b684403 195 *
jonebuckman 0:90962b684403 196 * @param fnt The new font.
jonebuckman 0:90962b684403 197 */
jonebuckman 0:90962b684403 198 void font(Font* fnt);
jonebuckman 0:90962b684403 199
jonebuckman 0:90962b684403 200 /** Determine whether the control needs to be repainted
jonebuckman 0:90962b684403 201 *
jonebuckman 0:90962b684403 202 * @returns Whether or not the control needs to be repainted.
jonebuckman 0:90962b684403 203 */
jonebuckman 0:90962b684403 204 bool invalid();
jonebuckman 0:90962b684403 205
jonebuckman 0:90962b684403 206 /** Mark this control as invalid
jonebuckman 0:90962b684403 207 */
jonebuckman 0:90962b684403 208 void invalidate();
jonebuckman 0:90962b684403 209
jonebuckman 0:90962b684403 210 protected:
jonebuckman 0:90962b684403 211 int m_X, m_Y, m_Width, m_Height, m_Margin, m_Border, m_Padding;
jonebuckman 0:90962b684403 212 unsigned int m_FgColor, m_BgColor;
jonebuckman 0:90962b684403 213 const char* m_Text;
jonebuckman 0:90962b684403 214 Font* m_Font;
jonebuckman 0:90962b684403 215 bool m_Invalid;
jonebuckman 0:90962b684403 216 };
jonebuckman 0:90962b684403 217
jonebuckman 0:90962b684403 218 #endif