display.h

00001 /* display.h -- Graphic Display Manager
00002    Copyright 2003 Free Software Foundation, Inc.
00003    Written by Stephane Carrez (stcarrez@nerim.fr)
00004 
00005 This file is part of GEL.
00006 
00007 GEL is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2, or (at your option)
00010 any later version.
00011 
00012 GEL 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 GEL; see the file COPYING.  If not, write to
00019 the Free Software Foundation, 59 Temple Place - Suite 330,
00020 Boston, MA 02111-1307, USA.  */
00021 
00022 #ifndef _GEL_DISPLAY_H
00023 #define _GEL_DISPLAY_H
00024 
00025 #include <sys/param.h>
00026 #include <stddef.h>
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00110 
00111 /* Forward declarations.  */
00112 struct gdm_display;
00113 
00115 #define GDM_HEIGHT (64)
00116 
00118 #define GDM_WIDTH  (128)
00119 
00120 #define GDM_SWIDTH (GDM_WIDTH/2)
00121 #define GDM_LCNT   (GDM_HEIGHT/8)
00122 #define GDM_LSIZE  (GDM_WIDTH)
00123 #define GDM_TSIZE  (GDM_LSIZE/8)
00124 
00125 typedef unsigned char gdm_mask;
00126 
00130 enum gdm_gc_mode
00131 {
00133   GDM_PLOT_OR,
00134 
00135   GDM_PLOT_SET = GDM_PLOT_OR,
00136 
00138   GDM_PLOT_AND,
00139 
00140   GDM_PLOT_CLEAR = GDM_PLOT_AND,
00141 
00143   GDM_PLOT_XOR
00144 };
00145 
00158 typedef struct gdm_line
00159 {
00160   unsigned char data[GDM_LSIZE];
00161   gdm_mask      touched;
00162   unsigned short y;
00163 } gdm_line;
00164 
00171 typedef int (* gdm_clip_point_handler) (struct gdm_display* dp,
00172                                         short x, short y);
00173 
00199 typedef struct gdm_display
00200 {
00202   struct gdm_line* lines[GDM_LCNT];
00203 
00204   unsigned short hw0_cur_y;
00205   unsigned short hw1_cur_y;
00206   enum gdm_gc_mode plot_mode;
00207   gdm_mask mask;
00208   gdm_mask or_mask;
00209   gdm_mask xor_mask;
00210   gdm_mask and_mask;
00211   gdm_clip_point_handler clip_point;
00212 
00213   
00214   struct gdm_line image[GDM_LCNT];
00215 } gdm_display;
00216 
00226 extern gdm_line* gdm_get_raw_line (gdm_display* dp, short y);
00227 
00228 extern inline gdm_line* gdm_get_raw_line (gdm_display* dp, short y)
00229 {
00230   if (y < 0 || y >= GDM_HEIGHT)
00231     return 0;
00232   else
00233     return dp->lines[y >> 3];
00234 }
00235 
00254 
00256 #define GDM_DISPLAY_ON    0x01
00257 
00259 #define GDM_DISPLAY_OFF   0x00
00260 
00262 #define GDM_BACKLIGHT_ON  0x02
00263 
00265 #define GDM_BACKLIGHT_OFF 0x00
00266 
00276 extern void gdm_initialize (gdm_display* dp);
00277 
00296 extern void gdm_set_mode  (gdm_display* dp, int mode);
00297 
00305 extern void gdm_set_gc  (gdm_display* dp, enum gdm_gc_mode mode);
00306 
00318 extern int gdm_refresh (gdm_display* dp);
00319 
00336 extern void gdm_touch (gdm_display* dp, short x, short y,
00337                        unsigned short width, unsigned short height);
00338 
00392 
00394 typedef struct gdm_point
00395 {
00396   short x;
00397   short y;
00398 } gdm_point;
00399 
00411 extern void gdm_draw_point (gdm_display* dp, short x, short y);
00412 
00424 extern void gdm_draw_points (gdm_display* dp, gdm_point* pts,
00425                              unsigned short npoints);
00426 
00439 extern void gdm_draw_line (gdm_display* dp, short x1, short y1,
00440                            short x2, short y2);
00441 
00443 #define GDM_LINE    0
00444 
00446 #define GDM_POLYGON 1
00447 
00449 #define GDM_SEGMENT 2
00450 
00468 extern void gdm_draw_lines (gdm_display* dp, gdm_point* pts,
00469                             unsigned short npoints, short mode);
00470 
00471 extern void gdm_draw_rectangle (gdm_display* dp, short x, short y,
00472                                 unsigned short width, unsigned short height);
00473 
00474 
00475 extern void gdm_draw_circle (gdm_display* dp, short x0, short y0, short r);
00476 
00489 extern void gdm_fill_rectangle (gdm_display* dp, short x, short y,
00490                                 unsigned short width, unsigned short height);
00493 #ifdef __cplusplus
00494 };
00495 #endif
00496 #endif