13 #include "../../gfx.h"
15 #if (GFX_USE_GWIN && GWIN_NEED_PROGRESSBAR) || defined(__DOXYGEN__)
17 #include "gwin_class.h"
20 static void PBResetDisplayPos(GProgressbarObject *gsw) {
21 if (gsw->w.g.width < gsw->w.g.height)
22 gsw->dpos = gsw->w.g.height-1-((gsw->w.g.height-1)*(gsw->pos-gsw->min))/(gsw->max-gsw->min);
24 gsw->dpos = ((gsw->w.g.width-1)*(gsw->pos-gsw->min))/(gsw->max-gsw->min);
28 static void PBDestroy(
GHandle gh) {
29 #if GWIN_PROGRESSBAR_AUTO
41 sizeof(GProgressbarObject),
54 #if GINPUT_NEED_KEYBOARD || GWIN_NEED_KEYBOARD
59 #if GINPUT_NEED_TOGGLE
79 if (!(gs = (GProgressbarObject *)_gwidgetCreate(g, &gs->w, pInit, &progressbarVMT)))
87 #if GWIN_PROGRESSBAR_AUTO
91 PBResetDisplayPos(gs);
98 #define gsw ((GProgressbarObject *)gh)
117 PBResetDisplayPos(gsw);
123 #define gsw ((GProgressbarObject *)gh)
128 if (pos < gsw->min) gsw->pos = gsw->min;
129 else if (pos > gsw->max) gsw->pos = gsw->max;
132 PBResetDisplayPos(gsw);
139 #define gsw ((GProgressbarObject *)gh)
144 gsw->res = resolution;
150 #define gsw ((GProgressbarObject *)gh)
155 gsw->pos += gsw->res;
156 if (gsw->pos < gsw->min) gsw->pos = gsw->min;
157 else if (gsw->pos > gsw->max) gsw->pos = gsw->max;
159 PBResetDisplayPos(gsw);
166 #define gsw ((GProgressbarObject *)gh)
171 gsw->pos -= gsw->res;
172 if (gsw->pos < gsw->min) gsw->pos = gsw->min;
173 else if (gsw->pos > gsw->max) gsw->pos = gsw->max;
175 PBResetDisplayPos(gsw);
181 #if GWIN_PROGRESSBAR_AUTO
183 static void _progressbarCallback(
void *param) {
184 #define gsw ((GProgressbarObject *)gh)
192 if (gsw->pos >= gsw->max)
199 #define gsw ((GProgressbarObject *)gh)
204 gtimerStart(&gsw->gt, _progressbarCallback, gh, gTrue, delay);
210 #define gsw ((GProgressbarObject *)gh)
226 #define gsw ((GProgressbarObject *)gw)
235 if ((gw->
g.
flags & GWIN_FLG_SYSENABLED))
242 if (gsw->dpos != gw->
g.
height-1)
251 if (gsw->dpos != gw->
g.
width-1)
265 #define gsw ((GProgressbarObject *)gw)
266 #define gi ((gImage *)param)
273 if ((gw->
g.
flags & GWIN_FLG_SYSENABLED))
282 if (gsw->dpos != gw->
g.
height-1) {
283 for(z=gw->
g.
height, v=gi->height; z > gsw->dpos;) {
297 if (gsw->dpos != gw->
g.
width-1)
299 if (gsw->dpos != 0) {
300 for(z=0, v=gi->width; z < gsw->dpos; z += v) {
302 v -= z+v - gsw->dpos;
void gdispGDrawStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char *str, gFont font, gColor color, gJustify justify)
Draw a text string vertically centered within the specified box.
void gdispGFillArea(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor color)
Fill an area with a color.
void gdispGDrawLine(GDisplay *g, gCoord x0, gCoord y0, gCoord x1, gCoord y1, gColor color)
Draw a line.
gI16 gCoord
The type for a coordinate or length on the screen.
void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor color)
Draw a rectangular box.
void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, gBool periodic, gDelay millisec)
Set a timer going or alter its properties if it is already going.
void gtimerInit(GTimer *pt)
Initialise a timer.
void gtimerDeinit(GTimer *pt)
Deinitialise a timer.
void gtimerStop(GTimer *pt)
Stop a timer (periodic or otherwise)
#define gt(str)
A wrapper macro to make writing and reading translatable applications easier.
gdispImageError gdispGImageDraw(GDisplay *g, gImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy)
Draw the image.
void gwinProgressbarSetRange(GHandle gh, int min, int max)
Set the progressbar range.
void gwinProgressbarStop(GHandle gh)
Stop the timer which is started by gwinProgressbarStart()
GHandle gwinGProgressbarCreate(GDisplay *g, GProgressbarObject *gs, const GWidgetInit *pInit)
Create a progressbar window.
void gwinProgressbarSetResolution(GHandle gh, int resolution)
Set the resolution for the incrementation and decrementation of the progressbar.
void gwinProgressbarSetPosition(GHandle gh, int pos)
Set the progressbar position.
void gwinProgressbarIncrement(GHandle gh)
Increment the progressbar value.
void gwinProgressbarDecrement(GHandle gh)
Decrement the progressbar value.
void gwinProgressbarStart(GHandle gh, gDelay delay)
Automatically increments the progress bar.
void gwinProgressbarDraw_Std(GWidgetObject *gw, void *param)
The default rendering function for the progressbar widget.
void gwinProgressbarDraw_Image(GWidgetObject *gw, void *param)
Renders a progressbar using an image.
void gwinSetVisible(GHandle gh, gBool visible)
Sets whether a window is visible or not.
A window object structure.
const struct gwinVMT * vmt
The Virtual Method Table for a GWIN window.