Simplify code using ATOMIC().
[bertos.git] / mware / text.h
1 /*!
2  * \file
3  * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
4  * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
5  * This file is part of DevLib - See devlib/README for information.
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.4  2004/08/25 14:12:09  rasky
18  *#* Aggiornato il comment block dei log RCS
19  *#*
20  *#* Revision 1.3  2004/08/05 18:46:44  bernie
21  *#* Documentation improvements.
22  *#*
23  *#* Revision 1.2  2004/06/03 11:27:09  bernie
24  *#* Add dual-license information.
25  *#*
26  *#*/
27
28 #ifndef TEXT_H
29 #define TEXT_H
30
31 #include "compiler.h"
32 #include <stdarg.h>
33
34 /*!
35  * \name Style flags
36  * \see text_style()
37  * \{
38  */
39 #define STYLEF_BOLD        BV(0)
40 #define STYLEF_ITALIC      BV(1)
41 #define STYLEF_UNDERLINE   BV(2)
42 #define STYLEF_INVERT      BV(3)
43 #define STYLEF_EXPANDED    BV(4)
44 #define STYLEF_CONDENSED   BV(5)
45 #define STYLEF_STRIKEOUT   BV(6)  /*<! Not implemented */
46
47 #define STYLEF_MASK \
48         (STYLEF_BOLD | STYLEF_ITALIC | STYLEF_UNDERLINE | \
49         STYLEF_EXPANDED | STYLEF_CONDENSED | STYLEF_INVERT)
50 /*\}*/
51
52 /*!
53  * \name Formatting flags for text rendering
54  * \see text_xprintf()
55  * \{
56  */
57 #define TEXT_NORMAL   0       /*!< Normal mode */
58 #define TEXT_FILL     BV(0)   /*!< Fill rest of line with spaces */
59 #define TEXT_CENTER   BV(1)   /*!< Center string in line */
60 #define TEXT_INVERT   BV(2)   /*!< Inverted mode */
61 #define TEXT_RIGHT    BV(3)   /*!< Right aligned */
62 /*\}*/
63
64 /*! Escape sequences codes */
65 #define ANSI_ESC_CLEARSCREEN 'c'
66
67
68
69 /* Fwd decl */
70 struct Bitmap;
71
72 void text_moveto(struct Bitmap *bm, int row, int col);
73 void text_setcoord(struct Bitmap *bm, int x, int y);
74 int text_putchar(char c, struct Bitmap *bm);
75 int text_puts(const char *str, struct Bitmap *bm);
76 int text_vprintf(struct Bitmap *bm, const char *fmt, va_list ap);
77 int text_printf(struct Bitmap *bm, const char *fmt, ...) FORMAT(__printf__, 2, 3);
78 int text_xprintf(struct Bitmap *bm, uint8_t row, uint8_t col, uint8_t mode, const char *fmt, ...) FORMAT(__printf__, 5, 6);
79 uint8_t text_style(uint8_t flags, uint8_t mask);
80 void text_clear(struct Bitmap *bm);
81
82 int text_puts_P(const char * PROGMEM str, struct Bitmap *bm);
83 int text_vprintf_P(struct Bitmap *bm, const char * PROGMEM fmt, va_list ap);
84 int text_printf_P(struct Bitmap *bm, const char * PROGMEM fmt, ...) FORMAT(__printf__, 2, 3);
85 int text_xprintf_P(struct Bitmap *bm, uint8_t row, uint8_t col, uint8_t mode, const char * PROGMEM fmt, ...) FORMAT(__printf__, 5, 6);
86
87 #endif /* TEXT_H */