You've already forked lazarus-ccr
ColorPalette: Remove properties related to "Selected" color, replace by "Picked" color etc. Reason: Color selection event handler must pass Shift state to calling routine for further evaluation --> Reactivate old OnColorPick (instead of OnSelectColor). Remove property PickShift.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4296 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -58,9 +58,6 @@ type
|
|||||||
pmContinuous // Select color at mouse-down and mouse-move, ColorPick event at mouse-up
|
pmContinuous // Select color at mouse-down and mouse-move, ColorPick event at mouse-up
|
||||||
);
|
);
|
||||||
|
|
||||||
TPickShiftEnum = (ssLeft, ssRight, ssMiddle);
|
|
||||||
TPickShift = set of TPickShiftEnum;
|
|
||||||
|
|
||||||
TPaletteKind = (pkStandardPalette, pkExtendedPalette, pkSystemPalette,
|
TPaletteKind = (pkStandardPalette, pkExtendedPalette, pkSystemPalette,
|
||||||
pkStandardAndSystemPalette, pkExtendedAndSystemPalette,
|
pkStandardAndSystemPalette, pkExtendedAndSystemPalette,
|
||||||
pkGradientPalette, pkHTMLPalette, pkWebSafePalette);
|
pkGradientPalette, pkHTMLPalette, pkWebSafePalette);
|
||||||
@ -83,14 +80,11 @@ type
|
|||||||
FCols: Integer;
|
FCols: Integer;
|
||||||
FOnColorMouseMove: TColorMouseEvent;
|
FOnColorMouseMove: TColorMouseEvent;
|
||||||
FOnColorPick: TColorMouseEvent;
|
FOnColorPick: TColorMouseEvent;
|
||||||
FOnSelectColor: TColorPaletteEvent;
|
|
||||||
FOnGetHintText: TColorPaletteHintEvent;
|
FOnGetHintText: TColorPaletteHintEvent;
|
||||||
FRows: Integer;
|
FRows: Integer;
|
||||||
FColors: TStringList;
|
FColors: TStringList;
|
||||||
FSelectedColor: TColor;
|
FPickedIndex: Integer;
|
||||||
FSelectedIndex: Integer;
|
|
||||||
FPickMode: TPickMode;
|
FPickMode: TPickMode;
|
||||||
FPickShift: TPickShift;
|
|
||||||
FMousePt: TPoint;
|
FMousePt: TPoint;
|
||||||
FMouseIndex: Integer;
|
FMouseIndex: Integer;
|
||||||
FPrevMouseIndex: Integer;
|
FPrevMouseIndex: Integer;
|
||||||
@ -118,7 +112,7 @@ type
|
|||||||
procedure SetCols(AValue: Integer);
|
procedure SetCols(AValue: Integer);
|
||||||
procedure SetGradientSteps(AValue: Byte);
|
procedure SetGradientSteps(AValue: Byte);
|
||||||
procedure SetPaletteKind(AValue: TPaletteKind);
|
procedure SetPaletteKind(AValue: TPaletteKind);
|
||||||
procedure SetSelectedIndex(AValue: Integer);
|
procedure SetPickedIndex(AValue: Integer);
|
||||||
procedure SetSelectionColor(AValue: TColor);
|
procedure SetSelectionColor(AValue: TColor);
|
||||||
procedure SetSelectionKind(AValue: TPaletteSelectionKind);
|
procedure SetSelectionKind(AValue: TPaletteSelectionKind);
|
||||||
procedure SetUseSpacers(AValue: Boolean);
|
procedure SetUseSpacers(AValue: Boolean);
|
||||||
@ -132,12 +126,10 @@ type
|
|||||||
procedure DoColorPick(AColor: TColor; AShift: TShiftState); virtual;
|
procedure DoColorPick(AColor: TColor; AShift: TShiftState); virtual;
|
||||||
procedure DoDeleteColor(AIndex: Integer); virtual;
|
procedure DoDeleteColor(AIndex: Integer); virtual;
|
||||||
procedure DoInsertColor(AIndex: Integer; AColor: TColor; AColorName: String = ''); virtual;
|
procedure DoInsertColor(AIndex: Integer; AColor: TColor; AColorName: String = ''); virtual;
|
||||||
procedure DoSelectColor(AColor: TColor); virtual;
|
|
||||||
function GetCellHeight: Integer; inline;
|
function GetCellHeight: Integer; inline;
|
||||||
function GetCellWidth: Integer; inline;
|
function GetCellWidth: Integer; inline;
|
||||||
function GetColorIndex(X,Y: Integer): Integer;
|
function GetColorIndex(X,Y: Integer): Integer;
|
||||||
function GetHintText(AIndex: Integer): String; virtual;
|
function GetHintText(AIndex: Integer): String; virtual;
|
||||||
function IsCorrectShift(Shift: TShiftState): Boolean;
|
|
||||||
procedure MouseDown(Button: TMouseButton; Shift:TShiftState; X, Y:Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift:TShiftState; X, Y:Integer); override;
|
||||||
procedure MouseEnter; override;
|
procedure MouseEnter; override;
|
||||||
procedure MouseLeave; override;
|
procedure MouseLeave; override;
|
||||||
@ -153,13 +145,15 @@ type
|
|||||||
property Flipped: Boolean read FFlipped write SetFlipped default false;
|
property Flipped: Boolean read FFlipped write SetFlipped default false;
|
||||||
property GradientSteps: Byte read FGradientSteps write SetGradientSteps default 3;
|
property GradientSteps: Byte read FGradientSteps write SetGradientSteps default 3;
|
||||||
property PaletteKind: TPaletteKind read FPaletteKind write SetPaletteKind default pkStandardPalette;
|
property PaletteKind: TPaletteKind read FPaletteKind write SetPaletteKind default pkStandardPalette;
|
||||||
|
property PickedIndex: Integer read FPickedIndex write SetPickedIndex default -1;
|
||||||
property PickMode: TPickMode read FPickMode write FPickMode default pmImmediate;
|
property PickMode: TPickMode read FPickMode write FPickMode default pmImmediate;
|
||||||
property PickShift: TPickShift read FPickShift write FPickShift default [ssLeft];
|
|
||||||
property SelectedIndex: Integer read FSelectedIndex write SetSelectedIndex default 0;
|
|
||||||
property SelectionColor: TColor read FSelectionColor write SetSelectionColor default clBlack;
|
property SelectionColor: TColor read FSelectionColor write SetSelectionColor default clBlack;
|
||||||
property SelectionKind: TPaletteSelectionKind read FSelectionKind write SetSelectionKind default pskNone;
|
property SelectionKind: TPaletteSelectionKind read FSelectionKind write SetSelectionKind default pskNone;
|
||||||
property ShowColorHint: Boolean read FShowColorHint write FShowColorHint default true;
|
property ShowColorHint: Boolean read FShowColorHint write FShowColorHint default true;
|
||||||
property UseSpacers: Boolean read FUseSpacers write SetUseSpacers default true;
|
property UseSpacers: Boolean read FUseSpacers write SetUseSpacers default true;
|
||||||
|
|
||||||
|
property OnColorPick: TColorMouseEvent read FOnColorPick write FOnColorPick;
|
||||||
|
property OnColorMouseMove: TColorMouseEvent read FOnColorMouseMove write FOnColorMouseMove;
|
||||||
property OnGetHintText: TColorPaletteHintEvent read FOnGetHintText write FOnGetHintText;
|
property OnGetHintText: TColorPaletteHintEvent read FOnGetHintText write FOnGetHintText;
|
||||||
|
|
||||||
public
|
public
|
||||||
@ -179,13 +173,8 @@ type
|
|||||||
property ColorCount: Integer read GetColorCount;
|
property ColorCount: Integer read GetColorCount;
|
||||||
property MouseIndex: Integer read FMouseIndex;
|
property MouseIndex: Integer read FMouseIndex;
|
||||||
property MouseColor: TColor read GetMouseColor;
|
property MouseColor: TColor read GetMouseColor;
|
||||||
property PickedColor: TColor read GetPickedColor; deprecated 'Use SelectedColor';
|
property PickedColor: TColor read GetPickedColor;
|
||||||
property SelectedColor: TColor read FSelectedColor;
|
|
||||||
|
|
||||||
property OnSelectColor: TColorPaletteEvent read FOnSelectColor write FOnSelectColor;
|
|
||||||
property OnColorPick: TColorMouseEvent read FOnColorPick write FOnColorPick;
|
|
||||||
property OnColorMouseMove: TColorMouseEvent read FOnColorMouseMove write FOnColorMouseMove;
|
|
||||||
|
|
||||||
property Height stored False;
|
property Height stored False;
|
||||||
property Width stored False;
|
property Width stored False;
|
||||||
end;
|
end;
|
||||||
@ -201,9 +190,8 @@ type
|
|||||||
property Flipped;
|
property Flipped;
|
||||||
property GradientSteps;
|
property GradientSteps;
|
||||||
property PaletteKind;
|
property PaletteKind;
|
||||||
|
property PickedIndex;
|
||||||
property PickMode;
|
property PickMode;
|
||||||
property PickShift;
|
|
||||||
property SelectedIndex;
|
|
||||||
property SelectionColor;
|
property SelectionColor;
|
||||||
property SelectionKind;
|
property SelectionKind;
|
||||||
property ShowColorHint;
|
property ShowColorHint;
|
||||||
@ -212,7 +200,6 @@ type
|
|||||||
property OnColorMouseMove;
|
property OnColorMouseMove;
|
||||||
property OnColorPick;
|
property OnColorPick;
|
||||||
property OnGetHintText;
|
property OnGetHintText;
|
||||||
property OnSelectColor;
|
|
||||||
|
|
||||||
// inherited from TCustomColorPalette's ancestors
|
// inherited from TCustomColorPalette's ancestors
|
||||||
property Align;
|
property Align;
|
||||||
@ -272,7 +259,6 @@ begin
|
|||||||
FButtonWidth := 12;
|
FButtonWidth := 12;
|
||||||
FPrevMouseIndex := -1;
|
FPrevMouseIndex := -1;
|
||||||
FPickMode := pmImmediate;
|
FPickMode := pmImmediate;
|
||||||
FPickShift := [ssLeft];
|
|
||||||
FShowColorHint := true;
|
FShowColorHint := true;
|
||||||
FGradientSteps := 3;
|
FGradientSteps := 3;
|
||||||
FUseSpacers := true;
|
FUseSpacers := true;
|
||||||
@ -330,10 +316,10 @@ procedure TCustomColorPalette.ColorPick(AIndex: Integer; Shift: TShiftState);
|
|||||||
var
|
var
|
||||||
c: TColor;
|
c: TColor;
|
||||||
begin
|
begin
|
||||||
|
FPickedIndex := AIndex;
|
||||||
c := GetColors(AIndex);
|
c := GetColors(AIndex);
|
||||||
DoColorPick(c, Shift);
|
DoColorPick(c, Shift);
|
||||||
if IsCorrectShift(Shift) then
|
Invalidate;
|
||||||
SelectedIndex := AIndex;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.ColorMouseMove(AColor: TColor; Shift: TShiftState);
|
procedure TCustomColorPalette.ColorMouseMove(AColor: TColor; Shift: TShiftState);
|
||||||
@ -373,13 +359,6 @@ begin
|
|||||||
FColors.InsertObject(AIndex, AColorName, TObject(PtrInt(AColor)));
|
FColors.InsertObject(AIndex, AColorName, TObject(PtrInt(AColor)));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.DoSelectColor(AColor: TColor);
|
|
||||||
begin
|
|
||||||
FSelectedColor := AColor;
|
|
||||||
Invalidate;
|
|
||||||
if Assigned(FOnSelectColor) then FOnSelectColor(self, AColor);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TCustomColorPalette.GetColorCount: Integer;
|
function TCustomColorPalette.GetColorCount: Integer;
|
||||||
begin
|
begin
|
||||||
Result := FColors.Count;
|
Result := FColors.Count;
|
||||||
@ -488,7 +467,7 @@ end;
|
|||||||
|
|
||||||
function TCustomColorPalette.GetPickedColor: TColor;
|
function TCustomColorPalette.GetPickedColor: TColor;
|
||||||
begin
|
begin
|
||||||
Result := GetColors(FMouseIndex);
|
Result := GetColors(FPickedIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.InsertColor(AIndex: Integer; AColor: TColor;
|
procedure TCustomColorPalette.InsertColor(AIndex: Integer; AColor: TColor;
|
||||||
@ -497,15 +476,6 @@ begin
|
|||||||
DoInsertColor(AIndex, AColor, AColorName);
|
DoInsertColor(AIndex, AColor, AColorName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomColorPalette.IsCorrectShift(Shift: TShiftState): Boolean;
|
|
||||||
begin
|
|
||||||
Result := True;
|
|
||||||
if (ssLeft in FPickShift) and (Classes.ssLeft in Shift) then exit;
|
|
||||||
if (ssRight in FPickShift) and (Classes.ssRight in Shift) then exit;
|
|
||||||
if (ssMiddle in FPickShift) and (Classes.ssMiddle in Shift) then exit;
|
|
||||||
Result := false;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCustomColorPalette.LoadPalette(const FileName: String);
|
procedure TCustomColorPalette.LoadPalette(const FileName: String);
|
||||||
var
|
var
|
||||||
F: TextFile;
|
F: TextFile;
|
||||||
@ -620,7 +590,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
UpdateSize;
|
UpdateSize;
|
||||||
SelectedIndex := 0;
|
PickedIndex := -1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.MouseDown(Button: TMouseButton;
|
procedure TCustomColorPalette.MouseDown(Button: TMouseButton;
|
||||||
@ -665,7 +635,8 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
|
|
||||||
FMouseIndex := GetColorIndex(X, Y);
|
FMouseIndex := GetColorIndex(X, Y);
|
||||||
if (FMouseIndex >= 0) and (FMouseIndex < FColors.Count) then
|
if (FMouseIndex >= 0) and (FMouseIndex < FColors.Count) and
|
||||||
|
([ssLeft, ssRight, ssMiddle] * Shift <> []) then
|
||||||
begin
|
begin
|
||||||
C := GetColors(FMouseIndex);
|
C := GetColors(FMouseIndex);
|
||||||
if ShowHint and FShowColorHint then
|
if ShowHint and FShowColorHint then
|
||||||
@ -761,7 +732,7 @@ begin
|
|||||||
|
|
||||||
for I := 0 to pred(FColors.Count) do
|
for I := 0 to pred(FColors.Count) do
|
||||||
begin
|
begin
|
||||||
if I = FSelectedIndex then // Selected rect of box with selected color
|
if I = FPickedIndex then // Selected rect of box with selected color
|
||||||
Rsel := Bounds(X, Y, FButtonWidth, FButtonHeight);
|
Rsel := Bounds(X, Y, FButtonWidth, FButtonHeight);
|
||||||
PaintBox(X, Y, X + FButtonWidth, Y + FButtonHeight, GetColors(I));
|
PaintBox(X, Y, X + FButtonWidth, Y + FButtonHeight, GetColors(I));
|
||||||
if FFlipped then
|
if FFlipped then
|
||||||
@ -808,7 +779,7 @@ begin
|
|||||||
Canvas.Pen.Color := FSelectionColor;
|
Canvas.Pen.Color := FSelectionColor;
|
||||||
pskThinInverted, pskThickInverted:
|
pskThinInverted, pskThickInverted:
|
||||||
begin
|
begin
|
||||||
Canvas.Pen.Color := InvertColor(GetColors(FSelectedIndex));
|
Canvas.Pen.Color := InvertColor(GetPickedColor);
|
||||||
if (FSelectionKind = pskThinInverted) and (Canvas.Pen.Color = FButtonBorderColor) then
|
if (FSelectionKind = pskThinInverted) and (Canvas.Pen.Color = FButtonBorderColor) then
|
||||||
Canvas.Pen.Color := FSelectionColor;
|
Canvas.Pen.Color := FSelectionColor;
|
||||||
end;
|
end;
|
||||||
@ -890,6 +861,9 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ Setter for the property ColumnCount.
|
||||||
|
WARNING: If Flipped is true then this property is reinterpreted as the number
|
||||||
|
of ROWS! }
|
||||||
procedure TCustomColorPalette.SetCols(AValue: Integer);
|
procedure TCustomColorPalette.SetCols(AValue: Integer);
|
||||||
begin
|
begin
|
||||||
if AValue = FCols then
|
if AValue = FCols then
|
||||||
@ -899,6 +873,9 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ Setter for the property Flipped.
|
||||||
|
WARNING: If Flipped is true then the property ColumnCount is reinterpreted
|
||||||
|
as the number of ROWS! }
|
||||||
procedure TCustomColorPalette.SetFlipped(AValue: Boolean);
|
procedure TCustomColorPalette.SetFlipped(AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
if FFlipped = AValue then exit;
|
if FFlipped = AValue then exit;
|
||||||
@ -1171,152 +1148,6 @@ begin
|
|||||||
DoAddColor(RGBToColor( 0, 0, 0), 'Black');
|
DoAddColor(RGBToColor( 0, 0, 0), 'Black');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
|
||||||
if FPaletteKind = pkHTMLPalette then
|
|
||||||
begin
|
|
||||||
DoAddColor(RGBToColor(255,255,255), 'white');
|
|
||||||
DoAddColor(RGBToColor(255,255,240), 'ivory');
|
|
||||||
DoAddColor(RGBToColor(255,255,224), 'lightyellow');
|
|
||||||
DoAddColor(RGBToColor(255,255, 0), 'yellow');
|
|
||||||
DoAddColor(RGBToColor(255,250,250), 'snow');
|
|
||||||
DoAddColor(RGBToColor(255,250,240), 'floralwhite');
|
|
||||||
DoAddColor(RGBToColor(255,250,205), 'lemonchiffon');
|
|
||||||
DoAddColor(RGBToColor(255,248,220), 'cornsilk');
|
|
||||||
DoAddColor(RGBToColor(255,245,238), 'seashell');
|
|
||||||
DoAddColor(RGBToColor(255,240,245), 'lavenderblush');
|
|
||||||
DoAddColor(RGBToColor(255,239,213), 'papayawhip');
|
|
||||||
DoAddColor(RGBToColor(255,235,205), 'blanchedalmond');
|
|
||||||
DoAddColor(RGBToColor(255,228,225), 'mistyrose');
|
|
||||||
DoAddColor(RGBToColor(255,228,196), 'bisque');
|
|
||||||
DoAddColor(RGBToColor(255,228,181), 'moccasin');
|
|
||||||
DoAddColor(RGBToColor(255,222,173), 'navajowhite');
|
|
||||||
DoAddColor(RGBToColor(255,218,185), 'peachpuff');
|
|
||||||
DoAddColor(RGBToColor(255,215, 0), 'gold');
|
|
||||||
DoAddColor(RGBToColor(255,192,203), 'pink');
|
|
||||||
DoAddColor(RGBToColor(255,182,193), 'lightpink');
|
|
||||||
DoAddColor(RGBToColor(255,165, 0), 'orange');
|
|
||||||
DoAddColor(RGBToColor(255,160,122), 'lightsalmon');
|
|
||||||
DoAddColor(RGBToColor(255,140, 0), 'darkorange');
|
|
||||||
DoAddColor(RGBToColor(255,127, 80), 'coral');
|
|
||||||
DoAddColor(RGBToColor(255,105,180), 'hotpink');
|
|
||||||
DoAddColor(RGBToColor(255, 99, 71), 'tomato');
|
|
||||||
DoAddColor(RGBToColor(255, 69, 0), 'orangered');
|
|
||||||
DoAddColor(RGBToColor(255, 20,147), 'deeppink');
|
|
||||||
DoAddColor(RGBToColor(255, 0,255), 'fuchsia');
|
|
||||||
DoAddColor(RGBToColor(255, 0,255), 'fuchsia');
|
|
||||||
DoAddColor(RGBToColor(255, 0, 0), 'red');
|
|
||||||
DoAddColor(RGBToColor(253,245,230), 'oldlace');
|
|
||||||
DoAddColor(RGBToColor(250,250,210), 'lightgoldenrodyellow');
|
|
||||||
DoAddColor(RGBToColor(250,240,230), 'linen');
|
|
||||||
DoAddColor(RGBToColor(250,235,215), 'antiquewhite');
|
|
||||||
DoAddColor(RGBToColor(250,128,114), 'salmon');
|
|
||||||
DoAddColor(RGBToColor(248,248,255), 'ghostwhite');
|
|
||||||
DoAddColor(RGBToColor(245,255,250), 'mintcream');
|
|
||||||
DoAddColor(RGBToColor(245,245,245), 'whitesmoke');
|
|
||||||
DoAddColor(RGBToColor(245,245,220), 'beige');
|
|
||||||
DoAddColor(RGBToColor(245,222,179), 'wheat');
|
|
||||||
DoAddColor(RGBToColor(244,164, 96), 'sandybrown');
|
|
||||||
DoAddColor(RGBToColor(240,255,255), 'azure');
|
|
||||||
DoAddColor(RGBToColor(240,255,240), 'honeydew');
|
|
||||||
DoAddColor(RGBToColor(240,248,255), 'aliceblue');
|
|
||||||
DoAddColor(RGBToColor(240,230,140), 'khaki');
|
|
||||||
DoAddColor(RGBToColor(240,128,128), 'lightcoral');
|
|
||||||
DoAddColor(RGBToColor(238,232,170), 'palegoldenrod');
|
|
||||||
DoAddColor(RGBToColor(238,130,238), 'violet');
|
|
||||||
DoAddColor(RGBToColor(233,150,122), 'darksalmon');
|
|
||||||
DoAddColor(RGBToColor(230,230,250), 'lavender');
|
|
||||||
DoAddColor(RGBToColor(224,255,255), 'lightcyan');
|
|
||||||
DoAddColor(RGBToColor(222,184,135), 'burlywood');
|
|
||||||
DoAddColor(RGBToColor(221,160,221), 'plum');
|
|
||||||
DoAddColor(RGBToColor(220,220,220), 'gainsboro');
|
|
||||||
DoAddColor(RGBToColor(220, 20, 60), 'crimson');
|
|
||||||
DoAddColor(RGBToColor(219,112,147), 'palevioletred');
|
|
||||||
DoAddColor(RGBToColor(218,165, 32), 'goldenrod');
|
|
||||||
DoAddColor(RGBToColor(218,112,214), 'orchid');
|
|
||||||
DoAddColor(RGBToColor(216,191,216), 'thistle');
|
|
||||||
DoAddColor(RGBToColor(211,211,211), 'lightgrey');
|
|
||||||
DoAddColor(RGBToColor(210,180,140), 'tan');
|
|
||||||
DoAddColor(RGBToColor(210,105, 30), 'chocolate');
|
|
||||||
DoAddColor(RGBToColor(205,133, 63), 'peru');
|
|
||||||
DoAddColor(RGBToColor(205, 92, 92), 'indianred');
|
|
||||||
DoAddColor(RGBToColor(199, 21,133), 'mediumvioletred');
|
|
||||||
DoAddColor(RGBToColor(192,192,192), 'silver');
|
|
||||||
DoAddColor(RGBToColor(189,183,107), 'darkkhaki');
|
|
||||||
DoAddColor(RGBToColor(188,143,143), 'rosybrown');
|
|
||||||
DoAddColor(RGBToColor(186, 85,211), 'mediumorchid');
|
|
||||||
DoAddColor(RGBToColor(184,134, 11), 'darkgoldenrod');
|
|
||||||
DoAddColor(RGBToColor(178, 34, 34), 'firebrick');
|
|
||||||
DoAddColor(RGBToColor(176,224,230), 'powderblue');
|
|
||||||
DoAddColor(RGBToColor(176,196,222), 'lightsteelblue');
|
|
||||||
DoAddColor(RGBToColor(175,238,238), 'paleturquoise');
|
|
||||||
DoAddColor(RGBToColor(173,255, 47), 'greenyellow');
|
|
||||||
DoAddColor(RGBToColor(173,216,230), 'lightblue');
|
|
||||||
DoAddColor(RGBToColor(169,169,169), 'darkgray');
|
|
||||||
DoAddColor(RGBToColor(165, 42, 42), 'brown');
|
|
||||||
DoAddColor(RGBToColor(160, 82, 45), 'sienna');
|
|
||||||
DoAddColor(RGBToColor(154,205, 50), 'yellowgreen');
|
|
||||||
DoAddColor(RGBToColor(153, 50,204), 'darkorchid');
|
|
||||||
DoAddColor(RGBToColor(152,251,152), 'palegreen');
|
|
||||||
DoAddColor(RGBToColor(148, 0,211), 'darkviolet');
|
|
||||||
DoAddColor(RGBToColor(147,112,219), 'mediumpurple');
|
|
||||||
DoAddColor(RGBToColor(144,238,144), 'lightgreen');
|
|
||||||
DoAddColor(RGBToColor(143,188,143), 'darkseagreen');
|
|
||||||
DoAddColor(RGBToColor(139, 69, 19), 'saddlebrown');
|
|
||||||
DoAddColor(RGBToColor(139, 0,139), 'darkmagenta');
|
|
||||||
DoAddColor(RGBToColor(139, 0, 0), 'darkred');
|
|
||||||
DoAddColor(RGBToColor(138, 43,226), 'blueviolet');
|
|
||||||
DoAddColor(RGBToColor(135,206,250), 'lightskyblue');
|
|
||||||
DoAddColor(RGBToColor(135,206,235), 'skyblue');
|
|
||||||
DoAddColor(RGBToColor(128,128,128), 'gray');
|
|
||||||
DoAddColor(RGBToColor(128,128, 0), 'olive');
|
|
||||||
DoAddColor(RGBToColor(128, 0,128), 'purple');
|
|
||||||
DoAddColor(RGBToColor(128, 0, 0), 'maroon');
|
|
||||||
DoAddColor(RGBToColor(127,255,212), 'aquamarine');
|
|
||||||
DoAddColor(RGBToColor(127,255, 0), 'chartreuse');
|
|
||||||
DoAddColor(RGBToColor(124,252, 0), 'lawngreen');
|
|
||||||
DoAddColor(RGBToColor(123,104,238), 'mediumslateblue');
|
|
||||||
DoAddColor(RGBToColor(119,136,153), 'lightslategray');
|
|
||||||
DoAddColor(RGBToColor(112,128,144), 'slategray');
|
|
||||||
DoAddColor(RGBToColor(107,142, 35), 'olivedrab');
|
|
||||||
DoAddColor(RGBToColor(106, 90,205), 'slateblue');
|
|
||||||
DoAddColor(RGBToColor(105,105,105), 'dimgray');
|
|
||||||
DoAddColor(RGBToColor(102,205,170), 'mediumaquamarine');
|
|
||||||
DoAddColor(RGBToColor(100,149,237), 'cornflowerblue');
|
|
||||||
DoAddColor(RGBToColor( 95,158,160), 'cadetblue');
|
|
||||||
DoAddColor(RGBToColor( 85,107, 47), 'darkolivegreen');
|
|
||||||
DoAddColor(RGBToColor( 75, 0,130), 'indigo');
|
|
||||||
DoAddColor(RGBToColor( 72,209,204), 'mediumturquoise');
|
|
||||||
DoAddColor(RGBToColor( 72, 61,139), 'darkslateblue');
|
|
||||||
DoAddColor(RGBToColor( 70,130,180), 'steelblue');
|
|
||||||
DoAddColor(RGBToColor( 65,105,225), 'royalblue');
|
|
||||||
DoAddColor(RGBToColor( 64,224,208), 'turquoise');
|
|
||||||
DoAddColor(RGBToColor( 60,179,113), 'mediumseagreen');
|
|
||||||
DoAddColor(RGBToColor( 50,205, 50), 'limegreen');
|
|
||||||
DoAddColor(RGBToColor( 47, 79, 79), 'darkslategray');
|
|
||||||
DoAddColor(RGBToColor( 46,139, 87), 'seagreen');
|
|
||||||
DoAddColor(RGBToColor( 34,139, 34), 'forestgreen');
|
|
||||||
DoAddColor(RGBToColor( 32,178,170), 'lightseagreen');
|
|
||||||
DoAddColor(RGBToColor( 30,144,255), 'dodgerblue');
|
|
||||||
DoAddColor(RGBToColor( 25, 25,112), 'midnightblue');
|
|
||||||
DoAddColor(RGBToColor( 0,255,255), 'aqua');
|
|
||||||
DoAddColor(RGBToColor( 0,255,255), 'cyan');
|
|
||||||
DoAddColor(RGBToColor( 0,255,127), 'springgreen');
|
|
||||||
DoAddColor(RGBToColor( 0,255, 0), 'lime');
|
|
||||||
DoAddColor(RGBToColor( 0,250,154), 'mediumspringgreen');
|
|
||||||
DoAddColor(RGBToColor( 0,206,209), 'darkturquoise');
|
|
||||||
DoAddColor(RGBToColor( 0,191,255), 'deepskyblue');
|
|
||||||
DoAddColor(RGBToColor( 0,139,139), 'darkcyan');
|
|
||||||
DoAddColor(RGBToColor( 0,128,128), 'teal');
|
|
||||||
DoAddColor(RGBToColor( 0,128, 0), 'green');
|
|
||||||
DoAddColor(RGBToColor( 0,100, 0), 'darkgreen');
|
|
||||||
DoAddColor(RGBToColor( 0, 0,255), 'blue');
|
|
||||||
DoAddColor(RGBToColor( 0, 0,205), 'mediumblue');
|
|
||||||
DoAddColor(RGBToColor( 0, 0,139), 'darkblue');
|
|
||||||
DoAddColor(RGBToColor( 0, 0,128), 'navy');
|
|
||||||
DoAddColor(RGBToColor( 0, 0, 0), 'black');
|
|
||||||
end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if FPaletteKind = pkWebSafePalette then
|
if FPaletteKind = pkWebSafePalette then
|
||||||
begin
|
begin
|
||||||
// https://en.wikipedia.org/wiki/Web_colors
|
// https://en.wikipedia.org/wiki/Web_colors
|
||||||
@ -1330,17 +1161,13 @@ begin
|
|||||||
SetCols(COLCOUNT[FPaletteKind]);
|
SetCols(COLCOUNT[FPaletteKind]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.SetSelectedIndex(AValue: Integer);
|
procedure TCustomColorPalette.SetPickedIndex(AValue: Integer);
|
||||||
begin
|
begin
|
||||||
if FSelectedIndex = AValue then exit;
|
if FPickedIndex = AValue then exit;
|
||||||
if AValue < 0 then
|
if (AValue >= 0) and (AValue < FColors.Count) then
|
||||||
FSelectedIndex := 0
|
FPickedIndex := AValue else
|
||||||
else
|
FPickedIndex := -1;
|
||||||
if AValue >= FColors.Count then
|
Invalidate;
|
||||||
FSelectedIndex := FColors.Count-1
|
|
||||||
else
|
|
||||||
FSelectedIndex := AValue;
|
|
||||||
DoSelectColor(GetColors(FSelectedIndex));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.SetSelectionColor(AValue: TColor);
|
procedure TCustomColorPalette.SetSelectionColor(AValue: TColor);
|
||||||
@ -1384,7 +1211,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
dec(dx);
|
dec(dx);
|
||||||
dec(dy);
|
dec(dy);
|
||||||
d := -1; // Correct for button frame line width
|
d := -1; // Needed to correct for button frame line width
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if FFlipped then // Rows and columns are interchanged here !!!
|
if FFlipped then // Rows and columns are interchanged here !!!
|
||||||
|
@ -55,7 +55,7 @@ object MainForm: TMainForm
|
|||||||
Caption = 'Load random palette'
|
Caption = 'Load random palette'
|
||||||
Enabled = False
|
Enabled = False
|
||||||
OnClick = BtnLoadRndPaletteClick
|
OnClick = BtnLoadRndPaletteClick
|
||||||
TabOrder = 1
|
TabOrder = 5
|
||||||
end
|
end
|
||||||
object BtnCreateRndPalette: TButton
|
object BtnCreateRndPalette: TButton
|
||||||
Left = 10
|
Left = 10
|
||||||
@ -64,7 +64,7 @@ object MainForm: TMainForm
|
|||||||
Width = 137
|
Width = 137
|
||||||
Caption = 'Create random palette'
|
Caption = 'Create random palette'
|
||||||
OnClick = BtnCreateRndPaletteClick
|
OnClick = BtnCreateRndPaletteClick
|
||||||
TabOrder = 2
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object BtnAddColor: TButton
|
object BtnAddColor: TButton
|
||||||
Left = 10
|
Left = 10
|
||||||
@ -73,16 +73,16 @@ object MainForm: TMainForm
|
|||||||
Width = 137
|
Width = 137
|
||||||
Caption = 'Add color...'
|
Caption = 'Add color...'
|
||||||
OnClick = BtnAddColorClick
|
OnClick = BtnAddColorClick
|
||||||
TabOrder = 3
|
TabOrder = 7
|
||||||
end
|
end
|
||||||
object BtnLoadDefaultPal: TButton
|
object BtnLoadPalette: TButton
|
||||||
Left = 10
|
Left = 10
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 339
|
Top = 339
|
||||||
Width = 137
|
Width = 137
|
||||||
Caption = 'Load palette...'
|
Caption = 'Load palette...'
|
||||||
OnClick = BtnLoadDefaultPalClick
|
OnClick = BtnLoadPaletteClick
|
||||||
TabOrder = 4
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object BtnDeleteColor: TButton
|
object BtnDeleteColor: TButton
|
||||||
Left = 10
|
Left = 10
|
||||||
@ -91,9 +91,9 @@ object MainForm: TMainForm
|
|||||||
Width = 137
|
Width = 137
|
||||||
Caption = 'Delete color #0'
|
Caption = 'Delete color #0'
|
||||||
OnClick = BtnDeleteColorClick
|
OnClick = BtnDeleteColorClick
|
||||||
TabOrder = 5
|
TabOrder = 8
|
||||||
end
|
end
|
||||||
object BtnLoadDefaultPal1: TButton
|
object BtnSavePalette: TButton
|
||||||
Left = 10
|
Left = 10
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 446
|
Top = 446
|
||||||
@ -119,9 +119,8 @@ object MainForm: TMainForm
|
|||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
Enabled = False
|
Enabled = False
|
||||||
MaxValue = 10
|
MaxValue = 10
|
||||||
MinValue = 1
|
|
||||||
OnChange = EdGradientStepsChange
|
OnChange = EdGradientStepsChange
|
||||||
TabOrder = 7
|
TabOrder = 2
|
||||||
Value = 3
|
Value = 3
|
||||||
end
|
end
|
||||||
object LblBuiltinPalettes: TLabel
|
object LblBuiltinPalettes: TLabel
|
||||||
@ -153,7 +152,7 @@ object MainForm: TMainForm
|
|||||||
)
|
)
|
||||||
OnSelect = CbBuiltinPalettesSelect
|
OnSelect = CbBuiltinPalettesSelect
|
||||||
Style = csDropDownList
|
Style = csDropDownList
|
||||||
TabOrder = 8
|
TabOrder = 1
|
||||||
Text = 'Standard palette'
|
Text = 'Standard palette'
|
||||||
end
|
end
|
||||||
object MouseColorSample: TShape
|
object MouseColorSample: TShape
|
||||||
@ -214,7 +213,7 @@ object MainForm: TMainForm
|
|||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
MaxValue = 16
|
MaxValue = 16
|
||||||
OnChange = EdButtonDistanceChange
|
OnChange = EdButtonDistanceChange
|
||||||
TabOrder = 0
|
TabOrder = 9
|
||||||
Value = 1
|
Value = 1
|
||||||
end
|
end
|
||||||
object LblButtonSize: TLabel
|
object LblButtonSize: TLabel
|
||||||
@ -234,7 +233,7 @@ object MainForm: TMainForm
|
|||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
MinValue = 1
|
MinValue = 1
|
||||||
OnChange = EdButtonSizeChange
|
OnChange = EdButtonSizeChange
|
||||||
TabOrder = 1
|
TabOrder = 8
|
||||||
Value = 16
|
Value = 16
|
||||||
end
|
end
|
||||||
object LblButtonBorderColor: TLabel
|
object LblButtonBorderColor: TLabel
|
||||||
@ -255,7 +254,7 @@ object MainForm: TMainForm
|
|||||||
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone]
|
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone]
|
||||||
ItemHeight = 16
|
ItemHeight = 16
|
||||||
OnSelect = CbButtonBorderColorSelect
|
OnSelect = CbButtonBorderColorSelect
|
||||||
TabOrder = 2
|
TabOrder = 6
|
||||||
end
|
end
|
||||||
object CbPickMode: TComboBox
|
object CbPickMode: TComboBox
|
||||||
Left = 10
|
Left = 10
|
||||||
@ -272,7 +271,7 @@ object MainForm: TMainForm
|
|||||||
)
|
)
|
||||||
OnSelect = CbPickModeSelect
|
OnSelect = CbPickModeSelect
|
||||||
Style = csDropDownList
|
Style = csDropDownList
|
||||||
TabOrder = 3
|
TabOrder = 0
|
||||||
Text = 'default'
|
Text = 'default'
|
||||||
end
|
end
|
||||||
object LblPickMode: TLabel
|
object LblPickMode: TLabel
|
||||||
@ -293,7 +292,7 @@ object MainForm: TMainForm
|
|||||||
Checked = True
|
Checked = True
|
||||||
OnChange = CbShowColorHintsChange
|
OnChange = CbShowColorHintsChange
|
||||||
State = cbChecked
|
State = cbChecked
|
||||||
TabOrder = 4
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object EdColCount: TSpinEdit
|
object EdColCount: TSpinEdit
|
||||||
Left = 10
|
Left = 10
|
||||||
@ -303,7 +302,7 @@ object MainForm: TMainForm
|
|||||||
Alignment = taRightJustify
|
Alignment = taRightJustify
|
||||||
MinValue = 1
|
MinValue = 1
|
||||||
OnChange = EdColCountChange
|
OnChange = EdColCountChange
|
||||||
TabOrder = 5
|
TabOrder = 10
|
||||||
Value = 8
|
Value = 8
|
||||||
end
|
end
|
||||||
object LblColCount: TLabel
|
object LblColCount: TLabel
|
||||||
@ -322,7 +321,7 @@ object MainForm: TMainForm
|
|||||||
Width = 108
|
Width = 108
|
||||||
Caption = 'Custom hint text'
|
Caption = 'Custom hint text'
|
||||||
OnChange = CbCustomHintTextChange
|
OnChange = CbCustomHintTextChange
|
||||||
TabOrder = 6
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object CbUseSpacers: TCheckBox
|
object CbUseSpacers: TCheckBox
|
||||||
Left = 10
|
Left = 10
|
||||||
@ -333,7 +332,7 @@ object MainForm: TMainForm
|
|||||||
Checked = True
|
Checked = True
|
||||||
OnChange = CbUseSpacersChange
|
OnChange = CbUseSpacersChange
|
||||||
State = cbChecked
|
State = cbChecked
|
||||||
TabOrder = 7
|
TabOrder = 5
|
||||||
end
|
end
|
||||||
object LblBkColor: TLabel
|
object LblBkColor: TLabel
|
||||||
Left = 10
|
Left = 10
|
||||||
@ -353,7 +352,7 @@ object MainForm: TMainForm
|
|||||||
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone]
|
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone]
|
||||||
ItemHeight = 16
|
ItemHeight = 16
|
||||||
OnSelect = CbBkColorSelect
|
OnSelect = CbBkColorSelect
|
||||||
TabOrder = 8
|
TabOrder = 7
|
||||||
end
|
end
|
||||||
object LblSelKind: TLabel
|
object LblSelKind: TLabel
|
||||||
Left = 10
|
Left = 10
|
||||||
@ -381,7 +380,7 @@ object MainForm: TMainForm
|
|||||||
)
|
)
|
||||||
OnSelect = CbSelKindSelect
|
OnSelect = CbSelKindSelect
|
||||||
Style = csDropDownList
|
Style = csDropDownList
|
||||||
TabOrder = 9
|
TabOrder = 1
|
||||||
Text = 'none'
|
Text = 'none'
|
||||||
end
|
end
|
||||||
object LblSelColor: TLabel
|
object LblSelColor: TLabel
|
||||||
@ -402,7 +401,7 @@ object MainForm: TMainForm
|
|||||||
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone]
|
Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone]
|
||||||
ItemHeight = 16
|
ItemHeight = 16
|
||||||
OnSelect = CbSelColorSelect
|
OnSelect = CbSelColorSelect
|
||||||
TabOrder = 10
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object CbFlipped: TCheckBox
|
object CbFlipped: TCheckBox
|
||||||
Left = 10
|
Left = 10
|
||||||
@ -451,9 +450,9 @@ object MainForm: TMainForm
|
|||||||
ButtonHeight = 20
|
ButtonHeight = 20
|
||||||
ButtonWidth = 20
|
ButtonWidth = 20
|
||||||
ColumnCount = 8
|
ColumnCount = 8
|
||||||
PickShift = [ssLeft, ssRight]
|
PickedIndex = 0
|
||||||
|
OnColorPick = ColorPaletteColorPick
|
||||||
OnGetHintText = ColorPaletteGetHintText
|
OnGetHintText = ColorPaletteGetHintText
|
||||||
OnSelectColor = ColorPaletteSelectColor
|
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
PopupMenu = PalettePopupMenu
|
PopupMenu = PalettePopupMenu
|
||||||
OnDblClick = ColorPaletteDblClick
|
OnDblClick = ColorPaletteDblClick
|
||||||
|
@ -16,11 +16,11 @@ type
|
|||||||
Bevel1: TBevel;
|
Bevel1: TBevel;
|
||||||
Bevel2: TBevel;
|
Bevel2: TBevel;
|
||||||
BtnDeleteColor: TButton;
|
BtnDeleteColor: TButton;
|
||||||
BtnLoadDefaultPal1: TButton;
|
BtnSavePalette: TButton;
|
||||||
BtnLoadRndPalette: TButton;
|
BtnLoadRndPalette: TButton;
|
||||||
BtnCreateRndPalette: TButton;
|
BtnCreateRndPalette: TButton;
|
||||||
BtnAddColor: TButton;
|
BtnAddColor: TButton;
|
||||||
BtnLoadDefaultPal: TButton;
|
BtnLoadPalette: TButton;
|
||||||
BtnEditColor: TButton;
|
BtnEditColor: TButton;
|
||||||
CbBuiltinPalettes: TComboBox;
|
CbBuiltinPalettes: TComboBox;
|
||||||
CbSelColor: TColorBox;
|
CbSelColor: TColorBox;
|
||||||
@ -64,7 +64,7 @@ type
|
|||||||
procedure BtnCreateRndPaletteClick(Sender: TObject);
|
procedure BtnCreateRndPaletteClick(Sender: TObject);
|
||||||
procedure BtnDeleteColorClick(Sender: TObject);
|
procedure BtnDeleteColorClick(Sender: TObject);
|
||||||
procedure BtnEditColorClick(Sender: TObject);
|
procedure BtnEditColorClick(Sender: TObject);
|
||||||
procedure BtnLoadDefaultPalClick(Sender: TObject);
|
procedure BtnLoadPaletteClick(Sender: TObject);
|
||||||
procedure BtnLoadRndPaletteClick(Sender: TObject);
|
procedure BtnLoadRndPaletteClick(Sender: TObject);
|
||||||
procedure CbBuiltinPalettesSelect(Sender: TObject);
|
procedure CbBuiltinPalettesSelect(Sender: TObject);
|
||||||
procedure CbBkColorSelect(Sender: TObject);
|
procedure CbBkColorSelect(Sender: TObject);
|
||||||
@ -76,6 +76,8 @@ type
|
|||||||
procedure CbButtonBorderColorSelect(Sender: TObject);
|
procedure CbButtonBorderColorSelect(Sender: TObject);
|
||||||
procedure CbUseSpacersChange(Sender: TObject);
|
procedure CbUseSpacersChange(Sender: TObject);
|
||||||
procedure CbFlippedChange(Sender: TObject);
|
procedure CbFlippedChange(Sender: TObject);
|
||||||
|
procedure ColorPaletteColorPick(Sender: TObject; AColor: TColor;
|
||||||
|
Shift: TShiftState);
|
||||||
procedure ColorPaletteDblClick(Sender: TObject);
|
procedure ColorPaletteDblClick(Sender: TObject);
|
||||||
procedure ColorPaletteGetHintText(Sender: TObject; AColor: TColor;
|
procedure ColorPaletteGetHintText(Sender: TObject; AColor: TColor;
|
||||||
var AText: String);
|
var AText: String);
|
||||||
@ -83,7 +85,6 @@ type
|
|||||||
procedure ColorPaletteMouseLeave(Sender: TObject);
|
procedure ColorPaletteMouseLeave(Sender: TObject);
|
||||||
procedure ColorPaletteMouseMove(Sender: TObject; Shift: TShiftState; X,
|
procedure ColorPaletteMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
Y: Integer);
|
Y: Integer);
|
||||||
procedure ColorPaletteSelectColor(Sender: TObject; AColor: TColor);
|
|
||||||
procedure EdButtonDistanceChange(Sender: TObject);
|
procedure EdButtonDistanceChange(Sender: TObject);
|
||||||
procedure EdButtonSizeChange(Sender: TObject);
|
procedure EdButtonSizeChange(Sender: TObject);
|
||||||
procedure EdColCountChange(Sender: TObject);
|
procedure EdColCountChange(Sender: TObject);
|
||||||
@ -146,18 +147,18 @@ procedure TMainForm.BtnDeleteColorClick(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
with ColorPalette do
|
with ColorPalette do
|
||||||
begin
|
begin
|
||||||
DeleteColor(SelectedIndex);
|
DeleteColor(PickedIndex);
|
||||||
if SelectedIndex = ColorCount then SelectedIndex := ColorCount-1;
|
if PickedIndex = ColorCount then PickedIndex := ColorCount-1;
|
||||||
ColorSample.Brush.Color := Colors[SelectedColor];
|
ColorSample.Brush.Color := PickedColor;
|
||||||
if Colors[SelectedColor] = clNone then
|
if PickedColor = clNone then
|
||||||
ColorSample.Brush.Style := bsClear else
|
ColorSample.Brush.Style := bsClear else
|
||||||
ColorSample.Brush.Style := bsSolid;
|
ColorSample.Brush.Style := bsSolid;
|
||||||
UpdateCaption;
|
UpdateCaption;
|
||||||
SetColorInfo(LblColorInfo, 'Current', SelectedIndex);
|
SetColorInfo(LblColorInfo, 'Current', PickedIndex);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainForm.BtnLoadDefaultPalClick(Sender: TObject);
|
procedure TMainForm.BtnLoadPaletteClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
with OpenDialog do
|
with OpenDialog do
|
||||||
if Execute then
|
if Execute then
|
||||||
@ -250,17 +251,29 @@ begin
|
|||||||
ColorPalette.Flipped := CbFlipped.Checked;
|
ColorPalette.Flipped := CbFlipped.Checked;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainForm.ColorPaletteColorPick(Sender: TObject; AColor: TColor;
|
||||||
|
Shift: TShiftState);
|
||||||
|
begin
|
||||||
|
ColorSample.Brush.Color := AColor;
|
||||||
|
if AColor = clNone then
|
||||||
|
ColorSample.Brush.Style := bsClear else
|
||||||
|
ColorSample.Brush.Style := bsSolid;
|
||||||
|
SetColorInfo(LblColorInfo, 'Picked color', ColorPalette.PickedIndex);
|
||||||
|
BtnDeleteColor.Caption := 'Delete color #' + IntToStr(ColorPalette.PickedIndex);
|
||||||
|
UpdateCaption;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainForm.ColorPaletteDblClick(Sender: TObject);
|
procedure TMainForm.ColorPaletteDblClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
with ColorDialog do
|
with ColorDialog do
|
||||||
begin
|
begin
|
||||||
Color := ColorPalette.Colors[ColorPalette.SelectedIndex];
|
Color := ColorPalette.PickedColor;
|
||||||
if Execute then
|
if Execute then
|
||||||
begin
|
begin
|
||||||
ColorPalette.Colors[ColorPalette.SelectedIndex] := Color;
|
ColorPalette.Colors[ColorPalette.PickedIndex] := Color;
|
||||||
ColorSample.Brush.Color := Color;
|
ColorSample.Brush.Color := Color;
|
||||||
ColorSample.Brush.Style := bsSolid;
|
ColorSample.Brush.Style := bsSolid;
|
||||||
SetColorInfo(LblColorInfo, 'Current', ColorPalette.SelectedIndex);
|
SetColorInfo(LblColorInfo, 'Current', ColorPalette.PickedIndex);
|
||||||
with BtnEditColor do
|
with BtnEditColor do
|
||||||
begin
|
begin
|
||||||
Caption := 'Edit';
|
Caption := 'Edit';
|
||||||
@ -297,18 +310,7 @@ begin
|
|||||||
if MouseColorSample.Brush.Color = clNone then
|
if MouseColorSample.Brush.Color = clNone then
|
||||||
MouseColorSample.Brush.Style := bsClear else
|
MouseColorSample.Brush.Style := bsClear else
|
||||||
MouseColorSample.Brush.Style := bsSolid;
|
MouseColorSample.Brush.Style := bsSolid;
|
||||||
SetColorInfo(LblMouseColorInfo, 'MouseColor', ColorPalette.MouseIndex);
|
SetColorInfo(LblMouseColorInfo, 'Mouse color', ColorPalette.MouseIndex);
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMainForm.ColorPaletteSelectColor(Sender: TObject; AColor: TColor);
|
|
||||||
begin
|
|
||||||
ColorSample.Brush.Color := AColor;
|
|
||||||
if AColor = clNone then
|
|
||||||
ColorSample.Brush.Style := bsClear else
|
|
||||||
ColorSample.Brush.Style := bsSolid;
|
|
||||||
SetColorInfo(LblColorInfo, 'SelectedColor', ColorPalette.SelectedIndex);
|
|
||||||
BtnDeleteColor.Caption := 'Delete color #' + IntToStr(ColorPalette.SelectedIndex);
|
|
||||||
UpdateCaption;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainForm.EdButtonDistanceChange(Sender: TObject);
|
procedure TMainForm.EdButtonDistanceChange(Sender: TObject);
|
||||||
@ -343,11 +345,11 @@ begin
|
|||||||
ColorSample.Brush.Style := bsSolid;
|
ColorSample.Brush.Style := bsSolid;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if ColorSample.Brush.Color <> ColorPalette.SelectedColor then
|
if ColorSample.Brush.Color <> ColorPalette.PickedColor then
|
||||||
begin
|
begin
|
||||||
BtnEditColor.caption := 'Update >';
|
BtnEditColor.caption := 'Update >';
|
||||||
BtnEditColor.hint := 'Update palette';
|
BtnEditColor.hint := 'Update palette';
|
||||||
SetColorInfo(LblColorInfo, 'New color', ColorPalette.SelectedIndex);
|
SetColorInfo(LblColorInfo, 'New color', ColorPalette.PickedIndex);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -363,8 +365,8 @@ begin
|
|||||||
EdButtonDistance.Value := ColorPalette.ButtonDistance;
|
EdButtonDistance.Value := ColorPalette.ButtonDistance;
|
||||||
EdButtonSize.Value := ColorPalette.ButtonWidth;
|
EdButtonSize.Value := ColorPalette.ButtonWidth;
|
||||||
|
|
||||||
ColorSample.Brush.Color := ColorPalette.SelectedColor;
|
ColorSample.Brush.Color := ColorPalette.PickedColor;
|
||||||
SetColorInfo(LblColorInfo, 'Current', ColorPalette.SelectedIndex);
|
SetColorInfo(LblColorInfo, 'Current', ColorPalette.PickedIndex);
|
||||||
UpdateCaption;
|
UpdateCaption;
|
||||||
|
|
||||||
{ ColorPalette.PickShift must contain ssRight in order to be able to select
|
{ ColorPalette.PickShift must contain ssRight in order to be able to select
|
||||||
@ -407,14 +409,14 @@ end;
|
|||||||
procedure TMainForm.UpdateCaption;
|
procedure TMainForm.UpdateCaption;
|
||||||
begin
|
begin
|
||||||
Caption := Format('ColorPalette demo - CurIndex: %d (%d colors available)',
|
Caption := Format('ColorPalette demo - CurIndex: %d (%d colors available)',
|
||||||
[ColorPalette.SelectedIndex, ColorPalette.ColorCount]
|
[ColorPalette.PickedIndex, ColorPalette.ColorCount]
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainForm.UpdatePalette;
|
procedure TMainForm.UpdatePalette;
|
||||||
begin
|
begin
|
||||||
ColorPalette.Colors[ColorPalette.SelectedIndex] := ColorSample.Brush.Color;
|
ColorPalette.Colors[ColorPalette.PickedIndex] := ColorSample.Brush.Color;
|
||||||
SetColorInfo(LblColorInfo, 'Current', ColorPalette.SelectedIndex);
|
SetColorInfo(LblColorInfo, 'Current', ColorPalette.PickedIndex);
|
||||||
with BtnEditColor do
|
with BtnEditColor do
|
||||||
begin
|
begin
|
||||||
Caption := 'Edit';
|
Caption := 'Edit';
|
||||||
|
@ -2,10 +2,10 @@ object Form1: TForm1
|
|||||||
Left = 290
|
Left = 290
|
||||||
Height = 491
|
Height = 491
|
||||||
Top = 160
|
Top = 160
|
||||||
Width = 584
|
Width = 639
|
||||||
Caption = 'Form1'
|
Caption = 'Form1'
|
||||||
ClientHeight = 491
|
ClientHeight = 491
|
||||||
ClientWidth = 584
|
ClientWidth = 639
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
ShowHint = True
|
ShowHint = True
|
||||||
LCLVersion = '1.5'
|
LCLVersion = '1.5'
|
||||||
@ -13,37 +13,30 @@ object Form1: TForm1
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 436
|
Height = 436
|
||||||
Top = 55
|
Top = 55
|
||||||
Width = 584
|
Width = 639
|
||||||
Align = alClient
|
Align = alClient
|
||||||
Anchors = []
|
|
||||||
AutoSize = True
|
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 436
|
ClientHeight = 436
|
||||||
ClientWidth = 584
|
ClientWidth = 639
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object Shape1: TShape
|
object Shape1: TShape
|
||||||
Left = 56
|
Left = 64
|
||||||
Height = 120
|
Height = 120
|
||||||
Top = 40
|
Top = 40
|
||||||
Width = 146
|
Width = 146
|
||||||
Anchors = []
|
|
||||||
BorderSpacing.Around = 8
|
|
||||||
Brush.Style = bsClear
|
Brush.Style = bsClear
|
||||||
end
|
end
|
||||||
object Shape2: TShape
|
object Shape2: TShape
|
||||||
Left = 216
|
Left = 224
|
||||||
Height = 120
|
Height = 120
|
||||||
Top = 40
|
Top = 40
|
||||||
Width = 146
|
Width = 146
|
||||||
Anchors = []
|
|
||||||
BorderSpacing.Around = 8
|
|
||||||
end
|
end
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
Left = 56
|
Left = 64
|
||||||
Height = 56
|
Height = 56
|
||||||
Top = 176
|
Top = 176
|
||||||
Width = 146
|
Width = 146
|
||||||
Anchors = []
|
|
||||||
AutoSize = False
|
AutoSize = False
|
||||||
Caption = 'Gradient start'#13#10#13#10'(Left click)'
|
Caption = 'Gradient start'#13#10#13#10'(Left click)'
|
||||||
Font.Color = clWhite
|
Font.Color = clWhite
|
||||||
@ -51,11 +44,10 @@ object Form1: TForm1
|
|||||||
ParentFont = False
|
ParentFont = False
|
||||||
end
|
end
|
||||||
object Label2: TLabel
|
object Label2: TLabel
|
||||||
Left = 216
|
Left = 224
|
||||||
Height = 56
|
Height = 56
|
||||||
Top = 176
|
Top = 176
|
||||||
Width = 146
|
Width = 146
|
||||||
Anchors = []
|
|
||||||
AutoSize = False
|
AutoSize = False
|
||||||
Caption = 'Mouse color:'
|
Caption = 'Mouse color:'
|
||||||
Font.Color = clWhite
|
Font.Color = clWhite
|
||||||
@ -63,20 +55,17 @@ object Form1: TForm1
|
|||||||
ParentFont = False
|
ParentFont = False
|
||||||
end
|
end
|
||||||
object Shape3: TShape
|
object Shape3: TShape
|
||||||
Left = 376
|
Left = 384
|
||||||
Height = 120
|
Height = 120
|
||||||
Top = 40
|
Top = 40
|
||||||
Width = 146
|
Width = 146
|
||||||
Anchors = []
|
|
||||||
BorderSpacing.Around = 8
|
|
||||||
Brush.Style = bsClear
|
Brush.Style = bsClear
|
||||||
end
|
end
|
||||||
object Label3: TLabel
|
object Label3: TLabel
|
||||||
Left = 376
|
Left = 384
|
||||||
Height = 56
|
Height = 56
|
||||||
Top = 176
|
Top = 176
|
||||||
Width = 146
|
Width = 146
|
||||||
Anchors = []
|
|
||||||
AutoSize = False
|
AutoSize = False
|
||||||
Caption = 'Gradient end'#13#10#13#10'(Right click)'
|
Caption = 'Gradient end'#13#10#13#10'(Right click)'
|
||||||
Font.Color = clWhite
|
Font.Color = clWhite
|
||||||
@ -88,9 +77,10 @@ object Form1: TForm1
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 55
|
Height = 55
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 584
|
Width = 639
|
||||||
Bands = <
|
Bands = <
|
||||||
item
|
item
|
||||||
|
Break = False
|
||||||
Control = ToolBar
|
Control = ToolBar
|
||||||
MinHeight = 45
|
MinHeight = 45
|
||||||
MinWidth = 45
|
MinWidth = 45
|
||||||
@ -127,8 +117,7 @@ object Form1: TForm1
|
|||||||
Flipped = True
|
Flipped = True
|
||||||
GradientSteps = 1
|
GradientSteps = 1
|
||||||
PaletteKind = pkGradientPalette
|
PaletteKind = pkGradientPalette
|
||||||
PickShift = [ssLeft, ssRight]
|
PickedIndex = 0
|
||||||
SelectionColor = clWhite
|
|
||||||
SelectionKind = pskThickInverted
|
SelectionKind = pskThickInverted
|
||||||
ShowColorHint = False
|
ShowColorHint = False
|
||||||
UseSpacers = False
|
UseSpacers = False
|
||||||
|
@ -49,50 +49,22 @@ implementation
|
|||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
(*
|
|
||||||
procedure TForm1.ColorPalettePickColorColor(Sender: TObject; AColor: TColor;
|
|
||||||
AShift: TShiftState);
|
|
||||||
begin
|
|
||||||
if ColorPalette.SelectedColor = clNone then
|
|
||||||
Shape1.Brush.Style := bsClear
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
Shape1.Brush.Style := bsSolid;
|
|
||||||
Shape1.Brush.Color := ColorPalette.SelectedColor;
|
|
||||||
end;
|
|
||||||
Label1.Caption := Format('Selected color:'#13'%s', [
|
|
||||||
ColorPalette.ColorNames[ColorPalette.SelectedIndex]
|
|
||||||
]);
|
|
||||||
|
|
||||||
inc(counter);
|
|
||||||
if odd(counter) then
|
|
||||||
FStartColor := Colorpalette.SelectedColor else
|
|
||||||
FEndColor := ColorPalette.SelectedColor;
|
|
||||||
|
|
||||||
Panel1.Invalidate;
|
|
||||||
end;
|
|
||||||
*)
|
|
||||||
procedure TForm1.FormCreate(Sender: TObject);
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
// ColorPalette.InsertColor(0, clNone);
|
|
||||||
//ColorPalette.ColumnCount := 3; //ColorPalette.ColorCount div 3;
|
|
||||||
// ColorPalette.Vertical := true;
|
|
||||||
//ColorPalette.ColumnCount := 3;
|
|
||||||
ColorPalette.SelectedIndex := -1;
|
|
||||||
colorPalette.SelectedIndex := 0;
|
|
||||||
Toolbar.BorderSpacing.Left := 0;
|
Toolbar.BorderSpacing.Left := 0;
|
||||||
Toolbar.AutoSize := true;
|
Toolbar.AutoSize := true;
|
||||||
Coolbar.AutoSize := true;
|
Coolbar.AutoSize := true;
|
||||||
|
|
||||||
ColorPaletteColorPick(self, ColorPalette.SelectedColor, [Classes.ssLeft]);
|
ColorPaletteColorPick(self, ColorPalette.Colors[0], [ssLeft]);
|
||||||
ColorPaletteColorPick(self, ColorPalette.Colors[ColorPalette.ColorCount-1], [Classes.ssRight]);
|
ColorPaletteColorPick(self, ColorPalette.Colors[ColorPalette.ColorCount-1], [ssRight]);
|
||||||
|
|
||||||
|
// For Laz 1.4.2 where TPanel.OnPaint is not published:
|
||||||
Panel1.OnPaint := @Panel1Paint;
|
Panel1.OnPaint := @Panel1Paint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.Panel1Paint(Sender: TObject);
|
procedure TForm1.Panel1Paint(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
// Panel1.Canvas.GradientFill(Panel1.ClientRect, clSkyBlue, clNavy, gdVertical);
|
|
||||||
Panel1.Canvas.GradientFill(Panel1.ClientRect,
|
Panel1.Canvas.GradientFill(Panel1.ClientRect,
|
||||||
FStartColor,
|
FStartColor,
|
||||||
FEndColor,
|
FEndColor,
|
||||||
@ -106,6 +78,7 @@ var
|
|||||||
begin
|
begin
|
||||||
// Vertical orientation
|
// Vertical orientation
|
||||||
CoolBar.AutoSize := false;
|
CoolBar.AutoSize := false;
|
||||||
|
Toolbar.AutoSize := false;
|
||||||
if TbChangeOrientation.Down then
|
if TbChangeOrientation.Down then
|
||||||
begin
|
begin
|
||||||
CoolBar.Vertical := true;
|
CoolBar.Vertical := true;
|
||||||
@ -113,7 +86,8 @@ begin
|
|||||||
ToolBar.Align := alLeft;
|
ToolBar.Align := alLeft;
|
||||||
ColorPalette.Flipped := not ColorPalette.Flipped;
|
ColorPalette.Flipped := not ColorPalette.Flipped;
|
||||||
ColorPalette.Top := 9999;
|
ColorPalette.Top := 9999;
|
||||||
end else
|
end
|
||||||
|
else
|
||||||
// Horizontal orientation
|
// Horizontal orientation
|
||||||
begin
|
begin
|
||||||
CoolBar.Vertical := false;
|
CoolBar.Vertical := false;
|
||||||
@ -122,6 +96,7 @@ begin
|
|||||||
ColorPalette.Flipped := not ColorPalette.Flipped;
|
ColorPalette.Flipped := not ColorPalette.Flipped;
|
||||||
ColorPalette.Left := 9999;
|
ColorPalette.Left := 9999;
|
||||||
end;
|
end;
|
||||||
|
Toolbar.AutoSize := true;
|
||||||
CoolBar.AutoSize := true;
|
CoolBar.AutoSize := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -137,7 +112,8 @@ end;
|
|||||||
procedure TForm1.ColorPaletteColorPick(Sender: TObject; AColor: TColor;
|
procedure TForm1.ColorPaletteColorPick(Sender: TObject; AColor: TColor;
|
||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
if (Shift * [Classes.ssLeft] <> []) then
|
// Select gradient start color with left mouse button
|
||||||
|
if (Shift * [ssLeft] <> []) then
|
||||||
begin
|
begin
|
||||||
FStartColor := AColor;
|
FStartColor := AColor;
|
||||||
if FStartColor = clNone then
|
if FStartColor = clNone then
|
||||||
@ -151,7 +127,8 @@ begin
|
|||||||
#13'(Left click)';
|
#13'(Left click)';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (Shift * [Classes.ssRight] <> []) then
|
// Select gradient end color with right mouse button
|
||||||
|
if (Shift * [ssRight] <> []) then
|
||||||
begin
|
begin
|
||||||
FEndColor := AColor;
|
FEndColor := AColor;
|
||||||
if FEndColor = clNone then
|
if FEndColor = clNone then
|
||||||
|
Reference in New Issue
Block a user