From 41d9e5262eb7af0466417b63855c61ed17a5af8c Mon Sep 17 00:00:00 2001 From: juha Date: Fri, 15 Mar 2013 13:09:47 +0000 Subject: [PATCH] LCL: Add ColorRectWidth property to TColorListBox. Issue #24041, patch from Michael Fuchs git-svn-id: trunk@40554 - --- lcl/colorbox.pas | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lcl/colorbox.pas b/lcl/colorbox.pas index 1c4946bd01..19ce3d89a2 100644 --- a/lcl/colorbox.pas +++ b/lcl/colorbox.pas @@ -152,6 +152,7 @@ type TCustomColorListBox = class(TCustomListBox) private + FColorRectWidth: Integer; FDefaultColorColor: TColor; FNoneColorColor: TColor; FOnGetColors: TLBGetColorsEvent; @@ -160,6 +161,7 @@ type function GetColor(Index : Integer): TColor; function GetColorName(Index: Integer): string; function GetSelected: TColor; + procedure SetColorRectWidth(AValue: Integer); procedure SetDefaultColorColor(const AValue: TColor); procedure SetNoneColorColor(const AValue: TColor); procedure SetSelected(Value: TColor); @@ -175,7 +177,7 @@ type function PickCustomColor: Boolean; virtual; public constructor Create(AOwner: TComponent); override; - + property ColorRectWidth: Integer read FColorRectWidth write SetColorRectWidth default 14; property Style: TColorBoxStyle read FStyle write SetStyle default [cbStandardColors, cbExtendedColors, cbSystemColors]; property Colors[Index: Integer]: TColor read GetColor; @@ -190,6 +192,7 @@ type TColorListBox = class(TCustomColorListBox) published + property ColorRectWidth; property DefaultColorColor; property NoneColorColor; property Selected; @@ -666,7 +669,7 @@ constructor TCustomColorListBox.Create(AOwner: TComponent); begin inherited Create(AOwner); inherited Style := lbOwnerDrawFixed; - + FColorRectWidth := 14; FStyle := [cbStandardColors, cbExtendedColors, cbSystemColors]; FNoneColorColor := clBlack; FDefaultColorColor := clBlack; @@ -695,6 +698,13 @@ begin Result := FSelected; end; +procedure TCustomColorListBox.SetColorRectWidth(AValue: Integer); +begin + if FColorRectWidth = AValue then Exit; + FColorRectWidth := AValue; + Invalidate; +end; + procedure TCustomColorListBox.SetDefaultColorColor(const AValue: TColor); begin if FDefaultColorColor <> AValue then @@ -835,7 +845,7 @@ begin r.top := Rect.top + 3; r.bottom := Rect.bottom - 3; r.left := Rect.left + 3; - r.right := r.left + 14; + r.right := r.left + FColorRectWidth; Exclude(State,odPainted); with Canvas do begin @@ -861,7 +871,7 @@ begin Pen.Color := PenColor; end; r := Rect; - r.left := r.left + 20; + r.left := r.left + FColorRectWidth + 4; inherited DrawItem(Index, BidiFlipRect(r, Rect, UseRightToLeftAlignment), State); end;