00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <stdlib.h>
00026 #include <unicode.h>
00027
00028 #include <common/xmalloc.h>
00029 #include "charcanvas.h"
00030
00031
00032 cc_canvas *
00033 cc_create_canvas (unsigned int width, unsigned int height)
00034 {
00035 size_t i;
00036 size_t size = width * height;
00037 cc_elem *element;
00038 cc_canvas *new = xmalloc (sizeof (cc_canvas));
00039
00040 new->width = width;
00041 new->height = height;
00042 new->elements = xmalloc (size * sizeof (cc_elem));
00043 element = new->elements;
00044
00045 for (i = 0; i < size; ++i, ++element)
00046 {
00047 element->c = L' ';
00048 element->damaged_flag = 0;
00049 element->bitmap = 0;
00050 }
00051
00052 return new;
00053 }
00054
00055
00056 void
00057 cc_delete_canvas (cc_canvas *canvas)
00058 {
00059 int i;
00060 int size = canvas->width * canvas->height;
00061 cc_elem *element = canvas->elements;
00062
00063 for (i = 0; i < size; ++i, ++element)
00064 free (element->bitmap);
00065
00066 free (canvas->elements);
00067 free (canvas);
00068 }
00069
00070
00071 void
00072 cc_put_char (cc_canvas *canvas, unsigned int x_pos, unsigned int y_pos,
00073 wchar_t character)
00074 {
00075 cc_elem *element = cc_get_element (canvas, x_pos, y_pos);
00076 element->c = character;
00077 element->damaged_flag = 1;
00078 }
00079
00080
00081 void
00082 cc_write_text (cc_canvas *canvas, unsigned int x_pos, unsigned int y_pos,
00083 char *utf8_string)
00084 {
00085
00086 }
00087
00088
00089 cc_elem*
00090 cc_get_element (cc_canvas *canvas, unsigned int x_pos, unsigned int y_pos)
00091 {
00092 return canvas->elements + x_pos + y_pos * canvas->width;
00093 }
00094
00095
00096 void
00097 cc_clear_damaged_regions (cc_canvas *canvas)
00098 {
00099 size_t i;
00100 size_t size = canvas->width * canvas->height;
00101 cc_elem *element = canvas->elements;
00102
00103 for (i = 0; i < size; ++i, ++element)
00104 element->damaged_flag = 0;
00105
00106 free (canvas->elements);
00107 free (canvas);
00108 }
00109