root / proj / libs / graph / include / text.h @ 343
History | View | Annotate | Download (2.63 KB)
1 | 337 | up20180642 | #ifndef TEXT_H_INCLUDED
|
---|---|---|---|
2 | #define TEXT_H_INCLUDED
|
||
3 | |||
4 | /**
|
||
5 | * @defgroup text_t text_t
|
||
6 | * @ingroup font_t
|
||
7 | * @brief Text module.
|
||
8 | *
|
||
9 | * Allows to draw text in screen.
|
||
10 | * @{
|
||
11 | */
|
||
12 | |||
13 | #include "font.h" |
||
14 | |||
15 | /**
|
||
16 | * @brief Enumeration of vertical alignment schemes.
|
||
17 | */
|
||
18 | typedef enum{ |
||
19 | text_valign_top = -1,
|
||
20 | text_valign_center = 0,
|
||
21 | text_valign_bottom = 1
|
||
22 | } text_valign; |
||
23 | /**
|
||
24 | * @brief Enumeration of horizontal alignment schemes.
|
||
25 | */
|
||
26 | typedef enum{ |
||
27 | text_halign_left = -1,
|
||
28 | text_halign_center = 0,
|
||
29 | text_halign_right = 1
|
||
30 | } text_halign; |
||
31 | |||
32 | /**
|
||
33 | * @brief Drawable text.
|
||
34 | */
|
||
35 | typedef struct text text_t; |
||
36 | /**
|
||
37 | * @brief Construct text.
|
||
38 | * @param fnt Font to draw the text
|
||
39 | * @param txt String to be drawn
|
||
40 | * @return Pointer to constructed text
|
||
41 | */
|
||
42 | text_t* (text_ctor)(const font_t *fnt, const char *txt); |
||
43 | /**
|
||
44 | * @brief Destruct text.
|
||
45 | * @param p Pointer to text to be destroyed
|
||
46 | */
|
||
47 | void (text_dtor)(text_t *p);
|
||
48 | /**
|
||
49 | * @brief Set text string.
|
||
50 | * @param p Pointer to text
|
||
51 | * @param txt String to be set
|
||
52 | */
|
||
53 | void (text_set_string)(text_t *p, const char *txt); |
||
54 | /**
|
||
55 | * @brief Set text position.
|
||
56 | * @param p Pointer to text
|
||
57 | * @param x X-position of the text
|
||
58 | * @param y Y-position of the text
|
||
59 | */
|
||
60 | void (text_set_pos) (text_t *p, int16_t x, int16_t y);
|
||
61 | /**
|
||
62 | * @brief Set text size (letter size, in pixels).
|
||
63 | * @param p Pointer to text
|
||
64 | * @param size Letter size of the text
|
||
65 | */
|
||
66 | void (text_set_size) (text_t *p, uint16_t size);
|
||
67 | /**
|
||
68 | * @brief Set text color.
|
||
69 | * @param p Pointer to text
|
||
70 | * @param color Text color
|
||
71 | */
|
||
72 | void (text_set_color) (text_t *p, uint32_t color);
|
||
73 | /**
|
||
74 | * @brief Set text vertical alignment.
|
||
75 | * @param p Pointer to text
|
||
76 | * @param valign Vertical alignment of the text
|
||
77 | */
|
||
78 | void (text_set_valign)(text_t *p, text_valign valign);
|
||
79 | /**
|
||
80 | * @brief Set text horizontal alignment.
|
||
81 | * @param p Pointer to text
|
||
82 | * @param halign Horizontal alignment of the text
|
||
83 | */
|
||
84 | void (text_set_halign)(text_t *p, text_halign halign);
|
||
85 | /**
|
||
86 | * @brief Get string of the text.
|
||
87 | * @param p Pointer to text
|
||
88 | * @return Pointer to string
|
||
89 | */
|
||
90 | const char* (text_get_string)(const text_t *p); |
||
91 | /**
|
||
92 | * @brief Get text x-position.
|
||
93 | * @param p Pointer to text
|
||
94 | * @return X-position of text
|
||
95 | */
|
||
96 | int16_t (text_get_x) (const text_t *p);
|
||
97 | /**
|
||
98 | * @brief Get text y-position.
|
||
99 | * @param p Pointer to text
|
||
100 | * @return Y-position of text
|
||
101 | */
|
||
102 | int16_t (text_get_y) (const text_t *p);
|
||
103 | /**
|
||
104 | * @brief Draw text on the screen buffer.
|
||
105 | * @param p Pointer to text
|
||
106 | * @return SUCCESS if operation was successful, false otherwise
|
||
107 | */
|
||
108 | int (text_draw) (const text_t *p); |
||
109 | |||
110 | /**
|
||
111 | * @}
|
||
112 | */
|
||
113 | |||
114 | #endif //TEXT_H_INCLUDED |