Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _BASEWINDOW_H
00024 #define _BASEWINDOW_H
00025
00026 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029
00030 #ifdef HAVE_NCURSES_H
00031 # include <ncurses.h>
00032 #else // HAVE_NCURSES_H
00033 # ifdef HAVE_CURSES_H
00034 # include <curses.h>
00035 # else
00036 # error "Neither curses.h nor ncurses.h available"
00037 # endif // HAVE_CURSES_H
00038 #endif // HAVE_NCURSES_H
00039 #include "curswa.h"
00040
00041 #include "uiexception.h"
00042
00043 #ifdef HAVE_UNISTD_H
00044 # include <unistd.h>
00045 #endif
00046
00047 #ifdef HAVE_LIST
00048 # include <list>
00049 #endif
00050
00051 namespace YAPET {
00052 namespace UI {
00066 class BaseWindow {
00067 public:
00077 class AlarmFunction {
00078 public:
00079 inline virtual ~AlarmFunction() {}
00087 virtual void process (int) = 0;
00088 };
00089 private:
00090 #if defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00091 static AlarmFunction* alarm_fun;
00092 #endif // defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00093 static std::list<BaseWindow*> basewindow_list;
00094
00095 protected:
00104 static void registerBaseWindow (BaseWindow* r);
00113 static void unregisterBaseWindow (BaseWindow* r);
00114 #if defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00115
00126 static void sig_handler (int signo);
00133 static void init_signal();
00134 #endif // defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00135
00143 inline int maxX() const {
00144 int max_x, max_y;
00145 getmaxyx (stdscr, max_y, max_x);
00146 return max_x;
00147 }
00148
00156 inline int maxY() const {
00157 int max_x, max_y;
00158 getmaxyx (stdscr, max_y, max_x);
00159 return max_y;
00160 }
00161
00169 inline int minX() const {
00170 int x, y;
00171 getbegyx (stdscr, y, x);
00172 return x;
00173 }
00174
00182 inline int minY() const {
00183 int x, y;
00184 getbegyx (stdscr, y, x);
00185 return y;
00186 }
00187 public:
00194 enum MinDimension {
00195 MIN_Y = 24,
00196 MIN_X = 80
00197 };
00203 static void initCurses() throw(UIException);
00209 static void endCurses();
00215 static void deleteAll();
00221 static void resizeAll();
00227 static void refreshAll();
00228 #if defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00229
00240 static void setTimeout (AlarmFunction* af, int sec);
00246 static void suspendTimeout();
00247 #endif // defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00248 BaseWindow();
00249 virtual ~BaseWindow();
00250 virtual void resize() = 0;
00251 virtual void refresh() = 0;
00252 };
00253
00254 }
00255 }
00256 #endif // _BASEWINDOW_H