text_xprintf(): Support all styles; Pixel-wise text centering.
[bertos.git] / mware / gfx.c
index 930510e3017386254b71db35cd98459a64764b65..9f9cf6215c57ef984f76f49464b2ecc8ca033775 100755 (executable)
@@ -1,9 +1,9 @@
 /*!
  * \file
  * <!--
- * Copyright (C) 1999 Bernardo Innocenti <bernie@develer.com>
- * Copyright (C) 2003 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
+ * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
+ * This file is part of DevLib - See devlib/README for information.
  * -->
  *
  * \version $Id$
  * \brief General pourpose graphics routines
  */
 
-/*
- * $Log$
- * Revision 1.1  2004/05/23 15:43:16  bernie
- * Import mware modules.
- *
- * Revision 1.6  2004/03/24 15:03:45  bernie
- * Use explicit include paths; clean Doxygen comments
- *
- * Revision 1.5  2004/02/09 00:21:28  aleph
- * Various gfx fixes
- *
- * Revision 1.4  2004/01/27 23:24:19  aleph
- * Add new graphics primitives
- *
- * Revision 1.3  2004/01/13 00:05:23  aleph
- * Fix clipping bug
- *
- * Revision 1.2  2004/01/07 23:33:01  aleph
- * Change copyright email
- *
- * Revision 1.1  2004/01/07 19:05:31  aleph
- * Add graphics routines
- *
- */
+/*#*
+ *#* $Log$
+ *#* Revision 1.6  2004/09/06 21:50:46  bernie
+ *#* Clarify side-effects in documentation.
+ *#*
+ *#* Revision 1.4  2004/08/24 16:53:10  bernie
+ *#* Use new-style config macros.
+ *#*
+ *#* Revision 1.3  2004/08/04 03:16:59  bernie
+ *#* Switch to new DevLib CONFIG_ convention.
+ *#*
+ *#* Revision 1.2  2004/06/03 11:27:09  bernie
+ *#* Add dual-license information.
+ *#*
+ *#*/
 
 #include "gfx.h"
 #include "config.h"
@@ -73,6 +64,8 @@
 
 /*!
  * Initialize a Bitmap structure with the provided parameters.
+ *
+ * \note The pen position is reset to the origin.
  */
 void gfx_InitBitmap(Bitmap *bm, uint8_t *raster, coord_t w, coord_t h)
 {
@@ -86,6 +79,8 @@ void gfx_InitBitmap(Bitmap *bm, uint8_t *raster, coord_t w, coord_t h)
 
 /*!
  * Clear the whole bitmap surface to all zeros
+ *
+ * \note This function does \b not update the current pen position
  */
 void gfx_ClearBitmap(Bitmap *bm)
 {
@@ -96,6 +91,8 @@ void gfx_ClearBitmap(Bitmap *bm)
 /*!
  * Copy a raster picture located in program memory in the bitmap.
  * The size of the raster to copy *must* be the same of the raster bitmap.
+ *
+ * \note This function does \b not update the current pen position
  */
 void gfx_blitBitmap_P(Bitmap *bm, const prog_uchar *raster)
 {
@@ -103,12 +100,18 @@ void gfx_blitBitmap_P(Bitmap *bm, const prog_uchar *raster)
 }
 
 
+/*!
+ * Draw a line on the bitmap \a bm using the specified start and end
+ * coordinates.
+ *
+ * \note This function does \b not update the current pen position
+ */
 void gfx_DrawLine(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
 {
        int x, y, e, len, adx, ady, signx, signy;
 
 
-#ifdef CONFIG_GFX_CLIPPING
+#if CONFIG_GFX_CLIPPING
        /* FIXME: broken */
 
        #define XMIN 0
@@ -164,7 +167,7 @@ void gfx_DrawLine(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
        #undef XMAX
        #undef YMAX
 
-#endif /* CONFIG_GRAPH_CLIPPING */
+#endif /* CONFIG_GFX_CLIPPING */
 
 
        if (x2 > x1)
@@ -239,13 +242,21 @@ void gfx_DrawLine(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
 }
 
 
+/*!
+ * Move the current pen position to the specified coordinates.
+ */
 void gfx_MoveTo(Bitmap *bm, coord_t x, coord_t y)
 {
        bm->penX = x;
        bm->penY = y;
 }
 
-
+/*!
+ * Draw a line from the current pen position to the new coordinates.
+ *
+ * \note This function moves the current pen position to the
+ *       new coordinates.
+ */
 void gfx_LineTo(Bitmap *bm, coord_t x, coord_t y)
 {
        gfx_DrawLine(bm, bm->penX, bm->penY, x, y);
@@ -255,7 +266,10 @@ void gfx_LineTo(Bitmap *bm, coord_t x, coord_t y)
 
 /*!
  * Draw a filled rectangle.
+ *
  * \note The bottom-right border of the rectangle is not drawn.
+ *
+ * \note This function does \b not update the current pen position
  */
 void gfx_FillRect(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
 {
@@ -284,7 +298,9 @@ void gfx_FillRect(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
 
 /*!
  * Draw an empty rectangle.
+ *
  * \note The bottom-right border of the rectangle is not drawn.
+ * \note This function does \b not update the current pen position
  */
 void gfx_DrawRect(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
 {
@@ -303,6 +319,7 @@ void gfx_DrawRect(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
 /*!
  * Clear a rectangular area.
  * \note The bottom-right border of the rectangle is not drawn.
+ * \note This function does \b not update the current pen position
  */
 void gfx_ClearRect(Bitmap *bm, coord_t x1, coord_t y1, coord_t x2, coord_t y2)
 {
@@ -352,7 +369,7 @@ void gfx_SetClipRect(Bitmap *bm, coord_t minx, coord_t miny, coord_t maxx, coord
 }
 
 
-#ifdef CONFIG_LCD_VCOORDS
+#if CONFIG_GFX_VCOORDS
 /*!
  * Imposta gli estremi del sistema di coordinate cartesiane rispetto
  * al rettangolo di clipping della bitmap.
@@ -401,4 +418,4 @@ void gfx_VDrawLine(Bitmap *bm, vcoord_t x1, vcoord_t y1, vcoord_t x2, vcoord_t y
                gfx_TransformX(bm, x1), gfx_TransformY(bm, y1),
                gfx_TransformY(bm, x2), gfx_TransformY(bm, y2));
 }
-#endif /* CONFIG_LCD_VCOORDS */
+#endif /* CONFIG_GFX_VCOORDS */