You've already forked lazarus-ccr
Colorpalette: Deprecate OnColorMouseMove
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4306 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -135,8 +135,8 @@ type
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
procedure BlendWBColor(AColor: TColor; Steps: Integer);
|
procedure BlendWBColor(AColor: TColor; Steps: Integer);
|
||||||
procedure ColorPick(AIndex: Integer; Shift: TShiftState); dynamic;
|
procedure ColorPick(AIndex: Integer; Shift: TShiftState); virtual;
|
||||||
procedure ColorMouseMove(AColor: TColor; Shift: TShiftState); dynamic;
|
procedure ColorMouseMove(AColor: TColor; Shift: TShiftState); virtual;
|
||||||
procedure DoAddColor(AColor: TColor; AColorName: String = ''); virtual;
|
procedure DoAddColor(AColor: TColor; AColorName: String = ''); virtual;
|
||||||
procedure DoColorPick(AColor: TColor; AShift: TShiftState); virtual;
|
procedure DoColorPick(AColor: TColor; AShift: TShiftState); virtual;
|
||||||
procedure DoDeleteColor(AIndex: Integer); virtual;
|
procedure DoDeleteColor(AIndex: Integer); virtual;
|
||||||
@@ -168,7 +168,7 @@ type
|
|||||||
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 OnColorPick: TColorMouseEvent read FOnColorPick write FOnColorPick;
|
||||||
property OnColorMouseMove: TColorMouseEvent read FOnColorMouseMove write FOnColorMouseMove;
|
property OnColorMouseMove: TColorMouseEvent read FOnColorMouseMove write FOnColorMouseMove; deprecated 'Use OnMouseMove() and MouseColor';
|
||||||
property OnGetHintText: TColorPaletteHintEvent read FOnGetHintText write FOnGetHintText;
|
property OnGetHintText: TColorPaletteHintEvent read FOnGetHintText write FOnGetHintText;
|
||||||
|
|
||||||
public
|
public
|
||||||
@@ -434,9 +434,9 @@ begin
|
|||||||
Result := -1;
|
Result := -1;
|
||||||
if FFlipped then
|
if FFlipped then
|
||||||
begin
|
begin
|
||||||
if (Y < 0) or (Y > FSizeToLastCol) then exit;
|
if (Y < 0) or (Y >= FSizeToLastCol-1) then exit;
|
||||||
end else
|
end else
|
||||||
if (X < 0) or (X > FSizeToLastCol) then exit;
|
if (X < 0) or (X >= FSizeToLastCol-1) then exit;
|
||||||
|
|
||||||
W := GetCellWidth;
|
W := GetCellWidth;
|
||||||
H := GetCellHeight;
|
H := GetCellHeight;
|
||||||
@@ -702,15 +702,15 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
Hint := FSavedHint;
|
Hint := FSavedHint;
|
||||||
FMouseIndex := -1;
|
FMouseIndex := -1;
|
||||||
ColorMouseMove(MouseColor, []);
|
if Assigned(OnMouseMove) then
|
||||||
|
OnMouseMove(self, GetKeyShiftState, FMousePt.X, FMousePt.Y);
|
||||||
|
// ColorMouseMove(MouseColor, []);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.MouseMove(Shift: TShiftState; X, Y: Integer);
|
procedure TCustomColorPalette.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
var
|
var
|
||||||
C: TColor;
|
C: TColor;
|
||||||
begin
|
begin
|
||||||
inherited;
|
|
||||||
|
|
||||||
FMouseIndex := GetColorIndex(X, Y);
|
FMouseIndex := GetColorIndex(X, Y);
|
||||||
C := GetColors(FMouseIndex);
|
C := GetColors(FMouseIndex);
|
||||||
ColorMouseMove(C, Shift);
|
ColorMouseMove(C, Shift);
|
||||||
@@ -731,6 +731,8 @@ begin
|
|||||||
ColorPick(FMouseIndex, Shift);
|
ColorPick(FMouseIndex, Shift);
|
||||||
|
|
||||||
FPrevMouseIndex := FMouseIndex;
|
FPrevMouseIndex := FMouseIndex;
|
||||||
|
|
||||||
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomColorPalette.MouseUp(Button: TMouseButton;
|
procedure TCustomColorPalette.MouseUp(Button: TMouseButton;
|
||||||
@@ -1296,7 +1298,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
dec(dx);
|
dec(dx);
|
||||||
dec(dy);
|
dec(dy);
|
||||||
d := -1; // Needed to correct for button frame line width
|
d := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if FFlipped then // Rows and columns are interchanged here !!!
|
if FFlipped then // Rows and columns are interchanged here !!!
|
||||||
|
@@ -315,7 +315,7 @@ begin
|
|||||||
MousecolorSample.Brush.Color := Colorpalette.MouseColor;
|
MousecolorSample.Brush.Color := Colorpalette.MouseColor;
|
||||||
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, 'Mouse color', ColorPalette.MouseIndex);
|
SetColorInfo(LblMouseColorInfo, 'Mouse color', ColorPalette.MouseIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@@ -44,7 +44,7 @@
|
|||||||
<Unit1>
|
<Unit1>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<ComponentName Value="Form1"/>
|
<ComponentName Value="MainForm"/>
|
||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="Unit1"/>
|
<UnitName Value="Unit1"/>
|
||||||
|
@@ -15,7 +15,7 @@ uses
|
|||||||
begin
|
begin
|
||||||
RequireDerivedFormResource:=True;
|
RequireDerivedFormResource:=True;
|
||||||
Application.Initialize;
|
Application.Initialize;
|
||||||
Application.CreateForm(TForm1, Form1);
|
Application.CreateForm(TMainForm, MainForm);
|
||||||
Application.Run;
|
Application.Run;
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
object Form1: TForm1
|
object MainForm: TMainForm
|
||||||
Left = 290
|
Left = 290
|
||||||
Height = 491
|
Height = 491
|
||||||
Top = 160
|
Top = 160
|
||||||
Width = 633
|
Width = 633
|
||||||
Caption = 'Form1'
|
Caption = 'MainForm'
|
||||||
ClientHeight = 491
|
ClientHeight = 491
|
||||||
ClientWidth = 633
|
ClientWidth = 633
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
@@ -161,6 +161,7 @@ object Form1: TForm1
|
|||||||
ParentColor = False
|
ParentColor = False
|
||||||
ParentShowHint = False
|
ParentShowHint = False
|
||||||
ShowHint = True
|
ShowHint = True
|
||||||
|
OnMouseMove = ColorPaletteMouseMove
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object ImageList: TImageList
|
object ImageList: TImageList
|
||||||
|
@@ -10,9 +10,9 @@ uses
|
|||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
{ TForm1 }
|
{ TMainForm }
|
||||||
|
|
||||||
TForm1 = class(TForm)
|
TMainForm = class(TForm)
|
||||||
ColorPalette: TColorPalette;
|
ColorPalette: TColorPalette;
|
||||||
CoolBar: TCoolBar;
|
CoolBar: TCoolBar;
|
||||||
ImageList: TImageList;
|
ImageList: TImageList;
|
||||||
@@ -30,6 +30,8 @@ type
|
|||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
procedure ColorPaletteColorPick(Sender: TObject; AColor: TColor;
|
procedure ColorPaletteColorPick(Sender: TObject; AColor: TColor;
|
||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
|
procedure ColorPaletteMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
|
Y: Integer);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure MainPanelPaint(Sender: TObject);
|
procedure MainPanelPaint(Sender: TObject);
|
||||||
procedure TbChangeOrientationClick(Sender: TObject);
|
procedure TbChangeOrientationClick(Sender: TObject);
|
||||||
@@ -42,21 +44,22 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
Form1: TForm1;
|
MainForm: TMainForm;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
{ TForm1 }
|
{ TMainForm }
|
||||||
|
|
||||||
{ OnColorMouseMove is called when the mouse enters a different color button,
|
{ OnColorMouseMove is called when the mouse enters a different color button,
|
||||||
or when the ColorPalette is left. }
|
or when the ColorPalette is left. }
|
||||||
procedure TForm1.ColorPaletteColorMouseMove(Sender: TObject; AColor: TColor;
|
procedure TMainForm.ColorPaletteColorMouseMove(Sender: TObject; AColor: TColor;
|
||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
var
|
var
|
||||||
clrName: String;
|
clrName: String;
|
||||||
begin
|
begin
|
||||||
|
(*
|
||||||
if ColorPalette.MouseColor = clNone then
|
if ColorPalette.MouseColor = clNone then
|
||||||
Shape2.Brush.Style := bsClear
|
Shape2.Brush.Style := bsClear
|
||||||
else begin
|
else begin
|
||||||
@@ -68,12 +71,13 @@ begin
|
|||||||
else
|
else
|
||||||
clrName := ColorPalette.ColorNames[ColorPalette.MouseIndex];
|
clrName := ColorPalette.ColorNames[ColorPalette.MouseIndex];
|
||||||
LblMouseColor.Caption := 'Mouse color:'#13 + clrName;
|
LblMouseColor.Caption := 'Mouse color:'#13 + clrName;
|
||||||
|
*)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ OnColorPick is called whenever a color button is clicked.
|
{ OnColorPick is called whenever a color button is clicked.
|
||||||
A left-click defines the start color of the gradient of the main panel,
|
A left-click defines the start color of the gradient of the main panel,
|
||||||
a right-click defines its end color. }
|
a right-click defines its end color. }
|
||||||
procedure TForm1.ColorPaletteColorPick(Sender: TObject; AColor: TColor;
|
procedure TMainForm.ColorPaletteColorPick(Sender: TObject; AColor: TColor;
|
||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
// Select gradient start color with left mouse button
|
// Select gradient start color with left mouse button
|
||||||
@@ -124,7 +128,29 @@ begin
|
|||||||
MainPanel.Invalidate;
|
MainPanel.Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.FormCreate(Sender: TObject);
|
procedure TMainForm.ColorPaletteMouseMove(Sender: TObject; Shift: TShiftState;
|
||||||
|
X, Y: Integer);
|
||||||
|
var
|
||||||
|
clrName: String;
|
||||||
|
begin
|
||||||
|
if ColorPalette.MouseColor = clNone then
|
||||||
|
begin
|
||||||
|
Shape2.Brush.Style := bsClear;
|
||||||
|
Shape2.Pen.Style := psDot;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
Shape2.Brush.Style := bsSolid;
|
||||||
|
Shape2.Brush.Color := ColorPalette.MouseColor;
|
||||||
|
Shape2.Pen.Style := psSolid;
|
||||||
|
end;
|
||||||
|
if ColorPalette.MouseIndex = -1 then
|
||||||
|
clrName := 'clNone'
|
||||||
|
else
|
||||||
|
clrName := ColorPalette.ColorNames[ColorPalette.MouseIndex];
|
||||||
|
LblMouseColor.Caption := 'Mouse color:'#13 + clrName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMainForm.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Toolbar.BorderSpacing.Left := 0;
|
Toolbar.BorderSpacing.Left := 0;
|
||||||
Toolbar.AutoSize := true;
|
Toolbar.AutoSize := true;
|
||||||
@@ -133,7 +159,7 @@ begin
|
|||||||
// Paint the three color boxes
|
// Paint the three color boxes
|
||||||
ColorPaletteColorPick(self, ColorPalette.Colors[0], [ssLeft]);
|
ColorPaletteColorPick(self, ColorPalette.Colors[0], [ssLeft]);
|
||||||
ColorPaletteColorPick(self, ColorPalette.Colors[ColorPalette.ColorCount-1], [ssRight]);
|
ColorPaletteColorPick(self, ColorPalette.Colors[ColorPalette.ColorCount-1], [ssRight]);
|
||||||
ColorPaletteColorMouseMove(self, ColorPalette.MouseColor, []);
|
ColorPaletteMouseMove(self, [], 0, 0);
|
||||||
|
|
||||||
// For Laz 1.4.2 where TPanel.OnPaint is not published:
|
// For Laz 1.4.2 where TPanel.OnPaint is not published:
|
||||||
MainPanel.OnPaint := @MainPanelPaint;
|
MainPanel.OnPaint := @MainPanelPaint;
|
||||||
@@ -142,7 +168,7 @@ end;
|
|||||||
{ Paints a color gradient onto the main panel of the form. The gradient is
|
{ Paints a color gradient onto the main panel of the form. The gradient is
|
||||||
defined by the FStartColor and FEndColor obtained by clicks into the
|
defined by the FStartColor and FEndColor obtained by clicks into the
|
||||||
ColorPalette. }
|
ColorPalette. }
|
||||||
procedure TForm1.MainPanelPaint(Sender: TObject);
|
procedure TMainForm.MainPanelPaint(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
MainPanel.Canvas.GradientFill(MainPanel.ClientRect,
|
MainPanel.Canvas.GradientFill(MainPanel.ClientRect,
|
||||||
FStartColor,
|
FStartColor,
|
||||||
@@ -152,7 +178,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{ Fires when the "Flip" button is clicked }
|
{ Fires when the "Flip" button is clicked }
|
||||||
procedure TForm1.TbChangeOrientationClick(Sender: TObject);
|
procedure TMainForm.TbChangeOrientationClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
|
Reference in New Issue
Block a user