Wrapper classes for the emwin library
Dependents: app_emwin1 app_emwin2_pos lpc4088_ebb_gui_emwin
EwPainter.cpp@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 | #include "mbed.h" |
embeddedartists | 0:316c181e9b65 | 2 | |
embeddedartists | 0:316c181e9b65 | 3 | #include "EwPainter.h" |
embeddedartists | 0:316c181e9b65 | 4 | |
embeddedartists | 0:316c181e9b65 | 5 | |
embeddedartists | 0:316c181e9b65 | 6 | EwPainter::EwPainter() { |
embeddedartists | 0:316c181e9b65 | 7 | _contextSaved = false; |
embeddedartists | 0:316c181e9b65 | 8 | } |
embeddedartists | 0:316c181e9b65 | 9 | |
embeddedartists | 0:316c181e9b65 | 10 | void EwPainter::enableAlpha(bool on) { |
embeddedartists | 0:316c181e9b65 | 11 | GUI_EnableAlpha((on ? 1 : 0)); |
embeddedartists | 0:316c181e9b65 | 12 | } |
embeddedartists | 0:316c181e9b65 | 13 | |
embeddedartists | 0:316c181e9b65 | 14 | ewColor_t EwPainter::getBackgroundColor() { |
embeddedartists | 0:316c181e9b65 | 15 | return GUI_GetBkColor(); |
embeddedartists | 0:316c181e9b65 | 16 | } |
embeddedartists | 0:316c181e9b65 | 17 | |
embeddedartists | 0:316c181e9b65 | 18 | void EwPainter::setBackgroundColor(ewColor_t c) { |
embeddedartists | 0:316c181e9b65 | 19 | GUI_SetBkColor(c); |
embeddedartists | 0:316c181e9b65 | 20 | } |
embeddedartists | 0:316c181e9b65 | 21 | |
embeddedartists | 0:316c181e9b65 | 22 | ewColor_t EwPainter::getColor() { |
embeddedartists | 0:316c181e9b65 | 23 | return GUI_GetColor(); |
embeddedartists | 0:316c181e9b65 | 24 | } |
embeddedartists | 0:316c181e9b65 | 25 | |
embeddedartists | 0:316c181e9b65 | 26 | void EwPainter::setColor(ewColor_t c) { |
embeddedartists | 0:316c181e9b65 | 27 | GUI_SetColor(c); |
embeddedartists | 0:316c181e9b65 | 28 | } |
embeddedartists | 0:316c181e9b65 | 29 | |
embeddedartists | 0:316c181e9b65 | 30 | uint8_t EwPainter::getPenSize() { |
embeddedartists | 0:316c181e9b65 | 31 | return GUI_GetPenSize(); |
embeddedartists | 0:316c181e9b65 | 32 | } |
embeddedartists | 0:316c181e9b65 | 33 | |
embeddedartists | 0:316c181e9b65 | 34 | void EwPainter::setPenSize(uint8_t size) { |
embeddedartists | 0:316c181e9b65 | 35 | GUI_SetPenSize(size); |
embeddedartists | 0:316c181e9b65 | 36 | } |
embeddedartists | 0:316c181e9b65 | 37 | |
embeddedartists | 0:316c181e9b65 | 38 | void EwPainter::move(int32_t dx, int32_t dy) { |
embeddedartists | 0:316c181e9b65 | 39 | GUI_MoveRel(dx, dy); |
embeddedartists | 0:316c181e9b65 | 40 | } |
embeddedartists | 0:316c181e9b65 | 41 | |
embeddedartists | 0:316c181e9b65 | 42 | void EwPainter::moveTo(int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 43 | GUI_MoveTo(x, y); |
embeddedartists | 0:316c181e9b65 | 44 | } |
embeddedartists | 0:316c181e9b65 | 45 | |
embeddedartists | 0:316c181e9b65 | 46 | void EwPainter::clear() { |
embeddedartists | 0:316c181e9b65 | 47 | GUI_Clear(); |
embeddedartists | 0:316c181e9b65 | 48 | } |
embeddedartists | 0:316c181e9b65 | 49 | |
embeddedartists | 0:316c181e9b65 | 50 | void EwPainter::clearRect(int32_t x0, int32_t y0, int32_t x1, int32_t y1) { |
embeddedartists | 0:316c181e9b65 | 51 | GUI_ClearRect(x0, y0, x1, y1); |
embeddedartists | 0:316c181e9b65 | 52 | } |
embeddedartists | 0:316c181e9b65 | 53 | |
embeddedartists | 0:316c181e9b65 | 54 | void EwPainter::copyRect(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t width, int32_t height) { |
embeddedartists | 0:316c181e9b65 | 55 | GUI_CopyRect(x0, y0, x1, y1, width, height); |
embeddedartists | 0:316c181e9b65 | 56 | } |
embeddedartists | 0:316c181e9b65 | 57 | |
embeddedartists | 0:316c181e9b65 | 58 | void EwPainter::drawHorizGradient(int32_t x0, int32_t y0, int32_t x1, int32_t y1, ewColor_t c0, ewColor_t c1) { |
embeddedartists | 0:316c181e9b65 | 59 | GUI_DrawGradientH(x0, y0, x1, y1, c0, c1); |
embeddedartists | 0:316c181e9b65 | 60 | } |
embeddedartists | 0:316c181e9b65 | 61 | |
embeddedartists | 0:316c181e9b65 | 62 | void EwPainter::drawVertGradient(int32_t x0, int32_t y0, int32_t x1, int32_t y1, ewColor_t c0, ewColor_t c1) { |
embeddedartists | 0:316c181e9b65 | 63 | GUI_DrawGradientV(x0, y0, x1, y1, c0, c1); |
embeddedartists | 0:316c181e9b65 | 64 | } |
embeddedartists | 0:316c181e9b65 | 65 | void EwPainter::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 | 66 | GUI_DrawGradientRoundedH(x0, y0, x1, y1, radius, c0, c1); |
embeddedartists | 0:316c181e9b65 | 67 | } |
embeddedartists | 0:316c181e9b65 | 68 | |
embeddedartists | 0:316c181e9b65 | 69 | void EwPainter::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 | 70 | GUI_DrawGradientRoundedV(x0, y0, x1, y1, radius, c0, c1); |
embeddedartists | 0:316c181e9b65 | 71 | } |
embeddedartists | 0:316c181e9b65 | 72 | |
embeddedartists | 0:316c181e9b65 | 73 | void EwPainter::drawPixel(int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 74 | GUI_DrawPixel(x, y); |
embeddedartists | 0:316c181e9b65 | 75 | } |
embeddedartists | 0:316c181e9b65 | 76 | |
embeddedartists | 0:316c181e9b65 | 77 | void EwPainter::drawPoint(int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 78 | GUI_DrawPoint(x, y); |
embeddedartists | 0:316c181e9b65 | 79 | } |
embeddedartists | 0:316c181e9b65 | 80 | |
embeddedartists | 0:316c181e9b65 | 81 | void EwPainter::drawRect(int32_t x0, int32_t y0, int32_t x1, int32_t y1) { |
embeddedartists | 0:316c181e9b65 | 82 | GUI_DrawRect(x0, y0, x1, y1); |
embeddedartists | 0:316c181e9b65 | 83 | } |
embeddedartists | 0:316c181e9b65 | 84 | |
embeddedartists | 0:316c181e9b65 | 85 | void EwPainter::drawRect(ewRect_t *pRect) { |
embeddedartists | 0:316c181e9b65 | 86 | GUI_DrawRectEx(pRect); |
embeddedartists | 0:316c181e9b65 | 87 | } |
embeddedartists | 0:316c181e9b65 | 88 | |
embeddedartists | 0:316c181e9b65 | 89 | |
embeddedartists | 0:316c181e9b65 | 90 | void EwPainter::drawRoundedFrame(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t radius, int32_t width) { |
embeddedartists | 0:316c181e9b65 | 91 | GUI_DrawRoundedFrame(x0, y0, x1, y1, radius, width); |
embeddedartists | 0:316c181e9b65 | 92 | } |
embeddedartists | 0:316c181e9b65 | 93 | |
embeddedartists | 0:316c181e9b65 | 94 | void EwPainter::drawRoundedRect(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t radius) { |
embeddedartists | 0:316c181e9b65 | 95 | GUI_DrawRoundedRect(x0, y0, x1, y1, radius); |
embeddedartists | 0:316c181e9b65 | 96 | } |
embeddedartists | 0:316c181e9b65 | 97 | |
embeddedartists | 0:316c181e9b65 | 98 | void EwPainter::fillRect(int32_t x0, int32_t y0, int32_t x1, int32_t y1) { |
embeddedartists | 0:316c181e9b65 | 99 | GUI_FillRect(x0, y0, x1, y1); |
embeddedartists | 0:316c181e9b65 | 100 | } |
embeddedartists | 0:316c181e9b65 | 101 | |
embeddedartists | 0:316c181e9b65 | 102 | void EwPainter::fillRect(ewRect_t *pRect) { |
embeddedartists | 0:316c181e9b65 | 103 | GUI_FillRectEx(pRect); |
embeddedartists | 0:316c181e9b65 | 104 | } |
embeddedartists | 0:316c181e9b65 | 105 | |
embeddedartists | 0:316c181e9b65 | 106 | void EwPainter::fillRoundedRect(int32_t x0, int32_t y0, int32_t x1, int32_t y1, int32_t radius) { |
embeddedartists | 0:316c181e9b65 | 107 | GUI_FillRoundedRect(x0, y0, x1, y1, radius); |
embeddedartists | 0:316c181e9b65 | 108 | } |
embeddedartists | 0:316c181e9b65 | 109 | |
embeddedartists | 0:316c181e9b65 | 110 | void EwPainter::drawLine(int32_t x0, int32_t y0, int32_t x1, int32_t y1) { |
embeddedartists | 0:316c181e9b65 | 111 | GUI_DrawLine(x0, y0, x1, y1); |
embeddedartists | 0:316c181e9b65 | 112 | } |
embeddedartists | 0:316c181e9b65 | 113 | |
embeddedartists | 0:316c181e9b65 | 114 | void EwPainter::drawLine(int32_t dx, int32_t dy) { |
embeddedartists | 0:316c181e9b65 | 115 | GUI_DrawLineRel(dx, dy); |
embeddedartists | 0:316c181e9b65 | 116 | } |
embeddedartists | 0:316c181e9b65 | 117 | |
embeddedartists | 0:316c181e9b65 | 118 | void EwPainter::drawLineTo(int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 119 | GUI_DrawLineTo(x, y); |
embeddedartists | 0:316c181e9b65 | 120 | } |
embeddedartists | 0:316c181e9b65 | 121 | |
embeddedartists | 0:316c181e9b65 | 122 | void EwPainter::drawHorizLine(int32_t y, int32_t x0, int32_t x1) { |
embeddedartists | 0:316c181e9b65 | 123 | GUI_DrawHLine(y, x0, x1); |
embeddedartists | 0:316c181e9b65 | 124 | } |
embeddedartists | 0:316c181e9b65 | 125 | |
embeddedartists | 0:316c181e9b65 | 126 | void EwPainter::drawVertLine(int32_t x, int32_t y0, int32_t y1) { |
embeddedartists | 0:316c181e9b65 | 127 | GUI_DrawVLine(x, y0, y1); |
embeddedartists | 0:316c181e9b65 | 128 | } |
embeddedartists | 0:316c181e9b65 | 129 | |
embeddedartists | 0:316c181e9b65 | 130 | void EwPainter::drawPolyLine(ewPoint_t* pPoints, int numPoints, int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 131 | GUI_DrawPolyLine(pPoints, numPoints, x, y); |
embeddedartists | 0:316c181e9b65 | 132 | } |
embeddedartists | 0:316c181e9b65 | 133 | |
embeddedartists | 0:316c181e9b65 | 134 | ewLineStyle_t EwPainter::getLineStyle() { |
embeddedartists | 0:316c181e9b65 | 135 | return (ewLineStyle_t) GUI_GetLineStyle(); |
embeddedartists | 0:316c181e9b65 | 136 | } |
embeddedartists | 0:316c181e9b65 | 137 | |
embeddedartists | 0:316c181e9b65 | 138 | ewLineStyle_t EwPainter::setLineStyle(ewLineStyle_t style) { |
embeddedartists | 0:316c181e9b65 | 139 | return (ewLineStyle_t)GUI_SetLineStyle(style); |
embeddedartists | 0:316c181e9b65 | 140 | } |
embeddedartists | 0:316c181e9b65 | 141 | |
embeddedartists | 0:316c181e9b65 | 142 | void EwPainter::drawPolygon(ewPoint_t* pPoints, int numPoints, int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 143 | GUI_DrawPolygon(pPoints, numPoints, x, y); |
embeddedartists | 0:316c181e9b65 | 144 | } |
embeddedartists | 0:316c181e9b65 | 145 | |
embeddedartists | 0:316c181e9b65 | 146 | void EwPainter::enlargePolygon(ewPoint_t* pDest, ewPoint_t* pSrc, int numPoints, int32_t len) { |
embeddedartists | 0:316c181e9b65 | 147 | GUI_EnlargePolygon(pDest, pSrc, numPoints, len); |
embeddedartists | 0:316c181e9b65 | 148 | } |
embeddedartists | 0:316c181e9b65 | 149 | |
embeddedartists | 0:316c181e9b65 | 150 | void EwPainter::magnifyPolygon(ewPoint_t* pDest, ewPoint_t* pSrc, int numPoints, int32_t mag) { |
embeddedartists | 0:316c181e9b65 | 151 | GUI_MagnifyPolygon(pDest, pSrc, numPoints, mag); |
embeddedartists | 0:316c181e9b65 | 152 | } |
embeddedartists | 0:316c181e9b65 | 153 | |
embeddedartists | 0:316c181e9b65 | 154 | void EwPainter::rotatePolygon(ewPoint_t* pDest, ewPoint_t* pSrc, int numPoints, float angle) { |
embeddedartists | 0:316c181e9b65 | 155 | GUI_RotatePolygon(pDest, pSrc, numPoints, angle); |
embeddedartists | 0:316c181e9b65 | 156 | } |
embeddedartists | 0:316c181e9b65 | 157 | |
embeddedartists | 0:316c181e9b65 | 158 | void EwPainter::fillPolygon(ewPoint_t* pPoints, int numPoints, int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 159 | GUI_FillPolygon(pPoints, numPoints, x, y); |
embeddedartists | 0:316c181e9b65 | 160 | } |
embeddedartists | 0:316c181e9b65 | 161 | |
embeddedartists | 0:316c181e9b65 | 162 | void EwPainter::drawCircle(int32_t x0, int32_t y0, int32_t radius) { |
embeddedartists | 0:316c181e9b65 | 163 | GUI_DrawCircle(x0, y0, radius); |
embeddedartists | 0:316c181e9b65 | 164 | } |
embeddedartists | 0:316c181e9b65 | 165 | |
embeddedartists | 0:316c181e9b65 | 166 | void EwPainter::fillCircle(int32_t x0, int32_t y0, int32_t radius) { |
embeddedartists | 0:316c181e9b65 | 167 | GUI_FillCircle(x0, y0, radius); |
embeddedartists | 0:316c181e9b65 | 168 | } |
embeddedartists | 0:316c181e9b65 | 169 | |
embeddedartists | 0:316c181e9b65 | 170 | void EwPainter::drawEllipse(int32_t x0, int32_t y0, int32_t rx, int32_t ry) { |
embeddedartists | 0:316c181e9b65 | 171 | GUI_DrawEllipse(x0, y0, rx, ry); |
embeddedartists | 0:316c181e9b65 | 172 | } |
embeddedartists | 0:316c181e9b65 | 173 | |
embeddedartists | 0:316c181e9b65 | 174 | void EwPainter::fillEllipse(int32_t x0, int32_t y0, int32_t rx, int32_t ry) { |
embeddedartists | 0:316c181e9b65 | 175 | GUI_FillEllipse(x0, y0, rx, ry); |
embeddedartists | 0:316c181e9b65 | 176 | } |
embeddedartists | 0:316c181e9b65 | 177 | |
embeddedartists | 0:316c181e9b65 | 178 | void EwPainter::drawArc(int32_t xCenter, int32_t yCenter, int32_t rx, int32_t ry, int32_t a0, int32_t a1) { |
embeddedartists | 0:316c181e9b65 | 179 | GUI_DrawArc(xCenter, yCenter, rx, ry, a0, a1); |
embeddedartists | 0:316c181e9b65 | 180 | } |
embeddedartists | 0:316c181e9b65 | 181 | |
embeddedartists | 0:316c181e9b65 | 182 | void EwPainter::drawGraph(int16_t* paY, int numPoints, int32_t x0, int32_t y0) { |
embeddedartists | 0:316c181e9b65 | 183 | GUI_DrawGraph(paY, numPoints, x0, y0); |
embeddedartists | 0:316c181e9b65 | 184 | } |
embeddedartists | 0:316c181e9b65 | 185 | |
embeddedartists | 0:316c181e9b65 | 186 | void EwPainter::drawPie(int32_t x0, int32_t y0, int32_t radius, int32_t a0, int32_t a1) { |
embeddedartists | 0:316c181e9b65 | 187 | GUI_DrawPie(x0, y0, radius, a0, a1, 0); |
embeddedartists | 0:316c181e9b65 | 188 | } |
embeddedartists | 0:316c181e9b65 | 189 | |
embeddedartists | 0:316c181e9b65 | 190 | void EwPainter::drawChar(uint16_t c) { |
embeddedartists | 0:316c181e9b65 | 191 | GUI_DispChar(c); |
embeddedartists | 0:316c181e9b65 | 192 | } |
embeddedartists | 0:316c181e9b65 | 193 | |
embeddedartists | 0:316c181e9b65 | 194 | void EwPainter::drawChar(uint16_t c, int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 195 | GUI_DispCharAt(c, x, y); |
embeddedartists | 0:316c181e9b65 | 196 | } |
embeddedartists | 0:316c181e9b65 | 197 | |
embeddedartists | 0:316c181e9b65 | 198 | void EwPainter::drawChars(uint16_t c, int32_t cnt) { |
embeddedartists | 0:316c181e9b65 | 199 | GUI_DispChars(c, cnt); |
embeddedartists | 0:316c181e9b65 | 200 | } |
embeddedartists | 0:316c181e9b65 | 201 | |
embeddedartists | 0:316c181e9b65 | 202 | void EwPainter::newLine() { |
embeddedartists | 0:316c181e9b65 | 203 | GUI_DispNextLine(); |
embeddedartists | 0:316c181e9b65 | 204 | } |
embeddedartists | 0:316c181e9b65 | 205 | |
embeddedartists | 0:316c181e9b65 | 206 | void EwPainter::drawString(const char* s, int32_t maxLen) { |
embeddedartists | 0:316c181e9b65 | 207 | if (maxLen <= -1) { |
embeddedartists | 0:316c181e9b65 | 208 | GUI_DispString(s); |
embeddedartists | 0:316c181e9b65 | 209 | } |
embeddedartists | 0:316c181e9b65 | 210 | else { |
embeddedartists | 0:316c181e9b65 | 211 | GUI_DispStringLen(s, maxLen); |
embeddedartists | 0:316c181e9b65 | 212 | } |
embeddedartists | 0:316c181e9b65 | 213 | } |
embeddedartists | 0:316c181e9b65 | 214 | void EwPainter::drawString(const char* s, int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 215 | GUI_DispStringAt(s, x, y); |
embeddedartists | 0:316c181e9b65 | 216 | } |
embeddedartists | 0:316c181e9b65 | 217 | |
embeddedartists | 0:316c181e9b65 | 218 | void EwPainter::drawStringClearEOL(const char* s, int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 219 | GUI_DispStringAtCEOL(s, x, y); |
embeddedartists | 0:316c181e9b65 | 220 | } |
embeddedartists | 0:316c181e9b65 | 221 | |
embeddedartists | 0:316c181e9b65 | 222 | void EwPainter::drawStringHorizCenter(const char* s, int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 223 | GUI_DispStringHCenterAt(s, x, y); |
embeddedartists | 0:316c181e9b65 | 224 | } |
embeddedartists | 0:316c181e9b65 | 225 | |
embeddedartists | 0:316c181e9b65 | 226 | void EwPainter::drawStringRect(const char* s, ewRect_t *pRect, ewTextAlign_t align, ewWrapMode_t wrap) { |
embeddedartists | 0:316c181e9b65 | 227 | if (wrap == WrapModeNone) { |
embeddedartists | 0:316c181e9b65 | 228 | GUI_DispStringInRect(s, pRect, align); |
embeddedartists | 0:316c181e9b65 | 229 | } |
embeddedartists | 0:316c181e9b65 | 230 | else { |
embeddedartists | 0:316c181e9b65 | 231 | GUI_DispStringInRectWrap(s, pRect, align, (GUI_WRAPMODE)wrap); |
embeddedartists | 0:316c181e9b65 | 232 | } |
embeddedartists | 0:316c181e9b65 | 233 | } |
embeddedartists | 0:316c181e9b65 | 234 | |
embeddedartists | 0:316c181e9b65 | 235 | void EwPainter::drawStringRect(const char* s, ewRect_t *pRect, ewTextAlign_t align, int32_t maxLen, ewRotation_t rotation) { |
embeddedartists | 0:316c181e9b65 | 236 | |
embeddedartists | 0:316c181e9b65 | 237 | GUI_ROTATION* ewRotation = GUI_ROTATE_0; |
embeddedartists | 0:316c181e9b65 | 238 | switch (rotation) { |
embeddedartists | 0:316c181e9b65 | 239 | case Rotation_0: |
embeddedartists | 0:316c181e9b65 | 240 | break; |
embeddedartists | 0:316c181e9b65 | 241 | case Rotation_180: |
embeddedartists | 0:316c181e9b65 | 242 | ewRotation = GUI_ROTATE_180; |
embeddedartists | 0:316c181e9b65 | 243 | break; |
embeddedartists | 0:316c181e9b65 | 244 | case Rotation_CCW: |
embeddedartists | 0:316c181e9b65 | 245 | ewRotation = GUI_ROTATE_CCW; |
embeddedartists | 0:316c181e9b65 | 246 | break; |
embeddedartists | 0:316c181e9b65 | 247 | case Rotation_CW: |
embeddedartists | 0:316c181e9b65 | 248 | ewRotation = GUI_ROTATE_CW; |
embeddedartists | 0:316c181e9b65 | 249 | break; |
embeddedartists | 0:316c181e9b65 | 250 | } |
embeddedartists | 0:316c181e9b65 | 251 | |
embeddedartists | 0:316c181e9b65 | 252 | GUI_DispStringInRectEx(s, pRect, align, maxLen, ewRotation); |
embeddedartists | 0:316c181e9b65 | 253 | } |
embeddedartists | 0:316c181e9b65 | 254 | |
embeddedartists | 0:316c181e9b65 | 255 | int32_t EwPainter::getNumWrapLines(const char* s, int32_t width, ewWrapMode_t wrap) { |
embeddedartists | 0:316c181e9b65 | 256 | return GUI_WrapGetNumLines(s, width, (GUI_WRAPMODE)wrap); |
embeddedartists | 0:316c181e9b65 | 257 | } |
embeddedartists | 0:316c181e9b65 | 258 | |
embeddedartists | 0:316c181e9b65 | 259 | ewTextMode_t EwPainter::getTextMode() { |
embeddedartists | 0:316c181e9b65 | 260 | return (ewTextMode_t) GUI_GetTextMode(); |
embeddedartists | 0:316c181e9b65 | 261 | } |
embeddedartists | 0:316c181e9b65 | 262 | |
embeddedartists | 0:316c181e9b65 | 263 | void EwPainter::setTextMode(ewTextMode_t mode) { |
embeddedartists | 0:316c181e9b65 | 264 | GUI_SetTextMode(mode); |
embeddedartists | 0:316c181e9b65 | 265 | } |
embeddedartists | 0:316c181e9b65 | 266 | |
embeddedartists | 0:316c181e9b65 | 267 | |
embeddedartists | 0:316c181e9b65 | 268 | void EwPainter::setTextStyle(ewTextStyle_t style) { |
embeddedartists | 0:316c181e9b65 | 269 | GUI_SetTextStyle(style); |
embeddedartists | 0:316c181e9b65 | 270 | } |
embeddedartists | 0:316c181e9b65 | 271 | |
embeddedartists | 0:316c181e9b65 | 272 | ewTextAlign_t EwPainter::getTextAlign() { |
embeddedartists | 0:316c181e9b65 | 273 | return (ewTextAlign_t) GUI_GetTextAlign(); |
embeddedartists | 0:316c181e9b65 | 274 | } |
embeddedartists | 0:316c181e9b65 | 275 | |
embeddedartists | 0:316c181e9b65 | 276 | void EwPainter::setTextAlign(ewTextAlign_t align) { |
embeddedartists | 0:316c181e9b65 | 277 | GUI_SetTextAlign(align); |
embeddedartists | 0:316c181e9b65 | 278 | } |
embeddedartists | 0:316c181e9b65 | 279 | |
embeddedartists | 0:316c181e9b65 | 280 | bool EwPainter::setTextPosition(int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 281 | return (GUI_GotoXY(x, y) == 0); |
embeddedartists | 0:316c181e9b65 | 282 | } |
embeddedartists | 0:316c181e9b65 | 283 | |
embeddedartists | 0:316c181e9b65 | 284 | void EwPainter::getTextPosition(int32_t &x, int32_t &y) { |
embeddedartists | 0:316c181e9b65 | 285 | x = GUI_GetDispPosX(); |
embeddedartists | 0:316c181e9b65 | 286 | y = GUI_GetDispPosY(); |
embeddedartists | 0:316c181e9b65 | 287 | } |
embeddedartists | 0:316c181e9b65 | 288 | |
embeddedartists | 0:316c181e9b65 | 289 | const ewFont_t* EwPainter::setFont(const ewFont_t* pFont) { |
embeddedartists | 0:316c181e9b65 | 290 | return GUI_SetFont(pFont); |
embeddedartists | 0:316c181e9b65 | 291 | } |
embeddedartists | 0:316c181e9b65 | 292 | |
embeddedartists | 0:316c181e9b65 | 293 | const ewFont_t* EwPainter::getFont() { |
embeddedartists | 0:316c181e9b65 | 294 | return GUI_GetFont(); |
embeddedartists | 0:316c181e9b65 | 295 | } |
embeddedartists | 0:316c181e9b65 | 296 | |
embeddedartists | 0:316c181e9b65 | 297 | int32_t EwPainter::getCharWidth(uint16_t c) { |
embeddedartists | 0:316c181e9b65 | 298 | return GUI_GetCharDistX(c); |
embeddedartists | 0:316c181e9b65 | 299 | } |
embeddedartists | 0:316c181e9b65 | 300 | |
embeddedartists | 0:316c181e9b65 | 301 | int32_t EwPainter::getFontHeight() { |
embeddedartists | 0:316c181e9b65 | 302 | return GUI_GetFontSizeY(); |
embeddedartists | 0:316c181e9b65 | 303 | } |
embeddedartists | 0:316c181e9b65 | 304 | |
embeddedartists | 0:316c181e9b65 | 305 | int32_t EwPainter::getFontDistY() { |
embeddedartists | 0:316c181e9b65 | 306 | return GUI_GetFontDistY(); |
embeddedartists | 0:316c181e9b65 | 307 | } |
embeddedartists | 0:316c181e9b65 | 308 | |
embeddedartists | 0:316c181e9b65 | 309 | int32_t EwPainter::getLeadingBlankCols(uint16_t c) { |
embeddedartists | 0:316c181e9b65 | 310 | return GUI_GetLeadingBlankCols(c); |
embeddedartists | 0:316c181e9b65 | 311 | } |
embeddedartists | 0:316c181e9b65 | 312 | |
embeddedartists | 0:316c181e9b65 | 313 | int32_t EwPainter::getTrailingBlankCols(uint16_t c) { |
embeddedartists | 0:316c181e9b65 | 314 | return GUI_GetTrailingBlankCols(c); |
embeddedartists | 0:316c181e9b65 | 315 | } |
embeddedartists | 0:316c181e9b65 | 316 | |
embeddedartists | 0:316c181e9b65 | 317 | int32_t EwPainter::getStringWidth(const char* s) { |
embeddedartists | 0:316c181e9b65 | 318 | return GUI_GetStringDistX(s); |
embeddedartists | 0:316c181e9b65 | 319 | } |
embeddedartists | 0:316c181e9b65 | 320 | |
embeddedartists | 0:316c181e9b65 | 321 | bool EwPainter::isCharInFont(const ewFont_t* pFont, uint16_t c) { |
embeddedartists | 0:316c181e9b65 | 322 | return (GUI_IsInFont(pFont, c) == 1); |
embeddedartists | 0:316c181e9b65 | 323 | } |
embeddedartists | 0:316c181e9b65 | 324 | |
embeddedartists | 0:316c181e9b65 | 325 | void EwPainter::drawBitmap(const ewBitmap_t* pBm, int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 326 | GUI_DrawBitmap(pBm, x, y); |
embeddedartists | 0:316c181e9b65 | 327 | } |
embeddedartists | 0:316c181e9b65 | 328 | |
embeddedartists | 0:316c181e9b65 | 329 | void EwPainter::drawBitmapMagnified(const ewBitmap_t* pBm, int32_t x, int32_t y, int32_t xMul, int32_t yMul) { |
embeddedartists | 0:316c181e9b65 | 330 | GUI_DrawBitmapMag(pBm, x, y, xMul, yMul); |
embeddedartists | 0:316c181e9b65 | 331 | } |
embeddedartists | 0:316c181e9b65 | 332 | |
embeddedartists | 0:316c181e9b65 | 333 | void EwPainter::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 | 334 | GUI_DrawBitmapEx(pBm, x, y, xCenter, yCenter, xMag, yMag); |
embeddedartists | 0:316c181e9b65 | 335 | } |
embeddedartists | 0:316c181e9b65 | 336 | |
embeddedartists | 0:316c181e9b65 | 337 | void EwPainter::drawJpeg(const void* pData, int32_t dataSize, int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 338 | GUI_JPEG_Draw(pData, dataSize, x, y); |
embeddedartists | 0:316c181e9b65 | 339 | } |
embeddedartists | 0:316c181e9b65 | 340 | |
embeddedartists | 0:316c181e9b65 | 341 | void EwPainter::drawJpegScaled(const void* pData, int32_t dataSize, int32_t x, int32_t y, int32_t num, int32_t denom) { |
embeddedartists | 0:316c181e9b65 | 342 | GUI_JPEG_DrawScaled(pData, dataSize, x, y, num, denom); |
embeddedartists | 0:316c181e9b65 | 343 | } |
embeddedartists | 0:316c181e9b65 | 344 | |
embeddedartists | 0:316c181e9b65 | 345 | void EwPainter::getJpegSize(const void* pData, int32_t dataSize, int32_t &width, int32_t &height) { |
embeddedartists | 0:316c181e9b65 | 346 | GUI_JPEG_INFO info; |
embeddedartists | 0:316c181e9b65 | 347 | GUI_JPEG_GetInfo(pData, dataSize, &info); |
embeddedartists | 0:316c181e9b65 | 348 | |
embeddedartists | 0:316c181e9b65 | 349 | width = info.XSize; |
embeddedartists | 0:316c181e9b65 | 350 | height = info.YSize; |
embeddedartists | 0:316c181e9b65 | 351 | } |
embeddedartists | 0:316c181e9b65 | 352 | |
embeddedartists | 0:316c181e9b65 | 353 | void EwPainter::drawGif(const void* pData, int32_t dataSize, int32_t x, int32_t y, int32_t imgIdx) { |
embeddedartists | 0:316c181e9b65 | 354 | if (imgIdx < 0) { |
embeddedartists | 0:316c181e9b65 | 355 | GUI_GIF_Draw(pData, dataSize, x, y); |
embeddedartists | 0:316c181e9b65 | 356 | } |
embeddedartists | 0:316c181e9b65 | 357 | else { |
embeddedartists | 0:316c181e9b65 | 358 | GUI_GIF_DrawSub(pData, dataSize, x, y, imgIdx); |
embeddedartists | 0:316c181e9b65 | 359 | } |
embeddedartists | 0:316c181e9b65 | 360 | } |
embeddedartists | 0:316c181e9b65 | 361 | |
embeddedartists | 0:316c181e9b65 | 362 | void EwPainter::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 | 363 | GUI_GIF_DrawSubScaled(pData, dataSize, x, y, imgIdx, num, denom); |
embeddedartists | 0:316c181e9b65 | 364 | } |
embeddedartists | 0:316c181e9b65 | 365 | |
embeddedartists | 0:316c181e9b65 | 366 | void EwPainter::getGifSize(const void* pData, int32_t dataSize, int32_t &width, int32_t &height) { |
embeddedartists | 0:316c181e9b65 | 367 | width = GUI_GIF_GetXSize(pData); |
embeddedartists | 0:316c181e9b65 | 368 | height = GUI_GIF_GetYSize(pData); |
embeddedartists | 0:316c181e9b65 | 369 | } |
embeddedartists | 0:316c181e9b65 | 370 | |
embeddedartists | 0:316c181e9b65 | 371 | int32_t EwPainter::getGifNumImages(const void* pData, int32_t dataSize) { |
embeddedartists | 0:316c181e9b65 | 372 | GUI_GIF_INFO info; |
embeddedartists | 0:316c181e9b65 | 373 | GUI_GIF_GetInfo(pData, dataSize, &info); |
embeddedartists | 0:316c181e9b65 | 374 | |
embeddedartists | 0:316c181e9b65 | 375 | return info.NumImages; |
embeddedartists | 0:316c181e9b65 | 376 | } |
embeddedartists | 0:316c181e9b65 | 377 | |
embeddedartists | 0:316c181e9b65 | 378 | void EwPainter::drawPng(const void* pData, int32_t dataSize, int32_t x, int32_t y) { |
embeddedartists | 0:316c181e9b65 | 379 | GUI_PNG_Draw(pData, dataSize, x, y); |
embeddedartists | 0:316c181e9b65 | 380 | } |
embeddedartists | 0:316c181e9b65 | 381 | |
embeddedartists | 0:316c181e9b65 | 382 | void EwPainter::getPngSize(const void* pData, int32_t dataSize, int32_t &width, int32_t &height) { |
embeddedartists | 0:316c181e9b65 | 383 | width = GUI_PNG_GetXSize(pData, dataSize); |
embeddedartists | 0:316c181e9b65 | 384 | height = GUI_PNG_GetYSize(pData, dataSize);; |
embeddedartists | 0:316c181e9b65 | 385 | } |
embeddedartists | 0:316c181e9b65 | 386 | |
embeddedartists | 0:316c181e9b65 | 387 | |
embeddedartists | 0:316c181e9b65 | 388 | void EwPainter::saveContext() { |
embeddedartists | 0:316c181e9b65 | 389 | GUI_SaveContext_W(&_context); |
embeddedartists | 0:316c181e9b65 | 390 | _contextSaved = true; |
embeddedartists | 0:316c181e9b65 | 391 | } |
embeddedartists | 0:316c181e9b65 | 392 | |
embeddedartists | 0:316c181e9b65 | 393 | void EwPainter::restoreContext() { |
embeddedartists | 0:316c181e9b65 | 394 | if (!_contextSaved) return; |
embeddedartists | 0:316c181e9b65 | 395 | |
embeddedartists | 0:316c181e9b65 | 396 | GUI_RestoreContext(&_context); |
embeddedartists | 0:316c181e9b65 | 397 | |
embeddedartists | 0:316c181e9b65 | 398 | _contextSaved = false; |
embeddedartists | 0:316c181e9b65 | 399 | } |
embeddedartists | 0:316c181e9b65 | 400 | |
embeddedartists | 0:316c181e9b65 | 401 |