00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _BASEWINDOW_H
00023 #define _BASEWINDOW_H
00024
00025 #ifdef HAVE_CONFIG_H
00026 # include <config.h>
00027 #endif
00028
00029 #ifdef HAVE_NCURSES_H
00030 # include <ncurses.h>
00031 #else // HAVE_NCURSES_H
00032 # ifdef HAVE_CURSES_H
00033 # include <curses.h>
00034 # else
00035 # error "Neither curses.h nor ncurses.h available"
00036 # endif // HAVE_CURSES_H
00037 #endif // HAVE_NCURSES_H
00038 #include "curswa.h"
00039
00040 #ifdef HAVE_UNISTD_H
00041 # include <unistd.h>
00042 #endif
00043
00044 #ifdef HAVE_LIST
00045 # include <list>
00046 #endif
00047
00048 namespace YAPETUI {
00062 class BaseWindow {
00063 public:
00073 class AlarmFunction {
00074 public:
00075 inline virtual ~AlarmFunction() {}
00083 virtual void process(int) = 0;
00084 };
00085 private:
00086 #if defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00087 static AlarmFunction* alarm_fun;
00088 #endif // defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00089 static std::list<BaseWindow*> basewindow_list;
00090
00091 protected:
00100 static void registerBaseWindow(BaseWindow* r);
00109 static void unregisterBaseWindow(BaseWindow* r);
00110 #if defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00111
00122 static void sig_handler(int signo);
00129 static void init_signal();
00130 #endif // defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00131
00139 inline int maxX() const {
00140 int max_x, max_y;
00141 getmaxyx(stdscr, max_y, max_x);
00142 return max_x;
00143 }
00144
00152 inline int maxY() const {
00153 int max_x, max_y;
00154 getmaxyx(stdscr, max_y, max_x);
00155 return max_y;
00156 }
00157
00165 inline int minX() const {
00166 int x, y;
00167 getbegyx(stdscr, y, x);
00168 return x;
00169 }
00170
00178 inline int minY() const {
00179 int x, y;
00180 getbegyx(stdscr, y, x);
00181 return y;
00182 }
00183 public:
00189 static void initCurses();
00195 static void endCurses();
00201 static void deleteAll();
00207 static void resizeAll();
00213 static void refreshAll();
00214 #if defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00215
00226 static void setTimeout(AlarmFunction* af, int sec);
00232 static void suspendTimeout();
00233 #endif // defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00234 BaseWindow();
00235 virtual ~BaseWindow();
00236 virtual void resize() = 0;
00237 virtual void refresh() = 0;
00238 };
00239
00240 }
00241
00242 #endif // _BASEWINDOW_H