Revision 319
documented font. also changed a bit the timer
font.h | ||
---|---|---|
2 | 2 |
#define FONT_H_INCLUDED |
3 | 3 |
|
4 | 4 |
struct font; |
5 |
/** |
|
6 |
* @brief Font. Represents a set of glyphs that can be drawn for showing text. |
|
7 |
*/ |
|
5 | 8 |
typedef struct font font_t; |
9 |
/** |
|
10 |
* @brief Construct font. |
|
11 |
* |
|
12 |
* The font is constructed from a provided path. That path is required to |
|
13 |
* contain glyphs with the name "ascii???.xpm2", files with format XPM2 where |
|
14 |
* instead of having "???" we have 3-digit ASCII codes, where the glyph with |
|
15 |
* that name map to that XPM2 file. |
|
16 |
* @param s Path to directory |
|
17 |
* @return Pointer to font |
|
18 |
*/ |
|
6 | 19 |
font_t* (font_ctor)(const char *s); |
7 |
int (font_dtor)(font_t *p); |
|
20 |
/** |
|
21 |
* @brief Destruct font. |
|
22 |
* @param p Pointer to font to be destroyed |
|
23 |
*/ |
|
24 |
void (font_dtor)(font_t *p); |
|
8 | 25 |
|
26 |
/** |
|
27 |
* @brief Initialize font stuff. |
|
28 |
* |
|
29 |
* More specifically, this involves loading the default font, which is currently consolas. |
|
30 |
* @return SUCCESS if initialization was successful, false otherwise |
|
31 |
*/ |
|
9 | 32 |
int (font_init)(void); |
33 |
/** |
|
34 |
* @brief Get default font. |
|
35 |
* |
|
36 |
* Currently, the default font is Consolas. |
|
37 |
* @return Pointer to default font |
|
38 |
*/ |
|
10 | 39 |
const font_t* font_get_default(void); |
40 |
/** |
|
41 |
* @brief Get Consolas font. |
|
42 |
* @return Pointer to Consolas font |
|
43 |
*/ |
|
11 | 44 |
const font_t* font_get_consolas(void); |
12 |
int (font_free)(void); |
|
45 |
/** |
|
46 |
* @brief Free resources used on initialization of fonts. |
|
47 |
*/ |
|
48 |
void (font_free)(void); |
|
13 | 49 |
|
50 |
/** |
|
51 |
* @brief Enumeration of vertical alignment schemes. |
|
52 |
*/ |
|
14 | 53 |
typedef enum{ |
15 | 54 |
text_valign_top = -1, |
16 | 55 |
text_valign_center = 0, |
17 | 56 |
text_valign_bottom = 1 |
18 | 57 |
} text_valign; |
19 |
|
|
58 |
/** |
|
59 |
* @brief Enumeration of horizontal alignment schemes. |
|
60 |
*/ |
|
20 | 61 |
typedef enum{ |
21 | 62 |
text_halign_left = -1, |
22 | 63 |
text_halign_center = 0, |
... | ... | |
24 | 65 |
} text_halign; |
25 | 66 |
|
26 | 67 |
struct text; |
68 |
/** |
|
69 |
* @brief Drawable text. |
|
70 |
*/ |
|
27 | 71 |
typedef struct text text_t; |
72 |
/** |
|
73 |
* @brief Construct text. |
|
74 |
* @param fnt Font to draw the text |
|
75 |
* @param txt String to be drawn |
|
76 |
* @return Pointer to constructed text |
|
77 |
*/ |
|
28 | 78 |
text_t* (text_ctor)(const font_t *fnt, const char *txt); |
79 |
/** |
|
80 |
* @brief Destruct text. |
|
81 |
* @param p Pointer to text to be destroyed |
|
82 |
*/ |
|
29 | 83 |
void (text_dtor)(text_t *p); |
30 |
char* (text_get_string)(const text_t *p); |
|
84 |
/** |
|
85 |
* @brief Set text string. |
|
86 |
* @param p Pointer to text |
|
87 |
* @param txt String to be set |
|
88 |
*/ |
|
31 | 89 |
void (text_set_string)(text_t *p, const char *txt); |
90 |
/** |
|
91 |
* @brief Set text position. |
|
92 |
* @param p Pointer to text |
|
93 |
* @param x X-position of the text |
|
94 |
* @param y Y-position of the text |
|
95 |
*/ |
|
32 | 96 |
void (text_set_pos) (text_t *p, int16_t x, int16_t y); |
97 |
/** |
|
98 |
* @brief Set text size (letter size). |
|
99 |
* @param p Pointer to text |
|
100 |
* @param size Letter size of the text |
|
101 |
*/ |
|
33 | 102 |
void (text_set_size) (text_t *p, unsigned size); |
103 |
/** |
|
104 |
* @brief Set text color. |
|
105 |
* @param p Pointer to text |
|
106 |
* @param color Text color |
|
107 |
*/ |
|
34 | 108 |
void (text_set_color) (text_t *p, uint32_t color); |
109 |
/** |
|
110 |
* @brief Set text vertical alignment. |
|
111 |
* @param p Pointer to text |
|
112 |
* @param valign Vertical alignment of the text |
|
113 |
*/ |
|
35 | 114 |
void (text_set_valign)(text_t *p, text_valign valign); |
115 |
/** |
|
116 |
* @brief Set text horizontal alignment. |
|
117 |
* @param p Pointer to text |
|
118 |
* @param halign Horizontal alignment of the text |
|
119 |
*/ |
|
36 | 120 |
void (text_set_halign)(text_t *p, text_halign halign); |
121 |
/** |
|
122 |
* @brief Get string of the text. |
|
123 |
* @param p Pointer to text |
|
124 |
* @return Pointer to string |
|
125 |
*/ |
|
126 |
const char* (text_get_string)(const text_t *p); |
|
127 |
/** |
|
128 |
* @brief Get text x-position. |
|
129 |
* @param p Pointer to text |
|
130 |
* @return X-position of text |
|
131 |
*/ |
|
37 | 132 |
int16_t (text_get_x) (const text_t *p); |
133 |
/** |
|
134 |
* @brief Get text y-position. |
|
135 |
* @param p Pointer to text |
|
136 |
* @return Y-position of text |
|
137 |
*/ |
|
38 | 138 |
int16_t (text_get_y) (const text_t *p); |
139 |
/** |
|
140 |
* @brief Draw text on the screen buffer. |
|
141 |
* @param p Pointer to text |
|
142 |
* @return SUCCESS if operation was successful, false otherwise |
|
143 |
*/ |
|
39 | 144 |
int (text_draw) (const text_t *p); |
40 | 145 |
|
41 | 146 |
#endif //FONT_H_INCLUDED |
Also available in: Unified diff