Add some other modules.
[bertos.git] / bertos / gfx / text.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2003, 2004, 2005 Develer S.r.l. (http://www.develer.com/)
30  * Copyright 1999 Bernie Innocenti <bernie@codewiz.org>
31  *
32  * -->
33  *
34  * \brief Text graphic routines (interface)
35  *
36  * \author Bernie Innocenti <bernie@codewiz.org>
37  * \author Stefano Fedrigo <aleph@develer.com>
38  * \version $Id$
39  *
40  * $WIZ$ module_name = "text"
41  * $WIZ$ module_harvard = "both"
42  */
43
44 #ifndef GFX_TEXT_H
45 #define GFX_TEXT_H
46
47 #include <cfg/compiler.h>
48 #include <cfg/macros.h> /* BV() */
49 #include <cpu/attr.h> /* CPU_HARVARD */
50 #include <gfx/gfx.h> /* coord_t */
51
52 #include <stdarg.h>
53
54 /**
55  * \name Style flags
56  * \see text_style()
57  * \{
58  */
59 #define STYLEF_BOLD        BV(0)
60 #define STYLEF_ITALIC      BV(1)
61 #define STYLEF_UNDERLINE   BV(2)
62 #define STYLEF_INVERT      BV(3)
63 #define STYLEF_EXPANDED    BV(4)
64 #define STYLEF_CONDENSED   BV(5)
65 #define STYLEF_STRIKEOUT   BV(6)  /*<! Not implemented */
66 #define STYLEF_TALL        BV(7)  /*<! Not implemented */
67
68 #define STYLEF_MASK \
69         (STYLEF_BOLD | STYLEF_ITALIC | STYLEF_UNDERLINE \
70         | STYLEF_INVERT | STYLEF_EXPANDED | STYLEF_CONDENSED \
71         | STYLEF_STRIKEOUT | STYLEF_TALL)
72 /*\}*/
73
74 /**
75  * \name Formatting flags for text rendering
76  * \see text_xprintf()
77  * \{
78  */
79 #define TEXT_NORMAL   0       /**< Normal mode */
80 #define TEXT_FILL     BV(13)  /**< Fill rest of line with spaces */
81 #define TEXT_CENTER   BV(14)  /**< Center string in line */
82 #define TEXT_RIGHT    BV(15)  /**< Right aligned */
83 /*\}*/
84
85 /** Escape sequences codes */
86 #define ANSI_ESC_CLEARSCREEN 'c'
87
88
89 /* Fwd decl */
90 struct Bitmap;
91
92 /* Low-level text functions (mware/text.c) */
93 void text_moveTo(struct Bitmap *bm, int row, int col);
94 void text_setCoord(struct Bitmap *bm, int x, int y);
95 int text_putchar(char c, struct Bitmap *bm);
96 uint8_t text_style(struct Bitmap *bm, uint8_t flags, uint8_t mask);
97 void text_clear(struct Bitmap *bm);
98 void text_clearLine(struct Bitmap *bm, int line);
99
100 /* Text formatting functions (mware/text_format.c) */
101 int text_puts(const char *str, struct Bitmap *bm);
102 int text_vprintf(struct Bitmap *bm, const char *fmt, va_list ap);
103 int text_printf(struct Bitmap *bm, const char *fmt, ...) FORMAT(__printf__, 2, 3);
104 int text_xyvprintf(struct Bitmap *bm, coord_t x, coord_t y, uint16_t mode, const char *fmt, va_list ap);
105 int text_xyprintf(struct Bitmap *bm, coord_t x, coord_t col, uint16_t mode, const char *fmt, ...) FORMAT(__printf__, 5, 6);
106 int text_xprintf(struct Bitmap *bm, uint8_t row, uint8_t col, uint16_t mode, const char *fmt, ...) FORMAT(__printf__, 5, 6);
107 int text_vwidthf(struct Bitmap *bm, const char * fmt, va_list ap);
108 int text_widthf(struct Bitmap *bm, const char * fmt, ...) FORMAT(__printf__, 2, 3);
109
110 /* Text formatting functions for program-memory strings (mware/text_format.c) */
111 #if CPU_HARVARD
112 #include <cpu/pgm.h>
113 int text_puts_P(const char * PROGMEM str, struct Bitmap *bm);
114 int text_vprintf_P(struct Bitmap *bm, const char * PROGMEM fmt, va_list ap);
115 int text_printf_P(struct Bitmap *bm, const char * PROGMEM fmt, ...) FORMAT(__printf__, 2, 3);
116 int text_xyvprintf_P(struct Bitmap *bm, coord_t x, coord_t y, uint16_t mode, const char *fmt, va_list ap);
117 int text_xyprintf_P(struct Bitmap *bm, coord_t x, coord_t col, uint16_t mode, const char *fmt, ...) FORMAT(__printf__, 5, 6);
118 int text_xprintf_P(struct Bitmap *bm, uint8_t row, uint8_t col, uint16_t mode, const char * PROGMEM fmt, ...) FORMAT(__printf__, 5, 6);
119 int text_vwidthf_P(struct Bitmap *bm, const char * PROGMEM fmt, va_list ap);
120 int text_widthf_P(struct Bitmap *bm, const char * PROGMEM fmt, ...);
121 #endif /* CPU_HARVARD */
122
123 #endif /* GFX_TEXT_H */