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