• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ui/basewindow.h

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

Generated on Sun Sep 19 2010 15:37:13 for YAPET by  doxygen 1.7.1