A simple yet powerful library for controlling graphical displays. Multiple display controllers are supported using inheritance.
Dependents: mbed_rifletool Hexi_Bubble_Game Hexi_Catch-the-dot_Game Hexi_Acceleromagnetic_Synth
Control.h
00001 /* NeatGUI Library 00002 * Copyright (c) 2013 Neil Thiessen 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef CONTROL_H 00018 #define CONTROL_H 00019 00020 #include "mbed.h" 00021 #include "Canvas.h" 00022 00023 /** Control abstract class. 00024 * Used as a base class for UI elements. 00025 */ 00026 class Control 00027 { 00028 public: 00029 /** Create a Control object with the specified size and location 00030 * 00031 * @param x The X coordinate of the control. 00032 * @param y The Y coordinate of the control. 00033 * @param w The width of the control. 00034 * @param h The height of the control. 00035 */ 00036 Control(int x, int y, int w, int h); 00037 00038 /** Paint the control on the specified canvas and mark as valid again 00039 * 00040 * @param canvas Pointer to the canvas to paint on. 00041 */ 00042 virtual void paint(Canvas *canvas); 00043 00044 /** Get the X coordinate of the control 00045 * 00046 * @returns The X coordinate of the control. 00047 */ 00048 int posX(); 00049 00050 /** Set the X coordinate of the control 00051 * 00052 * @param x The new X coordinate for the control. 00053 */ 00054 void posX(int x); 00055 00056 /** Get the Y coordinate of the control 00057 * 00058 * @returns The Y coordinate of the control. 00059 */ 00060 int posY(); 00061 00062 /** Set the Y coordinate of the control 00063 * 00064 * @param y The new Y coordinate for the control. 00065 */ 00066 void posY(int y); 00067 00068 /** Get the width of the control 00069 * 00070 * @returns The width of the control. 00071 */ 00072 int width(); 00073 00074 /** Set the width of the control 00075 * 00076 * @param w The new width for the control. 00077 */ 00078 void width(int w); 00079 00080 /** Get the height of the control 00081 * 00082 * @returns The height of the control. 00083 */ 00084 int height(); 00085 00086 /** Set the height of the control 00087 * 00088 * @param h The new height for the control. 00089 */ 00090 void height(int h); 00091 00092 /** Get the current margin width 00093 * 00094 * @returns The current margin width. 00095 */ 00096 int margin(); 00097 00098 /** Set the margin width 00099 * 00100 * @param m The new margin width. 00101 */ 00102 void margin(int m); 00103 00104 /** Get the current border width 00105 * 00106 * @returns The current border width. 00107 */ 00108 int border(); 00109 00110 /** Set the border width 00111 * 00112 * @param b The new border width. 00113 */ 00114 void border(int b); 00115 00116 /** Get the current padding width 00117 * 00118 * @returns The current padding width. 00119 */ 00120 int padding(); 00121 00122 /** Set the padding width 00123 * 00124 * @param p The new padding width. 00125 */ 00126 void padding(int p); 00127 00128 /** Get the X coordinate of the control's content area 00129 * 00130 * @returns The X coordinate of the control's content area. 00131 */ 00132 int contentPosX(); 00133 00134 /** Get the Y coordinate of the control's content area 00135 * 00136 * @returns The Y coordinate of the control's content area. 00137 */ 00138 int contentPosY(); 00139 00140 /** Get the width of the control's content area 00141 * 00142 * @returns The width of the control's content area. 00143 */ 00144 int contentWidth(); 00145 00146 /** Get the height of the control's content area 00147 * 00148 * @returns The height of the control's content area. 00149 */ 00150 int contentHeight(); 00151 00152 /** Get the foreground color 00153 * 00154 * @returns The foreground color as a 32-bit ARGB value. 00155 */ 00156 unsigned int foreColor(); 00157 00158 /** Set the foreground color 00159 * 00160 * @param c The new foreground color as a 32-bit ARGB value. 00161 */ 00162 void foreColor(unsigned int c); 00163 00164 /** Get the background color 00165 * 00166 * @returns The background color as a 32-bit ARGB value. 00167 */ 00168 unsigned int backColor(); 00169 00170 /** Set the background color 00171 * 00172 * @param c The new background color as a 32-bit ARGB value. 00173 */ 00174 void backColor(unsigned int c); 00175 00176 /** Get the current text of the control 00177 * 00178 * @returns The current text of the control. 00179 */ 00180 const char* text(); 00181 00182 /** Set the text of the control 00183 * 00184 * @param text The new text. 00185 */ 00186 void text(const char* text); 00187 00188 /** Get the current font of the control 00189 * 00190 * @returns The current font of the control. 00191 */ 00192 Font* font(); 00193 00194 /** Set the font of the control 00195 * 00196 * @param fnt The new font. 00197 */ 00198 void font(Font* fnt); 00199 00200 /** Determine whether the control needs to be repainted 00201 * 00202 * @returns Whether or not the control needs to be repainted. 00203 */ 00204 bool invalid(); 00205 00206 /** Mark this control as invalid 00207 */ 00208 void invalidate(); 00209 00210 protected: 00211 int m_X, m_Y, m_Width, m_Height, m_Margin, m_Border, m_Padding; 00212 unsigned int m_FgColor, m_BgColor; 00213 const char* m_Text; 00214 Font* m_Font; 00215 bool m_Invalid; 00216 }; 00217 00218 #endif
Generated on Tue Jul 12 2022 20:26:18 by 1.7.2