Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

charcanvas.c

00001 /*
00002  *  charcanvas.c - Canvas for character-oriented devices.
00003  *                 This file is part of the FreeLCD package.
00004  *  
00005  *  $Id: charcanvas_8c-source.html,v 1.1 2003/02/16 22:50:41 unicorn Exp $
00006  *
00007  *  This program is free software; you can redistribute it and/or modify it
00008  *  under the terms of the GNU General Public License as published by the
00009  *  Free Software Foundation; either version 2 of the License, or (at your
00010  *  option) any later version.
00011  * 
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00020  *  MA  02111-1307  USA
00021  *
00022  *  Copyright (c) 2002, 2003, Jeroen van den Berg <unicorn@hippie.nu>
00023  */
00024 
00025 #include <stdlib.h>
00026 #include <unicode.h>
00027 
00028 #include <common/xmalloc.h>
00029 #include "charcanvas.h"
00030 
00031 /*---------------------------------------------------- cc_create_canvas --*/
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 /*---------------------------------------------------- cc_delete_canvas --*/
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 /*--------------------------------------------------------- cc_put_char --*/
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 /*------------------------------------------------------- cc_write_text --*/
00081 void
00082 cc_write_text (cc_canvas *canvas, unsigned int x_pos, unsigned int y_pos,
00083                char *utf8_string)
00084 {
00085   /* FIXME */
00086 }
00087 
00088 /*------------------------------------------------------ cc_get_element --*/
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 /*-------------------------------------------- cc_clear_damaged_regions --*/
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 

Generated on Sun Feb 16 23:39:49 2003 for FreeLCD by doxygen1.2.18