mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
*EditField: Password fixes (thanks Shire)
git-svn-id: svn://ultimatepp.org/upp/trunk@2767 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
f78a7a2d52
commit
edb7374cef
1 changed files with 17 additions and 10 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue