aboutsummaryrefslogtreecommitdiffstats
path: root/src/gdisp
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2018-07-08 12:19:30 +1000
committerinmarket <andrewh@inmarket.com.au>2018-07-08 12:19:30 +1000
commit2e8eaa34717f99c9696867b62ff5f19e76a7ccf8 (patch)
tree5842c0ccaaffd195430b83fd2bd9211bd6f1fffe /src/gdisp
parent788cbced624d83a4c493182fde15cfa244910294 (diff)
downloaduGFX-2e8eaa34717f99c9696867b62ff5f19e76a7ccf8.tar.gz
uGFX-2e8eaa34717f99c9696867b62ff5f19e76a7ccf8.tar.bz2
uGFX-2e8eaa34717f99c9696867b62ff5f19e76a7ccf8.zip
Added type gJustify to replace V2.x justify_t, and values gJustifyXXX replace justifyXXX
Diffstat (limited to 'src/gdisp')
-rw-r--r--src/gdisp/gdisp.c40
-rw-r--r--src/gdisp/gdisp.h45
-rw-r--r--src/gdisp/gdisp_driver.h2
-rw-r--r--src/gdisp/gdisp_options.h4
4 files changed, 51 insertions, 40 deletions
diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp.c
index f3bac3bd..1dbd26b2 100644
--- a/src/gdisp/gdisp.c
+++ b/src/gdisp/gdisp.c
@@ -3439,7 +3439,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
MUTEX_EXIT(g);
}
- void gdispGDrawStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, font_t font, gColor color, justify_t justify) {
+ void gdispGDrawStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, font_t font, gColor color, gJustify justify) {
gCoord totalHeight;
if (!font)
@@ -3448,7 +3448,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
// Apply padding
#if GDISP_NEED_TEXT_BOXPADLR != 0 || GDISP_NEED_TEXT_BOXPADTB != 0
- if (!(justify & justifyNoPad)) {
+ if (!(justify & gJustifyNoPad)) {
#if GDISP_NEED_TEXT_BOXPADLR != 0
x += GDISP_NEED_TEXT_BOXPADLR;
cx -= 2*GDISP_NEED_TEXT_BOXPADLR;
@@ -3468,7 +3468,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
// Calculate the total text height
#if GDISP_NEED_TEXT_WORDWRAP
- if (!(justify & justifyNoWordWrap)) {
+ if (!(justify & gJustifyNoWordWrap)) {
// Count the number of lines
totalHeight = 0;
mf_wordwrap(font, cx, str, mf_countline_callback, &totalHeight);
@@ -3479,23 +3479,23 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
// Select the anchor position
switch((justify & JUSTIFYMASK_TOPBOTTOM)) {
- case justifyTop:
+ case gJustifyTop:
break;
- case justifyBottom:
+ case gJustifyBottom:
y += cy - totalHeight;
break;
- default: // justifyMiddle
+ default: // gJustifyMiddle
y += (cy+1 - totalHeight)/2;
break;
}
switch((justify & JUSTIFYMASK_LEFTRIGHT)) {
- case justifyCenter:
+ case gJustifyCenter:
x += (cx + 1) / 2;
break;
- case justifyRight:
+ case gJustifyRight:
x += cx;
break;
- default: // justifyLeft
+ default: // gJustifyLeft
break;
}
@@ -3503,7 +3503,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
g->t.font = font;
g->t.color = color;
#if GDISP_NEED_TEXT_WORDWRAP
- if (!(justify & justifyNoWordWrap)) {
+ if (!(justify & gJustifyNoWordWrap)) {
g->t.lrj = (justify & JUSTIFYMASK_LEFTRIGHT);
g->t.wrapx = x;
g->t.wrapy = y;
@@ -3517,7 +3517,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
MUTEX_EXIT(g);
}
- void gdispGFillStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, font_t font, gColor color, gColor bgcolor, justify_t justify) {
+ void gdispGFillStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, font_t font, gColor color, gColor bgcolor, gJustify justify) {
gCoord totalHeight;
if (!font)
@@ -3537,7 +3537,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
// Apply padding
#if GDISP_NEED_TEXT_BOXPADLR != 0 || GDISP_NEED_TEXT_BOXPADTB != 0
- if (!(justify & justifyNoPad)) {
+ if (!(justify & gJustifyNoPad)) {
#if GDISP_NEED_TEXT_BOXPADLR != 0
x += GDISP_NEED_TEXT_BOXPADLR;
cx -= 2*GDISP_NEED_TEXT_BOXPADLR;
@@ -3557,7 +3557,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
// Calculate the total text height
#if GDISP_NEED_TEXT_WORDWRAP
- if (!(justify & justifyNoWordWrap)) {
+ if (!(justify & gJustifyNoWordWrap)) {
// Count the number of lines
totalHeight = 0;
mf_wordwrap(font, cx, str, mf_countline_callback, &totalHeight);
@@ -3568,23 +3568,23 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
// Select the anchor position
switch((justify & JUSTIFYMASK_TOPBOTTOM)) {
- case justifyTop:
+ case gJustifyTop:
break;
- case justifyBottom:
+ case gJustifyBottom:
y += cy - totalHeight;
break;
- default: // justifyMiddle
+ default: // gJustifyMiddle
y += (cy+1 - totalHeight)/2;
break;
}
switch((justify & JUSTIFYMASK_LEFTRIGHT)) {
- case justifyCenter:
+ case gJustifyCenter:
x += (cx + 1) / 2;
break;
- case justifyRight:
+ case gJustifyRight:
x += cx;
break;
- default: // justifyLeft
+ default: // gJustifyLeft
break;
}
@@ -3593,7 +3593,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
g->t.color = color;
g->t.bgcolor = bgcolor;
#if GDISP_NEED_TEXT_WORDWRAP
- if (!(justify & justifyNoWordWrap)) {
+ if (!(justify & gJustifyNoWordWrap)) {
g->t.lrj = (justify & JUSTIFYMASK_LEFTRIGHT);
g->t.wrapx = x;
g->t.wrapy = y;
diff --git a/src/gdisp/gdisp.h b/src/gdisp/gdisp.h
index b5262f6e..aac33e44 100644
--- a/src/gdisp/gdisp.h
+++ b/src/gdisp/gdisp.h
@@ -54,23 +54,23 @@ typedef struct gPoint {
} gPoint;
/**
- * @enum justify
+ * @enum gJustify
* @brief Type for the text justification.
*/
-typedef enum justify {
- justifyLeft = 0x00, /**< Justify Left (the default) */
- justifyCenter = 0x01, /**< Justify Center */
- justifyRight = 0x02, /**< Justify Right */
- justifyTop = 0x10, /**< Justify Top */
- justifyMiddle = 0x00, /**< Justify Middle (the default) */
- justifyBottom = 0x20, /**< Justify Bottom */
- justifyWordWrap = 0x00, /**< Word wrap (the default if GDISP_NEED_TEXT_WORDWRAP is on) */
- justifyNoWordWrap = 0x40, /**< No word wrap */
- justifyPad = 0x00, /**< Pad the text box (the default) */
- justifyNoPad = 0x04 /**< No padding the text box */
-} justify_t;
-#define JUSTIFYMASK_LEFTRIGHT (justifyLeft|justifyCenter|justifyRight)
-#define JUSTIFYMASK_TOPBOTTOM (justifyTop|justifyMiddle|justifyBottom)
+typedef enum gJustify {
+ gJustifyLeft = 0x00, /**< Justify Left (the default) */
+ gJustifyCenter = 0x01, /**< Justify Center */
+ gJustifyRight = 0x02, /**< Justify Right */
+ gJustifyTop = 0x10, /**< Justify Top */
+ gJustifyMiddle = 0x00, /**< Justify Middle (the default) */
+ gJustifyBottom = 0x20, /**< Justify Bottom */
+ gJustifyWordWrap = 0x00, /**< Word wrap (the default if GDISP_NEED_TEXT_WORDWRAP is on) */
+ gJustifyNoWordWrap = 0x40, /**< No word wrap */
+ gJustifyPad = 0x00, /**< Pad the text box (the default) */
+ gJustifyNoPad = 0x04 /**< No padding the text box */
+} gJustify;
+#define JUSTIFYMASK_LEFTRIGHT (gJustifyLeft|gJustifyCenter|gJustifyRight)
+#define JUSTIFYMASK_TOPBOTTOM (gJustifyTop|gJustifyMiddle|gJustifyBottom)
/**
* @enum fontmetric
@@ -981,7 +981,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
*
* @api
*/
- void gdispGDrawStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, font_t font, gColor color, justify_t justify);
+ void gdispGDrawStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, font_t font, gColor color, gJustify justify);
#define gdispDrawStringBox(x,y,cx,cy,s,f,c,j) gdispGDrawStringBox(GDISP,x,y,cx,cy,s,f,c,j)
/**
@@ -1000,7 +1000,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
*
* @api
*/
- void gdispGFillStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, font_t font, gColor color, gColor bgColor, justify_t justify);
+ void gdispGFillStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, font_t font, gColor color, gColor bgColor, gJustify justify);
#define gdispFillStringBox(x,y,cx,cy,s,f,c,b,j) gdispGFillStringBox(GDISP,x,y,cx,cy,s,f,c,b,j)
/**
@@ -1235,6 +1235,17 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
#define powerDeepSleep gPowerDeepSleep
#define powerSleep gPowerSleep
#define powerOn gPowerOn
+ typedef gJustify justify_t;
+ #define justifyLeft gJustifyLeft
+ #define justifyCenter gJustifyCenter
+ #define justifyRight gJustifyRight
+ #define justifyTop gJustifyTop
+ #define justifyMiddle gJustifyMiddle
+ #define justifyBottom gJustifyBottom
+ #define justifyWordWrap gJustifyWordWrap
+ #define justifyNoWordWrap gJustifyNoWordWrap
+ #define justifyPad gJustifyPad
+ #define justifyNoPad gJustifyNoPad
typedef gColor color_t;
typedef gPixel pixel_t;
typedef gCoord coord_t;
diff --git a/src/gdisp/gdisp_driver.h b/src/gdisp/gdisp_driver.h
index 8b5bc7b9..7a2692e4 100644
--- a/src/gdisp/gdisp_driver.h
+++ b/src/gdisp/gdisp_driver.h
@@ -369,7 +369,7 @@ struct GDisplay {
gCoord clipx1, clipy1;
#if GDISP_NEED_TEXT_WORDWRAP
gCoord wrapx, wrapy;
- justify_t lrj;
+ gJustify lrj;
#endif
} t;
#endif
diff --git a/src/gdisp/gdisp_options.h b/src/gdisp/gdisp_options.h
index 06aeaf52..7398d381 100644
--- a/src/gdisp/gdisp_options.h
+++ b/src/gdisp/gdisp_options.h
@@ -577,7 +577,7 @@
/**
* @brief Adding pixels to the left and right side of the box to pad text.
* @details Only has an effect with @p gdispGDrawStringBox() and @p gdispGFillStringBox()
- * @note Can be turned off by using justifyNoPad
+ * @note Can be turned off by using gJustifyNoPad
* @details Defaults to 1
*/
#ifndef GDISP_NEED_TEXT_BOXPADLR
@@ -586,7 +586,7 @@
/**
* @brief Adding pixels to the top and bottom side of the box to pad text.
* @details Only has an effect with @p gdispGDrawStringBox() and @p gdispGFillStringBox()
- * @note Can be turned off by using justifyNoPad
+ * @note Can be turned off by using gJustifyNoPad
* @details Defaults to 1
*/
#ifndef GDISP_NEED_TEXT_BOXPADTB