aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-07-01 17:47:35 +1000
committerinmarket <andrewh@inmarket.com.au>2013-07-01 17:47:35 +1000
commit4afd5ec74429232e4db96001ed89757b0ba55ee7 (patch)
tree5889174cdcadbf39655a178509073952f68462d8
parentde27a6c2db6f5fb97b3a5d07395a629c879abfbc (diff)
parentdf5f701a11ea5603f1f0b44f0e6bd96084b6d09d (diff)
downloaduGFX-4afd5ec74429232e4db96001ed89757b0ba55ee7.tar.gz
uGFX-4afd5ec74429232e4db96001ed89757b0ba55ee7.tar.bz2
uGFX-4afd5ec74429232e4db96001ed89757b0ba55ee7.zip
Merge branch 'GWIN' into image
-rw-r--r--include/gdisp/image.h15
-rw-r--r--include/gwin/button.h2
-rw-r--r--include/gwin/checkbox.h2
-rw-r--r--include/gwin/class_gwin.h10
-rw-r--r--include/gwin/console.h2
-rw-r--r--include/gwin/graph.h2
-rw-r--r--include/gwin/gwidget.h4
-rw-r--r--include/gwin/gwin.h2
-rw-r--r--include/gwin/slider.h2
-rw-r--r--src/gdisp/image.c8
-rw-r--r--src/gwin/button.c2
-rw-r--r--src/gwin/checkbox.c2
-rw-r--r--src/gwin/console.c2
-rw-r--r--src/gwin/graph.c2
-rw-r--r--src/gwin/gwidget.c2
-rw-r--r--src/gwin/gwin.c6
-rw-r--r--src/gwin/slider.c2
17 files changed, 43 insertions, 24 deletions
diff --git a/include/gdisp/image.h b/include/gdisp/image.h
index 696500a6..ea8a02d4 100644
--- a/include/gdisp/image.h
+++ b/include/gdisp/image.h
@@ -185,7 +185,7 @@ extern "C" {
gdispImageError gdispImageOpen(gdispImage *img);
/**
- * @brief Close an image and release any dynamicly allocated working storage.
+ * @brief Close an image and release any dynamically allocated working storage.
*
* @param[in] img The image structure
*
@@ -196,6 +196,19 @@ extern "C" {
void gdispImageClose(gdispImage *img);
/**
+ * @brief Is an image open.
+ * @return TRUE if the image is currently open.
+ *
+ * @param[in] img The image structure
+ *
+ * @note Be careful with calling this on an uninitialized image structure as the image
+ * will contain random data which may be interpreted as meaning the image
+ * is open. Clearing the Image structure to 0's will guarantee the image
+ * is seen as being closed.
+ */
+ bool_t gdispImageIsOpen(gdispImage *img);
+
+ /**
* @brief Set the background color of the image.
*
* @param[in] img The image structure
diff --git a/include/gwin/button.h b/include/gwin/button.h
index a6b19333..73f42e37 100644
--- a/include/gwin/button.h
+++ b/include/gwin/button.h
@@ -84,7 +84,7 @@ extern "C" {
*
* @api
*/
-GHandle gwinCreateButton(GButtonObject *gb, GWidgetInit *pInit);
+GHandle gwinCreateButton(GButtonObject *gb, const GWidgetInit *pInit);
/**
* @brief Set the colors of a button.
diff --git a/include/gwin/checkbox.h b/include/gwin/checkbox.h
index 9a19a2e1..2823007a 100644
--- a/include/gwin/checkbox.h
+++ b/include/gwin/checkbox.h
@@ -73,7 +73,7 @@ typedef struct GCheckboxObject_t {
*
* @api
*/
-GHandle gwinCreateCheckbox(GCheckboxObject *gb, GWidgetInit *pInit);
+GHandle gwinCreateCheckbox(GCheckboxObject *gb, const GWidgetInit *pInit);
/**
* @brief Get the state of a checkbox
diff --git a/include/gwin/class_gwin.h b/include/gwin/class_gwin.h
index c3d2ee36..dbda3619 100644
--- a/include/gwin/class_gwin.h
+++ b/include/gwin/class_gwin.h
@@ -117,7 +117,7 @@ typedef struct gwinVMT {
typedef struct gwmVMT {
void (*Init) (void); // @< The window manager has just been set as the current window manager
void (*DeInit) (void); // @< The window manager has just been removed as the current window manager
- bool_t (*Add) (GHandle gh, GWindowInit *pInit); // @< A window has been added
+ bool_t (*Add) (GHandle gh, const GWindowInit *pInit); // @< A window has been added
void (*Delete) (GHandle gh); // @< A window has been deleted
void (*Visible) (GHandle gh); // @< A window has changed its visibility state
void (*Redim) (GHandle gh, coord_t x, coord_t y, coord_t w, coord_t h); // @< A window wants to be moved or resized
@@ -146,21 +146,19 @@ extern "C" {
*
* @notapi
*/
-GHandle _gwindowCreate(GWindowObject *pgw, GWindowInit *pInit, const gwinVMT *vmt, uint16_t flags);
+GHandle _gwindowCreate(GWindowObject *pgw, const GWindowInit *pInit, const gwinVMT *vmt, uint16_t flags);
#if GWIN_NEED_WIDGET || defined(__DOXYGEN__)
/**
* @brief Initialise (and allocate if necessary) the base Widget object
*
* @param[in] pgw The GWidgetObject structure. If NULL one is allocated from the heap
- * @param[in] x, y The top left corner of the Widget relative to the screen
- * @param[in] w, h The width and height of the Widget window
- * @param[in] size The size of the Widget object to allocate
+ * @param[in] pInit The user initialization parameters
* @param[in] vmt The virtual method table for the Widget object
*
* @notapi
*/
- GHandle _gwidgetCreate(GWidgetObject *pgw, GWidgetInit *pInit, const gwidgetVMT *vmt);
+ GHandle _gwidgetCreate(GWidgetObject *pgw, const GWidgetInit *pInit, const gwidgetVMT *vmt);
/**
* @brief Destroy the Widget object
diff --git a/include/gwin/console.h b/include/gwin/console.h
index 38c88f63..a3b3697c 100644
--- a/include/gwin/console.h
+++ b/include/gwin/console.h
@@ -64,7 +64,7 @@ extern "C" {
*
* @api
*/
-GHandle gwinCreateConsole(GConsoleObject *gc, GWindowInit *pInit);
+GHandle gwinCreateConsole(GConsoleObject *gc, const GWindowInit *pInit);
#if GFX_USE_OS_CHIBIOS && GWIN_CONSOLE_USE_BASESTREAM
/**
diff --git a/include/gwin/graph.h b/include/gwin/graph.h
index 5e6abee1..b5fc1405 100644
--- a/include/gwin/graph.h
+++ b/include/gwin/graph.h
@@ -107,7 +107,7 @@ extern "C" {
*
* @api
*/
-GHandle gwinCreateGraph(GGraphObject *gg, GWindowInit *pInit);
+GHandle gwinCreateGraph(GGraphObject *gg, const GWindowInit *pInit);
/**
* @brief Set the style of the graphing operations.
diff --git a/include/gwin/gwidget.h b/include/gwin/gwidget.h
index 50f19193..817f2b0d 100644
--- a/include/gwin/gwidget.h
+++ b/include/gwin/gwidget.h
@@ -23,7 +23,7 @@
* via an input device such as a mouse or toggle buttons. It is the
* base class for widgets such as buttons and sliders.
*
- * @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
+ * @pre GFX_USE_GWIN and GWIN_NEED_WIDGET must be set to TRUE in your gfxconf.h
* @{
*/
@@ -40,7 +40,7 @@ typedef void (*CustomWidgetDrawFunction)(struct GWidgetObject *gw, void *param);
* @note A widget is a GWIN window that accepts user input.
* It also has a number of other properties such as its ability
* to redraw itself (a widget maintains drawing state).
- * @note Do you access the members directly. Treat it as a black-box and use the method functions.
+ * @note Do not access the members directly. Treat it as a black-box and use the method functions.
*
* @{
*/
diff --git a/include/gwin/gwin.h b/include/gwin/gwin.h
index 93cca142..b4be6a83 100644
--- a/include/gwin/gwin.h
+++ b/include/gwin/gwin.h
@@ -154,7 +154,7 @@ extern "C" {
*
* @api
*/
- GHandle gwinCreateWindow(GWindowObject *pgw, GWindowInit *pInit);
+ GHandle gwinCreateWindow(GWindowObject *pgw, const GWindowInit *pInit);
/**
* @brief Destroy a window (of any type). Releases any dynamically allocated memory.
diff --git a/include/gwin/slider.h b/include/gwin/slider.h
index 4479950f..57bd5a72 100644
--- a/include/gwin/slider.h
+++ b/include/gwin/slider.h
@@ -82,7 +82,7 @@ extern "C" {
*
* @api
*/
-GHandle gwinCreateSlider(GSliderObject *gb, GWidgetInit *pInit);
+GHandle gwinCreateSlider(GSliderObject *gb, const GWidgetInit *pInit);
/**
* @brief Set the slider range.
diff --git a/src/gdisp/image.c b/src/gdisp/image.c
index fec05147..efeb6ad1 100644
--- a/src/gdisp/image.c
+++ b/src/gdisp/image.c
@@ -184,6 +184,14 @@ void gdispImageClose(gdispImage *img) {
img->fns->close(img);
else
img->io.fns->close(&img->io);
+ img->type = GDISP_IMAGE_TYPE_UNKNOWN;
+ img->flags = 0;
+ img->fns = 0;
+ img->priv = 0;
+}
+
+bool_t gdispImageIsOpen(gdispImage *img) {
+ return img->type != GDISP_IMAGE_TYPE_UNKNOWN && img->fns != 0;
}
void gdispImageSetBgColor(gdispImage *img, color_t bgcolor) {
diff --git a/src/gwin/button.c b/src/gwin/button.c
index 4f823aa6..303d1078 100644
--- a/src/gwin/button.c
+++ b/src/gwin/button.c
@@ -151,7 +151,7 @@ static uint16_t ToggleGet(GWidgetObject *gw, uint16_t role) {
return ((GButtonObject *)gw)->toggle;
}
-GHandle gwinCreateButton(GButtonObject *gw, GWidgetInit *pInit) {
+GHandle gwinCreateButton(GButtonObject *gw, const GWidgetInit *pInit) {
if (!(gw = (GButtonObject *)_gwidgetCreate(&gw->w, pInit, &buttonVMT)))
return 0;
diff --git a/src/gwin/checkbox.c b/src/gwin/checkbox.c
index b4628ae0..62f4c55b 100644
--- a/src/gwin/checkbox.c
+++ b/src/gwin/checkbox.c
@@ -113,7 +113,7 @@ static uint16_t ToggleGet(GWidgetObject *gw, uint16_t role) {
return ((GCheckboxObject *)gw)->toggle;
}
-GHandle gwinCreateCheckbox(GCheckboxObject *gb, GWidgetInit *pInit) {
+GHandle gwinCreateCheckbox(GCheckboxObject *gb, const GWidgetInit *pInit) {
if (!(gb = (GCheckboxObject *)_gwidgetCreate(&gb->w, pInit, &checkboxVMT)))
return 0;
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
diff --git a/src/gwin/graph.c b/src/gwin/graph.c
index 81ce1b5f..049f52e0 100644
--- a/src/gwin/graph.c
+++ b/src/gwin/graph.c
@@ -165,7 +165,7 @@ static void lineto(GGraphObject *gg, coord_t x0, coord_t y0, coord_t x1, coord_t
}
}
-GHandle gwinCreateGraph(GGraphObject *gg, GWindowInit *pInit) {
+GHandle gwinCreateGraph(GGraphObject *gg, const GWindowInit *pInit) {
if (!(gg = (GGraphObject *)_gwindowCreate(&gg->g, pInit, &graphVMT, 0)))
return 0;
gg->xorigin = gg->yorigin = 0;
diff --git a/src/gwin/gwidget.c b/src/gwin/gwidget.c
index 2825bf4c..a2b82f1d 100644
--- a/src/gwin/gwidget.c
+++ b/src/gwin/gwidget.c
@@ -165,7 +165,7 @@ void _gwidgetInit(void) {
geventRegisterCallback(&gl, gwidgetEvent, 0);
}
-GHandle _gwidgetCreate(GWidgetObject *pgw, GWidgetInit *pInit, const gwidgetVMT *vmt) {
+GHandle _gwidgetCreate(GWidgetObject *pgw, const GWidgetInit *pInit, const gwidgetVMT *vmt) {
if (!(pgw = (GWidgetObject *)_gwindowCreate(&pgw->g, &pInit->g, &vmt->g, GWIN_FLG_WIDGET|GWIN_FLG_ENABLED)))
return 0;
diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c
index 110d35cc..c1122b3f 100644
--- a/src/gwin/gwin.c
+++ b/src/gwin/gwin.c
@@ -52,7 +52,7 @@ static color_t defaultBgColor = Black;
} else
gwinClear(gh);
}
- static void _gwm_redim(GHandle gh, GWindowInit *pInit) {
+ static void _gwm_redim(GHandle gh, const GWindowInit *pInit) {
gh->x = pInit->x; gh->y = pInit->y;
gh->width = pInit->width; gh->height = pInit->height;
if (gh->x < 0) { gh->width += gh->x; gh->x = 0; }
@@ -85,7 +85,7 @@ void _gwinInit(void) {
// Internal routine for use by GWIN components only
// Initialise a window creating it dynamically if required.
-GHandle _gwindowCreate(GWindowObject *pgw, GWindowInit *pInit, const gwinVMT *vmt, uint16_t flags) {
+GHandle _gwindowCreate(GWindowObject *pgw, const GWindowInit *pInit, const gwinVMT *vmt, uint16_t flags) {
// Allocate the structure if necessary
if (!pgw) {
if (!(pgw = (GWindowObject *)gfxAlloc(vmt->size)))
@@ -149,7 +149,7 @@ void gwinSetDefaultBgColor(color_t bgclr) {
* The GWindow Routines
*-----------------------------------------------*/
-GHandle gwinCreateWindow(GWindowObject *pgw, GWindowInit *pInit) {
+GHandle gwinCreateWindow(GWindowObject *pgw, const GWindowInit *pInit) {
if (!(pgw = _gwindowCreate(pgw, pInit, &basegwinVMT, 0)))
return 0;
gwinSetVisible(pgw, pInit->show);
diff --git a/src/gwin/slider.c b/src/gwin/slider.c
index 08dd6ca7..2dfa3a7c 100644
--- a/src/gwin/slider.c
+++ b/src/gwin/slider.c
@@ -233,7 +233,7 @@ static uint16_t DialGet(GWidgetObject *gw, uint16_t role) {
return ((GSliderObject *)gw)->dial;
}
-GHandle gwinCreateSlider(GSliderObject *gs, GWidgetInit *pInit) {
+GHandle gwinCreateSlider(GSliderObject *gs, const GWidgetInit *pInit) {
if (!(gs = (GSliderObject *)_gwidgetCreate(&gs->w, pInit, &sliderVMT)))
return 0;
gs->t_dn = (uint16_t) -1;