*EditField: Password fixes (thanks Shire)

git-svn-id: svn://ultimatepp.org/upp/trunk@2767 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2010-10-11 08:14:50 +00:00
parent f78a7a2d52
commit edb7374cef

View file

@ -224,20 +224,25 @@ Size EditField::GetMinSize() const
int EditField::GetCursor(int posx)
{
FontInfo fi = font.Info();
const wchar *s = text;
posx -= 2;
if(posx <= 0) return 0;
FontInfo fi = font.Info();
int count = text.GetLength();
if(password)
return min((posx + fi['*'] / 2) / fi['*'], count);
int x = 0;
int x0 = 0;
const wchar *s = text;
int i = 0;
for(i = 0; i < text.GetLength(); i++) {
x0 = x;
x += fi[*s];
if(posx < (x + x0) / 2)
return i;
s++;
while(i < count) {
int witdh = fi[*s];
if(posx < x + witdh / 2)
break;
x += witdh;
s++; i++;
}
return posx > (x + x0) / 2 ? i : max(i - 1, 0);
return i;
}
Image EditField::CursorImage(Point, dword)
@ -688,6 +693,8 @@ void EditField::DragLeave()
void EditField::LeftDrag(Point p, dword flags)
{
if(password)
return;
int c = GetCursor(p.x + sc);
Size ssz = StdSampleSize();
int sell, selh;