LCL: Add ColorRectWidth property to TColorListBox. Issue #24041, patch from Michael Fuchs

git-svn-id: trunk@40554 -
This commit is contained in:
juha 2013-03-15 13:09:47 +00:00
parent 1984461ac1
commit 41d9e5262e

View File

@ -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;