00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 }