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

ui/checkboxgroup.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //
00003 // $Id: checkboxgroup.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 _CHECKBOXGROUP_H
00024 #define _CHECKBOXGROUP_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 #ifdef HAVE_INTTYPES_H
00042 # include <inttypes.h>
00043 #endif
00044 
00045 #ifdef HAVE_STRING
00046 # include <string>
00047 #endif
00048 
00049 #ifdef HAVE_VECTOR
00050 # include <vector>
00051 #endif
00052 
00053 
00054 #include "uiexception.h"
00055 
00056 namespace YAPET {
00057     namespace UI {
00058 
00074         class CheckBoxGroup {
00075             private:
00076                 enum {
00077                     BASE_HEIGHT = 2,
00078                     BASE_WIDTH = 8,
00079                     // ZERO BASED!
00080                     MAX_ITEMS = 15
00081                 };
00082 
00083                 WINDOW* window;
00084 
00090                 std::string title;
00091 
00098                 std::vector<std::string> items;
00099                 // This holds the options (checked and unchecked items)
00100                 uint16_t options;
00101 
00102                 int start_x;
00103                 int start_y;
00104                 int width;
00105                 int height;
00106 
00107                 inline CheckBoxGroup (const CheckBoxGroup&) {}
00108                 inline const CheckBoxGroup& operator= (const CheckBoxGroup&) {
00109                     return *this;
00110                 }
00111 
00112                 int ItemsUsableWidth() const ;
00113                 int ItemsUsableHeight() const;
00119                 int lastItemPos() const;
00120                 void addCheckBox (int pos) throw (UIException);
00121 
00131                 void setCheckMark (int pos, bool mark) throw (UIException);
00132 
00141                 void setCheckMark (int pos) throw (UIException);
00142 
00143                 void setCursor (int pos) throw (UIException);
00144                 void displayItems() throw (UIException);
00145 
00146             protected:
00147                 void createWindow() throw (UIException);
00148 
00149             public:
00169                 CheckBoxGroup (std::string t,
00170                                const std::vector<std::string>& it,
00171                                uint16_t o,
00172                                int x,
00173                                int y,
00174                                int w,
00175                                int h)  throw (UIException);
00176                 virtual ~CheckBoxGroup();
00177 
00178                 void refresh() throw (UIException);
00179 
00181                 int focus() throw (UIException);
00182 
00183                 void resize (int sx, int sy, int w, int h) throw (UIException);
00184 
00185                 inline int getHeight() const {
00186                     return BASE_HEIGHT + items.size();
00187                 }
00188 
00189                 inline uint16_t getOptions() const {
00190                     return options;
00191                 }
00192         };
00193     }
00194 }
00195 #endif // _CHECKBOXGROUP_H

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