13 #include "../../gfx.h" 15 #if GFX_USE_GWIN && GWIN_NEED_BUTTON 17 #include "gwin_class.h" 20 #define BTN_CNR_SIZE 5 // Rounded corner size for rounded buttons 21 #define BTN_ARROWHEAD_DIV 0 // What fraction of the length for the arrow head. Use 0 for 45 degree arrow head. 22 #define BTN_ARROWBODY_DIV 2 // What fraction of the width for the arrow body 23 #define BTN_TOP_FADE 50 // (BTN_TOP_FADE/255)% fade to white for top of button 24 #define BTN_BOTTOM_FADE 25 // (BTN_BOTTOM_FADE/255)% fade to black for bottom of button 40 #if !GWIN_BUTTON_LAZY_RELEASE 50 #if GINPUT_NEED_KEYBOARD || GWIN_NEED_KEYBOARD 51 static void ButtonKeyboard(
GWidgetObject* gw, GEventKeyboard* pke)
54 if (pke->c[0] == GKEY_ENTER || pke->c[0] == GKEY_SPACE) {
61 if (!(pke->keystate & GKEYSTATE_KEYUP))
68 #if GINPUT_NEED_TOGGLE 70 static void ButtonToggleOff(
GWidgetObject *gw, uint16_t role) {
77 static void ButtonToggleOn(
GWidgetObject *gw, uint16_t role) {
85 static void ButtonToggleAssign(
GWidgetObject *gw, uint16_t role, uint16_t instance) {
90 static uint16_t ButtonToggleGet(
GWidgetObject *gw, uint16_t role) {
113 #if GINPUT_NEED_KEYBOARD || GWIN_NEED_KEYBOARD 118 #if GINPUT_NEED_TOGGLE 138 if (!(gw = (
GButtonObject *)_gwidgetCreate(g, &gw->w, pInit, &buttonVMT)))
141 #if GINPUT_NEED_TOGGLE 142 gw->toggle = GWIDGET_NO_INSTANCE;
165 #if GWIN_FLAT_STYLING 172 pcol = getButtonColors(gw);
179 _gwidgetDrawFocusRect(gw, 1, 1, gw->
g.
width-2, gw->
g.
height-2);
192 pcol = getButtonColors(gw);
198 for(alpha = 0, i = 0; i < gw->
g.
height; i++, alpha += dalpha)
206 _gwidgetDrawFocusRect(gw, 0, 0, gw->
g.
width-1, gw->
g.
height-1);
217 pcol = getButtonColors(gw);
220 if (gw->
g.
width >= 2*BTN_CNR_SIZE+10) {
231 #if GDISP_NEED_ELLIPSE 238 pcol = getButtonColors(gw);
247 #if GDISP_NEED_CONVEX_POLYGON 255 pcol = getButtonColors(gw);
261 #if BTN_ARROWHEAD_DIV == 0 264 arw[1].
x = arw[0].
x+arw[3].
y;
266 arw[4].
x = arw[0].
x-arw[3].
y;
270 arw[1].
x = arw[0].
x << 1;
271 arw[2].
x = arw[0].
x + arw[0].
x/BTN_ARROWBODY_DIV;
272 arw[4].
x = arw[0].
x - arw[0].
x/BTN_ARROWBODY_DIV;
276 arw[1].
y = gw->
g.
height/BTN_ARROWHEAD_DIV;
277 arw[1].
x = arw[0].
x << 1;
278 arw[2].
x = arw[0].
x + arw[0].
x/BTN_ARROWBODY_DIV;
279 arw[4].
x = arw[0].
x - arw[0].
x/BTN_ARROWBODY_DIV;
289 arw[5].
x = arw[4].
x; arw[5].
y = arw[1].
y;
306 pcol = getButtonColors(gw);
312 #if BTN_ARROWHEAD_DIV == 0 315 arw[1].
x = arw[0].
x+arw[0].
y;
317 arw[4].
x = arw[0].
x-arw[0].
y;
320 arw[1].
y = arw[0].
y - arw[0].
x;
321 arw[1].
x = arw[0].
x << 1;
322 arw[2].
x = arw[0].
x + arw[0].
x/BTN_ARROWBODY_DIV;
323 arw[4].
x = arw[0].
x - arw[0].
x/BTN_ARROWBODY_DIV;
327 arw[1].
y = arw[0].
y - gw->
g.
height/BTN_ARROWHEAD_DIV;
328 arw[1].
x = arw[0].
x << 1;
329 arw[2].
x = arw[0].
x + arw[0].
x/BTN_ARROWBODY_DIV;
330 arw[4].
x = arw[0].
x - arw[0].
x/BTN_ARROWBODY_DIV;
340 arw[5].
x = arw[4].
x; arw[5].
y = arw[1].
y;
357 pcol = getButtonColors(gw);
363 #if BTN_ARROWHEAD_DIV == 0 366 arw[1].
y = arw[0].
y+arw[3].
x;
368 arw[4].
y = arw[0].
y-arw[3].
x;
372 arw[1].
y = arw[0].
y << 1;
373 arw[2].
y = arw[0].
y + arw[0].
y/BTN_ARROWBODY_DIV;
374 arw[4].
y = arw[0].
y - arw[0].
y/BTN_ARROWBODY_DIV;
378 arw[1].
x = gw->
g.
width/BTN_ARROWHEAD_DIV;
379 arw[1].
y = arw[0].
y << 1;
380 arw[2].
y = arw[0].
y + arw[0].
y/BTN_ARROWBODY_DIV;
381 arw[4].
y = arw[0].
y - arw[0].
y/BTN_ARROWBODY_DIV;
391 arw[5].
x = arw[1].
x; arw[5].
y = arw[4].
y;
408 pcol = getButtonColors(gw);
414 #if BTN_ARROWHEAD_DIV == 0 417 arw[1].
y = arw[0].
y+arw[0].
x;
419 arw[4].
y = arw[0].
y-arw[0].
x;
422 arw[1].
x = arw[0].
x - arw[0].
y;
423 arw[1].
y = arw[0].
y << 1;
424 arw[2].
y = arw[0].
y + arw[0].
y/BTN_ARROWBODY_DIV;
425 arw[4].
y = arw[0].
y - arw[0].
y/BTN_ARROWBODY_DIV;
429 arw[1].
x = arw[0].
x - gw->
g.
width/BTN_ARROWHEAD_DIV;
430 arw[1].
y = arw[0].
y << 1;
431 arw[2].
y = arw[0].
y + arw[0].
y/BTN_ARROWBODY_DIV;
432 arw[4].
y = arw[0].
y - arw[0].
y/BTN_ARROWBODY_DIV;
442 arw[5].
x = arw[1].
x; arw[5].
y = arw[4].
y;
453 #if GDISP_NEED_IMAGE || defined(__DOXYGEN__) 459 pcol = getButtonColors(gw);
461 if (!(gw->
g.
flags & GWIN_FLG_SYSENABLED)) {
void gdispGFillStringBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, const char *str, font_t font, color_t color, color_t bgColor, justify_t justify)
Draw a text string vertically centered within the specified box. The box background is filled with th...
void gdispGDrawEllipse(GDisplay *g, coord_t x, coord_t y, coord_t a, coord_t b, color_t color)
Draw an ellipse.
color_t gdispBlendColor(color_t fg, color_t bg, uint8_t alpha)
Blend 2 colors according to the alpha.
const struct gwinVMT * vmt
int16_t coord_t
The type for a coordinate or length on the screen.
void gdispGFillConvexPoly(GDisplay *g, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color)
Fill a convex polygon.
int32_t fixed
The type for a fixed point type.
void gdispGDrawPoly(GDisplay *g, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color)
Draw an enclosed polygon (convex, non-convex or complex).
#define GINPUT_NEED_MOUSE
Should mouse/touch functions be included.
#define FALSE
Generic 'false' boolean constant.
void gdispGFillEllipse(GDisplay *g, coord_t x, coord_t y, coord_t a, coord_t b, color_t color)
Draw a filled ellipse.
void gdispGDrawLine(GDisplay *g, coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color)
Draw a line.
void gdispGFillArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color)
Fill an area with a color.
void gwinSetVisible(GHandle gh, bool_t visible)
Sets whether a window is visible or not.
void gdispGDrawRoundedBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t radius, color_t color)
Draw a rectangular box with rounded corners.
void gdispGDrawStringBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, const char *str, font_t font, color_t color, justify_t justify)
Draw a text string vertically centered within the specified box.
#define FIXED(x)
Macros to convert to and from a fixed point.
Type for a 2D point on the screen.
gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy)
Draw the image.
void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color)
Draw a rectangular box.
The structure for an image.
The Virtual Method Table for a GWIN window.
A window object structure.
COLOR_TYPE color_t
The color type definition.
#define TRUE
Generic 'true' boolean constant.
void gdispGFillRoundedBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t radius, color_t color)
Draw a filled rectangular box with rounded corners.