Merge pull request #43 from inmarket/master

GDISP, GWIN updates
ugfx_release_2.6
Tectu 2013-03-18 01:57:18 -07:00
commit ffea4aa12e
7 changed files with 1247 additions and 1182 deletions

View File

@ -658,30 +658,35 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
/**
* @brief Draw an enclosed polygon (convex, non-convex or complex).
*
* @param[in] tx, ty Transform all points in pntarray by tx, ty
* @param[in] pntarray An array of points
* @param[in] cnt The number of points in the array
* @param[in] color The color to use
*
* @api
*/
void gdispDrawPoly(const point *pntarray, unsigned cnt, color_t color);
void gdispDrawPoly(coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color);
/**
* @brief Fill a convex polygon
* @details Doesn't handle non-convex or complex polygons.
*
* @param[in] tx, ty Transform all points in pntarray by tx, ty
* @param[in] pntarray An array of points
* @param[in] cnt The number of points in the array
* @param[in] color The color to use
*
* @note Convex polygons are those that have no internal angles. That is;
* you can draw a line from any point on the polygon to any other point
* on the polygon without it going outside the polygon.
* on the polygon without it going outside the polygon. In our case we generalise
* this a little by saying that an infinite horizontal line (at any y value) will cross
* no more than two edges on the polygon. Some non-convex polygons do fit this criteria
* and can therefore be drawn.
* @note This routine is designed to be very efficient with even simple display hardware.
*
* @api
*/
void gdispFillConvexPoly(const point *pntarray, unsigned cnt, color_t color);
void gdispFillConvexPoly(coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color);
#endif
/* Extra Text Functions */

View File

@ -47,9 +47,8 @@
/* Type definitions */
/*===========================================================================*/
typedef struct GGraphPoint_t {
coord_t x, y;
} GGraphPoint;
// GDISP now has its own point structure
#define GGraphPoint point
typedef enum GGraphPointType_e {
GGRAPH_POINT_NONE, GGRAPH_POINT_DOT, GGRAPH_POINT_SQUARE, GGRAPH_POINT_CIRCLE
@ -195,7 +194,7 @@ void gwinGraphDrawPoint(GHandle gh, coord_t x, coord_t y);
*
* @api
*/
void gwinGraphDrawPoints(GHandle gh, const GGraphPoint *points, unsigned count);
void gwinGraphDrawPoints(GHandle gh, const point *points, unsigned count);
#ifdef __cplusplus
}

View File

