mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 12:59:39 +02:00
LCL: Reduce UTF8Length calls. Call UTF16Length instead where appropriate.
git-svn-id: trunk@56638 -
This commit is contained in:
parent
f1fb8c1d13
commit
778f207e50
@ -668,7 +668,7 @@ end;
|
|||||||
function CalcColumnFieldWidth(Canvas: TCanvas; hasTitle: boolean;
|
function CalcColumnFieldWidth(Canvas: TCanvas; hasTitle: boolean;
|
||||||
aTitle: String; aTitleFont: TFont; Field: TField): Integer;
|
aTitle: String; aTitleFont: TFont; Field: TField): Integer;
|
||||||
var
|
var
|
||||||
aCharWidth: Integer;
|
aCharWidth, aTitleWidth: Integer;
|
||||||
aFont: TFont;
|
aFont: TFont;
|
||||||
UseTitleFont: boolean;
|
UseTitleFont: boolean;
|
||||||
begin
|
begin
|
||||||
@ -680,10 +680,11 @@ begin
|
|||||||
else begin
|
else begin
|
||||||
|
|
||||||
aCharWidth := CalcCanvasCharWidth(Canvas);
|
aCharWidth := CalcCanvasCharWidth(Canvas);
|
||||||
if Field.DisplayWidth>LazUTF8.UTF8Length(aTitle) then
|
aTitleWidth := UTF8Length(aTitle);
|
||||||
|
if Field.DisplayWidth > aTitleWidth then
|
||||||
result := aCharWidth * Field.DisplayWidth
|
result := aCharWidth * Field.DisplayWidth
|
||||||
else
|
else
|
||||||
result := aCharWidth * LazUTF8.UTF8Length(aTitle);
|
result := aCharWidth * aTitleWidth;
|
||||||
|
|
||||||
if HasTitle then begin
|
if HasTitle then begin
|
||||||
UseTitleFont :=
|
UseTitleFont :=
|
||||||
|
@ -9656,7 +9656,7 @@ begin
|
|||||||
if hasSelectedText then
|
if hasSelectedText then
|
||||||
begin
|
begin
|
||||||
W := getSelectedText;
|
W := getSelectedText;
|
||||||
Result := UTF8Length(W);
|
Result := UTF16Length(W);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
if (CachedSelectionStart <> -1) and (CachedSelectionLen <> -1) then
|
if (CachedSelectionStart <> -1) and (CachedSelectionLen <> -1) then
|
||||||
@ -9756,7 +9756,7 @@ begin
|
|||||||
if (QEvent_type(Event) = QEventFocusOut) then
|
if (QEvent_type(Event) = QEventFocusOut) then
|
||||||
begin
|
begin
|
||||||
CachedSelectionStart := QLineEdit_selectionStart(QLineEditH(Widget));
|
CachedSelectionStart := QLineEdit_selectionStart(QLineEditH(Widget));
|
||||||
CachedSelectionLen := UTF8Length(getSelectedText);
|
CachedSelectionLen := UTF16Length(getSelectedText);
|
||||||
end else
|
end else
|
||||||
if (QEvent_type(Event) = QEventFocusIn) then
|
if (QEvent_type(Event) = QEventFocusIn) then
|
||||||
begin
|
begin
|
||||||
@ -11606,7 +11606,7 @@ begin
|
|||||||
if Assigned(FLineEdit) and FLineEdit.getVisible then
|
if Assigned(FLineEdit) and FLineEdit.getVisible then
|
||||||
begin
|
begin
|
||||||
FLineEdit.CachedSelectionStart := QLineEdit_selectionStart(QLineEditH(FLineEdit.Widget));
|
FLineEdit.CachedSelectionStart := QLineEdit_selectionStart(QLineEditH(FLineEdit.Widget));
|
||||||
FLineEdit.CachedSelectionLen := UTF8Length(FLineEdit.getSelectedText);
|
FLineEdit.CachedSelectionLen := UTF16Length(FLineEdit.getSelectedText);
|
||||||
end;
|
end;
|
||||||
Result := inherited EventFilter(Sender, Event);
|
Result := inherited EventFilter(Sender, Event);
|
||||||
end;
|
end;
|
||||||
@ -11882,7 +11882,7 @@ begin
|
|||||||
if (LineEdit <> nil) and QLineEdit_hasSelectedText(LineEdit) then
|
if (LineEdit <> nil) and QLineEdit_hasSelectedText(LineEdit) then
|
||||||
begin
|
begin
|
||||||
QLineEdit_selectedText(LineEdit, @W);
|
QLineEdit_selectedText(LineEdit, @W);
|
||||||
Result := UTF8Length(W);
|
Result := UTF16Length(W);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
|
@ -9553,7 +9553,7 @@ begin
|
|||||||
if hasSelectedText then
|
if hasSelectedText then
|
||||||
begin
|
begin
|
||||||
W := getSelectedText;
|
W := getSelectedText;
|
||||||
Result := UTF8Length(W);
|
Result := UTF16Length(W);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
if (CachedSelectionStart <> -1) and (CachedSelectionLen <> -1) then
|
if (CachedSelectionStart <> -1) and (CachedSelectionLen <> -1) then
|
||||||
@ -9653,7 +9653,7 @@ begin
|
|||||||
if (QEvent_type(Event) = QEventFocusOut) then
|
if (QEvent_type(Event) = QEventFocusOut) then
|
||||||
begin
|
begin
|
||||||
CachedSelectionStart := QLineEdit_selectionStart(QLineEditH(Widget));
|
CachedSelectionStart := QLineEdit_selectionStart(QLineEditH(Widget));
|
||||||
CachedSelectionLen := UTF8Length(getSelectedText);
|
CachedSelectionLen := UTF16Length(getSelectedText);
|
||||||
end else
|
end else
|
||||||
if (QEvent_type(Event) = QEventFocusIn) then
|
if (QEvent_type(Event) = QEventFocusIn) then
|
||||||
begin
|
begin
|
||||||
@ -11508,7 +11508,7 @@ begin
|
|||||||
if Assigned(FLineEdit) and FLineEdit.getVisible then
|
if Assigned(FLineEdit) and FLineEdit.getVisible then
|
||||||
begin
|
begin
|
||||||
FLineEdit.CachedSelectionStart := QLineEdit_selectionStart(QLineEditH(FLineEdit.Widget));
|
FLineEdit.CachedSelectionStart := QLineEdit_selectionStart(QLineEditH(FLineEdit.Widget));
|
||||||
FLineEdit.CachedSelectionLen := UTF8Length(FLineEdit.getSelectedText);
|
FLineEdit.CachedSelectionLen := UTF16Length(FLineEdit.getSelectedText);
|
||||||
end;
|
end;
|
||||||
Result := inherited EventFilter(Sender, Event);
|
Result := inherited EventFilter(Sender, Event);
|
||||||
end;
|
end;
|
||||||
@ -11784,7 +11784,7 @@ begin
|
|||||||
if (LineEdit <> nil) and QLineEdit_hasSelectedText(LineEdit) then
|
if (LineEdit <> nil) and QLineEdit_hasSelectedText(LineEdit) then
|
||||||
begin
|
begin
|
||||||
QLineEdit_selectedText(LineEdit, @W);
|
QLineEdit_selectedText(LineEdit, @W);
|
||||||
Result := UTF8Length(W);
|
Result := UTF16Length(W);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user