00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "../intl.h"
00021 #include "passwordwidget.h"
00022
00023 #ifdef HAVE_STDLIB_H
00024 # include <stdlib.h>
00025 #endif
00026
00027 using namespace YAPETUI;
00028
00029 PasswordWidget::PasswordWidget(int sx, int sy, int w, int ml)
00030 throw(UIException) : InputWidget(sx, sy, w, ml) {}
00031
00032 PasswordWidget::~PasswordWidget() {
00033
00034 }
00035
00036 void
00037 PasswordWidget::refresh() throw(UIException) {
00038 int retval = wclear(getWindow());
00039 if (retval == ERR)
00040 throw UIException(_("Error clearing input widget"));
00041
00042 if (getPos() > 0) {
00043 char* tmp = (char*)malloc(getPos()+1);
00044 memset(tmp, '*', getPos());
00045 tmp[getPos()] = '\0';
00046 retval = mymvwaddnstr(getWindow(),
00047 0,
00048 0,
00049 tmp,
00050 getWidth()-1);
00051 free(tmp);
00052 if (retval == ERR)
00053 throw UIException(_("Error adding text to window"));
00054
00055 if (getPos() >= getWidth() - 1)
00056 retval = wmove(getWindow(), 0, getWidth()-1);
00057 else
00058 retval = wmove(getWindow(), 0, getPos());
00059
00060 if (retval == ERR)
00061 throw UIException(_("Error moving cursor"));
00062 }
00063
00064 retval = wrefresh(getWindow());
00065 if (retval == ERR)
00066 throw UIException(_("Error refreshing input widget"));
00067 }