lcl: more utf8 fixes

git-svn-id: trunk@16479 -
This commit is contained in:
paul 2008-09-08 07:34:25 +00:00
parent 8ae1d62bbe
commit 0e46060ced
2 changed files with 39 additions and 33 deletions

View File

@ -279,7 +279,7 @@ function TCustomComboBox.GetSelText: string;
begin
//debugln('TCustomComboBox.GetSelText ');
if FStyle in [csDropDown, csSimple] then
Result:= Copy(Text, SelStart + 1, SelLength)
Result:= UTF8Copy(Text, SelStart + 1, SelLength)
else
Result:= '';
end;
@ -297,14 +297,16 @@ var
OldSelStart: integer;
begin
//debugln('TCustomComboBox.SetSelText ',Val);
if FStyle in [csDropDown, csSimple] then begin
if FStyle in [csDropDown, csSimple] then
begin
OldText := Text;
OldSelStart := SelStart;
NewText:=LeftStr(OldText,OldSelStart)+Val
+RightStr(OldText,length(OldText)-SelStart-SelLength);
NewText := UTF8Copy(OldText, 1, OldSelStart) +
Val +
UTF8Copy(OldText, UTF8Length(OldText) - SelStart - SelLength, MaxInt);
Text := NewText;
SelStart := OldSelStart;
SelLength:=length(Val);
SelLength := UTF8Length(Val);
end;
end;
@ -318,8 +320,8 @@ end;
function TCustomComboBox.GetSelStart : integer;
begin
if HandleAllocated then
fSelStart:=TWSCustomComboBoxClass(WidgetSetClass).GetSelStart(Self);
Result:=fSelStart;
FSelStart := TWSCustomComboBoxClass(WidgetSetClass).GetSelStart(Self);
Result := FSelStart;
end;
{------------------------------------------------------------------------------
@ -331,7 +333,7 @@ end;
------------------------------------------------------------------------------}
procedure TCustomComboBox.SetSelStart(Val : integer);
begin
fSelStart:=Val;
FSelStart := Val;
if HandleAllocated then
TWSCustomComboBoxClass(WidgetSetClass).SetSelStart(Self, Val);
end;
@ -346,8 +348,8 @@ end;
function TCustomComboBox.GetSelLength : integer;
begin
if HandleAllocated then
fSelLength := TWSCustomComboBoxClass(WidgetSetClass).GetSelLength(Self);
Result:=fSelLength;
FSelLength := TWSCustomComboBoxClass(WidgetSetClass).GetSelLength(Self);
Result := FSelLength;
end;
{------------------------------------------------------------------------------
@ -359,7 +361,7 @@ end;
------------------------------------------------------------------------------}
procedure TCustomComboBox.SetSelLength(Val : integer);
begin
fSelLength:=Val;
FSelLength := Val;
if HandleAllocated then
TWSCustomComboBoxClass(WidgetSetClass).SetSelLength(Self, Val);
end;
@ -376,11 +378,13 @@ var
CurText: String;
begin
//debugln('TCustomComboBox.SelectAll ');
if (FStyle in [csDropDown, csSimple]) then begin
if (FStyle in [csDropDown, csSimple]) then
begin
CurText := Text;
if (CurText <> '') then begin
if (CurText <> '') then
begin
SetSelStart(0);
SetSelLength(Length(CurText));
SetSelLength(UTF8Length(CurText));
end;
end;
end;
@ -539,8 +543,8 @@ procedure TCustomComboBox.KeyPress(var Key: char);
begin
//Convert character cases if FCharCase is not ecNormalCase
case FCharCase of
ecLowerCase: Key := lowerCase(Key);
ecUpperCase: Key := upCase(Key);
ecLowerCase: Key := LowerCase(Key);
ecUpperCase: Key := UpCase(Key);
end;
inherited KeyPress(Key);
end;

View File

@ -81,7 +81,7 @@ end;
------------------------------------------------------------------------------}
function TCustomEdit.GetSelText : string;
begin
Result := Copy(Text, SelStart + 1, SelLength)
Result := UTF8Copy(Text, SelStart + 1, SelLength)
end;
{------------------------------------------------------------------------------
@ -113,10 +113,11 @@ var
begin
OldPos := SelStart;
OldText := Text;
NewText:=LeftStr(OldText,SelStart)+Val
+RightStr(OldText,length(OldText)-SelStart-SelLength);
NewText := UTF8Copy(OldText, 1, SelStart) +
Val +
UTF8Copy(OldText, UTF8Length(OldText) - SelStart - SelLength, MaxInt);
Text := NewText;
SelStart := OldPos + Length(Val);
SelStart := OldPos + UTF8Length(Val);
end;
{------------------------------------------------------------------------------
@ -185,9 +186,10 @@ end;
------------------------------------------------------------------------------}
procedure TCustomEdit.SelectAll;
begin
if Text <> '' then begin
if Text <> '' then
begin
SetSelStart(0);
SetSelLength(Length(Text));
SetSelLength(UTF8Length(Text));
end;
end;
@ -368,7 +370,7 @@ end;
procedure TCustomEdit.RealSetText(const Value: TCaption);
begin
if (MaxLength > 0) and (Length(Value) > MaxLength) then
inherited RealSetText(Copy(Value, 1, MaxLength))
inherited RealSetText(UTF8Copy(Value, 1, MaxLength))
else
inherited RealSetText(Value);
end;