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