Wrapper classes for the emwin library
Dependents: app_emwin1 app_emwin2_pos lpc4088_ebb_gui_emwin
EwPainter.h@1:0b16165ada7c, 2014-04-14 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Apr 14 08:38:33 2014 +0000
- Revision:
- 1:0b16165ada7c
- Parent:
- 0:316c181e9b65
Initialize uninitialized touchState in EwGui
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:316c181e9b65 | 1 | |
embeddedartists | 0:316c181e9b65 | 2 | #ifndef EWPAINTER_H |
embeddedartists | 0:316c181e9b65 | 3 | #define EWPAINTER_H |
embeddedartists | 0:316c181e9b65 | 4 | |
embeddedartists | 0:316c181e9b65 | 5 | #include "GUI.h" |
embeddedartists | 0:316c181e9b65 | 6 | |
embeddedartists | 0:316c181e9b65 | 7 | typedef GUI_COLOR ewColor_t; |
embeddedartists | 0:316c181e9b65 | 8 | typedef GUI_POINT ewPoint_t; |
embeddedartists | 0:316c181e9b65 | 9 | typedef GUI_RECT ewRect_t; |
embeddedartists | 0:316c181e9b65 | 10 | typedef GUI_FONT ewFont_t; |
embeddedartists | 0:316c181e9b65 | 11 | typedef GUI_BITMAP ewBitmap_t; |
embeddedartists | 0:316c181e9b65 | 12 | |
embeddedartists | 0:316c181e9b65 | 13 | enum ewLineStyle_t { |
embeddedartists | 0:316c181e9b65 | 14 | LineStyleSolid = GUI_LS_SOLID, |
embeddedartists | 0:316c181e9b65 | 15 | LineStyleDash = GUI_LS_DASH, |
embeddedartists | 0:316c181e9b65 | 16 | LineStyleDot = GUI_LS_DOT, |
embeddedartists | 0:316c181e9b65 | 17 | LineStyleDashDot = GUI_LS_DASHDOT, |
embeddedartists | 0:316c181e9b65 | 18 | LineStyleDashDotDot = GUI_LS_DASHDOTDOT |
embeddedartists | 0:316c181e9b65 | 19 | }; |
embeddedartists | 0:316c181e9b65 | 20 | |
embeddedartists | 0:316c181e9b65 | 21 | |
embeddedartists | 0:316c181e9b65 | 22 | enum ewTextAlign_t { |
embeddedartists | 0:316c181e9b65 | 23 | TextAlignTop = GUI_TA_TOP, |
embeddedartists | 0:316c181e9b65 | 24 | TextAlignBottom = GUI_TA_BOTTOM, |
embeddedartists | 0:316c181e9b65 | 25 | TextAlignVertCenter = GUI_TA_VCENTER, |
embeddedartists | 0:316c181e9b65 | 26 | TextAlignLeft = GUI_TA_LEFT, |
embeddedartists | 0:316c181e9b65 | 27 | TextAlignRight = GUI_TA_RIGHT, |
embeddedartists | 0:316c181e9b65 | 28 | TextAlignHorizCenter = GUI_TA_HCENTER |
embeddedartists | 0:316c181e9b65 | 29 | }; |
embeddedartists | 0:316c181e9b65 | 30 | |
embeddedartists | 0:316c181e9b65 | 31 | enum ewRotation_t { |
embeddedartists | 0:316c181e9b65 | 32 | Rotation_0 = 0, |
embeddedartists | 0:316c181e9b65 | 33 | Rotation_180, |
embeddedartists | 0:316c181e9b65 | 34 | Rotation_CCW, |
embeddedartists | 0:316c181e9b65 | 35 | Rotation_CW |
embeddedartists | 0:316c181e9b65 | 36 | }; |
embeddedartists | 0:316c181e9b65 | 37 | |
embeddedartists | 0:316c181e9b65 | 38 | enum ewWrapMode_t { |
embeddedartists | 0:316c181e9b65 | 39 | WrapModeNone = GUI_WRAPMODE_NONE, |
embeddedartists | 0:316c181e9b65 | 40 | WrapModeWord = GUI_WRAPMODE_WORD, |
embeddedartists | 0:316c181e9b65 | 41 | WrapModeChar = GUI_WRAPMODE_CHAR |
embeddedartists | 0:316c181e9b65 | 42 | }; |
embeddedartists | 0:316c181e9b65 | 43 | |
embeddedartists | 0:316c181e9b65 | 44 | enum ewTextMode_t { |
embeddedartists | 0:316c181e9b65 | 45 | TextModeNormal = GUI_TEXTMODE_NORMAL, |
embeddedartists | 0:316c181e9b65 | 46 | TextModeTransparent = GUI_TEXTMODE_TRANS, |
embeddedartists | 0:316c181e9b65 | 47 | TextModeReverse = GUI_TEXTMODE_REV, |
embeddedartists | 0:316c181e9b65 | 48 | TextModeXor = GUI_TEXTMODE_XOR |
embeddedartists | 0:316c181e9b65 | 49 | }; |
embeddedartists | 0:316c181e9b65 | 50 | |
embeddedartists | 0:316c181e9b65 | 51 | enum ewTextStyle_t { |
embeddedartists | 0:316c181e9b65 | 52 | TextStyleNormal = GUI_TS_NORMAL, |
embeddedartists | 0:316c181e9b65 | 53 | TextStyleUnderline = GUI_TS_UNDERLINE, |
embeddedartists | 0:316c181e9b65 | 54 | TextStyleStrikeThru = GUI_TS_STRIKETHRU, |
embeddedartists | 0:316c181e9b65 | 55 | TextStyleOverline = GUI_TS_OVERLINE |
embeddedartists | 0:316c181e9b65 | 56 | }; |
embeddedartists | 0:316c181e9b65 | 57 | |
embeddedartists | 0:316c181e9b65 | 58 | #define EW_BLUE (GUI_BLUE) |
embeddedartists | 0:316c181e9b65 | 59 | #define EW_GREEN (GUI_GREEN) |
embeddedartists | 0:316c181e9b65 | 60 | #define EW_RED (GUI_RED) |
embeddedartists | 0:316c181e9b65 | 61 | #define EW_CYAN (GUI_CYAN) |
embeddedartists | 0:316c181e9b65 | 62 | #define EW_MAGENTA (GUI_MAGENTA) |
embeddedartists | 0:316c181e9b65 | 63 | #define EW_YELLOW (GUI_YELLOW) |
embeddedartists | 0:316c181e9b65 | 64 | #define EW_LIGHTBLUE (GUI_LIGHTBLUE) |
embeddedartists | 0:316c181e9b65 | 65 | #define EW_LIGHTGREEN (GUI_LIGHTGREEN) |
embeddedartists | 0:316c181e9b65 | 66 | #define EW_LIGHTRED (GUI_LIGHTRED) |
embeddedartists | 0:316c181e9b65 | 67 | #define EW_LIGHTCYAN (GUI_LIGHTCYAN) |
embeddedartists | 0:316c181e9b65 | 68 | #define EW_LIGHTMAGENTA (GUI_LIGHTMAGENTA) |
embeddedartists | 0:316c181e9b65 | 69 | #define EW_LIGHTYELLOW (GUI_LIGHTYELLOW) |
embeddedartists | 0:316c181e9b65 | 70 | #define EW_DARKBLUE (GUI_DARKBLUE) |
embeddedartists | 0:316c181e9b65 | 71 | #define EW_DARKGREEN (GUI_DARKGREEN) |
embeddedartists | 0:316c181e9b65 | 72 | #define EW_DARKRED (GUI_DARKRED) |
embeddedartists | 0:316c181e9b65 | 73 | #define EW_DARKCYAN (GUI_DARKCYAN) |
embeddedartists | 0:316c181e9b65 | 74 | #define EW_DARKMAGENTA (GUI_DARKMAGENTA) |
embeddedartists | 0:316c181e9b65 | 75 | #define EW_DARKYELLOW (GUI_DARKYELLOW) |
embeddedartists | 0:316c181e9b65 | 76 | #define EW_WHITE (GUI_WHITE) |
embeddedartists | 0:316c181e9b65 | 77 | #define EW_LIGHTGRAY (GUI_LIGHTGRAY) |
embeddedartists | 0:316c181e9b65 | 78 | #define EW_GRAY (GUI_GRAY) |
embeddedartists | 0:316c181e9b65 | 79 | #define EW_DARKGRAY (GUI_DARKGRAY) |
embeddedartists | 0:316c181e9b65 | 80 | #define EW_BLACK (GUI_BLACK) |
embeddedartists | 0:316c181e9b65 | 81 | #define EW_BROWN (GUI_BROWN) |
embeddedartists | 0:316c181e9b65 | 82 | #define EW_ORANGE (GUI_ORANGE) |
embeddedartists | 0:316c181e9b65 | 83 | #define EW_TRANSPARENT (GUI_TRANSPARENT) |
embeddedartists | 0:316c181e9b65 | 84 | |
embeddedartists | 0:316c181e9b65 | 85 | #define EW_INVALID_COLOR (GUI_INVALID_COLOR) |
embeddedartists | 0:316c181e9b65 | 86 | |
embeddedartists | 0:316c181e9b65 | 87 | |
embeddedartists | 0:316c181e9b65 | 88 | /** |
embeddedartists | 0:316c181e9b65 | 89 | * This is a wrapper class for the drawing primitives in |
embeddedartists | 0:316c181e9b65 | 90 | * the emwin GUI interface. |
embeddedartists | 0:316c181e9b65 | 91 | */ |
embeddedartists | 0:316c181e9b65 | 92 | class EwPainter { |
embeddedartists | 0:316c181e9b65 | 93 | public: |
embeddedartists | 0:316c181e9b65 | 94 | |
embeddedartists | 0:316c181e9b65 | 95 | |
embeddedartists | 0:316c181e9b65 | 96 | |
embeddedartists | 0:316c181e9b65 | 97 | EwPainter(); |
embeddedartists | 0:316c181e9b65 | 98 | |
embeddedartists | 0:316c181e9b65 | 99 | void enableAlpha(bool on); |
embeddedartists | 0:316c181e9b65 | 100 | ewColor_t getBackgroundColor(); |
embeddedartists | 0:316c181e9b65 | 101 | void setBackgroundColor(ewColor_t c); |
embeddedartists | 0:316c181e9b65 | 102 | ewColor_t getColor(); |
embeddedartists | 0:316c181e9b65 | 103 | void setColor(ewColor_t c); |
embeddedartists | 0:316c181e9b65 | 104 | |
embeddedartists | 0:316c181e9b65 | 105 | uint8_t getPenSize(); |
embeddedartists | 0:316c181e9b65 | 106 | void setPenSize(uint8_t size); |
embeddedartists | 0:316c181e9b65 | 107 | |
embeddedartists | 0:316c181e9b65 | 108 | void move(int32_t dx, int32_t dy); |
embeddedartists | 0:316c181e9b65 | 109 | void moveTo(int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 110 | |
embeddedartists | 0:316c181e9b65 | 111 | void clear(); |
embeddedartists | 0:316c181e9b65 | 112 | void clearRect(int32_t x0, int32_t y0, int32_t x1, int32_t y1); |
embeddedartists | 0:316c181e9b65 | 113 | void copyRect(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t width, int32_t height); |
embeddedartists | 0:316c181e9b65 | 114 | |
embeddedartists | 0:316c181e9b65 | 115 | void drawHorizGradient(int32_t x0, int32_t y0, int32_t x1, int32_t y1, ewColor_t c0, ewColor_t c1); |
embeddedartists | 0:316c181e9b65 | 116 | void drawVertGradient(int32_t x0, int32_t y0, int32_t x1, int32_t y1, ewColor_t c0, ewColor_t c1); |
embeddedartists | 0:316c181e9b65 | 117 | void drawHorizRoundGradient(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t radius, ewColor_t c0, ewColor_t c1); |
embeddedartists | 0:316c181e9b65 | 118 | void drawVertRoundGradient(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t radius, ewColor_t c0, ewColor_t c1); |
embeddedartists | 0:316c181e9b65 | 119 | |
embeddedartists | 0:316c181e9b65 | 120 | void drawPixel(int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 121 | void drawPoint(int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 122 | void drawRect(int32_t x0, int32_t y0, int32_t x1, int32_t y1); |
embeddedartists | 0:316c181e9b65 | 123 | void drawRect(ewRect_t *rect); |
embeddedartists | 0:316c181e9b65 | 124 | void drawRoundedFrame(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t radius, int32_t width); |
embeddedartists | 0:316c181e9b65 | 125 | void drawRoundedRect(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t radius); |
embeddedartists | 0:316c181e9b65 | 126 | |
embeddedartists | 0:316c181e9b65 | 127 | void fillRect(int32_t x0, int32_t y0, int32_t x1, int32_t y1); |
embeddedartists | 0:316c181e9b65 | 128 | void fillRect(ewRect_t *rect); |
embeddedartists | 0:316c181e9b65 | 129 | void fillRoundedRect(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t radius); |
embeddedartists | 0:316c181e9b65 | 130 | |
embeddedartists | 0:316c181e9b65 | 131 | void drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1); |
embeddedartists | 0:316c181e9b65 | 132 | void drawLine(int32_t dx, int32_t dy); |
embeddedartists | 0:316c181e9b65 | 133 | void drawLineTo(int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 134 | void drawHorizLine(int32_t y, int32_t x0, int32_t x1); |
embeddedartists | 0:316c181e9b65 | 135 | void drawVertLine(int32_t x, int32_t y0, int32_t y1); |
embeddedartists | 0:316c181e9b65 | 136 | |
embeddedartists | 0:316c181e9b65 | 137 | void drawPolyLine(ewPoint_t* pPoints, int numPoints, int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 138 | |
embeddedartists | 0:316c181e9b65 | 139 | ewLineStyle_t getLineStyle(); |
embeddedartists | 0:316c181e9b65 | 140 | ewLineStyle_t setLineStyle(ewLineStyle_t style); |
embeddedartists | 0:316c181e9b65 | 141 | |
embeddedartists | 0:316c181e9b65 | 142 | void drawPolygon(ewPoint_t* pPoints, int numPoints, int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 143 | void enlargePolygon(ewPoint_t* pDest, ewPoint_t* pSrc, int numPoints, int32_t len); |
embeddedartists | 0:316c181e9b65 | 144 | void magnifyPolygon(ewPoint_t* pDest, ewPoint_t* pSrc, int numPoints, int32_t mag); |
embeddedartists | 0:316c181e9b65 | 145 | void rotatePolygon(ewPoint_t* pDest, ewPoint_t* pSrc, int numPoints, float angle); |
embeddedartists | 0:316c181e9b65 | 146 | void fillPolygon(ewPoint_t* pPoints, int numPoints, int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 147 | |
embeddedartists | 0:316c181e9b65 | 148 | void drawCircle(int32_t x0, int32_t y0, int32_t radius); |
embeddedartists | 0:316c181e9b65 | 149 | void fillCircle(int32_t x0, int32_t y0, int32_t radius); |
embeddedartists | 0:316c181e9b65 | 150 | |
embeddedartists | 0:316c181e9b65 | 151 | void drawEllipse(int32_t x0, int32_t y0, int32_t rx, int32_t ry); |
embeddedartists | 0:316c181e9b65 | 152 | void fillEllipse(int32_t x0, int32_t y0, int32_t rx, int32_t ry); |
embeddedartists | 0:316c181e9b65 | 153 | |
embeddedartists | 0:316c181e9b65 | 154 | void drawArc(int32_t xCenter, int32_t yCenter, int32_t rx, int32_t ry, int32_t a0, int32_t a1); |
embeddedartists | 0:316c181e9b65 | 155 | void drawGraph(int16_t* paY, int numPoints, int32_t x0, int32_t y0); |
embeddedartists | 0:316c181e9b65 | 156 | void drawPie(int32_t x0, int32_t y0, int32_t radius, int32_t a0, int32_t a1); |
embeddedartists | 0:316c181e9b65 | 157 | |
embeddedartists | 0:316c181e9b65 | 158 | void drawChar(uint16_t c); |
embeddedartists | 0:316c181e9b65 | 159 | void drawChar(uint16_t c, int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 160 | void drawChars(uint16_t c, int32_t cnt); |
embeddedartists | 0:316c181e9b65 | 161 | void newLine(); |
embeddedartists | 0:316c181e9b65 | 162 | void drawString(const char* s, int32_t maxLen = -1); |
embeddedartists | 0:316c181e9b65 | 163 | void drawString(const char* s, int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 164 | void drawStringClearEOL(const char* s, int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 165 | void drawStringHorizCenter(const char* s, int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 166 | void drawStringRect(const char* s, ewRect_t *pRect, ewTextAlign_t align, ewWrapMode_t wrap = WrapModeNone); |
embeddedartists | 0:316c181e9b65 | 167 | void drawStringRect(const char* s, ewRect_t *pRect, ewTextAlign_t align, int32_t maxLen, ewRotation_t rotation); |
embeddedartists | 0:316c181e9b65 | 168 | int32_t getNumWrapLines(const char* s, int32_t width, ewWrapMode_t wrap); |
embeddedartists | 0:316c181e9b65 | 169 | |
embeddedartists | 0:316c181e9b65 | 170 | ewTextMode_t getTextMode(); |
embeddedartists | 0:316c181e9b65 | 171 | void setTextMode(ewTextMode_t mode); |
embeddedartists | 0:316c181e9b65 | 172 | void setTextStyle(ewTextStyle_t style); |
embeddedartists | 0:316c181e9b65 | 173 | ewTextAlign_t getTextAlign(); |
embeddedartists | 0:316c181e9b65 | 174 | void setTextAlign(ewTextAlign_t align); |
embeddedartists | 0:316c181e9b65 | 175 | |
embeddedartists | 0:316c181e9b65 | 176 | bool setTextPosition(int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 177 | void getTextPosition(int32_t &x, int32_t &y); |
embeddedartists | 0:316c181e9b65 | 178 | |
embeddedartists | 0:316c181e9b65 | 179 | const ewFont_t* setFont(const ewFont_t* pFont); |
embeddedartists | 0:316c181e9b65 | 180 | const ewFont_t* getFont(); |
embeddedartists | 0:316c181e9b65 | 181 | int32_t getCharWidth(uint16_t c); |
embeddedartists | 0:316c181e9b65 | 182 | int32_t getFontHeight(); |
embeddedartists | 0:316c181e9b65 | 183 | int32_t getFontDistY(); |
embeddedartists | 0:316c181e9b65 | 184 | int32_t getLeadingBlankCols(uint16_t c); |
embeddedartists | 0:316c181e9b65 | 185 | int32_t getTrailingBlankCols(uint16_t c); |
embeddedartists | 0:316c181e9b65 | 186 | int32_t getStringWidth(const char* s); |
embeddedartists | 0:316c181e9b65 | 187 | bool isCharInFont(const ewFont_t* pFont, uint16_t c); |
embeddedartists | 0:316c181e9b65 | 188 | |
embeddedartists | 0:316c181e9b65 | 189 | void drawBitmap(const ewBitmap_t* pBm, int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 190 | void drawBitmapMagnified(const ewBitmap_t* pBm, int32_t x, int32_t y, int32_t xMul, int32_t yMul); |
embeddedartists | 0:316c181e9b65 | 191 | void drawBitmapScaled(const ewBitmap_t* pBm, int32_t x, int32_t y, int32_t xCenter, int32_t yCenter, int32_t xMag, int32_t yMag); |
embeddedartists | 0:316c181e9b65 | 192 | |
embeddedartists | 0:316c181e9b65 | 193 | void drawJpeg(const void* pData, int32_t dataSize, int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 194 | void drawJpegScaled(const void* pData, int32_t dataSize, int32_t x, int32_t y, int32_t num, int32_t denom); |
embeddedartists | 0:316c181e9b65 | 195 | void getJpegSize(const void* pData, int32_t dataSize, int32_t &width, int32_t &height); |
embeddedartists | 0:316c181e9b65 | 196 | |
embeddedartists | 0:316c181e9b65 | 197 | void drawGif(const void* pData, int32_t dataSize, int32_t x, int32_t y, int32_t imgIdx = -1); |
embeddedartists | 0:316c181e9b65 | 198 | void drawGifScaled(const void* pData, int32_t dataSize, int32_t x, int32_t y, int32_t imgIdx, int32_t num, int32_t denom); |
embeddedartists | 0:316c181e9b65 | 199 | void getGifSize(const void* pData, int32_t dataSize, int32_t &width, int32_t &height); |
embeddedartists | 0:316c181e9b65 | 200 | int32_t getGifNumImages(const void* pData, int32_t dataSize); |
embeddedartists | 0:316c181e9b65 | 201 | |
embeddedartists | 0:316c181e9b65 | 202 | void drawPng(const void* pData, int32_t dataSize, int32_t x, int32_t y); |
embeddedartists | 0:316c181e9b65 | 203 | void getPngSize(const void* pData, int32_t dataSize, int32_t &width, int32_t &height); |
embeddedartists | 0:316c181e9b65 | 204 | |
embeddedartists | 0:316c181e9b65 | 205 | |
embeddedartists | 0:316c181e9b65 | 206 | void saveContext(); |
embeddedartists | 0:316c181e9b65 | 207 | void restoreContext(); |
embeddedartists | 0:316c181e9b65 | 208 | |
embeddedartists | 0:316c181e9b65 | 209 | |
embeddedartists | 0:316c181e9b65 | 210 | private: |
embeddedartists | 0:316c181e9b65 | 211 | |
embeddedartists | 0:316c181e9b65 | 212 | |
embeddedartists | 0:316c181e9b65 | 213 | GUI_CONTEXT _context; |
embeddedartists | 0:316c181e9b65 | 214 | bool _contextSaved; |
embeddedartists | 0:316c181e9b65 | 215 | |
embeddedartists | 0:316c181e9b65 | 216 | }; |
embeddedartists | 0:316c181e9b65 | 217 | |
embeddedartists | 0:316c181e9b65 | 218 | #endif |