Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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"
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
00080 MAX_ITEMS = 15
00081 };
00082
00083 WINDOW* window;
00084
00090 std::string title;
00091
00098 std::vector<std::string> items;
00099
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