LCL: Reduce UTF8Length calls. Call UTF16Length instead where appropriate.

git-svn-id: trunk@56638 -
This commit is contained in:
juha 2017-12-05 21:30:47 +00:00
parent f1fb8c1d13
commit 778f207e50
3 changed files with 12 additions and 11 deletions

View File

@ -668,7 +668,7 @@ end;
function CalcColumnFieldWidth(Canvas: TCanvas; hasTitle: boolean;
aTitle: String; aTitleFont: TFont; Field: TField): Integer;
var
aCharWidth: Integer;
aCharWidth, aTitleWidth: Integer;
aFont: TFont;
UseTitleFont: boolean;
begin
@ -680,10 +680,11 @@ begin
else begin
aCharWidth := CalcCanvasCharWidth(Canvas);
if Field.DisplayWidth>LazUTF8.UTF8Length(aTitle) then
aTitleWidth := UTF8Length(aTitle);
if Field.DisplayWidth > aTitleWidth then
result := aCharWidth * Field.DisplayWidth
else
result := aCharWidth * LazUTF8.UTF8Length(aTitle);
result := aCharWidth * aTitleWidth;
if HasTitle then begin
UseTitleFont :=

View File

@ -9656,7 +9656,7 @@ begin
if hasSelectedText then
begin
W := getSelectedText;
Result := UTF8Length(W);
Result := UTF16Length(W);
end else
begin
if (CachedSelectionStart <> -1) and (CachedSelectionLen <> -1) then
@ -9756,7 +9756,7 @@ begin
if (QEvent_type(Event) = QEventFocusOut) then
begin
CachedSelectionStart := QLineEdit_selectionStart(QLineEditH(Widget));
CachedSelectionLen := UTF8Length(getSelectedText);
CachedSelectionLen := UTF16Length(getSelectedText);
end else
if (QEvent_type(Event) = QEventFocusIn) then
begin
@ -11606,7 +11606,7 @@ begin
if Assigned(FLineEdit) and FLineEdit.getVisible then
begin
FLineEdit.CachedSelectionStart := QLineEdit_selectionStart(QLineEditH(FLineEdit.Widget));
FLineEdit.CachedSelectionLen := UTF8Length(FLineEdit.getSelectedText);
FLineEdit.CachedSelectionLen := UTF16Length(FLineEdit.getSelectedText);
end;
Result := inherited EventFilter(Sender, Event);
end;
@ -11882,7 +11882,7 @@ begin
if (LineEdit <> nil) and QLineEdit_hasSelectedText(LineEdit) then
begin
QLineEdit_selectedText(LineEdit, @W);
Result := UTF8Length(W);
Result := UTF16Length(W);
end
else
Result := 0;

View File

@ -9553,7 +9553,7 @@ begin
if hasSelectedText then
begin
W := getSelectedText;
Result := UTF8Length(W);
Result := UTF16Length(W);
end else
begin
if (CachedSelectionStart <> -1) and (CachedSelectionLen <> -1) then
@ -9653,7 +9653,7 @@ begin
if (QEvent_type(Event) = QEventFocusOut) then
begin
CachedSelectionStart := QLineEdit_selectionStart(QLineEditH(Widget));
CachedSelectionLen := UTF8Length(getSelectedText);
CachedSelectionLen := UTF16Length(getSelectedText);
end else
if (QEvent_type(Event) = QEventFocusIn) then
begin
@ -11508,7 +11508,7 @@ begin
if Assigned(FLineEdit) and FLineEdit.getVisible then
begin
FLineEdit.CachedSelectionStart := QLineEdit_selectionStart(QLineEditH(FLineEdit.Widget));
FLineEdit.CachedSelectionLen := UTF8Length(FLineEdit.getSelectedText);
FLineEdit.CachedSelectionLen := UTF16Length(FLineEdit.getSelectedText);
end;
Result := inherited EventFilter(Sender, Event);
end;
@ -11784,7 +11784,7 @@ begin
if (LineEdit <> nil) and QLineEdit_hasSelectedText(LineEdit) then
begin
QLineEdit_selectedText(LineEdit, @W);
Result := UTF8Length(W);
Result := UTF16Length(W);
end
else
Result := 0;