@ -71,7 +71,31 @@ extern "C" {
#endif
/* Base Functions */
/**
* @brief Create a basic window.
* @return NULL if there is no resultant drawing area, otherwise a window handle.
*
* @param[in] gw The window structure to initialize. If this is NULL the structure is dynamically allocated.
* @param[in] x,y The screen coordinates for the bottom left corner of the window
* @param[in] width The width of the window
* @param[in] height The height of the window
* @note The default drawing color gets set to White and the background drawing color to Black.
* @note No default font is set so make sure to set one before drawing any text.
* @note The dimensions and position may be changed to fit on the real screen.
* @note The window is not automatically cleared on creation. You must do that by calling gwinClear() (possibly after changing your background color)
*
* @api
*/
GHandle gwinCreateWindow(GWindowObject *gw, coord_t x, coord_t y, coord_t width, coord_t height);
/**
* @brief Destroy a window (of any type). Releases any dynamically allocated memory.
*
* @param[in] gh The window handle
*
* @api
*/
void gwinDestroyWindow(GHandle gh);
/**
@ -126,51 +150,344 @@ void gwinDestroyWindow(GHandle gh);
#define gwinSetBgColor(gh, bgclr) (gh)->bgcolor = (bgclr)
/* Set up for text */
#if GDISP_NEED_TEXT
#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
/**
* @brief Set the current font for this window.
*
* @param[in] gh The window handle
* @param[in] font The font to use for text functions
*
* @api
*/
void gwinSetFont(GHandle gh, font_t font);
#endif
/* Drawing Functions */
/**
* @brief Clear the window
* @note Uses the current background color to clear the window
*
* @param[in] gh The window handle
*
* @api
*/
void gwinClear(GHandle gh);
/**
* @brief Set a pixel in the window
* @note Uses the current foreground color to set the pixel
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The coordinates of the pixel
*
* @api
*/
void gwinDrawPixel(GHandle gh, coord_t x, coord_t y);
/**
* @brief Draw a line in the window
* @note Uses the current foreground color to draw the line
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x0,y0 The start position
* @param[in] x1,y1 The end position
*
* @api
*/
void gwinDrawLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1);
/**
* @brief Draw a box in the window
* @note Uses the current foreground color to draw the box
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The start position
* @param[in] cx,cy The size of the box (outside dimensions)
*
* @api
*/
void gwinDrawBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy);
/**
* @brief Fill an rectangular area in the window
* @note Uses the current foreground color to fill the box
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The start position
* @param[in] cx,cy The size of the box (outside dimensions)
*
* @api
*/
void gwinFillArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy);
/**
* @brief Fill an area in the window using the supplied bitmap.
* @details The bitmap is in the pixel format specified by the low level driver
* @note If GDISP_NEED_ASYNC is defined then the buffer must be static
* or at least retained until this call has finished the blit. You can
* tell when all graphics drawing is finished by @p gdispIsBusy() going FALSE.
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x, y The start filled area
* @param[in] cx, cy The width and height to be filled
* @param[in] srcx, srcy The bitmap position to start the fill from
* @param[in] srccx The width of a line in the bitmap.
* @param[in] buffer The pixels to use to fill the area.
*
* @api
*/
void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer);
/* Circle Functions */
#if GDISP_NEED_CIRCLE
#if GDISP_NEED_CIRCLE || defined(__DOXYGEN__)
/**
* @brief Draw a circle in the window.
* @note Uses the current foreground color to draw the circle
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x, y The center of the circle
* @param[in] radius The radius of the circle
*
* @api
*/
void gwinDrawCircle(GHandle gh, coord_t x, coord_t y, coord_t radius);
/**
* @brief Draw a filled circle in the window.
* @note Uses the current foreground color to draw the filled circle
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x, y The center of the circle
* @param[in] radius The radius of the circle
*
* @api
*/
void gwinFillCircle(GHandle gh, coord_t x, coord_t y, coord_t radius);
#endif
/* Ellipse Functions */
#if GDISP_NEED_ELLIPSE
#if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__)
/**
* @brief Draw an ellipse.
* @note Uses the current foreground color to draw the ellipse
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The center of the ellipse
* @param[in] a,b The dimensions of the ellipse
*
* @api
*/
void gwinDrawEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b);
/**
* @brief Draw an filled ellipse.
* @note Uses the current foreground color to draw the filled ellipse
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The center of the ellipse
* @param[in] a,b The dimensions of the ellipse
*
* @api
*/
void gwinFillEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b);
#endif
/* Arc Functions */
#if GDISP_NEED_ARC
#if GDISP_NEED_ARC || defined(__DOXYGEN__)
/*
* @brief Draw an arc in the window.
* @note Uses the current foreground color to draw the arc
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The center point
* @param[in] radius The radius of the arc
* @param[in] start The start angle (0 to 360)
* @param[in] end The end angle (0 to 360)
*
* @api
*/
void gwinDrawArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle);
/*
* @brief Draw a filled arc in the window.
* @note Uses the current foreground color to draw the filled arc
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The center point
* @param[in] radius The radius of the arc
* @param[in] start The start angle (0 to 360)
* @param[in] end The end angle (0 to 360)
*
* @api
*/
void gwinFillArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle);
#endif
/* Read a pixel Function */
#if GDISP_NEED_PIXELREAD
#if GDISP_NEED_PIXELREAD || defined(__DOXYGEN__)
/**
* @brief Get the color of a pixel in the window.
* @return The color of the pixel.
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position in the window
*
* @api
*/
color_t gwinGetPixelColor(GHandle gh, coord_t x, coord_t y);
#endif
/* Extra Text Functions */
#if GDISP_NEED_TEXT
#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
/**
* @brief Draw a text character at the specified position in the window.
* @pre The font must have been set.
* @note Uses the current foreground color to draw the character
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position for the text
* @param[in] c The character to draw
*
* @api
*/
void gwinDrawChar(GHandle gh, coord_t x, coord_t y, char c);
/**
* @brief Draw a text character with a filled background at the specified position in the window.
* @pre The font must have been set.
* @note Uses the current foreground color to draw the character and fills the background using the background drawing color
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position for the text
* @param[in] c The character to draw
*
* @api
*/
void gwinFillChar(GHandle gh, coord_t x, coord_t y, char c);
/**
* @brief Draw a text string in the window
* @pre The font must have been set.
* @note Uses the current foreground color to draw the character
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position for the text
* @param[in] str The string to draw
*
* @api
*/
void gwinDrawString(GHandle gh, coord_t x, coord_t y, const char *str);
/**
* @brief Draw a text string with a filled background in the window
* @pre The font must have been set.
* @note Uses the current foreground color to draw the character and fills the background using the background drawing color
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position for the text
* @param[in] str The string to draw
*
* @api
*/
void gwinFillString(GHandle gh, coord_t x, coord_t y, const char *str);
/**
* @brief Draw a text string verticly centered within the specified box.
* @pre The font must have been set.
* @note Uses the current foreground color to draw the character.
* @note The specified box does not need to align with the window box
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position for the text (need to define top-right or base-line - check code)
* @param[in] cx,cy The width and height of the box
* @param[in] str The string to draw
* @param[in] justify Justify the text left, center or right within the box
*
* @api
*/
void gwinDrawStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify);
/**
* @brief Draw a text string verticly centered within the specified filled box.
* @pre The font must have been set.
* @note Uses the current foreground color to draw the character and fills the background using the background drawing color
* @note The entire box is filled. Note this box does not need to align with the window box
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position for the text (need to define top-right or base-line - check code)
* @param[in] cx,cy The width and height of the box
* @param[in] str The string to draw
* @param[in] justify Justify the text left, center or right within the box
*
* @api
*/
void gwinFillStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify);
#endif
#if GDISP_NEED_CONVEX_POLYGON || defined(__DOXYGEN__)
/**
* @brief Draw an enclosed polygon (convex, non-convex or complex).
*
* @note Uses the current foreground color.
*
* @param[in] gh The window handle
* @param[in] tx, ty Transform all points in pntarray by tx, ty
* @param[in] pntarray An array of points
* @param[in] cnt The number of points in the array
*
* @api
*/
void gwinDrawPoly(GHandle gh, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt);
/**
* @brief Fill a convex polygon
* @details Doesn't handle non-convex or complex polygons.
*
* @note Uses the current foreground color.
*
* @param[in] gh The window handle
* @param[in] tx, ty Transform all points in pntarray by tx, ty
* @param[in] pntarray An array of points
* @param[in] cnt The number of points in the array
*
* @note Convex polygons are those that have no internal angles. That is;
* you can draw a line from any point on the polygon to any other point
* on the polygon without it going outside the polygon. In our case we generalise
* this a little by saying that an infinite horizontal line (at any y value) will cross
* no more than two edges on the polygon. Some non-convex polygons do fit this criteria
* and can therefore be drawn.
* @note This routine is designed to be very efficient with even simple display hardware.
*
* @api
*/
void gwinFillConvexPoly(GHandle gh, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt);
#endif
#ifdef __cplusplus
}
#endif

