Difference between revisions of "Progressbar"
(Created page with "GWIN - Progressbar A progressbar is a rectangular box to visualize the progression of a progress or an operation. The progressbar widget can either be controlled manually or...") |
(→API reference) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | A progressbar is a rectangular box to visualize the progression of a progress or an operation. The progressbar widget can either be controlled manually or automatically. In both cases, the range of the progressbar can be changed through the <code>gwinProgressbarSetRange()</code> call. The default values are 0 to 100. Furthermore, the resolution can be modified through <code>gwinProgressbarSetResolution()</code>. This changes the size of the steps in which the progressbar will be incremented or decremented. The default resolution is 1. | |
− | + | == API reference == | |
+ | The API reference of the progressbar can be found [http://api.ugfx.org/group___progressbar.html here]. | ||
− | + | == Custom Draw Routines == | |
+ | The slider widget predefines a number of custom draw routines. They can be set using <code>gwinSetCustomDraw()</code> or by specifying the custom draw routine in the GWidgetInit structure during creation. The predefined custom draw routines are: | ||
+ | {| class="wikitable" | ||
+ | ! scope="col"|Custom Draw Routine | ||
+ | ! scope="col"|Description | ||
+ | |- | ||
+ | |gwinProgressbarDraw_Std | ||
+ | | The standard progress bar look. | ||
+ | |- | ||
+ | |gwinProgressbarDraw_Image | ||
+ | | The parameter is an open gdispImage that is tiled to fill the active part of the progress bar. | ||
+ | |} | ||
− | Manual | + | == Manual == |
There are two ways to change the value that a progressbar displays: | There are two ways to change the value that a progressbar displays: | ||
− | gwinProgressbarSetPosition() | + | * <code>gwinProgressbarSetPosition()</code> |
− | gwinProgressbarIncrease() and gwinProgressbarDecrease() | + | * <code>gwinProgressbarIncrease()</code> and <code>gwinProgressbarDecrease()</code> |
− | You can also use them together and mix them up. Note that the increase and decrease call increment and decrement by the resolution that was set using gwinProgressbarSetResolution(). | + | You can also use them together and mix them up. Note that the increase and decrease call increment and decrement by the resolution that was set using <code>gwinProgressbarSetResolution()</code>. |
+ | === Example === | ||
The following example shows how a progressbar is created and controlled manually. The range of the progressbar has not been modified and is therefore 0 to 100. The resolution has not been modified either and is therefore 1. | The following example shows how a progressbar is created and controlled manually. The range of the progressbar has not been modified and is therefore 0 to 100. The resolution has not been modified either and is therefore 1. | ||
<syntaxhighlight lang=c> | <syntaxhighlight lang=c> | ||
Line 53: | Line 66: | ||
− | Automatic | + | == Automatic == |
− | Note: You have to set GWIN_PROGRESSBAR_AUTO to TRUE in your gfxconf.h to use this feature. | + | '''''Note:''' You have to set <code>GWIN_PROGRESSBAR_AUTO</code> to ''TRUE'' in your [[gfxconf.h]] to use this feature.'' |
− | Using the gwinProgressbarStart() call, a progressbar can be automatically increased from its current to its maximum value. The GTIMER module is internally used for this purpose. No event is generated once the progressbar reached its maximum value. | + | Using the <code>gwinProgressbarStart()</code> call, a progressbar can be automatically increased from its current to its maximum value. The [[GTIMER]] module is internally used for this purpose. No event is generated once the progressbar reached its maximum value. |
The following example shows how a progressbar is created and controlled automatically. The range of the progressbar has not been modified and is therefore 0 to 100. The resolution is set to 10 and the timer interval to 500ms. Therefore it will take around 5 seconds until the progressbar reached its maximum value. | The following example shows how a progressbar is created and controlled automatically. The range of the progressbar has not been modified and is therefore 0 to 100. The resolution is set to 10 and the timer interval to 500ms. Therefore it will take around 5 seconds until the progressbar reached its maximum value. | ||
+ | |||
+ | === Example === | ||
<syntaxhighlight lang=c> | <syntaxhighlight lang=c> | ||
#include "gfx.h" | #include "gfx.h" | ||
Line 95: | Line 110: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
[[Category:Widget]] | [[Category:Widget]] |
Latest revision as of 15:48, 4 February 2016
A progressbar is a rectangular box to visualize the progression of a progress or an operation. The progressbar widget can either be controlled manually or automatically. In both cases, the range of the progressbar can be changed through the gwinProgressbarSetRange()
call. The default values are 0 to 100. Furthermore, the resolution can be modified through gwinProgressbarSetResolution()
. This changes the size of the steps in which the progressbar will be incremented or decremented. The default resolution is 1.
API reference
The API reference of the progressbar can be found here.
Custom Draw Routines
The slider widget predefines a number of custom draw routines. They can be set using gwinSetCustomDraw()
or by specifying the custom draw routine in the GWidgetInit structure during creation. The predefined custom draw routines are:
Custom Draw Routine | Description |
---|---|
gwinProgressbarDraw_Std | The standard progress bar look. |
gwinProgressbarDraw_Image | The parameter is an open gdispImage that is tiled to fill the active part of the progress bar. |
Manual
There are two ways to change the value that a progressbar displays:
-
gwinProgressbarSetPosition()
-
gwinProgressbarIncrease()
andgwinProgressbarDecrease()
You can also use them together and mix them up. Note that the increase and decrease call increment and decrement by the resolution that was set using gwinProgressbarSetResolution()
.
Example
The following example shows how a progressbar is created and controlled manually. The range of the progressbar has not been modified and is therefore 0 to 100. The resolution has not been modified either and is therefore 1.
#include "gfx.h" GHandle ghProgressbar; static void _createWidget(void) { GWidgetInit wi; wi.customDraw = 0; wi.customParam = 0; wi.customStyle = 0; wi.g.show = TRUE; wi.g.y = 10; wi.g.x = 10; wi.g.width = 200; wi.g.height = 20; wi.text = "Progress 1"; ghProgressbar = gwinProgressbarCreate(NULL, &wi); } int main(void) { gfxInit(); gwinSetDefaultFont(gdispOpenFont("UI2")); gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE); gdispClear(White); _createWidget(); // use any of these however you need them gwinProgressbarSetPosition(ghProgressbar, 42); gwinProgressbarIncrement(ghProgressbar); gwinProgressbarDecrement(ghProgressbar); while (1) { gfxSleepMilliseconds(500); } return 0; }
Automatic
Note: You have to set GWIN_PROGRESSBAR_AUTO
to TRUE in your gfxconf.h to use this feature.
Using the gwinProgressbarStart()
call, a progressbar can be automatically increased from its current to its maximum value. The GTIMER module is internally used for this purpose. No event is generated once the progressbar reached its maximum value.
The following example shows how a progressbar is created and controlled automatically. The range of the progressbar has not been modified and is therefore 0 to 100. The resolution is set to 10 and the timer interval to 500ms. Therefore it will take around 5 seconds until the progressbar reached its maximum value.
Example
#include "gfx.h" GHandle ghProgressbar; static void _createWidget(void) { GWidgetInit wi; wi.customDraw = 0; wi.customParam = 0; wi.customStyle = 0; wi.g.show = TRUE; wi.g.y = 10; wi.g.x = 10; wi.g.width = 200; wi.g.height = 20; wi.text = "Progress 1"; ghProgressbar = gwinProgressbarCreate(NULL, &wi); } int main(void) { gfxInit(); gwinSetDefaultFont(gdispOpenFont("UI2")); gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE); gdispClear(White); _createWidget(); gwinProgressbarSetResolution(ghProgressbar, 10); gwinProgressbarStart(ghProgressbar, 500); while (1) { gfxSleepMilliseconds(500); } return 0; }