diff options
author | inmarket <andrewh@inmarket.com.au> | 2013-06-24 22:58:37 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2013-06-24 22:58:37 +1000 |
commit | 8ed9e763c0f97f2946990a911bb940f8c80ff761 (patch) | |
tree | 5f6c19677a530ddfada345242bce1190e3797dfa /include | |
parent | c8300fe9c2c7facff1ad32978a5d961690473de4 (diff) | |
download | uGFX-8ed9e763c0f97f2946990a911bb940f8c80ff761.tar.gz uGFX-8ed9e763c0f97f2946990a911bb940f8c80ff761.tar.bz2 uGFX-8ed9e763c0f97f2946990a911bb940f8c80ff761.zip |
GWIN reduce Initialisation parameters and fix visibility issues
Diffstat (limited to 'include')
-rw-r--r-- | include/gwin/button.h | 9 | ||||
-rw-r--r-- | include/gwin/checkbox.h | 9 | ||||
-rw-r--r-- | include/gwin/class_gwin.h | 11 | ||||
-rw-r--r-- | include/gwin/console.h | 11 | ||||
-rw-r--r-- | include/gwin/graph.h | 8 | ||||
-rw-r--r-- | include/gwin/gwidget.h | 16 | ||||
-rw-r--r-- | include/gwin/gwin.h | 23 | ||||
-rw-r--r-- | include/gwin/slider.h | 9 |
8 files changed, 50 insertions, 46 deletions
diff --git a/include/gwin/button.h b/include/gwin/button.h index 21de74bd..a6b19333 100644 --- a/include/gwin/button.h +++ b/include/gwin/button.h @@ -70,26 +70,21 @@ extern "C" { * @return NULL if there is no resultant drawing area, otherwise a window handle. * * @param[in] gb The GButtonObject structure to initialise. If this is NULL the structure is dynamically allocated. - * @param[in] x,y The screen co-ordinates for the top left corner of the window - * @param[in] width The width of the window - * @param[in] height The height of the window + * @param[in] pInit The initialisation parameters * * @note The drawing color and the background color get set to the current defaults. If you haven't called * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively. * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there * is no default font and text drawing operations will no nothing. - * @note The dimensions and position may be changed to fit on the real screen. * @note A button remembers its normal drawing state. If there is a window manager then it is automatically * redrawn if the window is moved or its visibility state is changed. - * @note The button is initially marked as invisible so that more properties can be set before display. - * Call @p gwinSetVisible() to display it when ready. * @note A button supports mouse and a toggle input. * @note When assigning a toggle, only one toggle is supported. If you try to assign more than one toggle it will * forget the previous toggle. When assigning a toggle the role parameter must be 0. * * @api */ -GHandle gwinCreateButton(GButtonObject *gb, coord_t x, coord_t y, coord_t width, coord_t height); +GHandle gwinCreateButton(GButtonObject *gb, GWidgetInit *pInit); /** * @brief Set the colors of a button. diff --git a/include/gwin/checkbox.h b/include/gwin/checkbox.h index 4a5e032a..9a19a2e1 100644 --- a/include/gwin/checkbox.h +++ b/include/gwin/checkbox.h @@ -59,26 +59,21 @@ typedef struct GCheckboxObject_t { * @return NULL if there is no resultant drawing area, otherwise a window handle. * * @param[in] gb The GCheckboxObject structure to initialise. If this is NULL, the structure is dynamically allocated. - * @param[in] x,y The screen co-ordinates for the top left corner of the window - * @param[in] width The width of the window - * @param[in] height The height of the window + * @param[in] pInit The initialization parameters to use * * @note The drawing color and the background color get set to the current defaults. If you haven't called * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively. * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there * is no default font and text drawing operations will no nothing. - * @note The dimensions and position may be changed to fit on the real screen. * @note A checkbox remembers its normal drawing state. If there is a window manager then it is automatically * redrawn if the window is moved or its visibility state is changed. - * @note The checkbox is initially marked as invisible so that more properties can be set before display. - * Call @p gwinSetVisible() to display it when ready. * @note A checkbox supports mouse and a toggle input. * @note When assigning a toggle, only one toggle is supported. If you try to assign more than one toggle it will * forget the previous toggle. When assigning a toggle the role parameter must be 0. * * @api */ -GHandle gwinCreateCheckbox(GCheckboxObject *gb, coord_t x, coord_t y, coord_t width, coord_t height); +GHandle gwinCreateCheckbox(GCheckboxObject *gb, GWidgetInit *pInit); /** * @brief Get the state of a checkbox diff --git a/include/gwin/class_gwin.h b/include/gwin/class_gwin.h index eda69e1e..c3d2ee36 100644 --- a/include/gwin/class_gwin.h +++ b/include/gwin/class_gwin.h @@ -45,6 +45,7 @@ */ typedef struct gwinVMT { const char * classname; // @< The GWIN classname (mandatory) + size_t size; // @< The size of the class object void (*Destroy) (GWindowObject *gh); // @< The GWIN destroy function (optional) void (*Redraw) (GWindowObject *gh); // @< The GWIN redraw routine (optional) void (*AfterClear) (GWindowObject *gh); // @< The GWIN after-clear function (optional) @@ -116,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, coord_t x, coord_t y, coord_t w, coord_t h); // @< A window has been added + bool_t (*Add) (GHandle gh, 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 @@ -139,15 +140,13 @@ extern "C" { * @brief Initialise (and allocate if necessary) the base GWIN object * * @param[in] pgw The GWindowObject structure. If NULL one is allocated from the heap - * @param[in] x, y The top left corner of the GWIN relative to the screen - * @param[in] w, h The width and height of the GWIN window - * @param[in] size The size of the GWIN object to allocate + * @param[in] pInit The user initialization parameters * @param[in] vmt The virtual method table for the GWIN object * @param[in] flags The default flags to use * * @notapi */ -GHandle _gwindowCreate(GWindowObject *pgw, coord_t x, coord_t y, coord_t w, coord_t h, size_t size, const gwinVMT *vmt, uint16_t flags); +GHandle _gwindowCreate(GWindowObject *pgw, GWindowInit *pInit, const gwinVMT *vmt, uint16_t flags); #if GWIN_NEED_WIDGET || defined(__DOXYGEN__) /** @@ -161,7 +160,7 @@ GHandle _gwindowCreate(GWindowObject *pgw, coord_t x, coord_t y, coord_t w, coor * * @notapi */ - GHandle _gwidgetCreate(GWidgetObject *pgw, coord_t x, coord_t y, coord_t w, coord_t h, size_t size, const gwidgetVMT *vmt); + GHandle _gwidgetCreate(GWidgetObject *pgw, GWidgetInit *pInit, const gwidgetVMT *vmt); /** * @brief Destroy the Widget object diff --git a/include/gwin/console.h b/include/gwin/console.h index 5682113e..38c88f63 100644 --- a/include/gwin/console.h +++ b/include/gwin/console.h @@ -51,23 +51,20 @@ extern "C" { * @return NULL if there is no resultant drawing area, otherwise a window handle. * * @param[in] gc The GConsoleObject structure to initialise. If this is NULL the structure is dynamically allocated. - * @param[in] x,y The screen co-ordinates for the top left corner of the window - * @param[in] width The width of the window - * @param[in] height The height of the window + * @param[in] pInit The initialization parameters to use * * @note The drawing color and the background color get set to the current defaults. If you haven't called * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively. * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there * is no default font and text drawing operations will no nothing. - * @note The dimensions and position may be changed to fit on the real screen. - * @note On creation the window is marked as visible but is not automatically cleared. You may do that by calling @p gwinClear() - * (possibly after changing your background color) + * @note On creation even if the window is visible it is not automatically cleared. + * You may do that by calling @p gwinClear() (possibly after changing your background color) * @note A console does not save the drawing state. It is not automatically redrawn if the window is moved or * its visibility state is changed. * * @api */ -GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height); +GHandle gwinCreateConsole(GConsoleObject *gc, GWindowInit *pInit); #if GFX_USE_OS_CHIBIOS && GWIN_CONSOLE_USE_BASESTREAM /** diff --git a/include/gwin/graph.h b/include/gwin/graph.h index 2595d2e7..5e6abee1 100644 --- a/include/gwin/graph.h +++ b/include/gwin/graph.h @@ -91,17 +91,13 @@ extern "C" { * @return NULL if there is no resultant drawing area, otherwise a window handle. * * @param[in] gg The GGraphObject structure to initialise. If this is NULL the structure is dynamically allocated. - * @param[in] x,y The screen co-ordinates for the top left corner of the window - * @param[in] width The width of the window - * @param[in] height The height of the window + * @param[in] pInit The initialization parameters to use * * @note The drawing color and the background color get set to the current defaults. If you haven't called * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively. * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there * is no default font and text drawing operations will no nothing. * @note The dimensions and position may be changed to fit on the real screen. - * @note On creation the window is marked as visible but is not automatically cleared. You may do that by calling @p gwinClear() - * (possibly after changing your background color) * @note A graph does not save the drawing state. It is not automatically redrawn if the window is moved or * its visibility state is changed. * @note The coordinate system within the window for graphing operations (but not for any other drawing @@ -111,7 +107,7 @@ extern "C" { * * @api */ -GHandle gwinCreateGraph(GGraphObject *gg, coord_t x, coord_t y, coord_t width, coord_t height); +GHandle gwinCreateGraph(GGraphObject *gg, GWindowInit *pInit); /** * @brief Set the style of the graphing operations. diff --git a/include/gwin/gwidget.h b/include/gwin/gwidget.h index 0c47dfde..50f19193 100644 --- a/include/gwin/gwidget.h +++ b/include/gwin/gwidget.h @@ -53,6 +53,22 @@ typedef struct GWidgetObject { /* @} */ /** + * @brief The structure to initialise a widget. + * + * @note Some widgets may have extra parameters. + * @note The text element must be static string (not stack allocated). If you want to use + * a dynamic string (eg a stack allocated string) use NULL for this member and then call + * @p gwinSetText() with useAlloc set to TRUE. + * + * @{ + */ +typedef struct GWidgetInit { + GWindowInit g; // @< The GWIN initializer + const char * text; // @< The initial text +} GWidgetInit; +/* @} */ + +/** * A comment/rant on the above structure: * We would really like the GWindowObject member to be anonymous. While this is * allowed under the C11, C99, GNU and various other standards which have been diff --git a/include/gwin/gwin.h b/include/gwin/gwin.h index efce49fc..2a03c125 100644 --- a/include/gwin/gwin.h +++ b/include/gwin/gwin.h @@ -50,6 +50,21 @@ typedef struct GWindowObject { /* @} */ /** + * @brief The structure to initialise a GWIN. + * + * @note Some gwin's will need extra parameters. + * @note The dimensions and position may be changed to fit on the real screen. + * + * @{ + */ +typedef struct GWindowInit { + coord_t x, y; // @< The initial screen position + coord_t width, height; // @< The initial dimension + bool_t show; // @< Should the window be visible initially +} GWindowInit; +/* @} */ + +/** * @brief A window's minimized, maximized or normal size */ typedef enum { GWIN_NORMAL, GWIN_MAXIMIZE, GWIN_MINIMIZE } GWindowMinMax; @@ -128,22 +143,18 @@ extern "C" { * @return NULL if there is no resultant drawing area, otherwise a window handle. * * @param[in] pgw The window structure to initialize. If this is NULL the structure is dynamically allocated. - * @param[in] x,y The screen coordinates for the top left corner of the window - * @param[in] width The width of the window - * @param[in] height The height of the window + * @param[in] pInit How to initialise the window * * @note The drawing color and the background color get set to the current defaults. If you haven't called * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively. * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there * is no default font and text drawing operations will no nothing. - * @note The dimensions and position may be changed to fit on the real screen. - * @note On creation the window is marked as visible. * @note A basic window does not save the drawing state. It is not automatically redrawn if the window is moved or * its visibility state is changed. * * @api */ - GHandle gwinCreateWindow(GWindowObject *pgw, coord_t x, coord_t y, coord_t width, coord_t height); + GHandle gwinCreateWindow(GWindowObject *pgw, 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 9baecbb1..4479950f 100644 --- a/include/gwin/slider.h +++ b/include/gwin/slider.h @@ -64,19 +64,14 @@ extern "C" { * @return NULL if there is no resultant drawing area, otherwise a window handle. * * @param[in] gb The GSliderObject structure to initialise. If this is NULL the structure is dynamically allocated. - * @param[in] x,y The screen co-ordinates for the top left corner of the window - * @param[in] width The width of the window - * @param[in] height The height of the window + * @param[in] pInit The initialization parameters to use * * @note The drawing color and the background color get set to the current defaults. If you haven't called * @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively. * @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there * is no default font and text drawing operations will no nothing. - * @note The dimensions and position may be changed to fit on the real screen. * @note A slider remembers its normal drawing state. If there is a window manager then it is automatically * redrawn if the window is moved or its visibility state is changed. - * @note The slider is initially marked as invisible so that more properties can be set before display. - * Call @p gwinSetVisible() to display it when ready. * @note The initial slider range is from 0 to 100 with an initial position of 0. * @note A slider supports mouse, toggle and dial input. * @note When assigning a toggle, only one toggle is supported per role. If you try to assign more than @@ -87,7 +82,7 @@ extern "C" { * * @api */ -GHandle gwinCreateSlider(GSliderObject *gb, coord_t x, coord_t y, coord_t width, coord_t height); +GHandle gwinCreateSlider(GSliderObject *gb, GWidgetInit *pInit); /** * @brief Set the slider range. |