GWIN Init structures are const (read-only to GWIN)

remotes/origin_old/ugfx_release_2.6
inmarket 2013-07-01 17:34:13 +10:00
parent a51ffd5b68
commit 57d3632e36
15 changed files with 21 additions and 23 deletions

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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
/**

View File

@ -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.

View File

@ -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.
*
* @{
*/

View File

@ -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.

View File

@ -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.

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;