panel.h

00001 /* panel.h -- Panel display and management interface
00002    Copyright 2001, 2002 Free Software Foundation, Inc.
00003    Written by Stephane Carrez (stcarrez@worldnet.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_PANEL_H
00023 #define _GEL_PANEL_H
00024 
00025 #include <sys/param.h>
00026 #include <lcd.h>
00027 #include <gel/event.h>
00028 #include <gel/timer.h>
00029 #include <gel/buttons.h>
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 
00048 
00049 struct panel_line
00050 {
00051   lcd_col_t     col_start;
00052   lcd_col_t     col_end;
00053   unsigned char content[LCD_MAX_COLS];
00054 };
00055 
00056 typedef unsigned short key_t;
00057 
00058 struct panel;
00059 
00068 typedef void (* panel_enter_t) (struct panel *p);
00069 
00079 typedef void (* panel_exit_t) (struct panel *p);
00080 
00092 typedef unsigned long (* panel_refresh_t) (struct panel *p);
00093 
00103 typedef void (* panel_input_t) (struct panel *p, enum key_mode mode,
00104                                 button_t button);
00105 
00106 struct panel
00107 {
00108   panel_enter_t     to_enter;
00109   panel_exit_t      to_exit;
00110   panel_refresh_t   to_refresh;
00111   panel_input_t     to_input;
00112   unsigned long     refresh_delay;
00113   unsigned long     inactivity_delay;
00114   unsigned char     visible;
00115   unsigned char     cursor_visible;
00116   lcd_col_t         cursor_col;
00117   lcd_line_t        cursor_line;
00118 
00119   struct panel *next;
00120   struct panel_line lines[LCD_MAX_LINES];
00121 };
00122 
00126 enum panel_justify
00127 {
00128   JUSTIFY_LEFT,
00129   JUSTIFY_RIGHT,
00130   JUSTIFY_CENTER
00131 };
00132 
00133 
00146 extern void panel_putchar (struct panel *p, lcd_line_t line,
00147                            lcd_col_t col, unsigned char ch);
00148 
00161 extern void panel_putstring (struct panel *p, lcd_line_t line,
00162                              lcd_col_t col, const char *str);
00163 
00177 extern void panel_putitem (struct panel *p, lcd_line_t line, lcd_col_t col,
00178                            enum panel_justify mode, int field_len,
00179                            const char *item);
00180 
00190 extern void panel_clear_line (struct panel *p, lcd_line_t line, lcd_col_t col);
00191 
00199 extern unsigned char panel_getchar_at (struct panel *p,
00200                                        lcd_line_t line, lcd_col_t col);
00201 
00209 extern void panel_refresh (void);
00210 
00216 extern void panel_touch (void);
00217 
00225 extern int panel_need_refresh (void);
00226 
00234 extern int panel_is_visible (struct panel *p);
00235 
00243 extern void panel_push (struct panel *p);
00244 
00253 extern void panel_pop (void);
00254 
00258 extern void panel_create (struct panel *p);
00259 
00263 extern void panel_initialize (void);
00264 
00265 extern void panel_setcursor (struct panel *p, lcd_line_t line, lcd_col_t col);
00266 
00267 extern void panel_show_cursor (struct panel *p, int mode);
00268 
00269 extern void panel_loop (void) __attribute__ ((noreturn));
00270 
00273 #ifdef __cplusplus
00274 };
00275 #endif
00276 #endif