Rev 6470 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6470 | Rev 6524 | ||
---|---|---|---|
1 | #ifndef KOLIBRI_STATICTEXT_H |
1 | #ifndef KOLIBRI_STATICTEXT_H |
2 | #define KOLIBRI_STATICTEXT_H |
2 | #define KOLIBRI_STATICTEXT_H |
3 | 3 | ||
4 | typedef enum { |
4 | typedef enum { |
5 | cp866, // 6x9 |
5 | cp866, // 6x9 |
6 | CP866, // 8x16 |
6 | CP866, // 8x16 |
7 | UTF16, |
7 | UTF16, |
8 | UTF8 |
8 | UTF8 |
9 | } encoding_t; |
9 | } encoding_t; |
10 | 10 | ||
11 | typedef struct { |
11 | typedef struct { |
12 | uint32_t start_xy; |
12 | uint32_t start_xy; |
13 | char *text; |
13 | char *text; |
14 | uint32_t color_flags; |
14 | uint32_t color_flags; |
15 | uint32_t bg_color; |
15 | uint32_t bg_color; |
16 | }statictext; |
16 | }statictext; |
17 | 17 | ||
18 | typedef struct { |
18 | typedef struct { |
19 | uint32_t start_xy; |
19 | uint32_t start_xy; |
20 | int32_t number; |
20 | int32_t number; |
21 | uint32_t color_flags; |
21 | uint32_t color_flags; |
22 | uint32_t bg_color; |
22 | uint32_t bg_color; |
23 | uint16_t width; |
23 | uint16_t width; |
24 | }staticnum; |
24 | }staticnum; |
25 | 25 | ||
26 | statictext* kolibri_statictext(statictext* st, uint32_t xy, char *text, encoding_t enc, int size, color_t font, color_t bg) |
26 | statictext* kolibri_statictext(statictext* st, uint32_t xy, char *text, encoding_t enc, int size, color_t font, color_t bg) |
27 | { |
27 | { |
28 | st->start_xy = xy; |
28 | st->start_xy = xy; |
29 | st->text = text; |
29 | st->text = text; |
30 | st->color_flags = 0x80000000; // asciiz |
30 | st->color_flags = 0x80000000; // asciiz |
31 | st->bg_color = bg; |
31 | st->bg_color = bg; |
32 | if(bg & 0xFFFFFF) st->color_flags |= 0x40000000;// use background |
32 | if(bg & 0xFFFFFF) st->color_flags |= 0x40000000;// use background |
33 | st->color_flags |= ((enc & 1) << 4) | (size & 7) << 24; |
33 | st->color_flags |= ((enc & 1) << 4) | (size & 7) << 24; |
34 | st->color_flags |= font & 0xFFFFFF; |
34 | st->color_flags |= font & 0xFFFFFF; |
35 | 35 | ||
36 | return st; |
36 | return st; |
37 | } |
37 | } |
38 | 38 | ||
39 | statictext* kolibri_statictext_def(statictext* st, uint32_t xy, char *text) |
39 | statictext* kolibri_statictext_def(statictext* st, uint32_t xy, char *text) |
40 | { |
40 | { |
41 | return kolibri_statictext(st, xy, text, 0, 0, kolibri_color_table.color_work_text, 0); |
41 | return kolibri_statictext(st, xy, text, 0, 0, kolibri_color_table.color_work_text, 0); |
42 | } |
42 | } |
43 | 43 | ||
44 | statictext* kolibri_new_statictext(uint32_t xy, char *text, encoding_t enc, int size, color_t font, color_t bg) |
44 | statictext* kolibri_new_statictext(uint32_t xy, char *text, encoding_t enc, int size, color_t font, color_t bg) |
45 | { |
45 | { |
46 | statictext *st = (statictext*)malloc(sizeof(statictext)); |
46 | statictext *st = (statictext*)malloc(sizeof(statictext)); |
47 | 47 | ||
48 | return kolibri_statictext(st, xy, text, enc, size, font, bg); |
48 | return kolibri_statictext(st, xy, text, enc, size, font, bg); |
49 | } |
49 | } |
50 | 50 | ||
51 | statictext* kolibri_new_statictext_def(uint32_t xy, char *text) |
51 | statictext* kolibri_new_statictext_def(uint32_t xy, char *text) |
52 | { |
52 | { |
53 | return kolibri_new_statictext(xy, text, 0, 0, kolibri_color_table.color_work_text, 0); |
53 | return kolibri_new_statictext(xy, text, 0, 0, kolibri_color_table.color_work_text, 0); |
54 | } |
54 | } |
55 | 55 | ||
56 | __attribute__((__stdcall__)) |
56 | __attribute__((__stdcall__)) |
57 | void statictext_draw(statictext *st) |
57 | void statictext_draw(statictext *st) |
58 | { |
58 | { |
59 | __asm__ __volatile__( |
59 | __asm__ __volatile__( |
60 | "int $0x40" |
60 | "int $0x40" |
61 | ::"a"(4), |
61 | ::"a"(4), |
62 | "b"(st->start_xy), |
62 | "b"(st->start_xy), |
63 | "c"(st->color_flags), |
63 | "c"(st->color_flags), |
64 | "d"(st->text), |
64 | "d"(st->text), |
65 | "D"(st->bg_color) |
65 | "D"(st->bg_color) |
66 | :); |
66 | :); |
67 | } |
67 | } |
- | 68 | ||
- | 69 | inline void gui_add_statictext(kolibri_window *wnd, statictext* st) |
|
- | 70 | { |
|
- | 71 | kolibri_window_add_element(wnd, KOLIBRI_STATICTEXT, st); |
|
- | 72 | } |
|
- | 73 | ||
- | 74 | ||
68 | 75 | ||
69 | staticnum* kolibri_staticnum(staticnum* st, uint32_t xy, int32_t width, int16_t number, encoding_t enc, int size, color_t font, color_t bg) |
76 | staticnum* kolibri_staticnum(staticnum* st, uint32_t xy, int32_t width, int16_t number, encoding_t enc, int size, color_t font, color_t bg) |
70 | { |
77 | { |
71 | st->start_xy = xy; |
78 | st->start_xy = xy; |
72 | st->number = number; |
79 | st->number = number; |
73 | st->color_flags = 0; |
80 | st->color_flags = 0; |
74 | st->bg_color = bg; |
81 | st->bg_color = bg; |
75 | if(bg & 0xFFFFFF) st->color_flags |= 0x40000000;// use background |
82 | if(bg & 0xFFFFFF) st->color_flags |= 0x40000000;// use background |
76 | st->color_flags |= ((enc & 1) << 4) | (size & 7) << 24; |
83 | st->color_flags |= ((enc & 1) << 4) | (size & 7) << 24; |
77 | st->color_flags |= font & 0xFFFFFF; |
84 | st->color_flags |= font & 0xFFFFFF; |
78 | st->width = width; |
85 | st->width = width; |
79 | 86 | ||
80 | return st; |
87 | return st; |
81 | } |
88 | } |
82 | 89 | ||
83 | staticnum* kolibri_staticnum_def(staticnum* st, uint32_t xy, int16_t width, int32_t number) |
90 | staticnum* kolibri_staticnum_def(staticnum* st, uint32_t xy, int16_t width, int32_t number) |
84 | { |
91 | { |
85 | return kolibri_staticnum(st, xy, width, number, 0, 0, kolibri_color_table.color_work_text, 0); |
92 | return kolibri_staticnum(st, xy, width, number, 0, 0, kolibri_color_table.color_work_text, 0); |
86 | } |
93 | } |
87 | 94 | ||
88 | staticnum* kolibri_new_staticnum(uint32_t xy, int32_t width, int32_t number, encoding_t enc, int size, color_t font, color_t bg) |
95 | staticnum* kolibri_new_staticnum(uint32_t xy, int32_t width, int32_t number, encoding_t enc, int size, color_t font, color_t bg) |
89 | { |
96 | { |
90 | staticnum *st = (staticnum*)malloc(sizeof(staticnum)); |
97 | staticnum *st = (staticnum*)malloc(sizeof(staticnum)); |
91 | 98 | ||
92 | return kolibri_staticnum(st, xy, width, number, enc, size, font, bg); |
99 | return kolibri_staticnum(st, xy, width, number, enc, size, font, bg); |
93 | } |
100 | } |
94 | 101 | ||
95 | staticnum* kolibri_new_staticnum_def(uint32_t xy, int32_t width, int32_t number) |
102 | staticnum* kolibri_new_staticnum_def(uint32_t xy, int32_t width, int32_t number) |
96 | { |
103 | { |
97 | return kolibri_new_staticnum(xy, width, number, cp866, 0, kolibri_color_table.color_work_text, 0); |
104 | return kolibri_new_staticnum(xy, width, number, cp866, 0, kolibri_color_table.color_work_text, 0); |
98 | } |
105 | } |
- | 106 | ||
- | 107 | inline void gui_add_staticnum(kolibri_window *wnd, staticnum* sn) |
|
- | 108 | { |
|
- | 109 | kolibri_window_add_element(wnd, KOLIBRI_STATICNUM, sn); |
|
- | 110 | } |
|
- | 111 | ||
99 | 112 | ||
100 | __attribute__((__stdcall__)) |
113 | __attribute__((__stdcall__)) |
101 | void staticnum_draw(staticnum *st) |
114 | void staticnum_draw(staticnum *st) |
102 | { |
115 | { |
103 | register uint32_t fmt; |
116 | register uint32_t fmt; |
104 | if (st->width < 0) |
117 | if (st->width < 0) |
105 | fmt = (-st->width << 16); // leading zeros, decimal |
118 | fmt = (-st->width << 16); // leading zeros, decimal |
106 | else |
119 | else |
107 | fmt = (st->width << 16) | 0x80000000; // no leading zeros, decimal |
120 | fmt = (st->width << 16) | 0x80000000; // no leading zeros, decimal |
108 | 121 | ||
109 | __asm__ __volatile__( |
122 | __asm__ __volatile__( |
110 | "int $0x40" |
123 | "int $0x40" |
111 | ::"a"(47), |
124 | ::"a"(47), |
112 | "b"(fmt), |
125 | "b"(fmt), |
113 | "c"(st->number), |
126 | "c"(st->number), |
114 | "d"(st->start_xy), |
127 | "d"(st->start_xy), |
115 | "S"(st->color_flags), |
128 | "S"(st->color_flags), |
116 | "D"(st->bg_color) |
129 | "D"(st->bg_color) |
117 | :); |
130 | :); |
118 | } |
131 | } |
119 | 132 | ||
120 | 133 | ||
121 | #endif /* KOLIBRI_STATICTEXT_H */><>><>>><>><>><>><> |
134 | #endif /* KOLIBRI_STATICTEXT_H */><>><>>><>><>><>><> |