1 #ifndef GUI_DRAW_H
2 #define GUI_DRAW_H
3
4 #include "conf.h"
5 #include "palette.h"
6
7
8
9 extern unsigned char *chdk_colors;
10
11 #define IDX_COLOR_TRANSPARENT 0
12 #define IDX_COLOR_BLACK 1
13 #define IDX_COLOR_WHITE 2
14 #define IDX_COLOR_RED 3
15 #define IDX_COLOR_RED_DK 4
16 #define IDX_COLOR_RED_LT 5
17 #define IDX_COLOR_GREEN 6
18 #define IDX_COLOR_GREEN_DK 7
19 #define IDX_COLOR_GREEN_LT 8
20 #define IDX_COLOR_BLUE 9
21 #define IDX_COLOR_BLUE_DK 10
22 #define IDX_COLOR_BLUE_LT 11
23 #define IDX_COLOR_GREY 12
24 #define IDX_COLOR_GREY_DK 13
25 #define IDX_COLOR_GREY_LT 14
26 #define IDX_COLOR_YELLOW 15
27 #define IDX_COLOR_YELLOW_DK 16
28 #define IDX_COLOR_YELLOW_LT 17
29 #define IDX_COLOR_GREY_DK_TRANS 18
30 #define IDX_COLOR_MAGENTA 19
31 #define IDX_COLOR_CYAN IDX_COLOR_BLUE_LT
32
33 #define IDX_COLOR_MAX 19
34
35 #define COLOR_WHITE (chdk_colors[IDX_COLOR_WHITE])
36 #define COLOR_RED (chdk_colors[IDX_COLOR_RED])
37 #define COLOR_RED_DK (chdk_colors[IDX_COLOR_RED_DK])
38 #define COLOR_RED_LT (chdk_colors[IDX_COLOR_RED_LT])
39 #define COLOR_GREEN (chdk_colors[IDX_COLOR_GREEN])
40 #define COLOR_GREEN_DK (chdk_colors[IDX_COLOR_GREEN_DK])
41 #define COLOR_GREEN_LT (chdk_colors[IDX_COLOR_GREEN_LT])
42 #define COLOR_BLUE (chdk_colors[IDX_COLOR_BLUE])
43 #define COLOR_BLUE_DK (chdk_colors[IDX_COLOR_BLUE_DK])
44 #define COLOR_BLUE_LT (chdk_colors[IDX_COLOR_BLUE_LT])
45 #define COLOR_GREY (chdk_colors[IDX_COLOR_GREY])
46 #define COLOR_GREY_DK (chdk_colors[IDX_COLOR_GREY_DK])
47 #define COLOR_GREY_LT (chdk_colors[IDX_COLOR_GREY_LT])
48 #define COLOR_YELLOW (chdk_colors[IDX_COLOR_YELLOW])
49 #define COLOR_YELLOW_DK (chdk_colors[IDX_COLOR_YELLOW_DK])
50 #define COLOR_YELLOW_LT (chdk_colors[IDX_COLOR_YELLOW_LT])
51 #define COLOR_GREY_DK_TRANS (chdk_colors[IDX_COLOR_GREY_DK_TRANS])
52 #define COLOR_MAGENTA (chdk_colors[IDX_COLOR_MAGENTA])
53 #define COLOR_CYAN (chdk_colors[IDX_COLOR_CYAN])
54
55
56 #define FONT_REAL_WIDTH 8
57 #define FONT_REAL_HEIGHT 16
58
59 #ifndef THUMB_FW
60
61 #define FONT_WIDTH 8
62 #define FONT_HEIGHT 16
63
64 #define DEFAULT_SYMBOL_FILE "A/CHDK/SYMBOLS/icon_10.rbf"
65
66 #else
67
68 #define FONT_WIDTH 14
69 #define FONT_HEIGHT 32
70
71 #define DEFAULT_SYMBOL_FILE "A/CHDK/SYMBOLS/icon_16.rbf"
72
73 #endif
74
75
76 #define TEXT_LEFT 0
77 #define TEXT_CENTER 1
78 #define TEXT_RIGHT 2
79 #define TEXT_FILL 16
80
81
82 #define RECT_BORDER0 0
83 #define RECT_BORDER1 1
84 #define RECT_BORDER2 2
85 #define RECT_BORDER3 3
86 #define RECT_BORDER4 4
87 #define RECT_BORDER5 5
88 #define RECT_BORDER6 6
89 #define RECT_BORDER7 7
90 #define RECT_BORDER_MASK 7
91 #define DRAW_FILLED 8
92 #define RECT_SHADOW0 0
93 #define RECT_SHADOW1 0x10
94 #define RECT_SHADOW2 0x20
95 #define RECT_SHADOW3 0x30
96 #define RECT_SHADOW_MASK 0x30
97 #define RECT_ROUND_CORNERS 0x40
98
99
100 extern void draw_init();
101 extern void draw_set_draw_proc(void (*pixel_proc)(unsigned int offset, color cl));
102 extern void update_draw_proc();
103
104 extern void draw_set_guard();
105 extern int draw_test_guard();
106
107 extern color draw_get_pixel(coord x, coord y);
108 extern color draw_get_pixel_unrotated(coord x, coord y);
109
110 extern void draw_pixel(coord x, coord y, color cl);
111 extern void draw_pixel_unrotated(coord x, coord y, color cl);
112
113 extern void draw_dblpixel_raw(unsigned int offset, unsigned int px, unsigned int op);
114 extern void set_transparent(unsigned int offset, int n_pixel);
115 extern unsigned int color_to_rawpx(color cl, unsigned int *op);
116
117 extern void draw_line(coord x1, coord y1, coord x2, coord y2, color cl);
118 extern void draw_hline(coord x, coord y, int len, color cl);
119 extern void draw_vline(coord x, coord y, int len, color cl);
120
121
122 extern void draw_rectangle(coord x1, coord y1, coord x2, coord y2, twoColors cl, int flags);
123 extern void draw_ellipse(coord xc, coord yc, unsigned int a, unsigned int b, color cl, int flags);
124
125
126 extern int text_dimensions(const char *s, int width, int max_chars, int *max_lines);
127 extern void draw_char(coord x, coord y, const char ch, twoColors cl);
128 extern int draw_string_clipped(coord x, coord y, const char *s, twoColors cl, int max_width);
129 extern int draw_string(coord x, coord y, const char *s, twoColors cl);
130 extern int draw_string_justified(coord x, coord y, const char *s, twoColors cl, int xo, int max_width, int justification);
131 extern int draw_text_justified(coord x, coord y, const char *s, twoColors cl, int max_chars, int max_lines, int justification);
132 extern void draw_string_scaled(coord x, coord y, const char *s, twoColors cl, int xsize, int ysize);
133 extern void draw_osd_string(OSD_pos pos, int xo, int yo, char *s, twoColors c, OSD_scale scale);
134 extern void draw_button(int x, int y, int w, int str_id, int active);
135
136 extern void draw_txt_string(coord col, coord row, const char *str, twoColors cl);
137
138 extern void draw_suspend(int ms);
139 extern int draw_is_suspended(void);
140 extern void draw_restore();
141
142 extern color get_script_color(int cl);
143
144 extern color chdkColorToCanonColor(chdkColor c);
145 extern twoColors user_color(confColor c);
146
147
148
149
150
151 enum icon_actions
152 {
153 IA_END,
154 IA_HLINE,
155 IA_VLINE,
156 IA_LINE,
157 IA_RECT,
158 IA_FILLED_RECT,
159 IA_ROUND_RECT,
160 IA_FILLED_ROUND_RECT
161 };
162
163
164 typedef struct
165 {
166 unsigned char action;
167 unsigned char x1, y1;
168 unsigned char x2, y2;
169 color cb, cf;
170 } icon_cmd;
171
172
173 extern void draw_icon_cmds(coord x, coord y, icon_cmd *cmds);
174
175
176 #endif