View Issue Details

IDProjectCategoryView StatusLast Update
0038308PatchesLCLpublic2021-02-21 17:50
ReporterCudaText man Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionno change required 
Product Version2.1 (SVN) 
Summary0038308: add method TCustomLabel.UpdateDrawFlags to unify code in 3 places
DescriptionThis methods makes no difference in 1st place (from total 3 places);
makes small difference in 2nd place (where it was missed setting DT_LEFT/DT_RIGHT Alignment flags);
makes small difference in 3rd place (where it was missed settings n DT_ flags).
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetGTK 2
Attached Files

Activities

CudaText man

2021-01-05 10:02

reporter  

labl.diff (3,594 bytes)   
Index: lcl/include/customlabel.inc
===================================================================
--- lcl/include/customlabel.inc	(revision 64335)
+++ lcl/include/customlabel.inc	(working copy)
@@ -38,6 +38,23 @@
   CalculateSize(AWidth,PreferredWidth,PreferredHeight);
 end;
 
+procedure TCustomLabel.UpdateDrawFlags(var Flags: Cardinal);
+const
+  cAlignment: array[TAlignment] of Longint = (DT_LEFT, DT_RIGHT, DT_CENTER);
+begin
+  Flags := Flags or DT_EXPANDTABS;
+  if WordWrap then
+    Flags := Flags or DT_WORDBREAK
+  else
+  if not HasMultiLine then
+    Flags := Flags or DT_SINGLELINE;
+  if not ShowAccelChar then
+    Flags := Flags or DT_NOPREFIX;
+  if UseRightToLeftReading then
+    Flags := Flags or DT_RTLREADING;
+  Flags := Flags or cAlignment[BidiFlipAlignment(Self.Alignment, UseRightToLeftAlignment)];
+end;
+
 procedure TCustomLabel.CalculateSize(MaxWidth: integer; var NeededWidth,
   NeededHeight: integer);
 var
@@ -44,7 +61,7 @@
   DC, OldHandle: HDC;
   R: TRect;
   OldFont: HGDIOBJ;
-  Flags: cardinal;
+  Flags: Cardinal;
   LabelText: String;
 begin
   LabelText := GetLabelText;
@@ -60,16 +77,8 @@
     Canvas.Handle := DC;
     R := Rect(0, 0, MaxWidth, cMaxLabelSize);
     OldFont := SelectObject(DC, HGDIOBJ(Font.Reference.Handle));
-    Flags := DT_CALCRECT or DT_EXPANDTABS;
-    if WordWrap then
-      Flags := Flags or DT_WORDBREAK
-    else
-    if not HasMultiLine then
-      Flags := Flags or DT_SINGLELINE;
-    if not ShowAccelChar then
-      Flags := Flags or DT_NOPREFIX;
-    if UseRightToLeftReading then
-      Flags := Flags or DT_RTLREADING;
+    Flags := DT_CALCRECT;
+    UpdateDrawFlags(Flags);
 
     DoDrawText(R, Flags);
     SelectObject(DC, OldFont);
@@ -328,7 +337,7 @@
 var
   R: TRect;
   DC: HDC;
-  DrawFlags: UINT;
+  DrawFlags: Cardinal;
   OldFont: HGDIOBJ;
   MinFontHeight: Integer;
   MaxFontHeight: Integer;
@@ -345,9 +354,8 @@
     MinFontHeight := 4;
     MaxFontHeight := MaxHeight * 2;
     CurFontHeight := (MinFontHeight + MaxFontHeight) div 2;
-    DrawFlags := DT_CALCRECT or DT_NOPREFIX or DT_EXPANDTABS;
-    if WordWrap then
-      DrawFlags := DrawFlags or DT_WORDBREAK;
+    DrawFlags := DT_CALCRECT;
+    UpdateDrawFlags(DrawFlags);
     R.Left := 0;
     R.Top := 0;
     DC := GetDC(Parent.Handle);
@@ -426,9 +434,7 @@
 var
   R, CalcRect: TRect;
   TextLeft, TextTop: integer;
-  Flags: Longint;
-const
-  cAlignment: array[TAlignment] of Longint = (DT_LEFT, DT_RIGHT, DT_CENTER);
+  Flags: Cardinal;
 begin
   R := Rect(0,0,Width,Height);
   Canvas.Brush.Color := Color;
@@ -440,17 +446,8 @@
   Canvas.Brush.Style:=bsClear;
   Canvas.Font := Font;
 
-  Flags := DT_EXPANDTABS;
-  if WordWrap then
-    Flags := Flags or DT_WORDBREAK
-  else
-  if not HasMultiLine then
-    Flags := Flags or DT_SINGLELINE;
-  if not ShowAccelChar then
-    Flags := Flags or DT_NOPREFIX;
-  Flags := Flags or cAlignment[BidiFlipAlignment(Self.Alignment, UseRightToLeftAlignment)];
-  if UseRightToLeftReading then
-    Flags := Flags or DT_RTLREADING;
+  Flags := 0;
+  UpdateDrawFlags(Flags);
 
   if FLayout<>tlTop then
   begin
Index: lcl/stdctrls.pp
===================================================================
--- lcl/stdctrls.pp	(revision 64335)
+++ lcl/stdctrls.pp	(working copy)
@@ -1552,6 +1552,7 @@
     FInternalSetBounds: Boolean;
     procedure SetAlignment(Value: TAlignment);
     procedure SetOptimalFill(const AValue: Boolean);
+    procedure UpdateDrawFlags(var Flags: Cardinal);
   protected
     class procedure WSRegisterClass; override;
     function  CanTab: boolean; override;
labl.diff (3,594 bytes)   

Juha Manninen

2021-02-21 09:55

developer   ~0129051

Rejected.

Issue History

Date Modified Username Field Change
2021-01-05 10:02 CudaText man New Issue
2021-01-05 10:02 CudaText man File Added: labl.diff
2021-02-21 09:55 Juha Manninen Assigned To => Juha Manninen
2021-02-21 09:55 Juha Manninen Status new => resolved
2021-02-21 09:55 Juha Manninen Resolution open => no change required
2021-02-21 09:55 Juha Manninen LazTarget => -
2021-02-21 09:55 Juha Manninen Widgetset GTK 2 => GTK 2
2021-02-21 09:55 Juha Manninen Note Added: 0129051
2021-02-21 17:50 CudaText man Status resolved => closed