2cd1cacf7c1e2a83b1f09dd01dc48d1ac880b177
[bertos.git] / mware / text.h
1 /*!
2  * \file
3  * Copyright (C) 1999 Bernardo Innocenti <bernie@develer.com>
4  * Copyright (C) 2003 Develer S.r.l. (http://www.develer.com/)
5  * All Rights Reserved.
6  *
7  * \version $Id$
8  *
9  * \author Bernardo Innocenti <bernie@develer.com>
10  * \author Stefano Fedrigo <aleph@develer.com>
11  *
12  * \brief Text graphic routines
13  */
14
15 /*
16  * $Log$
17  * Revision 1.1  2004/05/23 15:43:16  bernie
18  * Import mware modules.
19  *
20  * Revision 1.9  2004/04/03 20:42:49  aleph
21  * Add text_clear()
22  *
23  * Revision 1.8  2004/03/19 16:52:28  bernie
24  * Move printf() like functions from text.c to text_format.c and add PROGMEM versions.
25  *
26  * Revision 1.7  2004/03/17 17:30:30  bernie
27  * Add GCC format checks to printf()-like functions.
28  *
29  * Revision 1.6  2004/02/21 21:40:20  aleph
30  * Various small fixes
31  *
32  * Revision 1.5  2004/02/18 11:50:10  aleph
33  * Add right alignment to xprintf
34  *
35  * Revision 1.4  2004/01/13 12:15:28  aleph
36  * Move font table in program memory; add font.h
37  *
38  * Revision 1.3  2004/01/13 00:06:47  aleph
39  * Fix clipping and ANSI esc bug, add text_xprintf()
40  *
41  * Revision 1.2  2004/01/08 18:03:12  aleph
42  * Add text functions to set coordinates
43  *
44  * Revision 1.1  2004/01/07 23:31:54  aleph
45  * Add text routines
46  *
47  */
48
49 #ifndef TEXT_H
50 #define TEXT_H
51
52 #include "compiler.h"
53 #include <stdarg.h>
54
55 /* Style flags */
56 #define STYLEF_BOLD        BV(0)
57 #define STYLEF_ITALIC      BV(1)
58 #define STYLEF_UNDERLINE   BV(2)
59 #define STYLEF_INVERT      BV(3)
60 #define STYLEF_EXPANDED    BV(4)
61 #define STYLEF_CONDENSED   BV(5)
62 #define STYLEF_STRIKEOUT   BV(6)  /* Not implemented */
63
64 #define STYLEF_MASK \
65         (STYLEF_BOLD | STYLEF_ITALIC | STYLEF_UNDERLINE | \
66         STYLEF_EXPANDED | STYLEF_CONDENSED | STYLEF_INVERT)
67
68 /* Flags for text_xprintf() */
69 #define TEXT_NORMAL   0       /*!< Normal mode */
70 #define TEXT_FILL     BV(0)   /*!< Fill rest of line with spaces */
71 #define TEXT_CENTER   BV(1)   /*!< Center string in line */
72 #define TEXT_INVERT   BV(2)   /*!< Inverted mode */
73 #define TEXT_RIGHT    BV(3)   /*!< Right aligned */
74
75 /* Escape sequences codes */
76 #define ANSI_ESC_CLEARSCREEN 'c'
77
78
79
80 /* Fwd decl */
81 struct Bitmap;
82
83 void text_moveto(struct Bitmap *bm, int row, int col);
84 void text_setcoord(struct Bitmap *bm, int x, int y);
85 int text_putchar(char c, struct Bitmap *bm);
86 int text_puts(const char *str, struct Bitmap *bm);
87 int text_vprintf(struct Bitmap *bm, const char *fmt, va_list ap);
88 int text_printf(struct Bitmap *bm, const char *fmt, ...) FORMAT(__printf__, 2, 3);
89 int text_xprintf(struct Bitmap *bm, uint8_t row, uint8_t col, uint8_t mode, const char *fmt, ...) FORMAT(__printf__, 5, 6);
90 uint8_t text_style(uint8_t flags, uint8_t mask);
91 void text_clear(struct Bitmap *bm);
92
93 int text_puts_P(const char * PROGMEM str, struct Bitmap *bm);
94 int text_vprintf_P(struct Bitmap *bm, const char * PROGMEM fmt, va_list ap);
95 int text_printf_P(struct Bitmap *bm, const char * PROGMEM fmt, ...) FORMAT(__printf__, 2, 3);
96 int text_xprintf_P(struct Bitmap *bm, uint8_t row, uint8_t col, uint8_t mode, const char * PROGMEM fmt, ...) FORMAT(__printf__, 5, 6);
97
98 #endif /* TEXT_H */