2013-03-02 12:20:57 +00:00
|
|
|
/*
|
2013-06-15 11:09:02 +00:00
|
|
|
* This file is subject to the terms of the GFX License. If a copy of
|
2013-05-03 14:36:17 +00:00
|
|
|
* the license was not distributed with this file, you can obtain one at:
|
2013-03-02 12:20:57 +00:00
|
|
|
*
|
2013-07-21 20:20:37 +00:00
|
|
|
* http://ugfx.org/license.html
|
2013-03-02 12:20:57 +00:00
|
|
|
*/
|
|
|
|
|
2013-05-06 04:44:47 +00:00
|
|
|
/**
|
|
|
|
* @file src/gwin/button.c
|
2014-05-20 16:05:38 +00:00
|
|
|
* @brief GWIN sub-system button code
|
2013-05-06 04:44:47 +00:00
|
|
|
*/
|
|
|
|
|
2013-03-02 12:20:57 +00:00
|
|
|
#include "gfx.h"
|
|
|
|
|
2013-07-05 15:45:24 +00:00
|
|
|
#if GFX_USE_GWIN && GWIN_NEED_BUTTON
|
2013-03-02 12:20:57 +00:00
|
|
|
|
2014-02-18 14:36:52 +00:00
|
|
|
#include "src/gwin/class_gwin.h"
|
2013-06-06 04:33:32 +00:00
|
|
|
|
|
|
|
// Parameters for various shapes
|
2013-03-10 06:15:49 +00:00
|
|
|
#define RND_CNR_SIZE 5 // Rounded corner size for rounded buttons
|
|
|
|
#define ARROWHEAD_DIVIDER 4 // A quarter of the height for the arrow head
|
|
|
|
#define ARROWBODY_DIVIDER 4 // A quarter of the width for the arrow body
|
2014-05-01 06:44:11 +00:00
|
|
|
#define TOP_FADE 50 // (TOP_FADE/255)% fade to white for top of button
|
|
|
|
#define BOTTOM_FADE 25 // (BOTTOM_FADE/255)% fade to black for bottom of button
|
2013-03-10 06:15:49 +00:00
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
// Our pressed state
|
|
|
|
#define GBUTTON_FLG_PRESSED (GWIN_FIRST_CONTROL_FLAG<<0)
|
|
|
|
|
|
|
|
// Send the button event
|
|
|
|
static void SendButtonEvent(GWidgetObject *gw) {
|
|
|
|
GSourceListener * psl;
|
|
|
|
GEvent * pe;
|
|
|
|
#define pbe ((GEventGWinButton *)pe)
|
2013-03-02 12:20:57 +00:00
|
|
|
|
|
|
|
// Trigger a GWIN Button Event
|
|
|
|
psl = 0;
|
2013-06-10 07:18:01 +00:00
|
|
|
while ((psl = geventGetSourceListener(GWIDGET_SOURCE, psl))) {
|
2013-03-02 12:20:57 +00:00
|
|
|
if (!(pe = geventGetEventBuffer(psl)))
|
|
|
|
continue;
|
|
|
|
pbe->type = GEVENT_GWIN_BUTTON;
|
2013-06-06 04:33:32 +00:00
|
|
|
pbe->button = (GHandle)gw;
|
2013-03-02 12:20:57 +00:00
|
|
|
geventSendEvent(psl);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef pbe
|
|
|
|
}
|
|
|
|
|
2013-07-05 15:45:24 +00:00
|
|
|
#if GINPUT_NEED_MOUSE
|
|
|
|
// A mouse down has occurred over the button
|
|
|
|
static void MouseDown(GWidgetObject *gw, coord_t x, coord_t y) {
|
|
|
|
(void) x; (void) y;
|
|
|
|
gw->g.flags |= GBUTTON_FLG_PRESSED;
|
2014-05-09 15:11:30 +00:00
|
|
|
_gwidgetUpdate((GHandle)gw);
|
2013-07-05 15:45:24 +00:00
|
|
|
}
|
2013-03-02 12:20:57 +00:00
|
|
|
|
2013-07-05 15:45:24 +00:00
|
|
|
// A mouse up has occurred (it may or may not be over the button)
|
|
|
|
static void MouseUp(GWidgetObject *gw, coord_t x, coord_t y) {
|
|
|
|
(void) x; (void) y;
|
|
|
|
gw->g.flags &= ~GBUTTON_FLG_PRESSED;
|
2014-05-09 15:11:30 +00:00
|
|
|
_gwidgetUpdate((GHandle)gw);
|
2013-03-02 12:20:57 +00:00
|
|
|
|
2013-07-05 15:45:24 +00:00
|
|
|
#if !GWIN_BUTTON_LAZY_RELEASE
|
|
|
|
// If the mouse up was not over the button then cancel the event
|
|
|
|
if (x < 0 || y < 0 || x >= gw->g.width || y >= gw->g.height)
|
|
|
|
return;
|
|
|
|
#endif
|
2013-03-02 12:20:57 +00:00
|
|
|
|
2013-07-05 15:45:24 +00:00
|
|
|
SendButtonEvent(gw);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if GINPUT_NEED_TOGGLE
|
|
|
|
// A toggle off has occurred
|
|
|
|
static void ToggleOff(GWidgetObject *gw, uint16_t role) {
|
|
|
|
(void) role;
|
|
|
|
gw->g.flags &= ~GBUTTON_FLG_PRESSED;
|
2014-05-09 15:11:30 +00:00
|
|
|
_gwidgetUpdate((GHandle)gw);
|
2013-07-05 15:45:24 +00:00
|
|
|
}
|
2013-03-02 12:20:57 +00:00
|
|
|
|
2013-07-05 15:45:24 +00:00
|
|
|
// A toggle on has occurred
|
|
|
|
static void ToggleOn(GWidgetObject *gw, uint16_t role) {
|
|
|
|
(void) role;
|
|
|
|
gw->g.flags |= GBUTTON_FLG_PRESSED;
|
2014-05-09 15:11:30 +00:00
|
|
|
_gwidgetUpdate((GHandle)gw);
|
2013-07-05 15:45:24 +00:00
|
|
|
// Trigger the event on button down (different than for mouse/touch)
|
|
|
|
SendButtonEvent(gw);
|
|
|
|
}
|
2013-03-02 12:20:57 +00:00
|
|
|
|
2013-07-05 15:45:24 +00:00
|
|
|
static void ToggleAssign(GWidgetObject *gw, uint16_t role, uint16_t instance) {
|
|
|
|
(void) role;
|
|
|
|
((GButtonObject *)gw)->toggle = instance;
|
|
|
|
}
|
2013-03-10 06:15:49 +00:00
|
|
|
|
2013-07-05 15:45:24 +00:00
|
|
|
static uint16_t ToggleGet(GWidgetObject *gw, uint16_t role) {
|
|
|
|
(void) role;
|
|
|
|
return ((GButtonObject *)gw)->toggle;
|
|
|
|
}
|
|
|
|
#endif
|
2013-06-10 07:18:01 +00:00
|
|
|
|
2013-07-05 15:45:24 +00:00
|
|
|
// The button VMT table
|
|
|
|
static const gwidgetVMT buttonVMT = {
|
|
|
|
{
|
|
|
|
"Button", // The classname
|
|
|
|
sizeof(GButtonObject), // The object size
|
|
|
|
_gwidgetDestroy, // The destroy routine
|
|
|
|
_gwidgetRedraw, // The redraw routine
|
|
|
|
0, // The after-clear routine
|
|
|
|
},
|
2014-05-01 03:57:44 +00:00
|
|
|
gwinButtonDraw_Normal, // The default drawing routine
|
2013-07-05 15:45:24 +00:00
|
|
|
#if GINPUT_NEED_MOUSE
|
|
|
|
{
|
|
|
|
MouseDown, // Process mouse down events
|
|
|
|
MouseUp, // Process mouse up events
|
|
|
|
0, // Process mouse move events (NOT USED)
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
#if GINPUT_NEED_TOGGLE
|
|
|
|
{
|
|
|
|
1, // 1 toggle role
|
|
|
|
ToggleAssign, // Assign Toggles
|
|
|
|
ToggleGet, // Get Toggles
|
|
|
|
ToggleOff, // Process toggle off events
|
|
|
|
ToggleOn, // Process toggle on events
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
#if GINPUT_NEED_DIAL
|
|
|
|
{
|
|
|
|
0, // No dial roles
|
|
|
|
0, // Assign Dials (NOT USED)
|
|
|
|
0, // Get Dials (NOT USED)
|
|
|
|
0, // Process dial move events (NOT USED)
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
};
|
2013-06-10 07:18:01 +00:00
|
|
|
|
2013-10-24 08:36:11 +00:00
|
|
|
GHandle gwinGButtonCreate(GDisplay *g, GButtonObject *gw, const GWidgetInit *pInit) {
|
|
|
|
if (!(gw = (GButtonObject *)_gwidgetCreate(g, &gw->w, pInit, &buttonVMT)))
|
2013-06-06 04:33:32 +00:00
|
|
|
return 0;
|
2013-03-10 06:15:49 +00:00
|
|
|
|
2013-07-05 15:45:24 +00:00
|
|
|
#if GINPUT_NEED_TOGGLE
|
|
|
|
gw->toggle = GWIDGET_NO_INSTANCE;
|
|
|
|
#endif
|
2013-06-24 12:58:37 +00:00
|
|
|
gwinSetVisible((GHandle)gw, pInit->g.show);
|
2013-06-06 04:33:32 +00:00
|
|
|
return (GHandle)gw;
|
2013-03-10 06:15:49 +00:00
|
|
|
}
|
|
|
|
|
2013-07-07 09:40:37 +00:00
|
|
|
bool_t gwinButtonIsPressed(GHandle gh) {
|
2013-06-06 04:33:32 +00:00
|
|
|
if (gh->vmt != (gwinVMT *)&buttonVMT)
|
|
|
|
return FALSE;
|
2013-03-10 06:15:49 +00:00
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
return (gh->flags & GBUTTON_FLG_PRESSED) ? TRUE : FALSE;
|
2013-03-10 06:15:49 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
/*----------------------------------------------------------
|
|
|
|
* Custom Draw Routines
|
|
|
|
*----------------------------------------------------------*/
|
2013-05-20 05:01:20 +00:00
|
|
|
|
2013-07-07 09:40:37 +00:00
|
|
|
static const GColorSet *getDrawColors(GWidgetObject *gw) {
|
2014-05-09 15:11:30 +00:00
|
|
|
if (!(gw->g.flags & GWIN_FLG_SYSENABLED)) return &gw->pstyle->disabled;
|
2013-07-07 09:40:37 +00:00
|
|
|
if ((gw->g.flags & GBUTTON_FLG_PRESSED)) return &gw->pstyle->pressed;
|
|
|
|
return &gw->pstyle->enabled;
|
2013-05-20 05:01:20 +00:00
|
|
|
}
|
|
|
|
|
2014-05-01 03:57:44 +00:00
|
|
|
#if GWIN_FLAT_STYLING
|
|
|
|
void gwinButtonDraw_Normal(GWidgetObject *gw, void *param) {
|
|
|
|
const GColorSet * pcol;
|
|
|
|
(void) param;
|
2013-03-10 06:15:49 +00:00
|
|
|
|
2014-05-01 03:57:44 +00:00
|
|
|
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
|
|
|
|
pcol = getDrawColors(gw);
|
|
|
|
|
|
|
|
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
|
|
|
|
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
|
|
|
|
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
void gwinButtonDraw_Normal(GWidgetObject *gw, void *param) {
|
|
|
|
const GColorSet * pcol;
|
|
|
|
fixed alpha;
|
|
|
|
fixed dalpha;
|
|
|
|
coord_t i;
|
|
|
|
color_t tcol, bcol;
|
|
|
|
(void) param;
|
|
|
|
|
|
|
|
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
|
|
|
|
pcol = getDrawColors(gw);
|
2013-06-06 04:33:32 +00:00
|
|
|
|
2014-05-01 03:57:44 +00:00
|
|
|
/* Fill the box blended from variants of the fill color */
|
2014-05-01 06:44:11 +00:00
|
|
|
tcol = gdispBlendColor(White, pcol->fill, TOP_FADE);
|
|
|
|
bcol = gdispBlendColor(Black, pcol->fill, BOTTOM_FADE);
|
2014-05-01 03:57:44 +00:00
|
|
|
dalpha = FIXED(255)/gw->g.height;
|
|
|
|
for(alpha = 0, i = 0; i < gw->g.height; i++, alpha += dalpha)
|
|
|
|
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+i, gw->g.x+gw->g.width-2, gw->g.y+i, gdispBlendColor(bcol, tcol, NONFIXED(alpha)));
|
|
|
|
|
|
|
|
gdispGDrawStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, justifyCenter);
|
|
|
|
gdispGDrawLine(gw->g.display, gw->g.x+gw->g.width-1, gw->g.y, gw->g.x+gw->g.width-1, gw->g.y+gw->g.height-1, pcol->edge);
|
|
|
|
gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gw->g.height-1, gw->g.x+gw->g.width-2, gw->g.y+gw->g.height-1, pcol->edge);
|
|
|
|
}
|
|
|
|
#endif
|
2013-03-10 06:15:49 +00:00
|
|
|
|
2013-03-02 12:20:57 +00:00
|
|
|
#if GDISP_NEED_ARC
|
2013-06-06 04:33:32 +00:00
|
|
|
void gwinButtonDraw_Rounded(GWidgetObject *gw, void *param) {
|
2013-07-07 09:40:37 +00:00
|
|
|
const GColorSet * pcol;
|
|
|
|
(void) param;
|
2013-06-06 04:33:32 +00:00
|
|
|
|
|
|
|
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
|
|
|
|
pcol = getDrawColors(gw);
|
|
|
|
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
|
2013-06-06 04:33:32 +00:00
|
|
|
if (gw->g.width >= 2*RND_CNR_SIZE+10) {
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillRoundedBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, RND_CNR_SIZE-1, pcol->fill);
|
|
|
|
gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+RND_CNR_SIZE, gw->g.width-2, gw->g.height-(2*RND_CNR_SIZE), gw->text, gw->g.font, pcol->text, justifyCenter);
|
|
|
|
gdispGDrawRoundedBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, RND_CNR_SIZE, pcol->edge);
|
2013-03-10 06:15:49 +00:00
|
|
|
} else {
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter);
|
|
|
|
gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, pcol->edge);
|
2013-03-02 12:20:57 +00:00
|
|
|
}
|
2013-03-10 06:15:49 +00:00
|
|
|
}
|
2013-03-02 12:20:57 +00:00
|
|
|
#endif
|
2013-03-10 06:15:49 +00:00
|
|
|
|
2013-03-02 12:20:57 +00:00
|
|
|
#if GDISP_NEED_ELLIPSE
|
2013-06-06 04:33:32 +00:00
|
|
|
void gwinButtonDraw_Ellipse(GWidgetObject *gw, void *param) {
|
2013-07-07 09:40:37 +00:00
|
|
|
const GColorSet * pcol;
|
|
|
|
(void) param;
|
2013-06-06 04:33:32 +00:00
|
|
|
|
|
|
|
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
|
|
|
|
pcol = getDrawColors(gw);
|
|
|
|
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
|
|
|
|
gdispGFillEllipse(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width/2-1, gw->g.height/2-1, pcol->fill);
|
|
|
|
gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
|
|
|
|
gdispGDrawEllipse(gw->g.display, gw->g.x, gw->g.y, gw->g.width/2, gw->g.height/2, pcol->edge);
|
2013-03-10 06:15:49 +00:00
|
|
|
}
|
2013-03-02 12:20:57 +00:00
|
|
|
#endif
|
2013-03-10 06:15:49 +00:00
|
|
|
|
|
|
|
#if GDISP_NEED_CONVEX_POLYGON
|
2013-06-06 04:33:32 +00:00
|
|
|
void gwinButtonDraw_ArrowUp(GWidgetObject *gw, void *param) {
|
2013-07-07 09:40:37 +00:00
|
|
|
const GColorSet * pcol;
|
|
|
|
(void) param;
|
|
|
|
point arw[7];
|
2013-06-06 04:33:32 +00:00
|
|
|
|
|
|
|
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
|
|
|
|
pcol = getDrawColors(gw);
|
|
|
|
|
|
|
|
arw[0].x = gw->g.width/2; arw[0].y = 0;
|
|
|
|
arw[1].x = gw->g.width-1; arw[1].y = gw->g.height/ARROWHEAD_DIVIDER;
|
|
|
|
arw[2].x = (gw->g.width + gw->g.width/ARROWBODY_DIVIDER)/2; arw[2].y = gw->g.height/ARROWHEAD_DIVIDER;
|
|
|
|
arw[3].x = (gw->g.width + gw->g.width/ARROWBODY_DIVIDER)/2; arw[3].y = gw->g.height-1;
|
|
|
|
arw[4].x = (gw->g.width - gw->g.width/ARROWBODY_DIVIDER)/2; arw[4].y = gw->g.height-1;
|
|
|
|
arw[5].x = (gw->g.width - gw->g.width/ARROWBODY_DIVIDER)/2; arw[5].y = gw->g.height/ARROWHEAD_DIVIDER;
|
|
|
|
arw[6].x = 0; arw[6].y = gw->g.height/ARROWHEAD_DIVIDER;
|
|
|
|
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
|
|
|
|
gdispGFillConvexPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->fill);
|
|
|
|
gdispGDrawPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->edge);
|
|
|
|
gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
|
2013-03-02 12:20:57 +00:00
|
|
|
}
|
2013-03-10 06:15:49 +00:00
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
void gwinButtonDraw_ArrowDown(GWidgetObject *gw, void *param) {
|
2013-07-07 09:40:37 +00:00
|
|
|
const GColorSet * pcol;
|
|
|
|
(void) param;
|
|
|
|
point arw[7];
|
2013-06-06 04:33:32 +00:00
|
|
|
|
|
|
|
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
|
|
|
|
pcol = getDrawColors(gw);
|
|
|
|
|
|
|
|
arw[0].x = gw->g.width/2; arw[0].y = gw->g.height-1;
|
|
|
|
arw[1].x = gw->g.width-1; arw[1].y = gw->g.height-1-gw->g.height/ARROWHEAD_DIVIDER;
|
|
|
|
arw[2].x = (gw->g.width + gw->g.width/ARROWBODY_DIVIDER)/2; arw[2].y = gw->g.height-1-gw->g.height/ARROWHEAD_DIVIDER;
|
|
|
|
arw[3].x = (gw->g.width + gw->g.width/ARROWBODY_DIVIDER)/2; arw[3].y = 0;
|
|
|
|
arw[4].x = (gw->g.width - gw->g.width/ARROWBODY_DIVIDER)/2; arw[4].y = 0;
|
|
|
|
arw[5].x = (gw->g.width - gw->g.width/ARROWBODY_DIVIDER)/2; arw[5].y = gw->g.height-1-gw->g.height/ARROWHEAD_DIVIDER;
|
|
|
|
arw[6].x = 0; arw[6].y = gw->g.height-1-gw->g.height/ARROWHEAD_DIVIDER;
|
|
|
|
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
|
|
|
|
gdispGFillConvexPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->fill);
|
|
|
|
gdispGDrawPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->edge);
|
|
|
|
gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
|
2013-03-10 06:15:49 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
void gwinButtonDraw_ArrowLeft(GWidgetObject *gw, void *param) {
|
2013-07-07 09:40:37 +00:00
|
|
|
const GColorSet * pcol;
|
|
|
|
(void) param;
|
|
|
|
point arw[7];
|
2013-06-06 04:33:32 +00:00
|
|
|
|
|
|
|
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
|
|
|
|
pcol = getDrawColors(gw);
|
|
|
|
|
|
|
|
arw[0].x = 0; arw[0].y = gw->g.height/2;
|
|
|
|
arw[1].x = gw->g.width/ARROWHEAD_DIVIDER; arw[1].y = 0;
|
|
|
|
arw[2].x = gw->g.width/ARROWHEAD_DIVIDER; arw[2].y = (gw->g.height - gw->g.height/ARROWBODY_DIVIDER)/2;
|
|
|
|
arw[3].x = gw->g.width-1; arw[3].y = (gw->g.height - gw->g.height/ARROWBODY_DIVIDER)/2;
|
|
|
|
arw[4].x = gw->g.width-1; arw[4].y = (gw->g.height + gw->g.height/ARROWBODY_DIVIDER)/2;
|
|
|
|
arw[5].x = gw->g.width/ARROWHEAD_DIVIDER; arw[5].y = (gw->g.height + gw->g.height/ARROWBODY_DIVIDER)/2;
|
|
|
|
arw[6].x = gw->g.width/ARROWHEAD_DIVIDER; arw[6].y = gw->g.height-1;
|
|
|
|
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
|
|
|
|
gdispGFillConvexPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->fill);
|
|
|
|
gdispGDrawPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->edge);
|
|
|
|
gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
|
2013-03-10 06:15:49 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
void gwinButtonDraw_ArrowRight(GWidgetObject *gw, void *param) {
|
2013-07-07 09:40:37 +00:00
|
|
|
const GColorSet * pcol;
|
|
|
|
(void) param;
|
|
|
|
point arw[7];
|
2013-06-06 04:33:32 +00:00
|
|
|
|
|
|
|
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
|
|
|
|
pcol = getDrawColors(gw);
|
|
|
|
|
|
|
|
arw[0].x = gw->g.width-1; arw[0].y = gw->g.height/2;
|
|
|
|
arw[1].x = gw->g.width-1-gw->g.width/ARROWHEAD_DIVIDER; arw[1].y = 0;
|
|
|
|
arw[2].x = gw->g.width-1-gw->g.width/ARROWHEAD_DIVIDER; arw[2].y = (gw->g.height - gw->g.height/ARROWBODY_DIVIDER)/2;
|
|
|
|
arw[3].x = 0; arw[3].y = (gw->g.height - gw->g.height/ARROWBODY_DIVIDER)/2;
|
|
|
|
arw[4].x = 0; arw[4].y = (gw->g.height + gw->g.height/ARROWBODY_DIVIDER)/2;
|
|
|
|
arw[5].x = gw->g.width-1-gw->g.width/ARROWHEAD_DIVIDER; arw[5].y = (gw->g.height + gw->g.height/ARROWBODY_DIVIDER)/2;
|
|
|
|
arw[6].x = gw->g.width-1-gw->g.width/ARROWHEAD_DIVIDER; arw[6].y = gw->g.height-1;
|
|
|
|
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->background);
|
|
|
|
gdispGFillConvexPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->fill);
|
|
|
|
gdispGDrawPoly(gw->g.display, gw->g.x, gw->g.y, arw, 7, pcol->edge);
|
|
|
|
gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
|
2013-03-10 06:15:49 +00:00
|
|
|
}
|
|
|
|
#endif
|
2013-03-02 12:20:57 +00:00
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
#if GDISP_NEED_IMAGE || defined(__DOXYGEN__)
|
|
|
|
void gwinButtonDraw_Image(GWidgetObject *gw, void *param) {
|
2013-07-07 09:40:37 +00:00
|
|
|
const GColorSet * pcol;
|
|
|
|
coord_t sy;
|
2013-04-07 06:02:10 +00:00
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
if (gw->g.vmt != (gwinVMT *)&buttonVMT) return;
|
2013-07-07 09:40:37 +00:00
|
|
|
pcol = getDrawColors(gw);
|
2013-03-02 12:20:57 +00:00
|
|
|
|
2014-05-09 15:11:30 +00:00
|
|
|
if (!(gw->g.flags & GWIN_FLG_SYSENABLED)) {
|
2013-06-06 04:33:32 +00:00
|
|
|
sy = 2 * gw->g.height;
|
|
|
|
} else if ((gw->g.flags & GBUTTON_FLG_PRESSED)) {
|
|
|
|
sy = gw->g.height;
|
|
|
|
} else {
|
|
|
|
sy = 0;
|
|
|
|
}
|
2013-03-02 12:20:57 +00:00
|
|
|
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGImageDraw(gw->g.display, (gdispImage *)param, gw->g.x, gw->g.y, gw->g.width, gw->g.height, 0, sy);
|
|
|
|
gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
|
2013-03-02 12:20:57 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* GFX_USE_GWIN && GWIN_NEED_BUTTON */
|