2013-03-02 12:03:40 +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:03:40 +00:00
|
|
|
*
|
2013-07-21 20:20:37 +00:00
|
|
|
* http://ugfx.org/license.html
|
2013-03-02 12:03:40 +00:00
|
|
|
*/
|
|
|
|
|
2014-08-20 07:42:53 +00:00
|
|
|
/**
|
2015-05-16 18:17:50 +00:00
|
|
|
* @file src/gwin/gwin.c
|
2014-08-20 07:42:53 +00:00
|
|
|
* @brief GWIN sub-system code
|
|
|
|
*/
|
|
|
|
|
2015-11-21 09:27:08 +00:00
|
|
|
#include "../../gfx.h"
|
2013-03-02 12:03:40 +00:00
|
|
|
|
2013-03-18 08:29:28 +00:00
|
|
|
#if GFX_USE_GWIN
|
2013-03-02 12:03:40 +00:00
|
|
|
|
2014-08-20 07:42:53 +00:00
|
|
|
#include "gwin_class.h"
|
2013-06-06 04:33:32 +00:00
|
|
|
|
2015-01-03 08:42:51 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2013-06-07 16:27:59 +00:00
|
|
|
/*-----------------------------------------------
|
|
|
|
* Data
|
|
|
|
*-----------------------------------------------*/
|
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
static const gwinVMT basegwinVMT = {
|
|
|
|
"GWIN", // The classname
|
2013-06-24 12:58:37 +00:00
|
|
|
sizeof(GWindowObject), // The object size
|
2013-06-06 04:33:32 +00:00
|
|
|
0, // The destroy routine
|
2013-06-07 16:27:59 +00:00
|
|
|
0, // The redraw routine
|
2013-06-06 04:33:32 +00:00
|
|
|
0, // The after-clear routine
|
|
|
|
};
|
|
|
|
|
2018-07-08 01:19:43 +00:00
|
|
|
static gColor defaultFgColor = GFX_WHITE;
|
|
|
|
static gColor defaultBgColor = GFX_BLACK;
|
2013-06-07 16:27:59 +00:00
|
|
|
#if GDISP_NEED_TEXT
|
2018-07-08 03:05:27 +00:00
|
|
|
static gFont defaultFont;
|
2013-06-07 16:27:59 +00:00
|
|
|
#endif
|
|
|
|
|
2015-10-21 08:08:49 +00:00
|
|
|
/* These init functions are defined by each module but not published */
|
|
|
|
extern void _gwmInit(void);
|
|
|
|
extern void _gwmDeinit(void);
|
|
|
|
#if GWIN_NEED_WIDGET
|
|
|
|
extern void _gwidgetInit(void);
|
|
|
|
extern void _gwidgetDeinit(void);
|
|
|
|
#endif
|
|
|
|
#if GWIN_NEED_CONTAINERS
|
|
|
|
extern void _gcontainerInit(void);
|
|
|
|
extern void _gcontainerDeinit(void);
|
|
|
|
#endif
|
|
|
|
|
2013-06-07 16:27:59 +00:00
|
|
|
/*-----------------------------------------------
|
|
|
|
* Helper Routines
|
|
|
|
*-----------------------------------------------*/
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
* Class Routines
|
|
|
|
*-----------------------------------------------*/
|
|
|
|
|
2014-02-02 18:24:43 +00:00
|
|
|
void _gwinInit(void)
|
|
|
|
{
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwmInit();
|
2013-06-10 07:18:01 +00:00
|
|
|
|
2015-10-21 08:08:49 +00:00
|
|
|
#if GWIN_NEED_WIDGET
|
2013-06-10 07:18:01 +00:00
|
|
|
_gwidgetInit();
|
|
|
|
#endif
|
2013-07-07 09:40:37 +00:00
|
|
|
|
2015-10-21 08:08:49 +00:00
|
|
|
#if GWIN_NEED_CONTAINERS
|
2014-05-09 15:11:30 +00:00
|
|
|
_gcontainerInit();
|
2013-06-07 16:27:59 +00:00
|
|
|
#endif
|
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
|
2014-02-02 18:24:43 +00:00
|
|
|
void _gwinDeinit(void)
|
|
|
|
{
|
2014-05-09 15:11:30 +00:00
|
|
|
#if GWIN_NEED_CONTAINERS
|
|
|
|
_gcontainerDeinit();
|
|
|
|
#endif
|
2014-02-02 18:24:43 +00:00
|
|
|
|
2015-10-21 08:08:49 +00:00
|
|
|
#if GWIN_NEED_WIDGET
|
2014-02-02 18:24:43 +00:00
|
|
|
_gwidgetDeinit();
|
|
|
|
#endif
|
|
|
|
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwmDeinit();
|
2014-02-02 18:24:43 +00:00
|
|
|
}
|
|
|
|
|
2013-03-02 12:03:40 +00:00
|
|
|
// Internal routine for use by GWIN components only
|
2013-06-07 16:27:59 +00:00
|
|
|
// Initialise a window creating it dynamically if required.
|
2014-05-09 11:32:29 +00:00
|
|
|
GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit, const gwinVMT *vmt, uint32_t flags) {
|
2013-03-02 12:03:40 +00:00
|
|
|
// Allocate the structure if necessary
|
2013-06-06 04:33:32 +00:00
|
|
|
if (!pgw) {
|
2014-02-02 11:59:36 +00:00
|
|
|
if (!(pgw = gfxAlloc(vmt->size)))
|
2013-03-02 12:03:40 +00:00
|
|
|
return 0;
|
2013-06-07 16:27:59 +00:00
|
|
|
pgw->flags = flags|GWIN_FLG_DYNAMIC;
|
2013-03-02 12:03:40 +00:00
|
|
|
} else
|
2013-06-07 16:27:59 +00:00
|
|
|
pgw->flags = flags;
|
2013-03-02 12:03:40 +00:00
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
// Initialise all basic fields
|
2013-10-24 08:36:11 +00:00
|
|
|
pgw->display = g;
|
2013-06-06 04:33:32 +00:00
|
|
|
pgw->vmt = vmt;
|
2013-06-06 06:48:30 +00:00
|
|
|
pgw->color = defaultFgColor;
|
|
|
|
pgw->bgcolor = defaultBgColor;
|
2013-03-18 08:29:28 +00:00
|
|
|
#if GDISP_NEED_TEXT
|
2013-06-06 04:33:32 +00:00
|
|
|
pgw->font = defaultFont;
|
2013-03-18 08:29:28 +00:00
|
|
|
#endif
|
2013-06-07 16:27:59 +00:00
|
|
|
|
2015-01-03 08:42:51 +00:00
|
|
|
// Make sure we don't create nasty problems for ourselves
|
|
|
|
if (vmt->size > sizeof(GWindowObject))
|
|
|
|
memset(pgw+1, 0, vmt->size - sizeof(GWindowObject));
|
|
|
|
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinWMAdd(pgw, pInit)) {
|
|
|
|
if ((pgw->flags & GWIN_FLG_DYNAMIC))
|
|
|
|
gfxFree(pgw);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-02-02 15:15:08 +00:00
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
return (GHandle)pgw;
|
2013-03-02 12:03:40 +00:00
|
|
|
}
|
|
|
|
|
2014-08-20 02:18:27 +00:00
|
|
|
// Internal routine for use by GWIN components only
|
|
|
|
void _gwinDestroy(GHandle gh, GRedrawMethod how) {
|
|
|
|
if (!gh)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Make the window invisible
|
2018-06-23 03:02:07 +00:00
|
|
|
gwinSetVisible(gh, gFalse);
|
2014-08-20 02:18:27 +00:00
|
|
|
|
|
|
|
// Make sure it is flushed first - must be REDRAW_WAIT or REDRAW_INSESSION
|
|
|
|
_gwinFlushRedraws(how);
|
|
|
|
|
|
|
|
#if GWIN_NEED_CONTAINERS
|
|
|
|
// Notify the parent it is about to be deleted
|
|
|
|
if (gh->parent && ((gcontainerVMT *)gh->parent->vmt)->NotifyDelete)
|
|
|
|
((gcontainerVMT *)gh->parent->vmt)->NotifyDelete(gh->parent, gh);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Remove from the window manager
|
|
|
|
#if GWIN_NEED_WINDOWMANAGER
|
|
|
|
_GWINwm->vmt->Delete(gh);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Class destroy routine
|
|
|
|
if (gh->vmt->Destroy)
|
|
|
|
gh->vmt->Destroy(gh);
|
|
|
|
|
|
|
|
// Clean up the structure
|
|
|
|
if (gh->flags & GWIN_FLG_DYNAMIC) {
|
|
|
|
gh->flags = 0; // To be sure, to be sure
|
|
|
|
gfxFree((void *)gh);
|
|
|
|
} else
|
|
|
|
gh->flags = 0; // To be sure, to be sure
|
|
|
|
}
|
|
|
|
|
2013-06-07 16:27:59 +00:00
|
|
|
/*-----------------------------------------------
|
|
|
|
* Routines that affect all windows
|
|
|
|
*-----------------------------------------------*/
|
|
|
|
|
2014-05-09 11:25:31 +00:00
|
|
|
void gwinClearInit(GWindowInit *pwi) {
|
|
|
|
char *p;
|
|
|
|
unsigned len;
|
|
|
|
|
|
|
|
for(p = (char *)pwi, len = sizeof(GWindowInit); len; len--)
|
|
|
|
*p++ = 0;
|
|
|
|
}
|
|
|
|
|
2018-07-08 01:19:43 +00:00
|
|
|
void gwinSetDefaultColor(gColor clr) {
|
2013-06-07 16:27:59 +00:00
|
|
|
defaultFgColor = clr;
|
|
|
|
}
|
|
|
|
|
2018-07-08 01:19:43 +00:00
|
|
|
gColor gwinGetDefaultColor(void) {
|
2013-07-03 14:20:32 +00:00
|
|
|
return defaultFgColor;
|
|
|
|
}
|
|
|
|
|
2018-07-08 01:19:43 +00:00
|
|
|
void gwinSetDefaultBgColor(gColor bgclr) {
|
2013-06-07 16:27:59 +00:00
|
|
|
defaultBgColor = bgclr;
|
|
|
|
}
|
|
|
|
|
2018-07-08 01:19:43 +00:00
|
|
|
gColor gwinGetDefaultBgColor(void) {
|
2013-07-03 14:20:32 +00:00
|
|
|
return defaultBgColor;
|
|
|
|
}
|
|
|
|
|
2013-06-07 16:27:59 +00:00
|
|
|
#if GDISP_NEED_TEXT
|
2018-07-08 03:05:27 +00:00
|
|
|
void gwinSetDefaultFont(gFont font) {
|
2013-06-07 16:27:59 +00:00
|
|
|
defaultFont = font;
|
|
|
|
}
|
2013-07-02 17:26:48 +00:00
|
|
|
|
2018-07-08 03:05:27 +00:00
|
|
|
gFont gwinGetDefaultFont(void) {
|
2013-07-02 17:26:48 +00:00
|
|
|
return defaultFont;
|
|
|
|
}
|
2013-06-07 16:27:59 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
* The GWindow Routines
|
|
|
|
*-----------------------------------------------*/
|
|
|
|
|
2013-10-24 08:36:11 +00:00
|
|
|
GHandle gwinGWindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit) {
|
|
|
|
if (!(pgw = _gwindowCreate(g, pgw, pInit, &basegwinVMT, 0)))
|
2013-06-24 12:58:37 +00:00
|
|
|
return 0;
|
2014-01-04 03:41:32 +00:00
|
|
|
|
2013-06-24 12:58:37 +00:00
|
|
|
gwinSetVisible(pgw, pInit->show);
|
2016-02-13 03:04:30 +00:00
|
|
|
_gwinFlushRedraws(REDRAW_WAIT);
|
2014-01-04 03:41:32 +00:00
|
|
|
|
2013-06-24 12:58:37 +00:00
|
|
|
return pgw;
|
2013-05-20 14:18:10 +00:00
|
|
|
}
|
|
|
|
|
2014-08-16 12:51:05 +00:00
|
|
|
void gwinDestroy(GHandle gh) {
|
|
|
|
_gwinDestroy(gh, REDRAW_WAIT);
|
|
|
|
}
|
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
const char *gwinGetClassName(GHandle gh) {
|
|
|
|
return gh->vmt->classname;
|
2013-04-06 12:31:40 +00:00
|
|
|
}
|
|
|
|
|
2018-06-23 03:02:07 +00:00
|
|
|
gBool gwinGetVisible(GHandle gh) {
|
|
|
|
return (gh->flags & GWIN_FLG_SYSVISIBLE) ? gTrue : gFalse;
|
2013-06-06 06:48:30 +00:00
|
|
|
}
|
|
|
|
|
2018-06-23 03:02:07 +00:00
|
|
|
gBool gwinGetEnabled(GHandle gh) {
|
|
|
|
return (gh->flags & GWIN_FLG_SYSENABLED) ? gTrue : gFalse;
|
2013-07-03 14:59:12 +00:00
|
|
|
}
|
|
|
|
|
2013-06-07 16:27:59 +00:00
|
|
|
#if GDISP_NEED_TEXT
|
2018-07-08 03:05:27 +00:00
|
|
|
void gwinSetFont(GHandle gh, gFont font) {
|
2013-03-18 08:29:28 +00:00
|
|
|
gh->font = font;
|
2013-03-02 12:03:40 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void gwinClear(GHandle gh) {
|
2013-12-18 15:49:49 +00:00
|
|
|
/*
|
|
|
|
* Don't render anything when the window is not visible but
|
|
|
|
* still call the AfterClear() routine as some widgets will
|
|
|
|
* need this to clear internal buffers or similar
|
|
|
|
*/
|
2014-05-21 03:02:00 +00:00
|
|
|
if (_gwinDrawStart(gh)) {
|
2014-01-06 23:08:28 +00:00
|
|
|
gdispGFillArea(gh->display, gh->x, gh->y, gh->width, gh->height, gh->bgcolor);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-12-18 15:49:49 +00:00
|
|
|
}
|
2014-05-21 03:02:00 +00:00
|
|
|
if (gh->vmt->AfterClear)
|
|
|
|
gh->vmt->AfterClear(gh);
|
2013-03-02 12:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinDrawPixel(GHandle gh, gCoord x, gCoord y) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGDrawPixel(gh->display, gh->x+x, gh->y+y, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-02 12:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinDrawLine(GHandle gh, gCoord x0, gCoord y0, gCoord x1, gCoord y1) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGDrawLine(gh->display, gh->x+x0, gh->y+y0, gh->x+x1, gh->y+y1, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-02 12:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinDrawBox(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGDrawBox(gh->display, gh->x+x, gh->y+y, cx, cy, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-02 12:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinFillArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillArea(gh->display, gh->x+x, gh->y+y, cx, cy, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-02 12:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-07-08 01:08:55 +00:00
|
|
|
void gwinBlitArea(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord srcx, gCoord srcy, gCoord srccx, const gPixel *buffer) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGBlitArea(gh->display, gh->x+x, gh->y+y, cx, cy, srcx, srcy, srccx, buffer);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-02 12:03:40 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 08:29:28 +00:00
|
|
|
#if GDISP_NEED_CIRCLE
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinDrawCircle(GHandle gh, gCoord x, gCoord y, gCoord radius) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGDrawCircle(gh->display, gh->x+x, gh->y+y, radius, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinFillCircle(GHandle gh, gCoord x, gCoord y, gCoord radius) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillCircle(gh->display, gh->x+x, gh->y+y, radius, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
#endif
|
|
|
|
|
2016-12-14 13:43:21 +00:00
|
|
|
#if GDISP_NEED_DUALCIRCLE
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinFillDualCircle(GHandle gh, gCoord x, gCoord y, gCoord radius1, gCoord radius2) {
|
2016-12-14 13:43:21 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
|
|
|
gdispGFillDualCircle(gh->display, gh->x+x, gh->y+y, radius1, gh->bgcolor, radius2, gh->color);
|
|
|
|
_gwinDrawEnd(gh);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-03-18 08:29:28 +00:00
|
|
|
#if GDISP_NEED_ELLIPSE
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinDrawEllipse(GHandle gh, gCoord x, gCoord y, gCoord a, gCoord b) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGDrawEllipse(gh->display, gh->x+x, gh->y+y, a, b, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinFillEllipse(GHandle gh, gCoord x, gCoord y, gCoord a, gCoord b) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillEllipse(gh->display, gh->x+x, gh->y+y, a, b, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
#endif
|
|
|
|
|
2013-03-18 08:29:28 +00:00
|
|
|
#if GDISP_NEED_ARC
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinDrawArc(GHandle gh, gCoord x, gCoord y, gCoord radius, gCoord startangle, gCoord endangle) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGDrawArc(gh->display, gh->x+x, gh->y+y, radius, startangle, endangle, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinFillArc(GHandle gh, gCoord x, gCoord y, gCoord radius, gCoord startangle, gCoord endangle) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillArc(gh->display, gh->x+x, gh->y+y, radius, startangle, endangle, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2016-12-14 13:49:11 +00:00
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinDrawThickArc(GHandle gh, gCoord x, gCoord y, gCoord startradius, gCoord endradius, gCoord startangle, gCoord endangle) {
|
2016-12-14 13:49:11 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
|
|
|
gdispGDrawThickArc(gh->display, gh->x+x, gh->y+y, startradius, endradius, startangle, endangle, gh->color);
|
|
|
|
_gwinDrawEnd(gh);
|
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
#endif
|
|
|
|
|
2014-10-27 23:20:11 +00:00
|
|
|
#if GDISP_NEED_ARCSECTORS
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinDrawArcSectors(GHandle gh, gCoord x, gCoord y, gCoord radius, uint8_t sectors) {
|
2014-10-27 23:20:11 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
|
|
|
gdispGDrawArcSectors(gh->display, gh->x+x, gh->y+y, radius, sectors, gh->color);
|
|
|
|
_gwinDrawEnd(gh);
|
|
|
|
}
|
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinFillArcSectors(GHandle gh, gCoord x, gCoord y, gCoord radius, uint8_t sectors) {
|
2014-10-27 23:20:11 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
|
|
|
gdispGFillArcSectors(gh->display, gh->x+x, gh->y+y, radius, sectors, gh->color);
|
|
|
|
_gwinDrawEnd(gh);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-03-18 08:29:28 +00:00
|
|
|
#if GDISP_NEED_PIXELREAD
|
2018-07-08 01:19:43 +00:00
|
|
|
gColor gwinGetPixelColor(GHandle gh, gCoord x, gCoord y) {
|
|
|
|
if (!_gwinDrawStart(gh)) return (gColor)0;
|
2013-10-24 08:36:11 +00:00
|
|
|
return gdispGGetPixelColor(gh->display, gh->x+x, gh->y+y);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
#endif
|
|
|
|
|
2013-03-18 08:29:28 +00:00
|
|
|
#if GDISP_NEED_TEXT
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinDrawChar(GHandle gh, gCoord x, gCoord y, char c) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!gh->font || !_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGDrawChar(gh->display, gh->x+x, gh->y+y, c, gh->font, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinFillChar(GHandle gh, gCoord x, gCoord y, char c) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!gh->font || !_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillChar(gh->display, gh->x+x, gh->y+y, c, gh->font, gh->color, gh->bgcolor);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinDrawString(GHandle gh, gCoord x, gCoord y, const char *str) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!gh->font || !_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGDrawString(gh->display, gh->x+x, gh->y+y, str, gh->font, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinFillString(GHandle gh, gCoord x, gCoord y, const char *str) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!gh->font || !_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillString(gh->display, gh->x+x, gh->y+y, str, gh->font, gh->color, gh->bgcolor);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
|
2018-07-08 02:19:30 +00:00
|
|
|
void gwinDrawStringBox(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, gJustify justify) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!gh->font || !_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGDrawStringBox(gh->display, gh->x+x, gh->y+y, cx, cy, str, gh->font, gh->color, justify);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
|
|
|
|
2018-07-08 02:19:30 +00:00
|
|
|
void gwinFillStringBox(GHandle gh, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, gJustify justify) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!gh->font || !_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillStringBox(gh->display, gh->x+x, gh->y+y, cx, cy, str, gh->font, gh->color, gh->bgcolor, justify);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
#endif
|
|
|
|
|
2013-03-18 08:29:28 +00:00
|
|
|
#if GDISP_NEED_CONVEX_POLYGON
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinDrawPoly(GHandle gh, gCoord tx, gCoord ty, const gPoint *pntarray, unsigned cnt) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGDrawPoly(gh->display, tx+gh->x, ty+gh->y, pntarray, cnt, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
|
|
|
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinFillConvexPoly(GHandle gh, gCoord tx, gCoord ty, const gPoint *pntarray, unsigned cnt) {
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
2013-10-24 08:36:11 +00:00
|
|
|
gdispGFillConvexPoly(gh->display, tx+gh->x, ty+gh->y, pntarray, cnt, gh->color);
|
2014-05-21 03:02:00 +00:00
|
|
|
_gwinDrawEnd(gh);
|
2013-03-18 08:29:28 +00:00
|
|
|
}
|
2018-07-08 00:54:19 +00:00
|
|
|
void gwinDrawThickLine(GHandle gh, gCoord x0, gCoord y0, gCoord x1, gCoord y1, gCoord width, gBool round) {
|
2014-07-15 02:40:43 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return;
|
|
|
|
gdispGDrawThickLine(gh->display, gh->x+x0, gh->y+y0, gh->x+x1, gh->y+y1, gh->color, width, round);
|
|
|
|
_gwinDrawEnd(gh);
|
|
|
|
}
|
2013-03-02 12:03:40 +00:00
|
|
|
#endif
|
|
|
|
|
2013-07-22 07:05:42 +00:00
|
|
|
#if GDISP_NEED_IMAGE
|
2018-07-08 00:54:19 +00:00
|
|
|
gdispImageError gwinDrawImage(GHandle gh, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy) {
|
2014-05-21 03:02:00 +00:00
|
|
|
gdispImageError ret;
|
2013-07-22 07:05:42 +00:00
|
|
|
|
2014-05-21 03:02:00 +00:00
|
|
|
if (!_gwinDrawStart(gh)) return GDISP_IMAGE_ERR_OK;
|
|
|
|
ret = gdispGImageDraw(gh->display, img, gh->x+x, gh->y+y, cx, cy, sx, sy);
|
|
|
|
_gwinDrawEnd(gh);
|
|
|
|
return ret;
|
2013-07-22 07:05:42 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-03-02 12:03:40 +00:00
|
|
|
#endif /* GFX_USE_GWIN */
|
|
|
|
/** @} */
|
|
|
|
|