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 #ifdef HAVE_UNISTD_H
00042 # include <unistd.h>
00043 #endif
00044
00045 #ifdef HAVE_LIST
00046 # include <list>
00047 #endif
00048
00049 namespace YAPETUI {
00063 class BaseWindow {
00064 public:
00074 class AlarmFunction {
00075 public:
00076 inline virtual ~AlarmFunction() {}
00084 virtual void process(int) = 0;
00085 };
00086 private:
00087 #if defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00088 static AlarmFunction* alarm_fun;
00089 #endif // defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00090 static std::list<BaseWindow*> basewindow_list;
00091
00092 protected:
00101 static void registerBaseWindow(BaseWindow* r);
00110 static void unregisterBaseWindow(BaseWindow* r);
00111 #if defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00112
00123 static void sig_handler(int signo);
00130 static void init_signal();
00131 #endif // defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00132
00140 inline int maxX() const {
00141 int max_x, max_y;
00142 getmaxyx(stdscr, max_y, max_x);
00143 return max_x;
00144 }
00145
00153 inline int maxY() const {
00154 int max_x, max_y;
00155 getmaxyx(stdscr, max_y, max_x);
00156 return max_y;
00157 }
00158
00166 inline int minX() const {
00167 int x, y;
00168 getbegyx(stdscr, y, x);
00169 return x;
00170 }
00171
00179 inline int minY() const {
00180 int x, y;
00181 getbegyx(stdscr, y, x);
00182 return y;
00183 }
00184 public:
00191 enum MinDimension {
00192 MIN_Y = 24,
00193 MIN_X = 80
00194 };
00200 static void initCurses();
00206 static void endCurses();
00212 static void deleteAll();
00218 static void resizeAll();
00224 static void refreshAll();
00225 #if defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00226
00237 static void setTimeout(AlarmFunction* af, int sec);
00243 static void suspendTimeout();
00244 #endif // defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H)
00245 BaseWindow();
00246 virtual ~BaseWindow();
00247 virtual void resize() = 0;
00248 virtual void refresh() = 0;
00249 };
00250
00251 }
00252
00253 #endif // _BASEWINDOW_H