Adding justification parameter to gwinLabelCreate()
This commit is contained in:
parent
c2b7e1bd41
commit
e8a769c382
9 changed files with 34 additions and 27 deletions
|
@ -228,19 +228,19 @@ static void createWidgets(void) {
|
||||||
wi.g.parent = ghPgLabels;
|
wi.g.parent = ghPgLabels;
|
||||||
wi.g.width = pagewidth-10; wi.g.height = LABEL_HEIGHT;
|
wi.g.width = pagewidth-10; wi.g.height = LABEL_HEIGHT;
|
||||||
wi.g.x = wi.g.y = 5; wi.text = "N/A";
|
wi.g.x = wi.g.y = 5; wi.text = "N/A";
|
||||||
ghLabelSlider1 = gwinLabelCreate(0, &wi);
|
ghLabelSlider1 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
gwinLabelSetAttribute(ghLabelSlider1, 100, "Slider 1:");
|
gwinLabelSetAttribute(ghLabelSlider1, 100, "Slider 1:");
|
||||||
wi.g.y += LABEL_HEIGHT + 2;
|
wi.g.y += LABEL_HEIGHT + 2;
|
||||||
ghLabelSlider2 = gwinLabelCreate(0, &wi);
|
ghLabelSlider2 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
gwinLabelSetAttribute(ghLabelSlider2, 100, "Slider 2:");
|
gwinLabelSetAttribute(ghLabelSlider2, 100, "Slider 2:");
|
||||||
wi.g.y += LABEL_HEIGHT + 2;
|
wi.g.y += LABEL_HEIGHT + 2;
|
||||||
ghLabelSlider3 = gwinLabelCreate(0, &wi);
|
ghLabelSlider3 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
gwinLabelSetAttribute(ghLabelSlider3, 100, "Slider 3:");
|
gwinLabelSetAttribute(ghLabelSlider3, 100, "Slider 3:");
|
||||||
wi.g.y += LABEL_HEIGHT + 2;
|
wi.g.y += LABEL_HEIGHT + 2;
|
||||||
ghLabelSlider4 = gwinLabelCreate(0, &wi);
|
ghLabelSlider4 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
gwinLabelSetAttribute(ghLabelSlider4, 100, "Slider 4:");
|
gwinLabelSetAttribute(ghLabelSlider4, 100, "Slider 4:");
|
||||||
wi.g.y += LABEL_HEIGHT + 2;
|
wi.g.y += LABEL_HEIGHT + 2;
|
||||||
ghLabelRadio1 = gwinLabelCreate(0, &wi);
|
ghLabelRadio1 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
gwinLabelSetAttribute(ghLabelRadio1, 100, "RadioButton 1:");
|
gwinLabelSetAttribute(ghLabelRadio1, 100, "RadioButton 1:");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ static void _createWidgets(void) {
|
||||||
wi.g.y = 100;
|
wi.g.y = 100;
|
||||||
wi.g.x = 150;
|
wi.g.x = 150;
|
||||||
wi.text = "Surprise!";
|
wi.text = "Surprise!";
|
||||||
gwinLabelCreate(0, &wi);
|
gwinLabelCreate(0, &wi, justifyCenter);
|
||||||
|
|
||||||
// Apply the frame parameters
|
// Apply the frame parameters
|
||||||
wi.g.width = 300;
|
wi.g.width = 300;
|
||||||
|
|
|
@ -42,13 +42,13 @@ static void createWidgets(void) {
|
||||||
// Create the IP label
|
// Create the IP label
|
||||||
wi.g.width = 200; wi.g.height = 20; wi.g.x = 10, wi.g.y = 80;
|
wi.g.width = 200; wi.g.height = 20; wi.g.x = 10, wi.g.y = 80;
|
||||||
wi.text = "192.168.1.42";
|
wi.text = "192.168.1.42";
|
||||||
ghLabel1 = gwinLabelCreate(0, &wi);
|
ghLabel1 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
gwinLabelSetAttribute(ghLabel1, 100, "Current IP:");
|
gwinLabelSetAttribute(ghLabel1, 100, "Current IP:");
|
||||||
|
|
||||||
// Create the DHCP label
|
// Create the DHCP label
|
||||||
wi.g.width = 200; wi.g.height = 20; wi.g.x = 10, wi.g.y = 100;
|
wi.g.width = 200; wi.g.height = 20; wi.g.x = 10, wi.g.y = 100;
|
||||||
wi.text = "Off";
|
wi.text = "Off";
|
||||||
ghLabel2 = gwinLabelCreate(0, &wi);
|
ghLabel2 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
gwinLabelSetAttribute(ghLabel2, 100, "DHCP:");
|
gwinLabelSetAttribute(ghLabel2, 100, "DHCP:");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,12 +43,12 @@ static void createWidgets(void) {
|
||||||
// Create the label for the first list
|
// Create the label for the first list
|
||||||
wi.g.width = 150; wi.g.height = 20; wi.g.x = 10, wi.g.y = 80;
|
wi.g.width = 150; wi.g.height = 20; wi.g.x = 10, wi.g.y = 80;
|
||||||
wi.text = "List 1: Default";
|
wi.text = "List 1: Default";
|
||||||
ghLabel1 = gwinLabelCreate(0, &wi);
|
ghLabel1 = gwinLabelCreate(0, &wi, justifyCenter);
|
||||||
|
|
||||||
// Create the label for the second list
|
// Create the label for the second list
|
||||||
wi.g.width = 150; wi.g.height = 20; wi.g.x = 165, wi.g.y = 80;
|
wi.g.width = 150; wi.g.height = 20; wi.g.x = 165, wi.g.y = 80;
|
||||||
wi.text = "List 2: Smooth scrolling";
|
wi.text = "List 2: Smooth scrolling";
|
||||||
ghLabel1 = gwinLabelCreate(0, &wi);
|
ghLabel1 = gwinLabelCreate(0, &wi, justifyCenter);
|
||||||
|
|
||||||
// The first list widget
|
// The first list widget
|
||||||
wi.g.width = 150;
|
wi.g.width = 150;
|
||||||
|
|
|
@ -52,19 +52,19 @@ static void createWidgets(void) {
|
||||||
wi.g.width = 120; wi.g.height = 20; wi.g.x = 10; wi.g.y = 10;
|
wi.g.width = 120; wi.g.height = 20; wi.g.x = 10; wi.g.y = 10;
|
||||||
wi.g.parent = ghPage1;
|
wi.g.parent = ghPage1;
|
||||||
wi.text = "This is page Nr. 1";
|
wi.text = "This is page Nr. 1";
|
||||||
ghLabel1 = gwinLabelCreate(0, &wi);
|
ghLabel1 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
|
|
||||||
// Add some widgets to Page 2
|
// Add some widgets to Page 2
|
||||||
wi.g.width = 120; wi.g.height = 20; wi.g.x = 10; wi.g.y = 50;
|
wi.g.width = 120; wi.g.height = 20; wi.g.x = 10; wi.g.y = 50;
|
||||||
wi.g.parent = ghPage2;
|
wi.g.parent = ghPage2;
|
||||||
wi.text = "This is page Nr. 2";
|
wi.text = "This is page Nr. 2";
|
||||||
ghLabel2 = gwinLabelCreate(0, &wi);
|
ghLabel2 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
|
|
||||||
// Add some widgets to Page 3
|
// Add some widgets to Page 3
|
||||||
wi.g.width = 120; wi.g.height = 20; wi.g.x = 10; wi.g.y = 90;
|
wi.g.width = 120; wi.g.height = 20; wi.g.x = 10; wi.g.y = 90;
|
||||||
wi.g.parent = ghPage3;
|
wi.g.parent = ghPage3;
|
||||||
wi.text = "This is page Nr. 3";
|
wi.text = "This is page Nr. 3";
|
||||||
ghLabel3 = gwinLabelCreate(0, &wi);
|
ghLabel3 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|
|
@ -325,19 +325,19 @@ static void createWidgets(void) {
|
||||||
wi.g.parent = ghPgLabels;
|
wi.g.parent = ghPgLabels;
|
||||||
wi.g.width = pagewidth-10; wi.g.height = LABEL_HEIGHT;
|
wi.g.width = pagewidth-10; wi.g.height = LABEL_HEIGHT;
|
||||||
wi.g.x = wi.g.y = 5; wi.text = "N/A";
|
wi.g.x = wi.g.y = 5; wi.text = "N/A";
|
||||||
ghLabelSlider1 = gwinLabelCreate(0, &wi);
|
ghLabelSlider1 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
gwinLabelSetAttribute(ghLabelSlider1, 100, "Slider 1:");
|
gwinLabelSetAttribute(ghLabelSlider1, 100, "Slider 1:");
|
||||||
wi.g.y += LABEL_HEIGHT + 2;
|
wi.g.y += LABEL_HEIGHT + 2;
|
||||||
ghLabelSlider2 = gwinLabelCreate(0, &wi);
|
ghLabelSlider2 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
gwinLabelSetAttribute(ghLabelSlider2, 100, "Slider 2:");
|
gwinLabelSetAttribute(ghLabelSlider2, 100, "Slider 2:");
|
||||||
wi.g.y += LABEL_HEIGHT + 2;
|
wi.g.y += LABEL_HEIGHT + 2;
|
||||||
ghLabelSlider3 = gwinLabelCreate(0, &wi);
|
ghLabelSlider3 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
gwinLabelSetAttribute(ghLabelSlider3, 100, "Slider 3:");
|
gwinLabelSetAttribute(ghLabelSlider3, 100, "Slider 3:");
|
||||||
wi.g.y += LABEL_HEIGHT + 2;
|
wi.g.y += LABEL_HEIGHT + 2;
|
||||||
ghLabelSlider4 = gwinLabelCreate(0, &wi);
|
ghLabelSlider4 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
gwinLabelSetAttribute(ghLabelSlider4, 100, "Slider 4:");
|
gwinLabelSetAttribute(ghLabelSlider4, 100, "Slider 4:");
|
||||||
wi.g.y += LABEL_HEIGHT + 2;
|
wi.g.y += LABEL_HEIGHT + 2;
|
||||||
ghLabelRadio1 = gwinLabelCreate(0, &wi);
|
ghLabelRadio1 = gwinLabelCreate(0, &wi, justifyLeft);
|
||||||
gwinLabelSetAttribute(ghLabelRadio1, 100, "RadioButton 1:");
|
gwinLabelSetAttribute(ghLabelRadio1, 100, "RadioButton 1:");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ FEATURE: Added word-wrapping support for gdispDrawStringBox() and gdispFillStrin
|
||||||
FIX: Fixing issue in touchscreen calibration code
|
FIX: Fixing issue in touchscreen calibration code
|
||||||
FEATURE: Added GFX_OS_PRE_INIT_FUNCTION for early hardware initialization
|
FEATURE: Added GFX_OS_PRE_INIT_FUNCTION for early hardware initialization
|
||||||
FIX: Fixing GTIMER for high clock rate devices
|
FIX: Fixing GTIMER for high clock rate devices
|
||||||
|
FEATURE: Adding justification parameter to gwinLabelCreate()
|
||||||
|
|
||||||
|
|
||||||
*** Release 2.3 ***
|
*** Release 2.3 ***
|
||||||
|
|
|
@ -80,7 +80,7 @@ static const gwidgetVMT labelVMT = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit) {
|
GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit, justify_t justify) {
|
||||||
uint16_t flags = 0;
|
uint16_t flags = 0;
|
||||||
|
|
||||||
// auto assign width
|
// auto assign width
|
||||||
|
@ -99,6 +99,8 @@ GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit)
|
||||||
if (!(widget = (GLabelObject *)_gwidgetCreate(g, &widget->w, pInit, &labelVMT)))
|
if (!(widget = (GLabelObject *)_gwidgetCreate(g, &widget->w, pInit, &labelVMT)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
widget->justify = justify;
|
||||||
|
|
||||||
#if GWIN_LABEL_ATTRIBUTE
|
#if GWIN_LABEL_ATTRIBUTE
|
||||||
widget->tab = 0;
|
widget->tab = 0;
|
||||||
widget->attr = 0;
|
widget->attr = 0;
|
||||||
|
@ -163,12 +165,13 @@ void gwinLabelDefaultDraw(GWidgetObject *gw, void *param) {
|
||||||
|
|
||||||
#if GWIN_LABEL_ATTRIBUTE
|
#if GWIN_LABEL_ATTRIBUTE
|
||||||
if (gw2obj->attr) {
|
if (gw2obj->attr) {
|
||||||
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw2obj->tab, h, gw2obj->attr, gw->g.font, c, gw->pstyle->background, justifyLeft);
|
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw2obj->tab, h, gw2obj->attr, gw->g.font, c, gw->pstyle->background, gw2obj->justify);
|
||||||
gdispGFillStringBox(gw->g.display, gw->g.x + gw2obj->tab, gw->g.y, w-gw2obj->tab, h, gw->text, gw->g.font, c, gw->pstyle->background, justifyLeft);
|
gdispGFillStringBox(gw->g.display, gw->g.x + gw2obj->tab, gw->g.y, w-gw2obj->tab, h, gw->text, gw->g.font, c, gw->pstyle->background, gw2obj->justify);
|
||||||
} else
|
} else {
|
||||||
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, w, h, gw->text, gw->g.font, c, gw->pstyle->background, justifyLeft);
|
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, w, h, gw->text, gw->g.font, c, gw->pstyle->background, gw2obj->justify);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, w, h, gw->text, gw->g.font, c, gw->pstyle->background, justifyLeft);
|
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, w, h, gw->text, gw->g.font, c, gw->pstyle->background, gw2obj->justify);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// render the border (if any)
|
// render the border (if any)
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
typedef struct GLabelObject {
|
typedef struct GLabelObject {
|
||||||
GWidgetObject w;
|
GWidgetObject w;
|
||||||
|
|
||||||
|
justify_t justify;
|
||||||
|
|
||||||
#if GWIN_LABEL_ATTRIBUTE
|
#if GWIN_LABEL_ATTRIBUTE
|
||||||
coord_t tab;
|
coord_t tab;
|
||||||
const char* attr;
|
const char* attr;
|
||||||
|
@ -55,13 +57,14 @@ extern "C" {
|
||||||
* @param[in] g The GDisplay to display this window on
|
* @param[in] g The GDisplay to display this window on
|
||||||
* @param[in] widget The label structure to initialise. If this is NULL, the structure is dynamically allocated.
|
* @param[in] widget The label structure to initialise. If this is NULL, the structure is dynamically allocated.
|
||||||
* @param[in] pInit The initialisation parameters to use.
|
* @param[in] pInit The initialisation parameters to use.
|
||||||
|
* @param[in] justify The justification.
|
||||||
*
|
*
|
||||||
* @return NULL if there is no resultat drawing area, otherwise the widget handle.
|
* @return NULL if there is no resultat drawing area, otherwise the widget handle.
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit);
|
GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit, justify_t justify);
|
||||||
#define gwinLabelCreate(w, pInit) gwinGLabelCreate(GDISP, w, pInit)
|
#define gwinLabelCreate(w, pInit, justify) gwinGLabelCreate(GDISP, w, pInit, justify)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Border settings for the default rendering routine
|
* @brief Border settings for the default rendering routine
|
||||||
|
|
Loading…
Add table
Reference in a new issue