mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 22:58:50 +02:00
LCL: Improve property ColorBox.ColorRectOffset. Issue #28135, patch from Alexey Torgashin.
git-svn-id: trunk@49135 -
This commit is contained in:
parent
8b2acf39c1
commit
89b1411c3f
@ -23,6 +23,10 @@ uses
|
||||
LResources, SysUtils, LCLProc, LCLType, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, StdCtrls, LCLStrConsts;
|
||||
|
||||
const
|
||||
cDefaultColorRectWidth = 14;
|
||||
cDefaultColorRectOffset = 3;
|
||||
|
||||
type
|
||||
{ TCustomColorBox }
|
||||
|
||||
@ -68,8 +72,8 @@ type
|
||||
function PickCustomColor: Boolean; virtual;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
property ColorRectWidth: Integer read FColorRectWidth write SetColorRectWidth default 14;
|
||||
property ColorRectOffset: Integer read FColorRectOffset write SetColorRectOffset default 3;
|
||||
property ColorRectWidth: Integer read FColorRectWidth write SetColorRectWidth default cDefaultColorRectWidth;
|
||||
property ColorRectOffset: Integer read FColorRectOffset write SetColorRectOffset default cDefaultColorRectOffset;
|
||||
property Style: TColorBoxStyle read FStyle write SetStyle
|
||||
default [cbStandardColors, cbExtendedColors, cbSystemColors];
|
||||
property Colors[Index: Integer]: TColor read GetColor;
|
||||
@ -157,6 +161,7 @@ type
|
||||
TCustomColorListBox = class(TCustomListBox)
|
||||
private
|
||||
FColorRectWidth: Integer;
|
||||
FColorRectOffset: Integer;
|
||||
FDefaultColorColor: TColor;
|
||||
FNoneColorColor: TColor;
|
||||
FOnGetColors: TLBGetColorsEvent;
|
||||
@ -165,6 +170,7 @@ type
|
||||
function GetColors(Index : Integer): TColor;
|
||||
function GetColorName(Index: Integer): string;
|
||||
function GetSelected: TColor;
|
||||
procedure SetColorRectOffset(AValue: Integer);
|
||||
procedure SetColorRectWidth(AValue: Integer);
|
||||
procedure SetColors(Index: Integer; AValue: TColor);
|
||||
procedure SetDefaultColorColor(const AValue: TColor);
|
||||
@ -182,7 +188,8 @@ type
|
||||
function PickCustomColor: Boolean; virtual;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
property ColorRectWidth: Integer read FColorRectWidth write SetColorRectWidth default 14;
|
||||
property ColorRectWidth: Integer read FColorRectWidth write SetColorRectWidth default cDefaultColorRectWidth;
|
||||
property ColorRectOffset: Integer read FColorRectOffset write SetColorRectOffset default cDefaultColorRectOffset;
|
||||
property Style: TColorBoxStyle read FStyle write SetStyle
|
||||
default [cbStandardColors, cbExtendedColors, cbSystemColors];
|
||||
property Colors[Index: Integer]: TColor read GetColors write SetColors;
|
||||
@ -198,6 +205,7 @@ type
|
||||
TColorListBox = class(TCustomColorListBox)
|
||||
published
|
||||
property ColorRectWidth;
|
||||
property ColorRectOffset;
|
||||
property DefaultColorColor;
|
||||
property NoneColorColor;
|
||||
property Selected;
|
||||
@ -364,8 +372,8 @@ begin
|
||||
inherited Style := csOwnerDrawFixed;
|
||||
inherited ReadOnly := True;
|
||||
|
||||
FColorRectWidth := 14;
|
||||
FColorRectOffset := 3;
|
||||
FColorRectWidth := cDefaultColorRectWidth;
|
||||
FColorRectOffset := cDefaultColorRectOffset;
|
||||
FStyle := [cbStandardColors, cbExtendedColors, cbSystemColors];
|
||||
FNoneColorColor := clBlack;
|
||||
FDefaultColorColor := clBlack;
|
||||
@ -703,7 +711,8 @@ constructor TCustomColorListBox.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
inherited Style := lbOwnerDrawFixed;
|
||||
FColorRectWidth := 14;
|
||||
FColorRectWidth := cDefaultColorRectWidth;
|
||||
FColorRectOffset := cDefaultColorRectOffset;
|
||||
FStyle := [cbStandardColors, cbExtendedColors, cbSystemColors];
|
||||
FNoneColorColor := clBlack;
|
||||
FDefaultColorColor := clBlack;
|
||||
@ -732,6 +741,13 @@ begin
|
||||
Result := FSelected;
|
||||
end;
|
||||
|
||||
procedure TCustomColorListBox.SetColorRectOffset(AValue: Integer);
|
||||
begin
|
||||
if FColorRectOffset = AValue then Exit;
|
||||
FColorRectOffset := AValue;
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TCustomColorListBox.SetColorRectWidth(AValue: Integer);
|
||||
begin
|
||||
if FColorRectWidth = AValue then Exit;
|
||||
@ -885,9 +901,9 @@ begin
|
||||
if Index < 0 then
|
||||
Exit;
|
||||
|
||||
r.top := Rect.top + 3;
|
||||
r.bottom := Rect.bottom - 3;
|
||||
r.left := Rect.left + 3;
|
||||
r.top := Rect.top + FColorRectOffset;
|
||||
r.bottom := Rect.bottom - FColorRectOffset;
|
||||
r.left := Rect.left + FColorRectOffset;
|
||||
r.right := r.left + FColorRectWidth;
|
||||
Exclude(State,odPainted);
|
||||
with Canvas do
|
||||
@ -914,7 +930,7 @@ begin
|
||||
Pen.Color := PenColor;
|
||||
end;
|
||||
r := Rect;
|
||||
r.left := r.left + FColorRectWidth + 4;
|
||||
r.left := r.left + FColorRectWidth + FColorRectOffset + 1;
|
||||
|
||||
inherited DrawItem(Index, BidiFlipRect(r, Rect, UseRightToLeftAlignment), State);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user