View File

@ -566,16 +566,16 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
}
#if GDISP_NEED_CONVEX_POLYGON
void gdispDrawPoly(const point *pntarray, unsigned cnt, color_t color) {
void gdispDrawPoly(coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color) {
const point *epnt, *p;
epnt = &pntarray[cnt-1];
for(p = pntarray; p < epnt; p++)
gdispDrawLine(p->x, p->y, p[1].x, p[1].y, color);
gdispDrawLine(p->x, p->y, pntarray->x, pntarray->y, color);
gdispDrawLine(tx+p->x, ty+p->y, tx+p[1].x, ty+p[1].y, color);
gdispDrawLine(tx+p->x, ty+p->y, tx+pntarray->x, ty+pntarray->y, color);
}
void gdispFillConvexPoly(const point *pntarray, unsigned cnt, color_t color) {
void gdispFillConvexPoly(coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color) {
const point *lpnt, *rpnt, *epnts;
fpcoord_t lx, rx, lk, rk;
coord_t y, ymax, lxc, rxc;
@ -622,14 +622,14 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
*/
if (lxc < rxc) {
if (rxc - lxc == 1)
gdispDrawPixel(lxc, y, color);
gdispDrawPixel(tx+lxc, ty+y, color);
else
gdispDrawLine(lxc, y, rxc-1, y, color);
gdispDrawLine(tx+lxc, ty+y, tx+rxc-1, ty+y, color);
} else if (lxc > rxc) {
if (lxc - rxc == 1)
gdispDrawPixel(rxc, y, color);
gdispDrawPixel(tx+rxc, ty+y, color);
else
gdispDrawLine(rxc, y, lxc-1, y, color);
gdispDrawLine(tx+rxc, ty+y, tx+lxc-1, ty+y, color);
}
lx += lk;

View File

@ -306,16 +306,16 @@ void gwinButtonDraw_Square(GHandle gh, bool_t isdown, const char *txt, const GBu
(void) param;
point arw[7];
arw[0].x = gh->x+gh->width/2; arw[0].y = gh->y;
arw[1].x = gh->x+gh->width-1; arw[1].y = gh->y+gh->height/ARROWHEAD_DIVIDER;
arw[2].x = gh->x+(gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[2].y = gh->y+gh->height/ARROWHEAD_DIVIDER;
arw[3].x = gh->x+(gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[3].y = gh->y+gh->height-1;
arw[4].x = gh->x+(gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[4].y = gh->y+gh->height-1;
arw[5].x = gh->x+(gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[5].y = gh->y+gh->height/ARROWHEAD_DIVIDER;
arw[6].x = gh->x; arw[6].y = gh->y+gh->height/ARROWHEAD_DIVIDER;
arw[0].x = gh->width/2; arw[0].y = 0;
arw[1].x = gh->width-1; arw[1].y = gh->height/ARROWHEAD_DIVIDER;
arw[2].x = (gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[2].y = gh->height/ARROWHEAD_DIVIDER;
arw[3].x = (gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[3].y = gh->height-1;
arw[4].x = (gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[4].y = gh->height-1;
arw[5].x = (gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[5].y = gh->height/ARROWHEAD_DIVIDER;
arw[6].x = 0; arw[6].y = gh->height/ARROWHEAD_DIVIDER;
gdispFillConvexPoly(arw, 7, pstyle->color_fill);
gdispDrawPoly(arw, 7, pstyle->color_edge);
gdispFillConvexPoly(gh->x, gh->y, arw, 7, pstyle->color_fill);
gdispDrawPoly(gh->x, gh->y, arw, 7, pstyle->color_edge);
gdispDrawStringBox(gh->x+1, gh->y+1, gh->width-2, gh->height-2, txt, gh->font, pstyle->color_txt, justifyCenter);
}
@ -324,16 +324,16 @@ void gwinButtonDraw_Square(GHandle gh, bool_t isdown, const char *txt, const GBu
(void) param;
point arw[7];
arw[0].x = gh->x+gh->width/2; arw[0].y = gh->y+gh->height-1;
arw[1].x = gh->x+gh->width-1; arw[1].y = gh->y+gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[2].x = gh->x+(gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[2].y = gh->y+gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[3].x = gh->x+(gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[3].y = gh->y;
arw[4].x = gh->x+(gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[4].y = gh->y;
arw[5].x = gh->x+(gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[5].y = gh->y+gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[6].x = gh->x; arw[6].y = gh->y+gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[0].x = gh->width/2; arw[0].y = gh->height-1;
arw[1].x = gh->width-1; arw[1].y = gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[2].x = (gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[2].y = gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[3].x = (gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[3].y = 0;
arw[4].x = (gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[4].y = 0;
arw[5].x = (gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[5].y = gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[6].x = 0; arw[6].y = gh->height-1-gh->height/ARROWHEAD_DIVIDER;
gdispFillConvexPoly(arw, 7, pstyle->color_fill);
gdispDrawPoly(arw, 7, pstyle->color_edge);
gdispFillConvexPoly(gh->x, gh->y, arw, 7, pstyle->color_fill);
gdispDrawPoly(gh->x, gh->y, arw, 7, pstyle->color_edge);
gdispDrawStringBox(gh->x+1, gh->y+1, gh->width-2, gh->height-2, txt, gh->font, pstyle->color_txt, justifyCenter);
}
@ -342,16 +342,16 @@ void gwinButtonDraw_Square(GHandle gh, bool_t isdown, const char *txt, const GBu
(void) param;
point arw[7];
arw[0].x = gh->x; arw[0].y = gh->y+gh->height/2;
arw[1].x = gh->x+gh->width/ARROWHEAD_DIVIDER; arw[1].y = gh->y;
arw[2].x = gh->x+gh->width/ARROWHEAD_DIVIDER; arw[2].y = gh->y+(gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[3].x = gh->x+gh->width-1; arw[3].y = gh->y+(gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[4].x = gh->x+gh->width-1; arw[4].y = gh->y+(gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[5].x = gh->x+gh->width/ARROWHEAD_DIVIDER; arw[5].y = gh->y+(gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[6].x = gh->x+gh->width/ARROWHEAD_DIVIDER; arw[6].y = gh->y+gh->height-1;
arw[0].x = 0; arw[0].y = gh->height/2;
arw[1].x = gh->width/ARROWHEAD_DIVIDER; arw[1].y = 0;
arw[2].x = gh->width/ARROWHEAD_DIVIDER; arw[2].y = (gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[3].x = gh->width-1; arw[3].y = (gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[4].x = gh->width-1; arw[4].y = (gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[5].x = gh->width/ARROWHEAD_DIVIDER; arw[5].y = (gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[6].x = gh->width/ARROWHEAD_DIVIDER; arw[6].y = gh->height-1;
gdispFillConvexPoly(arw, 7, pstyle->color_fill);
gdispDrawPoly(arw, 7, pstyle->color_edge);
gdispFillConvexPoly(gh->x, gh->y, arw, 7, pstyle->color_fill);
gdispDrawPoly(gh->x, gh->y, arw, 7, pstyle->color_edge);
gdispDrawStringBox(gh->x+1, gh->y+1, gh->width-2, gh->height-2, txt, gh->font, pstyle->color_txt, justifyCenter);
}
@ -360,16 +360,16 @@ void gwinButtonDraw_Square(GHandle gh, bool_t isdown, const char *txt, const GBu
(void) param;
point arw[7];
arw[0].x = gh->x+gh->width-1; arw[0].y = gh->y+gh->height/2;
arw[1].x = gh->x+gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[1].y = gh->y;
arw[2].x = gh->x+gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[2].y = gh->y+(gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[3].x = gh->x; arw[3].y = gh->y+(gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[4].x = gh->x; arw[4].y = gh->y+(gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[5].x = gh->x+gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[5].y = gh->y+(gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[6].x = gh->x+gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[6].y = gh->y+gh->height-1;
arw[0].x = gh->width-1; arw[0].y = gh->height/2;
arw[1].x = gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[1].y = 0;
arw[2].x = gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[2].y = (gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[3].x = 0; arw[3].y = (gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[4].x = 0; arw[4].y = (gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[5].x = gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[5].y = (gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[6].x = gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[6].y = gh->height-1;
gdispFillConvexPoly(arw, 7, pstyle->color_fill);
gdispDrawPoly(arw, 7, pstyle->color_edge);
gdispFillConvexPoly(gh->x, gh->y, arw, 7, pstyle->color_fill);
gdispDrawPoly(gh->x, gh->y, arw, 7, pstyle->color_edge);
gdispDrawStringBox(gh->x+1, gh->y+1, gh->width-2, gh->height-2, txt, gh->font, pstyle->color_txt, justifyCenter);
}
#endif

View File

@ -323,10 +323,10 @@ void gwinGraphDrawPoint(GHandle gh, coord_t x, coord_t y) {
#undef gg
}
void gwinGraphDrawPoints(GHandle gh, const GGraphPoint *points, unsigned count) {
void gwinGraphDrawPoints(GHandle gh, const point *points, unsigned count) {
#define gg ((GGraphObject *)gh)
unsigned i;
const GGraphPoint *p;
const point *p;
if (gh->type != GW_GRAPH)
return;

View File

@ -31,7 +31,7 @@
#include "hal.h"
#include "gfx.h"
#if GFX_USE_GWIN || defined(__DOXYGEN__)
#if GFX_USE_GWIN
#include "gwin/internal.h"
@ -70,21 +70,6 @@ GHandle _gwinInit(GWindowObject *gw, coord_t x, coord_t y, coord_t width, coord_
return (GHandle)gw;
}
/**
* @brief Create a basic window.
* @return NULL if there is no resultant drawing area, otherwise a window handle.
*
* @param[in] gw The window structure to initialise. If this is NULL the structure is dynamically allocated.
* @param[in] x,y The screen co-ordinates for the bottom left corner of the window
* @param[in] width The width of the window
* @param[in] height The height of the window
* @note The default drawing color gets set to White and the background drawing color to Black.
* @note No default font is set so make sure to set one before drawing any text.
* @note The dimensions and position may be changed to fit on the real screen.
* @note The window is not automatically cleared on creation. You must do that by calling gwinClear() (possibly after changing your background color)
*
* @api
*/
GHandle gwinCreateWindow(GWindowObject *gw, coord_t x, coord_t y, coord_t width, coord_t height) {
if (!(gw = (GWindowObject *)_gwinInit((GWindowObject *)gw, x, y, width, height, sizeof(GWindowObject))))
return 0;
@ -92,13 +77,6 @@ GHandle gwinCreateWindow(GWindowObject *gw, coord_t x, coord_t y, coord_t width,
return (GHandle)gw;
}
/**
* @brief Destroy a window (of any type). Releases any dynamicly allocated memory.
*
* @param[in] gh The window handle
*
* @api
*/
void gwinDestroyWindow(GHandle gh) {
// Clean up any type specific dynamic memory allocations
switch(gh->type) {
@ -123,15 +101,7 @@ void gwinDestroyWindow(GHandle gh) {
}
}
#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
/**
* @brief Set the current font for this window.
*
* @param[in] gh The window handle
* @param[in] font The font to use for text functions
*
* @api
*/
#if GDISP_NEED_TEXT
void gwinSetFont(GHandle gh, font_t font) {
gh->font = font;
#if GWIN_NEED_CONSOLE
@ -143,14 +113,6 @@ void gwinSetFont(GHandle gh, font_t font) {
}
#endif
/**
* @brief Clear the window
* @note Uses the current background color to clear the window
*
* @param[in] gh The window handle
*
* @api
*/
void gwinClear(GHandle gh) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
@ -165,16 +127,6 @@ void gwinClear(GHandle gh) {
#endif
}
/**
* @brief Set a pixel in the window
* @note Uses the current foreground color to set the pixel
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The coordinates of the pixel
*
* @api
*/
void gwinDrawPixel(GHandle gh, coord_t x, coord_t y) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
@ -182,17 +134,6 @@ void gwinDrawPixel(GHandle gh, coord_t x, coord_t y) {
gdispDrawPixel(gh->x+x, gh->y+y, gh->color);
}
/**
* @brief Draw a line in the window
* @note Uses the current foreground color to draw the line
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x0,y0 The start position
* @param[in] x1,y1 The end position
*
* @api
*/
void gwinDrawLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
@ -200,17 +141,6 @@ void gwinDrawLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1) {
gdispDrawLine(gh->x+x0, gh->y+y0, gh->x+x1, gh->y+y1, gh->color);
}
/**
* @brief Draw a box in the window
* @note Uses the current foreground color to draw the box
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The start position
* @param[in] cx,cy The size of the box (outside dimensions)
*
* @api
*/
void gwinDrawBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
@ -218,17 +148,6 @@ void gwinDrawBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy) {
gdispDrawBox(gh->x+x, gh->y+y, cx, cy, gh->color);
}
/**
* @brief Fill an rectangular area in the window
* @note Uses the current foreground color to fill the box
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The start position
* @param[in] cx,cy The size of the box (outside dimensions)
*
* @api
*/
void gwinFillArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
@ -236,23 +155,6 @@ void gwinFillArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy) {
gdispFillArea(gh->x+x, gh->y+y, cx, cy, gh->color);
}
/**
* @brief Fill an area in the window using the supplied bitmap.
* @details The bitmap is in the pixel format specified by the low level driver
* @note If GDISP_NEED_ASYNC is defined then the buffer must be static
* or at least retained until this call has finished the blit. You can
* tell when all graphics drawing is finished by @p gdispIsBusy() going FALSE.
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x, y The start filled area
* @param[in] cx, cy The width and height to be filled
* @param[in] srcx, srcy The bitmap position to start the fill from
* @param[in] srccx The width of a line in the bitmap.
* @param[in] buffer The pixels to use to fill the area.
*
* @api
*/
void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
@ -260,38 +162,14 @@ void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coor
gdispBlitAreaEx(gh->x+x, gh->y+y, cx, cy, srcx, srcy, srccx, buffer);
}
#if GDISP_NEED_CIRCLE || defined(__DOXYGEN__)
/**
* @brief Draw a circle in the window.
* @note Uses the current foreground color to draw the circle
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x, y The center of the circle
* @param[in] radius The radius of the circle
*
* @api
*/
#if GDISP_NEED_CIRCLE
void gwinDrawCircle(GHandle gh, coord_t x, coord_t y, coord_t radius) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
#endif
gdispDrawCircle(gh->x+x, gh->y+y, radius, gh->color);
}
#endif
#if GDISP_NEED_CIRCLE || defined(__DOXYGEN__)
/**
* @brief Draw a filled circle in the window.
* @note Uses the current foreground color to draw the filled circle
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x, y The center of the circle
* @param[in] radius The radius of the circle
*
* @api
*/
void gwinFillCircle(GHandle gh, coord_t x, coord_t y, coord_t radius) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
@ -300,38 +178,14 @@ void gwinFillCircle(GHandle gh, coord_t x, coord_t y, coord_t radius) {
}
#endif
#if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__)
/**
* @brief Draw an ellipse.
* @note Uses the current foreground color to draw the ellipse
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The center of the ellipse
* @param[in] a,b The dimensions of the ellipse
*
* @api
*/
#if GDISP_NEED_ELLIPSE
void gwinDrawEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
#endif
gdispDrawEllipse(gh->x+x, gh->y+y, a, b, gh->color);
}
#endif
#if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__)
/**
* @brief Draw an filled ellipse.
* @note Uses the current foreground color to draw the filled ellipse
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The center of the ellipse
* @param[in] a,b The dimensions of the ellipse
*
* @api
*/
void gwinFillEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
@ -340,42 +194,14 @@ void gwinFillEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b) {
}
#endif
#if GDISP_NEED_ARC || defined(__DOXYGEN__)
/*
* @brief Draw an arc in the window.
* @note Uses the current foreground color to draw the arc
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The center point
* @param[in] radius The radius of the arc
* @param[in] start The start angle (0 to 360)
* @param[in] end The end angle (0 to 360)
*
* @api
*/
#if GDISP_NEED_ARC
void gwinDrawArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
#endif
gdispDrawArc(gh->x+x, gh->y+y, radius, startangle, endangle, gh->color);
}
#endif
#if GDISP_NEED_ARC || defined(__DOXYGEN__)
/*
* @brief Draw a filled arc in the window.
* @note Uses the current foreground color to draw the filled arc
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The center point
* @param[in] radius The radius of the arc
* @param[in] start The start angle (0 to 360)
* @param[in] end The end angle (0 to 360)
*
* @api
*/
void gwinFillArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
@ -384,17 +210,7 @@ void gwinFillArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t start
}
#endif
#if GDISP_NEED_PIXELREAD || defined(__DOXYGEN__)
/**
* @brief Get the color of a pixel in the window.
* @return The color of the pixel.
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position in the window
*
* @api
*/
#if GDISP_NEED_PIXELREAD
color_t gwinGetPixelColor(GHandle gh, coord_t x, coord_t y) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
@ -403,19 +219,7 @@ color_t gwinGetPixelColor(GHandle gh, coord_t x, coord_t y) {
}
#endif
#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
/**
* @brief Draw a text character at the specified position in the window.
* @pre The font must have been set.
* @note Uses the current foreground color to draw the character
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position for the text
* @param[in] c The character to draw
*
* @api
*/
#if GDISP_NEED_TEXT
void gwinDrawChar(GHandle gh, coord_t x, coord_t y, char c) {
if (!gh->font) return;
#if GDISP_NEED_CLIP
@ -423,21 +227,7 @@ void gwinDrawChar(GHandle gh, coord_t x, coord_t y, char c) {
#endif
gdispDrawChar(gh->x+x, gh->y+y, c, gh->font, gh->color);
}
#endif
#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
/**
* @brief Draw a text character with a filled background at the specified position in the window.
* @pre The font must have been set.
* @note Uses the current foreground color to draw the character and fills the background using the background drawing color
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position for the text
* @param[in] c The character to draw
*
* @api
*/
void gwinFillChar(GHandle gh, coord_t x, coord_t y, char c) {
if (!gh->font) return;
#if GDISP_NEED_CLIP
@ -445,21 +235,7 @@ void gwinFillChar(GHandle gh, coord_t x, coord_t y, char c) {
#endif
gdispFillChar(gh->x+x, gh->y+y, c, gh->font, gh->color, gh->bgcolor);
}
#endif
#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
/**
* @brief Draw a text string in the window
* @pre The font must have been set.
* @note Uses the current foreground color to draw the character
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position for the text
* @param[in] str The string to draw
*
* @api
*/
void gwinDrawString(GHandle gh, coord_t x, coord_t y, const char *str) {
if (!gh->font) return;
#if GDISP_NEED_CLIP
@ -467,21 +243,7 @@ void gwinDrawString(GHandle gh, coord_t x, coord_t y, const char *str) {
#endif
gdispDrawString(gh->x+x, gh->y+y, str, gh->font, gh->color);
}
#endif
#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
/**
* @brief Draw a text string with a filled background in the window
* @pre The font must have been set.
* @note Uses the current foreground color to draw the character and fills the background using the background drawing color
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position for the text
* @param[in] str The string to draw
*
* @api
*/
void gwinFillString(GHandle gh, coord_t x, coord_t y, const char *str) {
if (!gh->font) return;
#if GDISP_NEED_CLIP
@ -489,24 +251,7 @@ void gwinFillString(GHandle gh, coord_t x, coord_t y, const char *str) {
#endif
gdispFillString(gh->x+x, gh->y+y, str, gh->font, gh->color, gh->bgcolor);
}
#endif
#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
/**
* @brief Draw a text string verticly centered within the specified box.
* @pre The font must have been set.
* @note Uses the current foreground color to draw the character.
* @note The specified box does not need to align with the window box
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position for the text (need to define top-right or base-line - check code)
* @param[in] cx,cy The width and height of the box
* @param[in] str The string to draw
* @param[in] justify Justify the text left, center or right within the box
*
* @api
*/
void gwinDrawStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify) {
if (!gh->font) return;
#if GDISP_NEED_CLIP
@ -514,24 +259,7 @@ void gwinDrawStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy,
#endif
gdispDrawStringBox(gh->x+x, gh->y+y, cx, cy, str, gh->font, gh->color, justify);
}
#endif
#if GDISP_NEED_TEXT || defined(__DOXYGEN__)
/**
* @brief Draw a text string verticly centered within the specified filled box.
* @pre The font must have been set.
* @note Uses the current foreground color to draw the character and fills the background using the background drawing color
* @note The entire box is filled. Note this box does not need to align with the window box
* @note May leave GDISP clipping to this window's dimensions
*
* @param[in] gh The window handle
* @param[in] x,y The position for the text (need to define top-right or base-line - check code)
* @param[in] cx,cy The width and height of the box
* @param[in] str The string to draw
* @param[in] justify Justify the text left, center or right within the box
*
* @api
*/
void gwinFillStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify) {
if (!gh->font) return;
#if GDISP_NEED_CLIP
@ -541,6 +269,22 @@ void gwinFillStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy,
}
#endif
#if GDISP_NEED_CONVEX_POLYGON
void gwinDrawPoly(GHandle gh, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
#endif
gdispDrawPoly(tx+gh->x, ty+gh->y, pntarray, cnt, gh->color);
}
void gwinFillConvexPoly(GHandle gh, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt) {
#if GDISP_NEED_CLIP
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
#endif
gdispFillConvexPoly(tx+gh->x, ty+gh->y, pntarray, cnt, gh->color);
}
#endif
#endif /* GFX_USE_GWIN */
/** @} */