You've already forked lazarus-ccr
ColorPalette: Fix painting of background color.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4289 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -99,6 +99,7 @@ type
|
||||
FPaletteKind: TPaletteKind;
|
||||
FGradientSteps: Byte;
|
||||
FUseSpacers: Boolean;
|
||||
FMargin: Integer;
|
||||
function GetColorCount: Integer;
|
||||
function GetColors(AIndex: Integer): TColor;
|
||||
function GetColorNames(AIndex: Integer): String;
|
||||
@ -236,9 +237,6 @@ implementation
|
||||
uses
|
||||
LCLIntf, StrUtils;
|
||||
|
||||
const
|
||||
SELMARGIN = 1; // extra margin for selection rectangle
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('Misc', [TColorPalette]);
|
||||
@ -414,8 +412,8 @@ var
|
||||
begin
|
||||
W := GetCellWidth;
|
||||
H := GetCellHeight;
|
||||
dec(X, SELMARGIN);
|
||||
dec(Y, SELMARGIN);
|
||||
dec(X, FMargin);
|
||||
dec(Y, FMargin);
|
||||
if (FButtonDistance = 0) and (FButtonBorderColor <> clNone) then
|
||||
begin
|
||||
dec(W);
|
||||
@ -701,22 +699,6 @@ procedure TCustomColorPalette.Paint;
|
||||
Canvas.FillRect(x1, y1, x2, y2) else
|
||||
Canvas.Rectangle(x1, y1, x2, y2);
|
||||
end;
|
||||
|
||||
// Paint background between the color buttons
|
||||
if ((Color <> clNone) and (FButtonDistance > 0)) then
|
||||
begin
|
||||
x1 := x1 - FButtonDistance div 2 - FButtonDistance mod 2;
|
||||
y1 := y1 - FButtonDistance div 2 - FButtonDistance mod 2;
|
||||
x2 := x1 + FButtonWidth - FButtonDistance;
|
||||
y2 := y1 + FButtonHeight - FButtonDistance;
|
||||
Canvas.Pen.Color := Color;
|
||||
Canvas.Pen.Width := FButtonDistance;
|
||||
Canvas.MoveTo(x1, y1);
|
||||
Canvas.LineTo(x2, y1);
|
||||
Canvas.LineTo(x2, y2);
|
||||
Canvas.LineTo(x1, y2);
|
||||
Canvas.LineTo(x1, y1);
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
@ -726,10 +708,17 @@ var
|
||||
begin
|
||||
Canvas.Pen.Endcap := pecSquare;
|
||||
|
||||
// Paint background color
|
||||
if Color <> clNone then begin
|
||||
Canvas.Brush.Color := Color;
|
||||
Canvas.Brush.Style := bsSolid;
|
||||
Canvas.FillRect(0, 0, Width, Height);
|
||||
end;
|
||||
|
||||
// Paint color boxes
|
||||
X := SELMARGIN;
|
||||
Y := SELMARGIN;
|
||||
xmax := Width - SELMARGIN;
|
||||
X := FMargin;
|
||||
Y := FMargin;
|
||||
xmax := Width - FMargin;
|
||||
if (FButtonDistance = 0) and (FButtonBordercolor <> clNone) then dec(xmax);
|
||||
for I := 0 to pred(FColors.Count) do
|
||||
begin
|
||||
@ -742,7 +731,7 @@ begin
|
||||
begin
|
||||
inc(Y, GetCellHeight);
|
||||
if (FButtonDistance = 0) and (FButtonBorderColor <> clNone) then dec(Y);
|
||||
X := SELMARGIN;
|
||||
X := FMargin;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -798,6 +787,9 @@ procedure TCustomColorPalette.SetButtonDistance(const AValue: Integer);
|
||||
begin
|
||||
if FButtonDistance = AValue then exit;
|
||||
FButtonDistance := AValue;
|
||||
if FButtonDistance = 0 then
|
||||
FMargin := 1 else
|
||||
FMargin := FButtonDistance div 2;
|
||||
UpdateSize;
|
||||
Invalidate;
|
||||
end;
|
||||
@ -1305,7 +1297,7 @@ begin
|
||||
dec(dy);
|
||||
d := -1;
|
||||
end;
|
||||
SetBounds(Left, Top, FCols * dx - d + 2*SELMARGIN, FRows * dy - d + 2*SELMARGIN);
|
||||
SetBounds(Left, Top, FCols * dx - d + 2*FMargin, FRows * dy - d + 2*FMargin);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -198,7 +198,7 @@ object MainForm: TMainForm
|
||||
object Label3: TLabel
|
||||
Left = 83
|
||||
Height = 15
|
||||
Top = 230
|
||||
Top = 276
|
||||
Width = 65
|
||||
Caption = 'Btn distance'
|
||||
ParentColor = False
|
||||
@ -206,7 +206,7 @@ object MainForm: TMainForm
|
||||
object EdButtonDistance: TSpinEdit
|
||||
Left = 83
|
||||
Height = 23
|
||||
Top = 250
|
||||
Top = 296
|
||||
Width = 58
|
||||
Alignment = taRightJustify
|
||||
MaxValue = 16
|
||||
@ -217,7 +217,7 @@ object MainForm: TMainForm
|
||||
object Label4: TLabel
|
||||
Left = 10
|
||||
Height = 15
|
||||
Top = 230
|
||||
Top = 276
|
||||
Width = 40
|
||||
Caption = 'Btn size'
|
||||
ParentColor = False
|
||||
@ -225,7 +225,7 @@ object MainForm: TMainForm
|
||||
object EdBoxSize: TSpinEdit
|
||||
Left = 10
|
||||
Height = 23
|
||||
Top = 250
|
||||
Top = 296
|
||||
Width = 59
|
||||
Alignment = taRightJustify
|
||||
MinValue = 1
|
||||
@ -302,7 +302,7 @@ object MainForm: TMainForm
|
||||
object EdColCount: TSpinEdit
|
||||
Left = 10
|
||||
Height = 23
|
||||
Top = 306
|
||||
Top = 352
|
||||
Width = 59
|
||||
Alignment = taRightJustify
|
||||
MinValue = 1
|
||||
@ -313,7 +313,7 @@ object MainForm: TMainForm
|
||||
object Label2: TLabel
|
||||
Left = 10
|
||||
Height = 15
|
||||
Top = 286
|
||||
Top = 332
|
||||
Width = 48
|
||||
Caption = 'Columns'
|
||||
ParentColor = False
|
||||
@ -338,6 +338,26 @@ object MainForm: TMainForm
|
||||
State = cbChecked
|
||||
TabOrder = 8
|
||||
end
|
||||
object LblButtonBorderColor1: TLabel
|
||||
Left = 10
|
||||
Height = 15
|
||||
Top = 224
|
||||
Width = 94
|
||||
Caption = 'Background color'
|
||||
FocusControl = CbColor
|
||||
ParentColor = False
|
||||
end
|
||||
object CbColor: TColorBox
|
||||
Left = 10
|
||||
Height = 22
|
||||
Top = 244
|
||||
Width = 138
|
||||
NoneColorColor = clWindow
|
||||
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone]
|
||||
ItemHeight = 16
|
||||
OnSelect = CbColorSelect
|
||||
TabOrder = 9
|
||||
end
|
||||
end
|
||||
object Bevel2: TBevel
|
||||
Left = 462
|
||||
@ -354,12 +374,12 @@ object MainForm: TMainForm
|
||||
Height = 535
|
||||
Top = 8
|
||||
Width = 287
|
||||
HorzScrollBar.Increment = 16
|
||||
HorzScrollBar.Page = 160
|
||||
HorzScrollBar.Increment = 15
|
||||
HorzScrollBar.Page = 155
|
||||
HorzScrollBar.Smooth = True
|
||||
HorzScrollBar.Tracking = True
|
||||
VertScrollBar.Increment = 4
|
||||
VertScrollBar.Page = 41
|
||||
VertScrollBar.Page = 42
|
||||
VertScrollBar.Smooth = True
|
||||
VertScrollBar.Tracking = True
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
@ -369,10 +389,10 @@ object MainForm: TMainForm
|
||||
TabOrder = 2
|
||||
object ColorPalette: TColorPalette
|
||||
Left = 0
|
||||
Height = 40
|
||||
Height = 41
|
||||
Hint = 'Click to select a color'
|
||||
Top = 1
|
||||
Width = 160
|
||||
Width = 155
|
||||
ButtonHeight = 20
|
||||
ButtonWidth = 20
|
||||
ColumnCount = 8
|
||||
|
@ -23,6 +23,7 @@ type
|
||||
BtnLoadDefaultPal: TButton;
|
||||
BtnEditColor: TButton;
|
||||
CbBuiltinPalettes: TComboBox;
|
||||
CbColor: TColorBox;
|
||||
CbShowSelection: TCheckBox;
|
||||
CbShowColorHints: TCheckBox;
|
||||
CbButtonBorderColor: TColorBox;
|
||||
@ -31,6 +32,7 @@ type
|
||||
ColorDialog: TColorDialog;
|
||||
ColorPalette: TColorPalette;
|
||||
CbPickMode: TComboBox;
|
||||
LblButtonBorderColor1: TLabel;
|
||||
MouseColorSample: TShape;
|
||||
EdButtonDistance: TSpinEdit;
|
||||
EdBoxSize: TSpinEdit;
|
||||
@ -61,6 +63,7 @@ type
|
||||
procedure BtnLoadDefaultPalClick(Sender: TObject);
|
||||
procedure BtnLoadRndPaletteClick(Sender: TObject);
|
||||
procedure CbBuiltinPalettesSelect(Sender: TObject);
|
||||
procedure CbColorSelect(Sender: TObject);
|
||||
procedure CbCustomHintTextChange(Sender: TObject);
|
||||
procedure CbPickModeSelect(Sender: TObject);
|
||||
procedure CbShowColorHintsChange(Sender: TObject);
|
||||
@ -198,6 +201,11 @@ begin
|
||||
LblGradientSteps.Enabled := EdGradientSteps.Enabled;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CbColorSelect(Sender: TObject);
|
||||
begin
|
||||
ColorPalette.Color := CbColor.Selected;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CbCustomHintTextChange(Sender: TObject);
|
||||
begin
|
||||
if CbCustomHintText.Checked then
|
||||
@ -334,7 +342,8 @@ begin
|
||||
CbPickMode.ItemIndex := ord(ColorPalette.PickMode);
|
||||
CbShowSelection.Checked := ColorPalette.ShowSelection;
|
||||
CbShowColorHints.Checked := ColorPalette.ShowColorHint;
|
||||
CbButtonBorderColor.Selected := ColorPalette.SelectedColor;
|
||||
CbButtonBorderColor.Selected := ColorPalette.ButtonBorderColor;
|
||||
CbColor.Selected := ColorPalette.Color;
|
||||
EdButtonDistance.Value := ColorPalette.ButtonDistance;
|
||||
EdBoxSize.Value := ColorPalette.ButtonWidth;
|
||||
|
||||
|
Reference in New Issue
Block a user