ui/basewindow.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //
00003 // $Id: basewindow.h,v 1.3 2008-02-19 09:20:08 rafi Exp $
00004 //
00005 // YAPET -- Yet Another Password Encryption Tool
00006 // Copyright (C) 2008  Rafael Ostertag
00007 //
00008 // This program is free software: you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation, either version 3 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
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" // Leave this here. It depends on the above includes.
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

Generated on Wed Feb 27 16:15:41 2008 for YAPET by  doxygen 1.5.4