fix to detect n900 battery; add support to built in battery variables to work with...
[monky] / lua / imlib2.pkg
1 $#include <Imlib2.h>
2 $#include <X11/Xlib.h>
3
4 $#define _userdata void*
5
6 typedef void *Imlib_Context;
7 typedef void *Imlib_Image;
8 typedef void *Imlib_Color_Modifier;
9 typedef void *Imlib_Updates;
10 typedef void *Imlib_Font;
11 typedef void *Imlib_Color_Range;
12 typedef void *Imlib_Filter;
13 typedef struct _imlib_color Imlib_Color;
14 typedef void *ImlibPolygon;
15
16 enum _imlib_operation
17 {
18         IMLIB_OP_COPY,
19         IMLIB_OP_ADD,
20         IMLIB_OP_SUBTRACT,
21         IMLIB_OP_RESHADE
22 };
23
24 enum _imlib_text_direction
25 {
26         IMLIB_TEXT_TO_RIGHT = 0,
27         IMLIB_TEXT_TO_LEFT = 1,
28         IMLIB_TEXT_TO_DOWN = 2,
29         IMLIB_TEXT_TO_UP = 3,
30         IMLIB_TEXT_TO_ANGLE = 4
31 };
32
33 enum _imlib_load_error
34 {
35         IMLIB_LOAD_ERROR_NONE,
36         IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST,
37         IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY,
38         IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ,
39         IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT,
40         IMLIB_LOAD_ERROR_PATH_TOO_LONG,
41         IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT,
42         IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY,
43         IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE,
44         IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS,
45         IMLIB_LOAD_ERROR_OUT_OF_MEMORY,
46         IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS,
47         IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE,
48         IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE,
49         IMLIB_LOAD_ERROR_UNKNOWN
50 };
51
52 enum _imlib_TTF_encoding
53 {
54         IMLIB_TTF_ENCODING_ISO_8859_1,
55         IMLIB_TTF_ENCODING_ISO_8859_2,
56         IMLIB_TTF_ENCODING_ISO_8859_3,
57         IMLIB_TTF_ENCODING_ISO_8859_4,
58         IMLIB_TTF_ENCODING_ISO_8859_5
59 };
60
61 typedef enum _imlib_operation Imlib_Operation;
62 typedef enum _imlib_load_error Imlib_Load_Error;
63 typedef enum _imlib_load_error ImlibLoadError;
64 typedef enum _imlib_text_direction Imlib_Text_Direction;
65 typedef enum _imlib_TTF_encoding Imlib_TTF_Encoding;
66
67 typedef struct _imlib_border Imlib_Border;
68
69 Imlib_Context imlib_context_new(void);
70 void imlib_context_free(Imlib_Context context);
71
72 void imlib_context_push(Imlib_Context context);
73 void imlib_context_pop(void);
74 Imlib_Context imlib_context_get(void);
75
76 void imlib_context_set_display(Display * display);
77 void imlib_context_disconnect_display(void);
78 void imlib_context_set_visual(Visual * visual);
79 void imlib_context_set_colormap(Colormap colormap);
80 void imlib_context_set_drawable(Drawable drawable);
81 void imlib_context_set_mask(Pixmap mask);
82 void imlib_context_set_dither_mask(char dither_mask);
83 void imlib_context_set_mask_alpha_threshold(int mask_alpha_threshold);
84 void imlib_context_set_anti_alias(char anti_alias);
85 void imlib_context_set_dither(char dither);
86 void imlib_context_set_blend(char blend);
87 void imlib_context_set_color_modifier(Imlib_Color_Modifier color_modifier);
88 void imlib_context_set_operation(Imlib_Operation operation);
89 void imlib_context_set_font(Imlib_Font font);
90 void imlib_context_set_direction(Imlib_Text_Direction direction);
91 void imlib_context_set_angle(double angle);
92 void imlib_context_set_color(int red, int green, int blue, int alpha);
93 void imlib_context_set_color_hsva(float hue, float saturation, float value, int alpha);
94 void imlib_context_set_color_hlsa(float hue, float lightness, float saturation, int alpha);
95 void imlib_context_set_color_cmya(int cyan, int magenta, int yellow, int alpha);
96 void imlib_context_set_color_range(Imlib_Color_Range color_range);
97 void imlib_context_set_progress_function(Imlib_Progress_Function
98                 progress_function);
99 void imlib_context_set_progress_granularity(char progress_granularity);
100 void imlib_context_set_image(Imlib_Image image);
101 void imlib_context_set_cliprect(int x, int y, int w, int h);
102 void imlib_context_set_TTF_encoding(Imlib_TTF_Encoding encoding);
103
104 Display *imlib_context_get_display(void);
105 Visual *imlib_context_get_visual(void);
106 Colormap imlib_context_get_colormap(void);
107 Drawable imlib_context_get_drawable(void);
108 Pixmap imlib_context_get_mask(void);
109 char imlib_context_get_dither_mask(void);
110 char imlib_context_get_anti_alias(void);
111 int imlib_context_get_mask_alpha_threshold(void);
112 char imlib_context_get_dither(void);
113 char imlib_context_get_blend(void);
114 Imlib_Color_Modifier imlib_context_get_color_modifier(void);
115 Imlib_Operation imlib_context_get_operation(void);
116 Imlib_Font imlib_context_get_font(void);
117 double imlib_context_get_angle(void);
118 Imlib_Text_Direction imlib_context_get_direction(void);
119 void imlib_context_get_color(int *red, int *green, int *blue, int *alpha);
120 void imlib_context_get_color_hsva(float *hue, float *saturation, float *value, int *alpha);
121 void imlib_context_get_color_hlsa(float *hue, float *lightness, float *saturation, int *alpha);
122 void imlib_context_get_color_cmya(int *cyan, int *magenta, int *yellow, int *alpha);
123 Imlib_Color *imlib_context_get_imlib_color(void);
124 Imlib_Color_Range imlib_context_get_color_range(void);
125 Imlib_Progress_Function imlib_context_get_progress_function(void);
126 char imlib_context_get_progress_granularity(void);
127 Imlib_Image imlib_context_get_image(void);
128 void imlib_context_get_cliprect(int *x, int *y, int *w, int *h);
129 Imlib_TTF_Encoding imlib_context_get_TTF_encoding(void);
130
131 int imlib_get_cache_size(void);
132 void imlib_set_cache_size(int bytes);
133 int imlib_get_color_usage(void);
134 void imlib_set_color_usage(int max);
135 void imlib_flush_loaders(void);
136 int imlib_get_visual_depth(Display * display, Visual * visual);
137 Visual *imlib_get_best_visual(Display * display, int screen,
138                 int *depth_return);
139
140 Imlib_Image imlib_load_image(const char *file);
141 Imlib_Image imlib_load_image_immediately(const char *file);
142 Imlib_Image imlib_load_image_without_cache(const char *file);
143 Imlib_Image imlib_load_image_immediately_without_cache(const char *file);
144 Imlib_Image imlib_load_image_with_error_return(const char *file,
145                 Imlib_Load_Error *
146                 error_return);
147 void imlib_free_image(void);
148 void imlib_free_image_and_decache(void);
149
150 int imlib_image_get_width(void);
151 int imlib_image_get_height(void);
152 const char *imlib_image_get_filename(void);
153 int *imlib_image_get_data(void);
154 int *imlib_image_get_data_for_reading_only(void);
155 void imlib_image_put_back_data(unsigned int * data);
156 char imlib_image_has_alpha(void);
157 void imlib_image_set_changes_on_disk(void);
158 void imlib_image_get_border(Imlib_Border * border);
159 void imlib_image_set_border(Imlib_Border * border);
160 void imlib_image_set_format(const char *format);
161 void imlib_image_set_irrelevant_format(char irrelevant);
162 void imlib_image_set_irrelevant_border(char irrelevant);
163 void imlib_image_set_irrelevant_alpha(char irrelevant);
164 char *imlib_image_format(void);
165 void imlib_image_set_has_alpha(char has_alpha);
166 void imlib_image_query_pixel(int x, int y, Imlib_Color * color_return);
167 void imlib_image_query_pixel_hsva(int x, int y, float *hue, float *saturation, float *value, int *alpha);
168 void imlib_image_query_pixel_hlsa(int x, int y, float *hue, float *lightness, float *saturation, int *alpha);
169 void imlib_image_query_pixel_cmya(int x, int y, int *cyan, int *magenta, int *yellow, int *alpha);
170
171 void imlib_render_pixmaps_for_whole_image(Pixmap * pixmap_return,
172                 Pixmap * mask_return);
173 void imlib_render_pixmaps_for_whole_image_at_size(Pixmap * pixmap_return,
174                 Pixmap * mask_return,
175                 int width, int height);
176 void imlib_free_pixmap_and_mask(Pixmap pixmap);
177 void imlib_render_image_on_drawable(int x, int y);
178 void imlib_render_image_on_drawable_at_size(int x, int y, int width,
179                 int height);
180 void imlib_render_image_part_on_drawable_at_size(int source_x,
181                 int source_y,
182                 int source_width,
183                 int source_height, int x,
184                 int y, int width,
185                 int height);
186 unsigned int imlib_render_get_pixel_color(void);
187 void imlib_blend_image_onto_image(Imlib_Image source_image,
188                 char merge_alpha, int source_x,
189                 int source_y, int source_width,
190                 int source_height, int destination_x,
191                 int destination_y, int destination_width,
192                 int destination_height);
193
194 Imlib_Image imlib_create_image(int width, int height);
195 Imlib_Image imlib_create_image_using_data(int width, int height,
196                 unsigned int * data);
197 Imlib_Image imlib_create_image_using_copied_data(int width, int height,
198                 unsigned int * data);
199 Imlib_Image imlib_create_image_from_drawable(Pixmap mask, int x, int y,
200                 int width, int height,
201                 char need_to_grab_x);
202 Imlib_Image imlib_create_image_from_ximage(XImage *image, XImage *mask, int x, int y,
203                 int width, int height,
204                 char need_to_grab_x);
205 Imlib_Image imlib_create_scaled_image_from_drawable(Pixmap mask,
206                 int source_x,
207                 int source_y,
208                 int source_width,
209                 int source_height,
210                 int destination_width,
211                 int destination_height,
212                 char need_to_grab_x,
213                 char
214                 get_mask_from_shape);
215 char imlib_copy_drawable_to_image(Pixmap mask, int x, int y, int width,
216                 int height, int destination_x,
217                 int destination_y, char need_to_grab_x);
218 Imlib_Image imlib_clone_image(void);
219 Imlib_Image imlib_create_cropped_image(int x, int y, int width,
220                 int height);
221 Imlib_Image imlib_create_cropped_scaled_image(int source_x, int source_y,
222                 int source_width,
223                 int source_height,
224                 int destination_width,
225                 int destination_height);
226
227 Imlib_Updates imlib_updates_clone(Imlib_Updates updates);
228 Imlib_Updates imlib_update_append_rect(Imlib_Updates updates, int x, int y,
229                 int w, int h);
230 Imlib_Updates imlib_updates_merge(Imlib_Updates updates, int w, int h);
231 Imlib_Updates imlib_updates_merge_for_rendering(Imlib_Updates updates,
232                 int w, int h);
233 void imlib_updates_free(Imlib_Updates updates);
234 Imlib_Updates imlib_updates_get_next(Imlib_Updates updates);
235 void imlib_updates_get_coordinates(Imlib_Updates updates, int *x_return,
236                 int *y_return, int *width_return,
237                 int *height_return);
238 void imlib_updates_set_coordinates(Imlib_Updates updates, int x, int y,
239                 int width, int height);
240 void imlib_render_image_updates_on_drawable(Imlib_Updates updates, int x,
241                 int y);
242 Imlib_Updates imlib_updates_init(void);
243 Imlib_Updates imlib_updates_append_updates(Imlib_Updates updates,
244                 Imlib_Updates appended_updates);
245
246 void imlib_image_flip_horizontal(void);
247 void imlib_image_flip_vertical(void);
248 void imlib_image_flip_diagonal(void);
249 void imlib_image_orientate(int orientation);
250 void imlib_image_blur(int radius);
251 void imlib_image_sharpen(int radius);
252 void imlib_image_tile_horizontal(void);
253 void imlib_image_tile_vertical(void);
254 void imlib_image_tile(void);
255
256 Imlib_Font imlib_load_font(const char *font_name);
257 void imlib_free_font(void);
258 int imlib_insert_font_into_fallback_chain(Imlib_Font font, Imlib_Font fallback_font);
259 void imlib_remove_font_from_fallback_chain(Imlib_Font fallback_font);
260 Imlib_Font imlib_get_prev_font_in_fallback_chain(Imlib_Font fn);
261 Imlib_Font imlib_get_next_font_in_fallback_chain(Imlib_Font fn);
262 void imlib_text_draw(int x, int y, const char *text);
263 void imlib_text_draw_with_return_metrics(int x, int y, const char *text,
264                 int *width_return,
265                 int *height_return,
266                 int *horizontal_advance_return,
267                 int *vertical_advance_return);
268 void imlib_get_text_size(const char *text, int *width_return,
269                 int *height_return);
270 void imlib_get_text_advance(const char *text, 
271                 int *horizontal_advance_return,
272                 int *vertical_advance_return);
273 int imlib_get_text_inset(const char *text);
274 void imlib_add_path_to_font_path(const char *path);
275 void imlib_remove_path_from_font_path(const char *path);
276 char **imlib_list_font_path(int *number_return);
277 int imlib_text_get_index_and_location(const char *text, int x, int y,
278                 int *char_x_return,
279                 int *char_y_return,
280                 int *char_width_return,
281                 int *char_height_return);
282 void imlib_text_get_location_at_index(const char *text, int index,
283                 int *char_x_return,
284                 int *char_y_return,
285                 int *char_width_return,
286                 int *char_height_return);
287 char **imlib_list_fonts(int *number_return);
288 void imlib_free_font_list(char **font_list, int number);
289 int imlib_get_font_cache_size(void);
290 void imlib_set_font_cache_size(int bytes);
291 void imlib_flush_font_cache(void);
292 int imlib_get_font_ascent(void);
293 int imlib_get_font_descent(void);
294 int imlib_get_maximum_font_ascent(void);
295 int imlib_get_maximum_font_descent(void);
296
297 Imlib_Color_Modifier imlib_create_color_modifier(void);
298 void imlib_free_color_modifier(void);
299 void imlib_modify_color_modifier_gamma(double gamma_value);
300 void imlib_modify_color_modifier_brightness(double brightness_value);
301 void imlib_modify_color_modifier_contrast(double contrast_value);
302 void imlib_set_color_modifier_tables(unsigned char * red_table,
303                 unsigned char * green_table,
304                 unsigned char * blue_table,
305                 unsigned char * alpha_table);
306 void imlib_get_color_modifier_tables(unsigned char * red_table,
307                 unsigned char * green_table,
308                 unsigned char * blue_table,
309                 unsigned char * alpha_table);
310 void imlib_reset_color_modifier(void);
311 void imlib_apply_color_modifier(void);
312 void imlib_apply_color_modifier_to_rectangle(int x, int y, int width,
313                 int height);
314
315 Imlib_Updates imlib_image_draw_pixel(int x, int y, char make_updates);
316 Imlib_Updates imlib_image_draw_line(int x1, int y1, int x2, int y2,
317                 char make_updates);
318 void imlib_image_draw_rectangle(int x, int y, int width, int height);
319 void imlib_image_fill_rectangle(int x, int y, int width, int height);
320 void imlib_image_copy_alpha_to_image(Imlib_Image image_source, int x,
321                 int y);
322 void imlib_image_copy_alpha_rectangle_to_image(Imlib_Image image_source,
323                 int x, int y, int width,
324                 int height,
325                 int destination_x,
326                 int destination_y);
327 void imlib_image_scroll_rect(int x, int y, int width, int height,
328                 int delta_x, int delta_y);
329 void imlib_image_copy_rect(int x, int y, int width, int height, int new_x,
330                 int new_y);
331
332 ImlibPolygon imlib_polygon_new(void);
333 void imlib_polygon_free(ImlibPolygon poly);
334 void imlib_polygon_add_point(ImlibPolygon poly, int x, int y);
335 void imlib_image_draw_polygon(ImlibPolygon poly, unsigned char closed);
336 void imlib_image_fill_polygon(ImlibPolygon poly);
337 void imlib_polygon_get_bounds(ImlibPolygon poly, int *px1, int *py1,
338                 int *px2, int *py2);
339 unsigned char imlib_polygon_contains_point(ImlibPolygon poly, int x,
340                 int y);
341
342 void imlib_image_draw_ellipse(int xc, int yc, int a, int b);
343 void imlib_image_fill_ellipse(int xc, int yc, int a, int b);
344
345 Imlib_Color_Range imlib_create_color_range(void);
346 void imlib_free_color_range(void);
347 void imlib_add_color_to_color_range(int distance_away);
348 void imlib_image_fill_color_range_rectangle(int x, int y, int width,
349                 int height, double angle);
350 void imlib_image_fill_hsva_color_range_rectangle(int x, int y, int width,
351                 int height, double angle);
352
353 void imlib_image_attach_data_value(const char *key, void *data, int value,
354                 Imlib_Data_Destructor_Function
355                 destructor_function);
356 void *imlib_image_get_attached_data(const char *key);
357 int imlib_image_get_attached_value(const char *key);
358 void imlib_image_remove_attached_data_value(const char *key);
359 void imlib_image_remove_and_free_attached_data_value(const char *key);
360
361 void imlib_save_image(const char *filename);
362 void imlib_save_image_with_error_return(const char *filename,
363                 Imlib_Load_Error * error_return);
364
365 Imlib_Image imlib_create_rotated_image(double angle);
366
367 void imlib_rotate_image_from_buffer(double angle, 
368                 Imlib_Image source_image);
369
370 void imlib_blend_image_onto_image_at_angle(Imlib_Image source_image,
371                 char merge_alpha, int source_x,
372                 int source_y, int source_width,
373                 int source_height,
374                 int destination_x,
375                 int destination_y, int angle_x,
376                 int angle_y);
377 void imlib_blend_image_onto_image_skewed(Imlib_Image source_image,
378                 char merge_alpha, int source_x,
379                 int source_y, int source_width,
380                 int source_height,
381                 int destination_x,
382                 int destination_y, int h_angle_x,
383                 int h_angle_y, int v_angle_x,
384                 int v_angle_y);
385 void imlib_render_image_on_drawable_skewed(int source_x, int source_y,
386                 int source_width,
387                 int source_height,
388                 int destination_x,
389                 int destination_y,
390                 int h_angle_x, int h_angle_y,
391                 int v_angle_x, int v_angle_y);
392 void imlib_render_image_on_drawable_at_angle(int source_x, int source_y,
393                 int source_width,
394                 int source_height,
395                 int destination_x,
396                 int destination_y,
397                 int angle_x, int angle_y);
398
399 void imlib_image_filter(void);
400 Imlib_Filter imlib_create_filter(int initsize);
401 void imlib_context_set_filter(Imlib_Filter filter);
402 Imlib_Filter imlib_context_get_filter(void);
403 void imlib_free_filter(void);
404 void imlib_filter_set(int xoff, int yoff, int a, int r, int g, int b);
405 void imlib_filter_set_alpha(int xoff, int yoff, int a, int r, int g,
406                 int b);
407 void imlib_filter_set_red(int xoff, int yoff, int a, int r, int g, int b);
408 void imlib_filter_set_green(int xoff, int yoff, int a, int r, int g,
409                 int b);
410 void imlib_filter_set_blue(int xoff, int yoff, int a, int r, int g, int b);
411 void imlib_filter_constants(int a, int r, int g, int b);
412 void imlib_filter_divisors(int a, int r, int g, int b);
413
414 void imlib_image_clear(void);
415 void imlib_image_clear_color(int r, int g, int b, int a);
416