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

ui/intinwidget.cc

Go to the documentation of this file.
00001 // $Id: intinwidget.cc 3343 2010-09-17 18:36:31Z java $
00002 //
00003 // Copyright (C) 2009-2010  Rafael Ostertag
00004 //
00005 // This file is part of YAPET.
00006 //
00007 // YAPET is free software: you can redistribute it and/or modify it under the
00008 // terms of the GNU General Public License as published by the Free Software
00009 // Foundation, either version 3 of the License, or (at your option) any later
00010 // version.
00011 //
00012 // YAPET is distributed in the hope that it will be useful, but WITHOUT ANY
00013 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00014 // FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00015 // details.
00016 //
00017 // You should have received a copy of the GNU General Public License along with
00018 // YAPET.  If not, see <http://www.gnu.org/licenses/>.
00019 //
00020 
00021 #ifdef HAVE_CONFIG_H
00022 # include "config.h"
00023 #endif
00024 
00025 #include "../intl.h"
00026 #include "intinwidget.h"
00027 
00028 #ifdef HAVE_CTYPE_H
00029 # include <ctype.h>
00030 #endif
00031 
00032 #ifdef HAVE_STDLIB_H
00033 # include <stdlib.h>
00034 #endif
00035 
00036 using namespace YAPET::UI;
00037 
00038 IntInWidget::IntInWidget (int sx, int sy, int w, int ml, bool ro)
00039     throw (UIException) : InputWidget (sx, sy, w, ml, ro) {
00040 }
00041 
00042 IntInWidget::~IntInWidget() {
00043 }
00044 
00045 void
00046 IntInWidget::processInput (int ch) throw (UIException) {
00047     if (isdigit (ch) )
00048         InputWidget::processInput (ch);
00049 }
00050 
00051 unsigned long
00052 IntInWidget::getInt() const {
00053     if (!hasText() ) return 0;
00054 
00055     return strtol (getText().c_str(), NULL, 10);
00056 }
00057 
00058 void
00059 IntInWidget::setInt(unsigned long i) {
00060     const int size = 40;
00061     char buff[size];
00062     snprintf(buff,size,"%lu", i);
00063     setText(buff);
00064 }

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