ui/passwordwidget.cc

Go to the documentation of this file.
00001 // $Id: passwordwidget.cc,v 1.4 2008-02-13 20:47:48 rafi Exp $
00002 //
00003 // YAPET -- Yet Another Password Encryption Tool
00004 // Copyright (C) 2008  Rafael Ostertag
00005 //
00006 // This program is free software: you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation, either version 3 of the License, or
00009 // (at your option) any later version.
00010 //
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 //
00019 
00020 #include "passwordwidget.h"
00021 
00022 using namespace YAPETUI;
00023 
00024 PasswordWidget::PasswordWidget(int sx, int sy, int w, int ml)
00025     throw(UIException) : InputWidget(sx, sy, w, ml) {}
00026 
00027 PasswordWidget::~PasswordWidget() {
00028 
00029 }
00030 
00031 void
00032 PasswordWidget::refresh() throw(UIException) {
00033     int retval = wclear(getWindow());
00034     if (retval == ERR)
00035     throw UIException("Error clearing input widget");
00036 
00037     if (getPos() > 0) {
00038     char* tmp = (char*)malloc(getPos()+1);
00039     memset(tmp, '*', getPos());
00040     tmp[getPos()] = '\0';
00041     retval = mymvwaddnstr(getWindow(),
00042                   0,
00043                   0,
00044                   tmp,
00045                   getWidth()-1);
00046     free(tmp);
00047     if (retval == ERR)
00048         throw UIException("Error adding text to window");
00049 
00050     if (getPos() >= getWidth() - 1)
00051         retval = wmove(getWindow(), 0, getWidth()-1);
00052     else
00053         retval = wmove(getWindow(), 0, getPos());
00054 
00055     if (retval == ERR)
00056         throw UIException("Error moving cursor");
00057     }
00058 
00059     retval = wrefresh(getWindow());
00060     if (retval == ERR)
00061     throw UIException("Error refreshing input widget");
00062 }

Generated on Wed Feb 27 16:15:41 2008 for YAPET by  doxygen 1.5.4