You've already forked lazarus-ccr
ColorPalette: New property SelectedIndex.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4281 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -76,22 +76,26 @@ type
|
|||||||
FOnSelectColor: TColorPaletteEvent;
|
FOnSelectColor: TColorPaletteEvent;
|
||||||
FRows: Integer;
|
FRows: Integer;
|
||||||
FColors: TList;
|
FColors: TList;
|
||||||
FPickedColor: TColor;
|
FSelectedColor: TColor;
|
||||||
FSelectedColor: TColor; // same as PickedColor, but updated only if "IsCorrectShift"
|
FSelectedIndex: Integer;
|
||||||
FPickMode: TPickMode;
|
FPickMode: TPickMode;
|
||||||
FPickShift: TPickShift;
|
FPickShift: TPickShift;
|
||||||
FMousePt: TPoint;
|
FMousePt: TPoint;
|
||||||
FMouseIndex: Integer;
|
FMouseIndex: Integer;
|
||||||
FPrevMouseIndex: Integer;
|
FPrevMouseIndex: Integer;
|
||||||
FStoredShift: TShiftState;
|
FStoredShift: TShiftState;
|
||||||
|
FShowSelection: Boolean;
|
||||||
function GetColorCount: Integer;
|
function GetColorCount: Integer;
|
||||||
function GetColors(Index: Integer): TColor;
|
function GetColors(AIndex: Integer): TColor;
|
||||||
|
function GetPickedColor: TColor;
|
||||||
procedure SetButtonHeight(const AValue: Integer);
|
procedure SetButtonHeight(const AValue: Integer);
|
||||||
procedure SetButtonWidth(const AValue: Integer);
|
procedure SetButtonWidth(const AValue: Integer);
|
||||||
procedure SetColors(Index: Integer; const AValue: TColor);
|
procedure SetColors(AIndex: Integer; const AValue: TColor);
|
||||||
procedure SetCols(AValue: Integer);
|
procedure SetCols(AValue: Integer);
|
||||||
|
procedure SetSelectedIndex(AValue: Integer);
|
||||||
|
procedure SetShowSelection(AValue: Boolean);
|
||||||
protected
|
protected
|
||||||
procedure ColorPick(AColor: TColor; Shift: TShiftState); dynamic;
|
procedure ColorPick(AIndex: Integer; Shift: TShiftState); dynamic;
|
||||||
procedure ColorMouseMove(AColor: TColor; Shift: TShiftState); dynamic;
|
procedure ColorMouseMove(AColor: TColor; Shift: TShiftState); dynamic;
|
||||||
procedure DoAddColor(AColor: TColor); virtual;
|
procedure DoAddColor(AColor: TColor); virtual;
|
||||||
procedure DoColorPick(AColor: TColor; AShift: TShiftState); virtual;
|
procedure DoColorPick(AColor: TColor; AShift: TShiftState); virtual;
|
||||||
@ -107,6 +111,8 @@ type
|
|||||||
property ColumnCount: Integer read FCols write SetCols;
|
property ColumnCount: Integer read FCols write SetCols;
|
||||||
property PickMode: TPickMode read FPickMode write FPickMode default pmDefault;
|
property PickMode: TPickMode read FPickMode write FPickMode default pmDefault;
|
||||||
property PickShift: TPickShift read FPickShift write FPickShift default [ssLeft];
|
property PickShift: TPickShift read FPickShift write FPickShift default [ssLeft];
|
||||||
|
property SelectedIndex: Integer read FSelectedIndex write SetSelectedIndex default 0;
|
||||||
|
property ShowSelection: Boolean read FShowSelection write SetShowSelection default false;
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -119,7 +125,7 @@ type
|
|||||||
|
|
||||||
property Colors[Index: Integer]: TColor read GetColors write SetColors;
|
property Colors[Index: Integer]: TColor read GetColors write SetColors;
|
||||||
property ColorCount: Integer read GetColorCount;
|
property ColorCount: Integer read GetColorCount;
|
||||||
property PickedColor: TColor read FSelectedColor; deprecated 'Use SelectedColor';
|
property PickedColor: TColor read GetPickedColor; deprecated 'Use SelectedColor';
|
||||||
property SelectedColor: TColor read FSelectedColor;
|
property SelectedColor: TColor read FSelectedColor;
|
||||||
|
|
||||||
property OnSelectColor: TColorPaletteEvent read FOnSelectColor write FOnSelectColor;
|
property OnSelectColor: TColorPaletteEvent read FOnSelectColor write FOnSelectColor;
|
||||||
@ -150,7 +156,9 @@ type
|
|||||||
property PickMode;
|
property PickMode;
|
||||||
property PickShift;
|
property PickShift;
|
||||||
property PopupMenu;
|
property PopupMenu;
|
||||||
|
property SelectedIndex;
|
||||||
property ShowHint;
|
property ShowHint;
|
||||||
|
property ShowSelection;
|
||||||
property Visible;
|
property Visible;
|
||||||
|
|
||||||
property OnChangeBounds;
|
property OnChangeBounds;
|
||||||
@ -227,11 +235,14 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.ColorPick(AColor: TColor; Shift: TShiftState);
|
procedure TCustomColorPalette.ColorPick(AIndex: Integer; Shift: TShiftState);
|
||||||
|
var
|
||||||
|
c: TColor;
|
||||||
begin
|
begin
|
||||||
DoColorPick(AColor, Shift);
|
c := GetColors(AIndex);
|
||||||
|
DoColorPick(c, Shift);
|
||||||
if IsCorrectShift(Shift) then
|
if IsCorrectShift(Shift) then
|
||||||
DoSelectColor(AColor);
|
SelectedIndex := AIndex;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.ColorMouseMove(AColor: TColor; Shift: TShiftState);
|
procedure TCustomColorPalette.ColorMouseMove(AColor: TColor; Shift: TShiftState);
|
||||||
@ -260,12 +271,15 @@ end;
|
|||||||
|
|
||||||
procedure TCustomColorPalette.DoDeleteColor(AIndex: Integer);
|
procedure TCustomColorPalette.DoDeleteColor(AIndex: Integer);
|
||||||
begin
|
begin
|
||||||
|
if (AIndex < 0) or (AIndex >= FColors.Count) then
|
||||||
|
exit;
|
||||||
FColors.Delete(AIndex);
|
FColors.Delete(AIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.DoSelectColor(AColor: TColor);
|
procedure TCustomColorPalette.DoSelectColor(AColor: TColor);
|
||||||
begin
|
begin
|
||||||
FSelectedColor := AColor;
|
FSelectedColor := AColor;
|
||||||
|
Invalidate;
|
||||||
if Assigned(FOnSelectColor) then FOnSelectColor(self, AColor);
|
if Assigned(FOnSelectColor) then FOnSelectColor(self, AColor);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -274,14 +288,20 @@ begin
|
|||||||
Result := FColors.Count;
|
Result := FColors.Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomColorPalette.GetColors(Index: Integer): TColor;
|
function TCustomColorPalette.GetColors(AIndex: Integer): TColor;
|
||||||
begin
|
begin
|
||||||
Result := TColor(PtrUInt(FColors.Items[Index]));
|
if (AIndex < 0) or (AIndex >= FColors.Count) then
|
||||||
|
Result := clNone
|
||||||
|
else
|
||||||
|
Result := TColor(PtrUInt(FColors.Items[AIndex]));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomColorPalette.GetPickedColor: TColor;
|
||||||
|
begin
|
||||||
|
Result := GetColors(FMouseIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomColorPalette.IsCorrectShift(Shift: TShiftState): Boolean;
|
function TCustomColorPalette.IsCorrectShift(Shift: TShiftState): Boolean;
|
||||||
var
|
|
||||||
ss: TShiftState;
|
|
||||||
begin
|
begin
|
||||||
Result := True;
|
Result := True;
|
||||||
if (ssLeft in FPickShift) and (Classes.ssLeft in Shift) then exit;
|
if (ssLeft in FPickShift) and (Classes.ssLeft in Shift) then exit;
|
||||||
@ -376,7 +396,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
UpdateSize;
|
UpdateSize;
|
||||||
Invalidate;
|
SelectedIndex := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.MouseDown(Button: TMouseButton;
|
procedure TCustomColorPalette.MouseDown(Button: TMouseButton;
|
||||||
@ -398,10 +418,9 @@ begin
|
|||||||
|
|
||||||
if (FMouseIndex < FColors.Count) then
|
if (FMouseIndex < FColors.Count) then
|
||||||
begin
|
begin
|
||||||
FPickedColor := GetColors(FMouseIndex);
|
|
||||||
FStoredShift := Shift; // store for usage by pmDefault at MouseUp
|
FStoredShift := Shift; // store for usage by pmDefault at MouseUp
|
||||||
if FPickMode <> pmDefault then
|
if FPickMode <> pmDefault then
|
||||||
ColorPick(FPickedColor, Shift);
|
ColorPick(FMouseIndex, Shift);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -422,10 +441,8 @@ begin
|
|||||||
if C <> clNone then
|
if C <> clNone then
|
||||||
ColorMouseMove(C, Shift);
|
ColorMouseMove(C, Shift);
|
||||||
|
|
||||||
if FPickMode = pmContinuous then begin
|
if FPickMode = pmContinuous then
|
||||||
FPickedColor := GetColors(FMouseIndex);
|
ColorPick(FMouseIndex, Shift);
|
||||||
ColorPick(FPickedColor, Shift);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FPrevMouseIndex := FMouseIndex;
|
FPrevMouseIndex := FMouseIndex;
|
||||||
@ -437,7 +454,7 @@ begin
|
|||||||
case FPickMode of
|
case FPickMode of
|
||||||
pmDefault:
|
pmDefault:
|
||||||
if (FMousePt.X = X) and (FMousePt.Y = Y) then
|
if (FMousePt.X = X) and (FMousePt.Y = Y) then
|
||||||
ColorPick(FPickedColor, FStoredShift);
|
ColorPick(FMouseIndex, FStoredShift);
|
||||||
pmImmediate, pmContinuous:
|
pmImmediate, pmContinuous:
|
||||||
begin
|
begin
|
||||||
X := X div FButtonWidth;
|
X := X div FButtonWidth;
|
||||||
@ -446,8 +463,7 @@ begin
|
|||||||
if (FMouseIndex >= 0) and (FMouseIndex < FColors.Count) and
|
if (FMouseIndex >= 0) and (FMouseIndex < FColors.Count) and
|
||||||
(FMouseIndex <> FPrevMouseIndex) then
|
(FMouseIndex <> FPrevMouseIndex) then
|
||||||
begin
|
begin
|
||||||
FPickedColor := GetColors(FMouseIndex);
|
ColorPick(FMouseIndex, Shift);
|
||||||
ColorPick(FPickedColor, Shift);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -460,6 +476,7 @@ procedure TCustomColorPalette.Paint;
|
|||||||
var
|
var
|
||||||
I, X, Y: Integer;
|
I, X, Y: Integer;
|
||||||
c: TColor;
|
c: TColor;
|
||||||
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
Canvas.Pen.Color := clBlack;
|
Canvas.Pen.Color := clBlack;
|
||||||
for I := 0 to Pred(FColors.Count) do
|
for I := 0 to Pred(FColors.Count) do
|
||||||
@ -469,9 +486,19 @@ begin
|
|||||||
c := GetColors(I);
|
c := GetColors(I);
|
||||||
if c <> clNone then
|
if c <> clNone then
|
||||||
begin
|
begin
|
||||||
|
R := Bounds(X * FButtonWidth, Y*FButtonHeight, FButtonWidth, FButtonHeight);
|
||||||
|
if FShowSelection and (FSelectedIndex = I) then
|
||||||
|
begin
|
||||||
|
if Red(c) + Green(c) + Blue(c) > 128*3 then
|
||||||
|
Canvas.Pen.Color := clBlack else
|
||||||
|
Canvas.Pen.Color := clWhite;
|
||||||
|
Canvas.Pen.Width := 3;
|
||||||
|
end else begin
|
||||||
|
Canvas.Pen.Color := clBlack;
|
||||||
|
Canvas.Pen.Width := 1;
|
||||||
|
end;
|
||||||
Canvas.Brush.Color := c;
|
Canvas.Brush.Color := c;
|
||||||
Canvas.Rectangle(Bounds(X * FButtonWidth, Y * FButtonHeight, FButtonWidth,
|
Canvas.Rectangle(R);
|
||||||
FButtonHeight));
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -517,9 +544,9 @@ begin
|
|||||||
UpdateSize;
|
UpdateSize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.SetColors(Index: Integer; const AValue: TColor);
|
procedure TCustomColorPalette.SetColors(AIndex: Integer; const AValue: TColor);
|
||||||
begin
|
begin
|
||||||
FColors.Items[Index] := Pointer(AValue);
|
FColors.Items[AIndex] := Pointer(AValue);
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -532,6 +559,26 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomColorPalette.SetShowSelection(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FShowSelection = AValue then exit;
|
||||||
|
FShowSelection := AValue;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomColorPalette.SetSelectedIndex(AValue: Integer);
|
||||||
|
begin
|
||||||
|
if FSelectedIndex = AValue then exit;
|
||||||
|
if AValue < 0 then
|
||||||
|
FSelectedIndex := 0
|
||||||
|
else
|
||||||
|
if AValue >= FColors.Count then
|
||||||
|
FSelectedIndex := FColors.Count-1
|
||||||
|
else
|
||||||
|
FSelectedIndex := AValue;
|
||||||
|
DoSelectColor(GetColors(FSelectedIndex));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.UpdateSize;
|
procedure TCustomColorPalette.UpdateSize;
|
||||||
begin
|
begin
|
||||||
if (FCols = 0) or (FColors.Count = 0) then FRows := 0
|
if (FCols = 0) or (FColors.Count = 0) then FRows := 0
|
||||||
|
@ -40,10 +40,10 @@ object MainForm: TMainForm
|
|||||||
Width = 63
|
Width = 63
|
||||||
end
|
end
|
||||||
object LblColorInfo: TLabel
|
object LblColorInfo: TLabel
|
||||||
Left = 12
|
Left = 9
|
||||||
Height = 65
|
Height = 65
|
||||||
Top = 45
|
Top = 45
|
||||||
Width = 135
|
Width = 146
|
||||||
AutoSize = False
|
AutoSize = False
|
||||||
Caption = 'LblColorInfo'
|
Caption = 'LblColorInfo'
|
||||||
Font.Color = clGreen
|
Font.Color = clGreen
|
||||||
@ -118,7 +118,7 @@ object MainForm: TMainForm
|
|||||||
object EdColCount: TSpinEdit
|
object EdColCount: TSpinEdit
|
||||||
Left = 11
|
Left = 11
|
||||||
Height = 23
|
Height = 23
|
||||||
Top = 432
|
Top = 463
|
||||||
Width = 66
|
Width = 66
|
||||||
MinValue = 1
|
MinValue = 1
|
||||||
OnChange = EdColCountChange
|
OnChange = EdColCountChange
|
||||||
@ -128,7 +128,7 @@ object MainForm: TMainForm
|
|||||||
object Label2: TLabel
|
object Label2: TLabel
|
||||||
Left = 11
|
Left = 11
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 411
|
Top = 442
|
||||||
Width = 80
|
Width = 80
|
||||||
Caption = 'Column count:'
|
Caption = 'Column count:'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
@ -152,13 +152,22 @@ object MainForm: TMainForm
|
|||||||
Text = 'default'
|
Text = 'default'
|
||||||
end
|
end
|
||||||
object LblPickMode: TLabel
|
object LblPickMode: TLabel
|
||||||
Left = 11
|
Left = 10
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 355
|
Top = 355
|
||||||
Width = 56
|
Width = 56
|
||||||
Caption = 'Pick mode'
|
Caption = 'Pick mode'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
|
object CbShowSelection: TCheckBox
|
||||||
|
Left = 11
|
||||||
|
Height = 19
|
||||||
|
Top = 413
|
||||||
|
Width = 99
|
||||||
|
Caption = 'Show selection'
|
||||||
|
OnChange = CbShowSelectionChange
|
||||||
|
TabOrder = 9
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object Bevel1: TBevel
|
object Bevel1: TBevel
|
||||||
Left = 160
|
Left = 160
|
||||||
|
@ -21,6 +21,7 @@ type
|
|||||||
BtnAddColor: TButton;
|
BtnAddColor: TButton;
|
||||||
BtnLoadDefaultPal: TButton;
|
BtnLoadDefaultPal: TButton;
|
||||||
BtnEditColor: TButton;
|
BtnEditColor: TButton;
|
||||||
|
CbShowSelection: TCheckBox;
|
||||||
ColorDialog: TColorDialog;
|
ColorDialog: TColorDialog;
|
||||||
ColorPalette: TColorPalette;
|
ColorPalette: TColorPalette;
|
||||||
CbPickMode: TComboBox;
|
CbPickMode: TComboBox;
|
||||||
@ -41,6 +42,7 @@ type
|
|||||||
procedure BtnLoadDefaultPalClick(Sender: TObject);
|
procedure BtnLoadDefaultPalClick(Sender: TObject);
|
||||||
procedure BtnLoadRndPaletteClick(Sender: TObject);
|
procedure BtnLoadRndPaletteClick(Sender: TObject);
|
||||||
procedure CbPickModeSelect(Sender: TObject);
|
procedure CbPickModeSelect(Sender: TObject);
|
||||||
|
procedure CbShowSelectionChange(Sender: TObject);
|
||||||
procedure ColorPaletteDblClick(Sender: TObject);
|
procedure ColorPaletteDblClick(Sender: TObject);
|
||||||
procedure ColorPaletteMouseDown(Sender: TObject; Button: TMouseButton;
|
procedure ColorPaletteMouseDown(Sender: TObject; Button: TMouseButton;
|
||||||
Shift: TShiftState; X, Y: Integer);
|
Shift: TShiftState; X, Y: Integer);
|
||||||
@ -51,7 +53,6 @@ type
|
|||||||
procedure MnuEditPickedColorClick(Sender: TObject);
|
procedure MnuEditPickedColorClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
curIndex: integer;
|
|
||||||
procedure EditCurColor;
|
procedure EditCurColor;
|
||||||
procedure SetColorInfo(ATitle: string; AColor: TColor);
|
procedure SetColorInfo(ATitle: string; AColor: TColor);
|
||||||
procedure UpdateCaption;
|
procedure UpdateCaption;
|
||||||
@ -105,17 +106,14 @@ procedure TMainForm.BtnDeleteColorClick(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
with ColorPalette do
|
with ColorPalette do
|
||||||
begin
|
begin
|
||||||
if (curIndex < ColorCount) and (ColorCount > 0) then
|
DeleteColor(SelectedIndex);
|
||||||
begin
|
if SelectedIndex = ColorCount then SelectedIndex := ColorCount-1;
|
||||||
DeleteColor(curIndex);
|
ColorSample.Brush.Color := Colors[SelectedColor];
|
||||||
if curIndex = ColorCount then dec(curIndex);
|
if Colors[SelectedColor] = clNone then
|
||||||
ColorSample.Brush.Color := Colors[curIndex] ;
|
ColorSample.Brush.Style := bsClear else
|
||||||
if Colors[curIndex] = clNone then
|
ColorSample.Brush.Style := bsSolid;
|
||||||
ColorSample.Brush.Style := bsClear else
|
UpdateCaption;
|
||||||
ColorSample.Brush.Style := bsSolid;
|
SetColorInfo('Current', Colors[SelectedIndex]);
|
||||||
UpdateCaption;
|
|
||||||
SetColorInfo('Current', ColorPalette.Colors[curIndex]);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -151,14 +149,19 @@ begin
|
|||||||
ColorPalette.PickMode := TPickMode(CbPickMode.ItemIndex);
|
ColorPalette.PickMode := TPickMode(CbPickMode.ItemIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainForm.CbShowSelectionChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ColorPalette.ShowSelection := CbShowSelection.Checked;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainForm.ColorPaletteDblClick(Sender: TObject);
|
procedure TMainForm.ColorPaletteDblClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
with ColorDialog do
|
with ColorDialog do
|
||||||
begin
|
begin
|
||||||
Color := ColorPalette.Colors[curIndex];
|
Color := ColorPalette.Colors[ColorPalette.SelectedIndex];
|
||||||
if Execute then
|
if Execute then
|
||||||
begin
|
begin
|
||||||
ColorPalette.Colors[curIndex] := Color;
|
ColorPalette.Colors[ColorPalette.SelectedIndex] := Color;
|
||||||
ColorSample.Brush.Color := Color;
|
ColorSample.Brush.Color := Color;
|
||||||
ColorSample.Brush.Style := bsSolid;
|
ColorSample.Brush.Style := bsSolid;
|
||||||
SetColorInfo('Current', Color);
|
SetColorInfo('Current', Color);
|
||||||
@ -174,23 +177,23 @@ end;
|
|||||||
procedure TMainForm.ColorPaletteMouseDown(Sender: TObject; Button: TMouseButton;
|
procedure TMainForm.ColorPaletteMouseDown(Sender: TObject; Button: TMouseButton;
|
||||||
Shift: TShiftState; X, Y: Integer);
|
Shift: TShiftState; X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
with ColorPalette do
|
exit;
|
||||||
begin
|
|
||||||
X := X div ButtonWidth;
|
|
||||||
Y := Y div ButtonHeight;
|
|
||||||
curIndex := X + Y * ColumnCount;
|
BtnDeleteColor.caption := 'Delete color #' + IntToStr(ColorPalette.SelectedIndex);
|
||||||
end;
|
|
||||||
BtnDeleteColor.caption := 'Delete color #' + IntToStr(curIndex);
|
|
||||||
UpdateCaption;
|
UpdateCaption;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainForm.ColorPaletteSelectColor(Sender: TObject; AColor: TColor);
|
procedure TMainForm.ColorPaletteSelectColor(Sender: TObject; AColor: TColor);
|
||||||
begin
|
begin
|
||||||
ColorSample.Brush.Color := ColorPalette.SelectedColor;
|
ColorSample.Brush.Color := AColor;
|
||||||
if ColorPalette.Colors[curIndex] = clNone then
|
if AColor = clNone then
|
||||||
ColorSample.Brush.Style := bsClear else
|
ColorSample.Brush.Style := bsClear else
|
||||||
ColorSample.Brush.Style := bsSolid;
|
ColorSample.Brush.Style := bsSolid;
|
||||||
SetColorInfo('SelectedColor', ColorPalette.SelectedColor);
|
SetColorInfo('SelectedColor', AColor);
|
||||||
|
BtnDeleteColor.Caption := 'Delete color #' + IntToStr(ColorPalette.SelectedIndex);
|
||||||
|
UpdateCaption;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainForm.EdColCountChange(Sender: TObject);
|
procedure TMainForm.EdColCountChange(Sender: TObject);
|
||||||
@ -218,9 +221,8 @@ end;
|
|||||||
|
|
||||||
procedure TMainForm.FormCreate(Sender: TObject);
|
procedure TMainForm.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
curIndex := 0;
|
ColorSample.Brush.Color := ColorPalette.SelectedColor;
|
||||||
ColorSample.Brush.Color := ColorPalette.Colors[0];
|
SetColorInfo('Current', ColorPalette.SelectedColor);
|
||||||
SetColorInfo('Current', ColorPalette.Colors[curIndex]);
|
|
||||||
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
|
||||||
@ -257,14 +259,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)',
|
||||||
[curIndex, ColorPalette.ColorCount]
|
[ColorPalette.SelectedIndex, ColorPalette.ColorCount]
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainForm.UpdatePalette;
|
procedure TMainForm.UpdatePalette;
|
||||||
begin
|
begin
|
||||||
ColorPalette.Colors[curIndex] := ColorSample.Brush.Color;
|
ColorPalette.Colors[ColorPalette.SelectedIndex] := ColorSample.Brush.Color;
|
||||||
SetColorInfo('Current', ColorPalette.Colors[curIndex]);
|
SetColorInfo('Current', ColorSample.Brush.Color);
|
||||||
with BtnEditColor do
|
with BtnEditColor do
|
||||||
begin
|
begin
|
||||||
Caption := 'Edit';
|
Caption := 'Edit';
|
||||||
|
Reference in New Issue
Block a user