00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _BUTTON_H
00023 #define _BUTTON_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"
00039
00040 #ifdef HAVE_STRING
00041 # include <string>
00042 #endif
00043
00044 #include "uiexception.h"
00045 #include "listwidget.h"
00046
00053 namespace YAPETUI {
00061 class Button {
00062 private:
00063 enum {
00069 BASE_SIZE = 4
00070 };
00071
00072 WINDOW* window;
00073
00074 inline Button(const Button&) {}
00075 inline const Button& operator=(const Button&) { return *this; }
00076
00077 std::string label;
00078
00079 int start_x;
00080 int start_y;
00081
00082 protected:
00083 inline virtual void onClick() {};
00084 void createWindow() throw(UIException);
00085
00086 public:
00087 Button(std::string l, int x, int y);
00088 virtual ~Button();
00089
00090 void setLabel(std::string l) throw(UIException);
00091 std::string getLabel() { return label; }
00092
00093 void refresh() throw(UIException);
00094
00103 int focus() throw(UIException);
00112 inline int getLength() const {
00113 return BASE_SIZE + label.length();
00114 }
00115 };
00116 }
00117
00118 #endif // _BUTTON_H