From 7baf5c5d448b626d6a062882434b25ca82212d94 Mon Sep 17 00:00:00 2001 From: inmarket Date: Thu, 6 Jun 2013 14:33:32 +1000 Subject: New simplified gwin using a pseudo class structure. --- src/gwin/console.c | 55 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'src/gwin/console.c') diff --git a/src/gwin/console.c b/src/gwin/console.c index 5c068c93..d9bda362 100644 --- a/src/gwin/console.c +++ b/src/gwin/console.c @@ -8,20 +8,15 @@ /** * @file src/gwin/console.c * @brief GWIN sub-system console code. - * - * @defgroup Console Console - * @ingroup GWIN - * - * @{ */ #include "gfx.h" -#if (GFX_USE_GWIN && GWIN_NEED_CONSOLE) || defined(__DOXYGEN__) +#if GFX_USE_GWIN && GWIN_NEED_CONSOLE #include -#include "gwin/internal.h" +#include "gwin/class_gwin.h" #define GWIN_CONSOLE_USE_CLEAR_LINES TRUE #define GWIN_CONSOLE_USE_FILLED_CHARS FALSE @@ -58,11 +53,20 @@ }; #endif -GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font) { - if (!(gc = (GConsoleObject *)_gwinInit((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject)))) +static void AfterClear(GWindowObject *gh) { + ((GConsoleObject *)gh)->cx = 0; + ((GConsoleObject *)gh)->cy = 0; +} + +static const gwinVMT consoleVMT = { + "Console", // The classname + 0, // The destroy routine + AfterClear, // The after-clear routine +}; + +GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height) { + if (!(gc = (GConsoleObject *)_gwinInit((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject), &consoleVMT))) return 0; - gc->gwin.type = GW_CONSOLE; - gwinSetFont(&gc->gwin, font); #if GFX_USE_OS_CHIBIOS && GWIN_CONSOLE_USE_BASESTREAM gc->stream.vmt = &GWindowConsoleVMT; #endif @@ -73,17 +77,21 @@ GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t widt #if GFX_USE_OS_CHIBIOS && GWIN_CONSOLE_USE_BASESTREAM BaseSequentialStream *gwinGetConsoleStream(GHandle gh) { - if (gh->type != GW_CONSOLE) + if (gh->vmt != &consoleVMT) return 0; return (BaseSequentialStream *)&(((GConsoleObject *)(gh))->stream); } #endif void gwinPutChar(GHandle gh, char c) { - uint8_t width; #define gcw ((GConsoleObject *)gh) + uint8_t width, fy, fp; + + if (gh->vmt != &consoleVMT || !gh->font) + return; - if (gh->type != GW_CONSOLE || !gh->font) return; + fy = gdispGetFontMetric(gh->font, fontHeight); + fp = gdispGetFontMetric(gh->font, fontCharPadding); #if GDISP_NEED_CLIP gdispSetClip(gh->x, gh->y, gh->width, gh->height); @@ -91,24 +99,24 @@ void gwinPutChar(GHandle gh, char c) { if (c == '\n') { gcw->cx = 0; - gcw->cy += gcw->fy; + gcw->cy += fy; // We use lazy scrolling here and only scroll when the next char arrives } else if (c == '\r') { // gcw->cx = 0; } else { - width = gdispGetCharWidth(c, gh->font) + gcw->fp; + width = gdispGetCharWidth(c, gh->font) + fp; if (gcw->cx + width >= gh->width) { gcw->cx = 0; - gcw->cy += gcw->fy; + gcw->cy += fy; } - if (gcw->cy + gcw->fy > gh->height) { + if (gcw->cy + fy > gh->height) { #if GDISP_NEED_SCROLL /* scroll the console */ - gdispVerticalScroll(gh->x, gh->y, gh->width, gh->height, gcw->fy, gh->bgcolor); + gdispVerticalScroll(gh->x, gh->y, gh->width, gh->height, fy, gh->bgcolor); /* reset the cursor to the start of the last line */ gcw->cx = 0; - gcw->cy = (((coord_t)(gh->height/gcw->fy))-1)*gcw->fy; + gcw->cy = (((coord_t)(gh->height/fy))-1)*fy; #else /* clear the console */ gdispFillArea(gh->x, gh->y, gh->width, gh->height, gh->bgcolor); @@ -121,7 +129,7 @@ void gwinPutChar(GHandle gh, char c) { #if GWIN_CONSOLE_USE_CLEAR_LINES /* clear to the end of the line */ if (gcw->cx == 0) - gdispFillArea(gh->x, gh->y + gcw->cy, gh->width, gcw->fy, gh->bgcolor); + gdispFillArea(gh->x, gh->y + gcw->cy, gh->width, fy, gh->bgcolor); #endif #if GWIN_CONSOLE_USE_FILLED_CHARS gdispFillChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color, gh->bgcolor); @@ -200,7 +208,8 @@ void gwinPrintf(GHandle gh, const char *fmt, ...) { char tmpbuf[MAX_FILLER + 1]; #endif - if (gh->type != GW_CONSOLE || !gh->font) return; + if (gh->vmt != &consoleVMT || !gh->font) + return; va_start(ap, fmt); while (TRUE) { @@ -343,5 +352,5 @@ void gwinPrintf(GHandle gh, const char *fmt, ...) { } #endif /* GFX_USE_GWIN && GWIN_NEED_CONSOLE */ -/** @} */ + -- cgit v1.2.3 From 777ec6af7c1b594f7b7a9cbaaf7ead90d8fb7e8f Mon Sep 17 00:00:00 2001 From: inmarket Date: Sat, 8 Jun 2013 02:27:59 +1000 Subject: Add a simple GWIN window manager, Change the way GWIN visibility works --- src/gwin/console.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gwin/console.c') diff --git a/src/gwin/console.c b/src/gwin/console.c index d9bda362..c4b2798d 100644 --- a/src/gwin/console.c +++ b/src/gwin/console.c @@ -61,11 +61,12 @@ static void AfterClear(GWindowObject *gh) { static const gwinVMT consoleVMT = { "Console", // The classname 0, // The destroy routine + 0, // The redraw routine AfterClear, // The after-clear routine }; GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height) { - if (!(gc = (GConsoleObject *)_gwinInit((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject), &consoleVMT))) + if (!(gc = (GConsoleObject *)_gwindowInit((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject), &consoleVMT, GWIN_FLG_VISIBLE))) return 0; #if GFX_USE_OS_CHIBIOS && GWIN_CONSOLE_USE_BASESTREAM gc->stream.vmt = &GWindowConsoleVMT; -- cgit v1.2.3 From 2cb35d6815a0a12035f4792c266b688c77085620 Mon Sep 17 00:00:00 2001 From: inmarket Date: Mon, 10 Jun 2013 17:18:01 +1000 Subject: Clean up GWIN Event assignment. Optimise event efficiency. --- src/gwin/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gwin/console.c') diff --git a/src/gwin/console.c b/src/gwin/console.c index c4b2798d..6941295a 100644 --- a/src/gwin/console.c +++ b/src/gwin/console.c @@ -66,7 +66,7 @@ static const gwinVMT consoleVMT = { }; GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height) { - if (!(gc = (GConsoleObject *)_gwindowInit((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject), &consoleVMT, GWIN_FLG_VISIBLE))) + if (!(gc = (GConsoleObject *)_gwindowCreate((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject), &consoleVMT, GWIN_FLG_VISIBLE))) return 0; #if GFX_USE_OS_CHIBIOS && GWIN_CONSOLE_USE_BASESTREAM gc->stream.vmt = &GWindowConsoleVMT; -- cgit v1.2.3 From 49b3e8f55ae135ce6475d1185db68e665430fe5e Mon Sep 17 00:00:00 2001 From: inmarket Date: Sat, 15 Jun 2013 21:09:02 +1000 Subject: License header updates --- src/gwin/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gwin/console.c') diff --git a/src/gwin/console.c b/src/gwin/console.c index 6941295a..38e2ea8b 100644 --- a/src/gwin/console.c +++ b/src/gwin/console.c @@ -1,5 +1,5 @@ /* - * This file is subject to the terms of the GFX License, v1.0. If a copy of + * This file is subject to the terms of the GFX License. If a copy of * the license was not distributed with this file, you can obtain one at: * * http://chibios-gfx.com/license.html -- cgit v1.2.3 From 8ed9e763c0f97f2946990a911bb940f8c80ff761 Mon Sep 17 00:00:00 2001 From: inmarket Date: Mon, 24 Jun 2013 22:58:37 +1000 Subject: GWIN reduce Initialisation parameters and fix visibility issues --- src/gwin/console.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gwin/console.c') diff --git a/src/gwin/console.c b/src/gwin/console.c index 38e2ea8b..39e534b4 100644 --- a/src/gwin/console.c +++ b/src/gwin/console.c @@ -60,19 +60,21 @@ static void AfterClear(GWindowObject *gh) { static const gwinVMT consoleVMT = { "Console", // The classname + sizeof(GConsoleObject), // The object size 0, // The destroy routine 0, // The redraw routine AfterClear, // The after-clear routine }; -GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height) { - if (!(gc = (GConsoleObject *)_gwindowCreate((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject), &consoleVMT, GWIN_FLG_VISIBLE))) +GHandle gwinCreateConsole(GConsoleObject *gc, GWindowInit *pInit) { + if (!(gc = (GConsoleObject *)_gwindowCreate(&gc->g, pInit, &consoleVMT, 0))) return 0; #if GFX_USE_OS_CHIBIOS && GWIN_CONSOLE_USE_BASESTREAM gc->stream.vmt = &GWindowConsoleVMT; #endif gc->cx = 0; gc->cy = 0; + gwinSetVisible((GHandle)gc, pInit->show); return (GHandle)gc; } -- cgit v1.2.3 From 57d3632e36fe2ab55589207a84c29544b15bd2c3 Mon Sep 17 00:00:00 2001 From: inmarket Date: Mon, 1 Jul 2013 17:34:13 +1000 Subject: GWIN Init structures are const (read-only to GWIN) --- src/gwin/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gwin/console.c') diff --git a/src/gwin/console.c b/src/gwin/console.c index 39e534b4..105cc79d 100644 --- a/src/gwin/console.c +++ b/src/gwin/console.c @@ -66,7 +66,7 @@ static const gwinVMT consoleVMT = { AfterClear, // The after-clear routine }; -GHandle gwinCreateConsole(GConsoleObject *gc, GWindowInit *pInit) { +GHandle gwinCreateConsole(GConsoleObject *gc, const GWindowInit *pInit) { if (!(gc = (GConsoleObject *)_gwindowCreate(&gc->g, pInit, &consoleVMT, 0))) return 0; #if GFX_USE_OS_CHIBIOS && GWIN_CONSOLE_USE_BASESTREAM -- cgit v1.2.3 From 3957505ab119b21c7b0f4e72f56030c97711988a Mon Sep 17 00:00:00 2001 From: inmarket Date: Sun, 7 Jul 2013 19:40:37 +1000 Subject: GWIN renaming, tidy up, color styles --- src/gwin/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gwin/console.c') diff --git a/src/gwin/console.c b/src/gwin/console.c index 105cc79d..06648e9b 100644 --- a/src/gwin/console.c +++ b/src/gwin/console.c @@ -66,7 +66,7 @@ static const gwinVMT consoleVMT = { AfterClear, // The after-clear routine }; -GHandle gwinCreateConsole(GConsoleObject *gc, const GWindowInit *pInit) { +GHandle gwinConsoleCreate(GConsoleObject *gc, const GWindowInit *pInit) { if (!(gc = (GConsoleObject *)_gwindowCreate(&gc->g, pInit, &consoleVMT, 0))) return 0; #if GFX_USE_OS_CHIBIOS && GWIN_CONSOLE_USE_BASESTREAM @@ -79,7 +79,7 @@ GHandle gwinCreateConsole(GConsoleObject *gc, const GWindowInit *pInit) { } #if GFX_USE_OS_CHIBIOS && GWIN_CONSOLE_USE_BASESTREAM - BaseSequentialStream *gwinGetConsoleStream(GHandle gh) { + BaseSequentialStream *gwinConsoleGetStream(GHandle gh) { if (gh->vmt != &consoleVMT) return 0; return (BaseSequentialStream *)&(((GConsoleObject *)(gh))->stream); -- cgit v1.2.3