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