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

ui/button.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //
00003 // $Id: button.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 _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" // Leave this here. It depends on the above includes.
00040 
00041 #ifdef HAVE_STRING
00042 # include <string>
00043 #endif
00044 
00045 #include "uiexception.h"
00046 
00053 namespace YAPET {
00054     namespace UI {
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&) {
00077                     return *this;
00078                 }
00079 
00080                 std::string label;
00081 
00082                 int start_x;
00083                 int start_y;
00084         bool readonly;
00085 
00086             protected:
00087                 inline virtual void onClick() {};
00088                 void createWindow() throw (UIException);
00089 
00090             public:
00091                 Button (std::string l, int x, int y, bool ro = false);
00092                 virtual ~Button();
00093 
00094                 void setLabel (std::string l) throw (UIException);
00095                 std::string getLabel() {
00096                     return label;
00097                 }
00098 
00099                 void refresh() throw (UIException);
00100 
00109                 int focus() throw (UIException);
00118                 inline int getLength() const {
00119                     return BASE_SIZE + label.length();
00120                 }
00121 
00122         inline void setReadonly(bool ro) { readonly = ro; }
00123         inline bool getReadonly() const { return readonly; }
00124         };
00125     }
00126 }
00127 #endif // _BUTTON_H

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