You've already forked lazarus-ccr
mbColorLib: Fix keyboard handling of all colorLib components (arrow keys stay within control and don't focus next control any more).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5541 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -24,18 +24,21 @@ type
|
|||||||
procedure SetGValue(g: integer);
|
procedure SetGValue(g: integer);
|
||||||
procedure SetBValue(b: integer);
|
procedure SetBValue(b: integer);
|
||||||
protected
|
protected
|
||||||
|
procedure CorrectCoords(var x, y: integer);
|
||||||
|
procedure CreateWnd; override;
|
||||||
|
procedure DrawMarker(x, y: integer);
|
||||||
function GetGradientColor2D(x, y: Integer): TColor; override;
|
function GetGradientColor2D(x, y: Integer): TColor; override;
|
||||||
procedure SetSelectedColor(c: TColor); override;
|
(*
|
||||||
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
||||||
message CN_KEYDOWN;
|
message CN_KEYDOWN;
|
||||||
|
*)
|
||||||
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure DrawMarker(x, y: integer);
|
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
procedure CreateWnd; override;
|
procedure SetSelectedColor(c: TColor); override;
|
||||||
procedure CorrectCoords(var x, y: integer);
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
published
|
published
|
||||||
@@ -78,24 +81,18 @@ begin
|
|||||||
MarkerStyle := msCircle;
|
MarkerStyle := msCircle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBAxisColorPicker.CreateWnd;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
CreateGradient;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ x is RED, y is GREEN }
|
|
||||||
function TBAxisColorPicker.GetGradientColor2D(x, y: Integer): TColor;
|
|
||||||
begin
|
|
||||||
Result := RGB(x, FBufferBmp.Height - 1 - y, FB);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TBAxisColorPicker.CorrectCoords(var x, y: integer);
|
procedure TBAxisColorPicker.CorrectCoords(var x, y: integer);
|
||||||
begin
|
begin
|
||||||
Clamp(x, 0, Width - 1);
|
Clamp(x, 0, Width - 1);
|
||||||
Clamp(y, 0, Height - 1);
|
Clamp(y, 0, Height - 1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBAxisColorPicker.CreateWnd;
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
CreateGradient;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBAxisColorPicker.DrawMarker(x, y: integer);
|
procedure TBAxisColorPicker.DrawMarker(x, y: integer);
|
||||||
var
|
var
|
||||||
c: TColor;
|
c: TColor;
|
||||||
@@ -104,8 +101,6 @@ begin
|
|||||||
FR := GetRValue(FSelected);
|
FR := GetRValue(FSelected);
|
||||||
FG := GetGValue(FSelected);
|
FG := GetGValue(FSelected);
|
||||||
FB := GetBValue(FSelected);
|
FB := GetBValue(FSelected);
|
||||||
if Assigned(FOnChange) then
|
|
||||||
FOnChange(Self);
|
|
||||||
dx := x;
|
dx := x;
|
||||||
dy := y;
|
dy := y;
|
||||||
if Focused or (csDesigning in ComponentState) then
|
if Focused or (csDesigning in ComponentState) then
|
||||||
@@ -115,18 +110,10 @@ begin
|
|||||||
InternalDrawMarker(x, y, c);
|
InternalDrawMarker(x, y, c);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBAxisColorPicker.SetSelectedColor(c: TColor);
|
{ x is RED, y is GREEN }
|
||||||
|
function TBAxisColorPicker.GetGradientColor2D(x, y: Integer): TColor;
|
||||||
begin
|
begin
|
||||||
if WebSafe then c := GetWebSafe(c);
|
Result := RGB(x, FBufferBmp.Height - 1 - y, FB);
|
||||||
FR := GetRValue(c);
|
|
||||||
FG := GetGValue(c);
|
|
||||||
FB := GetBValue(c);
|
|
||||||
FSelected := c;
|
|
||||||
FManual := false;
|
|
||||||
mxx := Round(FR*(Width/255));
|
|
||||||
myy := Round((255-FG)*(Height/255));
|
|
||||||
CreateGradient;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBAxisColorPicker.Paint;
|
procedure TBAxisColorPicker.Paint;
|
||||||
@@ -144,6 +131,77 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBAxisColorPicker.SetSelectedColor(c: TColor);
|
||||||
|
begin
|
||||||
|
if WebSafe then c := GetWebSafe(c);
|
||||||
|
FR := GetRValue(c);
|
||||||
|
FG := GetGValue(c);
|
||||||
|
FB := GetBValue(c);
|
||||||
|
FSelected := c;
|
||||||
|
FManual := false;
|
||||||
|
mxx := Round(FR*(Width/255));
|
||||||
|
myy := Round((255-FG)*(Height/255));
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBAxisColorPicker.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
|
var
|
||||||
|
eraseKey: Boolean;
|
||||||
|
delta: Integer;
|
||||||
|
begin
|
||||||
|
eraseKey := true;
|
||||||
|
if (ssCtrl in Shift) then delta := 10 else delta := 1;
|
||||||
|
|
||||||
|
case Key of
|
||||||
|
VK_LEFT:
|
||||||
|
begin
|
||||||
|
mxx := dx - delta;
|
||||||
|
myy := dy;
|
||||||
|
if mxx < 0 then mxx := 0;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
|
end;
|
||||||
|
VK_RIGHT:
|
||||||
|
begin
|
||||||
|
mxx := dx + delta;
|
||||||
|
myy := dy;
|
||||||
|
if mxx >= Width then mxx := Width - 1;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
|
end;
|
||||||
|
VK_UP:
|
||||||
|
begin
|
||||||
|
mxx := dx;
|
||||||
|
myy := dy - delta;
|
||||||
|
if myy < 0 then myy := 0;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
|
end;
|
||||||
|
VK_DOWN:
|
||||||
|
begin
|
||||||
|
mxx := dx;
|
||||||
|
myy := dy + delta;
|
||||||
|
if myy >= Height then myy := Height - 1;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
eraseKey := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if eraseKey then Key := 0;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TBAxisColorPicker.MouseDown(Button: TMouseButton; Shift: TShiftState;
|
procedure TBAxisColorPicker.MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||||
X, Y: Integer);
|
X, Y: Integer);
|
||||||
var
|
var
|
||||||
@@ -154,10 +212,10 @@ begin
|
|||||||
myy := y;
|
myy := y;
|
||||||
if Button = mbLeft then
|
if Button = mbLeft then
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF DELPHI}
|
||||||
R := ClientRect;
|
R := ClientRect;
|
||||||
R.TopLeft := ClientToScreen(R.TopLeft);
|
R.TopLeft := ClientToScreen(R.TopLeft);
|
||||||
R.BottomRight := ClientToScreen(R.BottomRight);
|
R.BottomRight := ClientToScreen(R.BottomRight);
|
||||||
{$IFDEF DELPHI}
|
|
||||||
ClipCursor(@R);
|
ClipCursor(@R);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FSelected := GetColorAtPoint(x, y);
|
FSelected := GetColorAtPoint(x, y);
|
||||||
@@ -173,11 +231,15 @@ begin
|
|||||||
{$IFDEF DELPHI}
|
{$IFDEF DELPHI}
|
||||||
ClipCursor(nil);
|
ClipCursor(nil);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
mxx := x;
|
if ssLeft in Shift then
|
||||||
myy := y;
|
begin
|
||||||
FSelected := GetColorAtPoint(x, y);
|
mxx := x;
|
||||||
FManual := true;
|
myy := y;
|
||||||
Invalidate;
|
FSelected := GetColorAtPoint(x, y);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBAxisColorPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
procedure TBAxisColorPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
@@ -190,9 +252,10 @@ begin
|
|||||||
FSelected := GetColorAtPoint(x, y);
|
FSelected := GetColorAtPoint(x, y);
|
||||||
FManual := true;
|
FManual := true;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
(*
|
||||||
procedure TBAxisColorPicker.CNKeyDown(
|
procedure TBAxisColorPicker.CNKeyDown(
|
||||||
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
||||||
var
|
var
|
||||||
@@ -289,7 +352,7 @@ begin
|
|||||||
if Assigned(OnKeyDown) then
|
if Assigned(OnKeyDown) then
|
||||||
OnKeyDown(Self, Message.CharCode, Shift);
|
OnKeyDown(Self, Message.CharCode, Shift);
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
procedure TBAxisColorPicker.SetRValue(r: integer);
|
procedure TBAxisColorPicker.SetRValue(r: integer);
|
||||||
begin
|
begin
|
||||||
Clamp(r, 0, 255);
|
Clamp(r, 0, 255);
|
||||||
|
@@ -24,18 +24,21 @@ type
|
|||||||
procedure SetAValue(a: integer);
|
procedure SetAValue(a: integer);
|
||||||
procedure SetBValue(b: integer);
|
procedure SetBValue(b: integer);
|
||||||
protected
|
protected
|
||||||
|
procedure CorrectCoords(var x, y: integer);
|
||||||
|
procedure CreateWnd; override;
|
||||||
|
procedure DrawMarker(x, y: integer);
|
||||||
function GetGradientColor2D(x, y: Integer): TColor; override;
|
function GetGradientColor2D(x, y: Integer): TColor; override;
|
||||||
procedure SetSelectedColor(c: TColor); override;
|
(*
|
||||||
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
||||||
message CN_KEYDOWN;
|
message CN_KEYDOWN;
|
||||||
|
*)
|
||||||
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure DrawMarker(x, y: integer);
|
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
procedure CreateWnd; override;
|
procedure SetSelectedColor(c: TColor); override;
|
||||||
procedure CorrectCoords(var x, y: integer);
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
published
|
published
|
||||||
@@ -112,8 +115,6 @@ begin
|
|||||||
FL := Round(GetCIELValue(FSelected));
|
FL := Round(GetCIELValue(FSelected));
|
||||||
FA := Round(GetCIEAValue(FSelected));
|
FA := Round(GetCIEAValue(FSelected));
|
||||||
FB := Round(GetCIEBValue(FSelected));
|
FB := Round(GetCIEBValue(FSelected));
|
||||||
if Assigned(FOnChange) then
|
|
||||||
FOnChange(Self);
|
|
||||||
dx := x;
|
dx := x;
|
||||||
dy := y;
|
dy := y;
|
||||||
if Focused or (csDesigning in ComponentState) then
|
if Focused or (csDesigning in ComponentState) then
|
||||||
@@ -131,10 +132,11 @@ begin
|
|||||||
FB := Round(GetCIEBValue(c));
|
FB := Round(GetCIEBValue(c));
|
||||||
FSelected := c;
|
FSelected := c;
|
||||||
FManual := false;
|
FManual := false;
|
||||||
mxx := Round((FB+128)*(Width/255));
|
mxx := Round((FB + 128) * Width / 255);
|
||||||
myy := Round(((100-FL)*255/100)*(Height/255));
|
myy := Round((100 - FL) * 255 / 100 * Height / 255);
|
||||||
CreateGradient;
|
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIEAColorPicker.Paint;
|
procedure TCIEAColorPicker.Paint;
|
||||||
@@ -147,8 +149,8 @@ end;
|
|||||||
procedure TCIEAColorPicker.Resize;
|
procedure TCIEAColorPicker.Resize;
|
||||||
begin
|
begin
|
||||||
FManual := false;
|
FManual := false;
|
||||||
mxx := Round((FB+128)*(Width/255));
|
mxx := Round((FB + 128) * Width / 255);
|
||||||
myy := Round(((100-FL)*255/100)*(Height/255));
|
myy := Round(((100 - FL) * 255 / 100) * Height / 255);
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -161,15 +163,17 @@ begin
|
|||||||
myy := y;
|
myy := y;
|
||||||
if Button = mbLeft then
|
if Button = mbLeft then
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF DELPHI}
|
||||||
R := ClientRect;
|
R := ClientRect;
|
||||||
R.TopLeft := ClientToScreen(R.TopLeft);
|
R.TopLeft := ClientToScreen(R.TopLeft);
|
||||||
R.BottomRight := ClientToScreen(R.BottomRight);
|
R.BottomRight := ClientToScreen(R.BottomRight);
|
||||||
{$IFDEF DELPHI}
|
|
||||||
ClipCursor(@R);
|
ClipCursor(@R);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FSelected := GetColorAtPoint(x, y);
|
FSelected := GetColorAtPoint(x, y);
|
||||||
FManual := true;
|
FManual := true;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
end;
|
end;
|
||||||
SetFocus;
|
SetFocus;
|
||||||
end;
|
end;
|
||||||
@@ -180,11 +184,16 @@ begin
|
|||||||
{$IFDEF DELPHI}
|
{$IFDEF DELPHI}
|
||||||
ClipCursor(nil);
|
ClipCursor(nil);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
mxx := x;
|
if ssLeft in Shift then
|
||||||
myy := y;
|
begin
|
||||||
FSelected := GetColorAtPoint(x, y);
|
mxx := x;
|
||||||
FManual := true;
|
myy := y;
|
||||||
Invalidate;
|
FSelected := GetColorAtPoint(x, y);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIEAColorPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
procedure TCIEAColorPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
@@ -197,104 +206,70 @@ begin
|
|||||||
FSelected := GetColorAtPoint(x, y);
|
FSelected := GetColorAtPoint(x, y);
|
||||||
FManual := true;
|
FManual := true;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIEAColorPicker.CNKeyDown(
|
procedure TCIEAColorPicker.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
|
||||||
var
|
var
|
||||||
Shift: TShiftState;
|
eraseKey: Boolean;
|
||||||
FInherited: boolean;
|
delta: Integer;
|
||||||
begin
|
begin
|
||||||
FInherited := false;
|
eraseKey := true;
|
||||||
Shift := KeyDataToShiftState(Message.KeyData);
|
if (ssCtrl in Shift) then delta := 10 else delta := 1;
|
||||||
if not (ssCtrl in Shift) then
|
|
||||||
case Message.CharCode of
|
case Key of
|
||||||
VK_LEFT:
|
VK_LEFT:
|
||||||
begin
|
begin
|
||||||
mxx := dx - 1;
|
mxx := dx - delta;
|
||||||
myy := dy;
|
myy := dy;
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
if mxx < 0 then mxx := 0;
|
||||||
FManual := true;
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
Invalidate;
|
FManual := true;
|
||||||
end;
|
Invalidate;
|
||||||
VK_RIGHT:
|
if Assigned(FOnChange) then
|
||||||
begin
|
FOnChange(Self);
|
||||||
mxx := dx + 1;
|
end;
|
||||||
myy := dy;
|
VK_RIGHT:
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
begin
|
||||||
FManual := true;
|
mxx := dx + delta;
|
||||||
Invalidate;
|
myy := dy;
|
||||||
end;
|
if mxx >= Width then mxx := Width - 1;
|
||||||
VK_UP:
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
begin
|
FManual := true;
|
||||||
mxx := dx;
|
Invalidate;
|
||||||
myy := dy - 1;
|
if Assigned(FOnChange) then
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
FOnChange(Self);
|
||||||
FManual := true;
|
end;
|
||||||
Invalidate;
|
VK_UP:
|
||||||
end;
|
begin
|
||||||
VK_DOWN:
|
mxx := dx;
|
||||||
begin
|
myy := dy - delta;
|
||||||
mxx := dx;
|
if myy < 0 then myy := 0;
|
||||||
myy := dy + 1;
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
FManual := true;
|
||||||
FManual := true;
|
Invalidate;
|
||||||
Invalidate;
|
if Assigned(FOnChange) then
|
||||||
end;
|
FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_DOWN:
|
||||||
|
begin
|
||||||
|
mxx := dx;
|
||||||
|
myy := dy + delta;
|
||||||
|
if myy >= Height then myy := Height - 1;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
|
end;
|
||||||
else
|
else
|
||||||
begin
|
eraseKey := false;
|
||||||
FInherited := true;
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
case Message.CharCode of
|
|
||||||
VK_LEFT:
|
|
||||||
begin
|
|
||||||
mxx := dx - 10;
|
|
||||||
myy := dy;
|
|
||||||
Refresh;
|
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
|
||||||
FManual := true;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
VK_RIGHT:
|
|
||||||
begin
|
|
||||||
mxx := dx + 10;
|
|
||||||
myy := dy;
|
|
||||||
Refresh;
|
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
|
||||||
FManual := true;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
VK_UP:
|
|
||||||
begin
|
|
||||||
mxx := dx;
|
|
||||||
myy := dy - 10;
|
|
||||||
Refresh;
|
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
|
||||||
FManual := true;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
VK_DOWN:
|
|
||||||
begin
|
|
||||||
mxx := dx;
|
|
||||||
myy := dy + 10;
|
|
||||||
Refresh;
|
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
|
||||||
FManual := true;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
FInherited := true;
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
if not FInherited then
|
|
||||||
if Assigned(OnKeyDown) then
|
if eraseKey then Key := 0;
|
||||||
OnKeyDown(Self, Message.CharCode, Shift);
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIEAColorPicker.SetLValue(l: integer);
|
procedure TCIEAColorPicker.SetLValue(l: integer);
|
||||||
|
@@ -27,18 +27,20 @@ type
|
|||||||
procedure SetAValue(a: integer);
|
procedure SetAValue(a: integer);
|
||||||
procedure SetBValue(b: integer);
|
procedure SetBValue(b: integer);
|
||||||
protected
|
protected
|
||||||
|
procedure CorrectCoords(var x, y: integer);
|
||||||
|
procedure CreateWnd; override;
|
||||||
|
procedure DrawMarker(x, y: integer);
|
||||||
function GetGradientColor2D(x, y: Integer): TColor; override;
|
function GetGradientColor2D(x, y: Integer): TColor; override;
|
||||||
procedure SetSelectedColor(c: TColor); override;
|
(*
|
||||||
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
||||||
message CN_KEYDOWN;
|
message CN_KEYDOWN;*)
|
||||||
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure DrawMarker(x, y: integer);
|
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
procedure CreateWnd; override;
|
procedure SetSelectedColor(c: TColor); override;
|
||||||
procedure CorrectCoords(var x, y: integer);
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
published
|
published
|
||||||
@@ -110,8 +112,6 @@ begin
|
|||||||
FL := Round(GetCIELValue(FSelected));
|
FL := Round(GetCIELValue(FSelected));
|
||||||
FA := Round(GetCIEAValue(FSelected));
|
FA := Round(GetCIEAValue(FSelected));
|
||||||
FB := Round(GetCIEBValue(FSelected));
|
FB := Round(GetCIEBValue(FSelected));
|
||||||
if Assigned(FOnChange) then
|
|
||||||
FOnChange(Self);
|
|
||||||
dx := x;
|
dx := x;
|
||||||
dy := y;
|
dy := y;
|
||||||
if Focused or (csDesigning in ComponentState) then
|
if Focused or (csDesigning in ComponentState) then
|
||||||
@@ -129,10 +129,11 @@ begin
|
|||||||
FB := Round(GetCIEBValue(c));
|
FB := Round(GetCIEBValue(c));
|
||||||
FSelected := c;
|
FSelected := c;
|
||||||
FManual := false;
|
FManual := false;
|
||||||
mxx := Round((FA+128)*(Width/255));
|
mxx := Round((FA + 128) * Width / 255);
|
||||||
myy := Round(((100-FL)*255/100)*(Height/255));
|
myy := Round((100 - FL) * 255 / 100* Height / 255);
|
||||||
CreateGradient;
|
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIEBColorPicker.Paint;
|
procedure TCIEBColorPicker.Paint;
|
||||||
@@ -175,14 +176,19 @@ end;
|
|||||||
procedure TCIEBColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure TCIEBColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
{$IFDEF DELPHI}
|
if ssLeft in Shift then
|
||||||
ClipCursor(nil);
|
begin
|
||||||
{$ENDIF}
|
{$IFDEF DELPHI}
|
||||||
mxx := x;
|
ClipCursor(nil);
|
||||||
myy := y;
|
{$ENDIF}
|
||||||
FSelected := GetColorAtPoint(x, y);
|
mxx := x;
|
||||||
FManual := true;
|
myy := y;
|
||||||
Invalidate;
|
FSelected := GetColorAtPoint(x, y);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIEBColorPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
procedure TCIEBColorPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
@@ -195,104 +201,70 @@ begin
|
|||||||
FSelected := GetColorAtPoint(x, y);
|
FSelected := GetColorAtPoint(x, y);
|
||||||
FManual := true;
|
FManual := true;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIEBColorPicker.CNKeyDown(
|
procedure TCIEBColorPicker.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
|
||||||
var
|
var
|
||||||
Shift: TShiftState;
|
eraseKey: Boolean;
|
||||||
FInherited: boolean;
|
delta: Integer;
|
||||||
begin
|
begin
|
||||||
FInherited := false;
|
eraseKey := true;
|
||||||
Shift := KeyDataToShiftState(Message.KeyData);
|
if (ssCtrl in Shift) then delta := 10 else delta := 1;
|
||||||
if not (ssCtrl in Shift) then
|
|
||||||
case Message.CharCode of
|
case Key of
|
||||||
VK_LEFT:
|
VK_LEFT:
|
||||||
begin
|
begin
|
||||||
mxx := dx - 1;
|
mxx := dx - delta;
|
||||||
myy := dy;
|
myy := dy;
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
if myy < 0 then myy := 0;
|
||||||
FManual := true;
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
Invalidate;
|
FManual := true;
|
||||||
end;
|
Invalidate;
|
||||||
VK_RIGHT:
|
if Assigned(FOnChange) then
|
||||||
begin
|
FOnChange(Self);
|
||||||
mxx := dx + 1;
|
end;
|
||||||
myy := dy;
|
VK_RIGHT:
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
begin
|
||||||
FManual := true;
|
mxx := dx + delta;
|
||||||
Invalidate;
|
myy := dy;
|
||||||
end;
|
if myy >= Width then myy := Width - 1;
|
||||||
VK_UP:
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
begin
|
FManual := true;
|
||||||
mxx := dx;
|
Invalidate;
|
||||||
myy := dy - 1;
|
if Assigned(FOnChange) then
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
FOnChange(Self);
|
||||||
FManual := true;
|
end;
|
||||||
Invalidate;
|
VK_UP:
|
||||||
end;
|
begin
|
||||||
VK_DOWN:
|
mxx := dx;
|
||||||
begin
|
myy := dy - delta;
|
||||||
mxx := dx;
|
if myy < 0 then myy := 0;
|
||||||
myy := dy + 1;
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
FManual := true;
|
||||||
FManual := true;
|
Invalidate;
|
||||||
Invalidate;
|
if Assigned(FOnChange) then
|
||||||
end;
|
FOnChange(Self);
|
||||||
else
|
end;
|
||||||
begin
|
VK_DOWN:
|
||||||
FInherited := true;
|
begin
|
||||||
inherited;
|
mxx := dx;
|
||||||
end;
|
myy := dy + delta;
|
||||||
end
|
if myy >= Height then myy := Height - 1;
|
||||||
else
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
case Message.CharCode of
|
FManual := true;
|
||||||
VK_LEFT:
|
Invalidate;
|
||||||
begin
|
if Assigned(FOnChange) then
|
||||||
mxx := dx - 10;
|
FOnChange(Self);
|
||||||
myy := dy;
|
end;
|
||||||
Refresh;
|
else
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
eraseKey := false;
|
||||||
FManual := true;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
VK_RIGHT:
|
|
||||||
begin
|
|
||||||
mxx := dx + 10;
|
|
||||||
myy := dy;
|
|
||||||
Refresh;
|
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
|
||||||
FManual := true;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
VK_UP:
|
|
||||||
begin
|
|
||||||
mxx := dx;
|
|
||||||
myy := dy - 10;
|
|
||||||
Refresh;
|
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
|
||||||
FManual := true;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
VK_DOWN:
|
|
||||||
begin
|
|
||||||
mxx := dx;
|
|
||||||
myy := dy + 10;
|
|
||||||
Refresh;
|
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
|
||||||
FManual := true;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
FInherited := true;
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
if not FInherited then
|
|
||||||
if Assigned(OnKeyDown) then
|
if eraseKey then Key := 0;
|
||||||
OnKeyDown(Self, Message.CharCode, Shift);
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIEBColorPicker.SetLValue(L: integer);
|
procedure TCIEBColorPicker.SetLValue(L: integer);
|
||||||
|
@@ -24,18 +24,21 @@ type
|
|||||||
procedure SetAValue(a: integer);
|
procedure SetAValue(a: integer);
|
||||||
procedure SetBValue(b: integer);
|
procedure SetBValue(b: integer);
|
||||||
protected
|
protected
|
||||||
|
procedure CorrectCoords(var x, y: integer);
|
||||||
|
procedure CreateWnd; override;
|
||||||
|
procedure DrawMarker(x, y: integer);
|
||||||
function GetGradientColor2D(x, y: Integer): TColor; override;
|
function GetGradientColor2D(x, y: Integer): TColor; override;
|
||||||
procedure SetSelectedColor(c: TColor); override;
|
(*
|
||||||
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
||||||
message CN_KEYDOWN;
|
message CN_KEYDOWN;
|
||||||
|
*)
|
||||||
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure DrawMarker(x, y: integer);
|
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
procedure CreateWnd; override;
|
procedure SetSelectedColor(c: TColor); override;
|
||||||
procedure CorrectCoords(var x, y: integer);
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
published
|
published
|
||||||
@@ -77,6 +80,7 @@ begin
|
|||||||
mxx := 0;
|
mxx := 0;
|
||||||
myy := 0;
|
myy := 0;
|
||||||
MarkerStyle := msCircle;
|
MarkerStyle := msCircle;
|
||||||
|
SetSelectedColor(clAqua);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIELColorPicker.CreateWnd;
|
procedure TCIELColorPicker.CreateWnd;
|
||||||
@@ -105,8 +109,6 @@ begin
|
|||||||
FL := Round(GetCIELValue(FSelected));
|
FL := Round(GetCIELValue(FSelected));
|
||||||
FA := Round(GetCIEAValue(FSelected));
|
FA := Round(GetCIEAValue(FSelected));
|
||||||
FB := Round(GetCIEBValue(FSelected));
|
FB := Round(GetCIEBValue(FSelected));
|
||||||
if Assigned(FOnChange) then
|
|
||||||
FOnChange(Self);
|
|
||||||
dx := x;
|
dx := x;
|
||||||
dy := y;
|
dy := y;
|
||||||
if Focused or (csDesigning in ComponentState) then
|
if Focused or (csDesigning in ComponentState) then
|
||||||
@@ -124,10 +126,11 @@ begin
|
|||||||
FB := Round(GetCIEBValue(c));
|
FB := Round(GetCIEBValue(c));
|
||||||
FSelected := c;
|
FSelected := c;
|
||||||
FManual := false;
|
FManual := false;
|
||||||
mxx := Round((FA+128)*(Width/255));
|
mxx := Round((FA + 128) * Width / 255);
|
||||||
myy := Round((255-(FB+128))*(Height/255));
|
myy := Round((255 - (FB + 128)) * Height / 255);
|
||||||
CreateGradient;
|
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIELColorPicker.Paint;
|
procedure TCIELColorPicker.Paint;
|
||||||
@@ -140,8 +143,8 @@ end;
|
|||||||
procedure TCIELColorPicker.Resize;
|
procedure TCIELColorPicker.Resize;
|
||||||
begin
|
begin
|
||||||
FManual := false;
|
FManual := false;
|
||||||
mxx := Round((FA+128)*(Width/255));
|
mxx := Round((FA + 128) * Width / 255);
|
||||||
myy := Round((255-(FB+128))*(Height/255));
|
myy := Round((255 - (FB + 128)) * Height / 255);
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -170,14 +173,19 @@ end;
|
|||||||
procedure TCIELColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure TCIELColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
{$IFDEF DELPHI}
|
if ssLeft in Shift then
|
||||||
ClipCursor(nil);
|
begin
|
||||||
{$ENDIF}
|
{$IFDEF DELPHI}
|
||||||
mxx := x;
|
ClipCursor(nil);
|
||||||
myy := y;
|
{$ENDIF}
|
||||||
FSelected := GetColorAtPoint(x, y);
|
mxx := x;
|
||||||
FManual := true;
|
myy := y;
|
||||||
Invalidate;
|
FSelected := GetColorAtPoint(x, y);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIELColorPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
procedure TCIELColorPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
@@ -190,104 +198,69 @@ begin
|
|||||||
FSelected := GetColorAtPoint(x, y);
|
FSelected := GetColorAtPoint(x, y);
|
||||||
FManual := true;
|
FManual := true;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIELColorPicker.CNKeyDown(
|
procedure TCIELColorPicker.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
|
||||||
var
|
var
|
||||||
Shift: TShiftState;
|
eraseKey: Boolean;
|
||||||
FInherited: boolean;
|
delta: Integer;
|
||||||
begin
|
begin
|
||||||
FInherited := false;
|
erasekey := true;
|
||||||
Shift := KeyDataToShiftState(Message.KeyData);
|
if (ssCtrl in Shift) then delta := 10 else delta := 1;
|
||||||
if not (ssCtrl in Shift) then
|
case Key of
|
||||||
case Message.CharCode of
|
VK_LEFT:
|
||||||
VK_LEFT:
|
begin
|
||||||
begin
|
mxx := dx - delta;
|
||||||
mxx := dx - 1;
|
myy := dy;
|
||||||
myy := dy;
|
if mxx < 0 then mxx := 0;
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
FManual := true;
|
FManual := true;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
if Assigned(FOnChange) then
|
||||||
VK_RIGHT:
|
FOnChange(Self);
|
||||||
begin
|
end;
|
||||||
mxx := dx + 1;
|
VK_RIGHT:
|
||||||
myy := dy;
|
begin
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
mxx := dx + delta;
|
||||||
FManual := true;
|
myy := dy;
|
||||||
Invalidate;
|
if mxx >= Width then mxx := Width - 1;
|
||||||
end;
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
VK_UP:
|
FManual := true;
|
||||||
begin
|
Invalidate;
|
||||||
mxx := dx;
|
if Assigned(FOnChange) then
|
||||||
myy := dy - 1;
|
FOnChange(Self);
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
end;
|
||||||
FManual := true;
|
VK_UP:
|
||||||
Invalidate;
|
begin
|
||||||
end;
|
mxx := dx;
|
||||||
VK_DOWN:
|
myy := dy - delta;
|
||||||
begin
|
if myy < 0 then myy := 0;
|
||||||
mxx := dx;
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
myy := dy + 1;
|
FManual := true;
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
Invalidate;
|
||||||
FManual := true;
|
if Assigned(FOnChange) then
|
||||||
Invalidate;
|
FOnChange(Self);
|
||||||
end;
|
end;
|
||||||
|
VK_DOWN:
|
||||||
|
begin
|
||||||
|
mxx := dx;
|
||||||
|
myy := dy + delta;
|
||||||
|
if myy >= Height then myy := Height - 1;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
|
end;
|
||||||
else
|
else
|
||||||
begin
|
eraseKey := false;
|
||||||
FInherited := true;
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
case Message.CharCode of
|
|
||||||
VK_LEFT:
|
|
||||||
begin
|
|
||||||
mxx := dx - 10;
|
|
||||||
myy := dy;
|
|
||||||
Refresh;
|
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
|
||||||
FManual := true;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
VK_RIGHT:
|
|
||||||
begin
|
|
||||||
mxx := dx + 10;
|
|
||||||
myy := dy;
|
|
||||||
Refresh;
|
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
|
||||||
FManual := true;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
VK_UP:
|
|
||||||
begin
|
|
||||||
mxx := dx;
|
|
||||||
myy := dy - 10;
|
|
||||||
Refresh;
|
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
|
||||||
FManual := true;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
VK_DOWN:
|
|
||||||
begin
|
|
||||||
mxx := dx;
|
|
||||||
myy := dy + 10;
|
|
||||||
Refresh;
|
|
||||||
FSelected := GetColorAtPoint(mxx, myy);
|
|
||||||
FManual := true;
|
|
||||||
Invalidate;
|
|
||||||
end;
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
FInherited := true;
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
if not FInherited then
|
|
||||||
if Assigned(OnKeyDown) then
|
if eraseKey then Key := 0;
|
||||||
OnKeyDown(Self, Message.CharCode, Shift);
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCIELColorPicker.SetLValue(l: integer);
|
procedure TCIELColorPicker.SetLValue(l: integer);
|
||||||
|
@@ -24,18 +24,21 @@ type
|
|||||||
procedure SetGValue(g: integer);
|
procedure SetGValue(g: integer);
|
||||||
procedure SetBValue(b: integer);
|
procedure SetBValue(b: integer);
|
||||||
protected
|
protected
|
||||||
|
procedure CorrectCoords(var x, y: integer);
|
||||||
|
procedure CreateWnd; override;
|
||||||
|
procedure DrawMarker(x, y: integer);
|
||||||
function GetGradientColor2D(x, y: Integer): TColor; override;
|
function GetGradientColor2D(x, y: Integer): TColor; override;
|
||||||
procedure SetSelectedColor(c: TColor); override;
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
|
(*
|
||||||
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
||||||
message CN_KEYDOWN;
|
message CN_KEYDOWN;
|
||||||
|
*)
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure DrawMarker(x, y: integer);
|
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
procedure CreateWnd; override;
|
procedure SetSelectedColor(c: TColor); override;
|
||||||
procedure CorrectCoords(var x, y: integer);
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
published
|
published
|
||||||
@@ -78,6 +81,12 @@ begin
|
|||||||
MarkerStyle := msCircle;
|
MarkerStyle := msCircle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TGAxisColorPicker.CorrectCoords(var x, y: integer);
|
||||||
|
begin
|
||||||
|
Clamp(x, 0, Width-1);
|
||||||
|
Clamp(y, 0, Height-1);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TGAxisColorPicker.CreateWnd;
|
procedure TGAxisColorPicker.CreateWnd;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
@@ -89,12 +98,6 @@ begin
|
|||||||
Result := RGB(FBufferBmp.Height - 1 - y, FG, x);
|
Result := RGB(FBufferBmp.Height - 1 - y, FG, x);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGAxisColorPicker.CorrectCoords(var x, y: integer);
|
|
||||||
begin
|
|
||||||
Clamp(x, 0, Width-1);
|
|
||||||
Clamp(y, 0, Height-1);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TGAxisColorPicker.DrawMarker(x, y: integer);
|
procedure TGAxisColorPicker.DrawMarker(x, y: integer);
|
||||||
var
|
var
|
||||||
c: TColor;
|
c: TColor;
|
||||||
@@ -103,8 +106,6 @@ begin
|
|||||||
FR := GetRValue(FSelected);
|
FR := GetRValue(FSelected);
|
||||||
FG := GetGValue(FSelected);
|
FG := GetGValue(FSelected);
|
||||||
FB := GetBValue(FSelected);
|
FB := GetBValue(FSelected);
|
||||||
if Assigned(FOnChange) then
|
|
||||||
FOnChange(Self);
|
|
||||||
dx := x;
|
dx := x;
|
||||||
dy := y;
|
dy := y;
|
||||||
if Focused or (csDesigning in ComponentState) then
|
if Focused or (csDesigning in ComponentState) then
|
||||||
@@ -122,10 +123,11 @@ begin
|
|||||||
FB := GetBValue(c);
|
FB := GetBValue(c);
|
||||||
FSelected := c;
|
FSelected := c;
|
||||||
FManual := false;
|
FManual := false;
|
||||||
myy := Round((255-FR)*(Height/255));
|
myy := Round((255 - FR) * Height / 255);
|
||||||
mxx := Round(FB*(Width/255));
|
mxx := Round(FB * Width / 255);
|
||||||
CreateGradient;
|
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGAxisColorPicker.Paint;
|
procedure TGAxisColorPicker.Paint;
|
||||||
@@ -138,8 +140,69 @@ end;
|
|||||||
procedure TGAxisColorPicker.Resize;
|
procedure TGAxisColorPicker.Resize;
|
||||||
begin
|
begin
|
||||||
FManual := false;
|
FManual := false;
|
||||||
myy := Round((255-FR)*(Height/255));
|
myy := Round((255 - FR) * Height / 255);
|
||||||
mxx := Round(FB*(Width/255));
|
mxx := Round(FB * Width / 255);
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGAxisColorPicker.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
|
var
|
||||||
|
eraseKey: Boolean;
|
||||||
|
delta: Integer;
|
||||||
|
begin
|
||||||
|
eraseKey := true;
|
||||||
|
if (ssCtrl in Shift) then delta := 10 else delta := 1;
|
||||||
|
|
||||||
|
case Key of
|
||||||
|
VK_LEFT:
|
||||||
|
begin
|
||||||
|
mxx := dx - delta;
|
||||||
|
myy := dy;
|
||||||
|
if mxx < 0 then mxx := 0;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_RIGHT:
|
||||||
|
begin
|
||||||
|
mxx := dx + delta;
|
||||||
|
myy := dy;
|
||||||
|
if mxx >= Width then mxx := Width - 1;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_UP:
|
||||||
|
begin
|
||||||
|
mxx := dx;
|
||||||
|
myy := dy - delta;
|
||||||
|
if myy < 0 then myy := 0;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_DOWN:
|
||||||
|
begin
|
||||||
|
mxx := dx;
|
||||||
|
myy := dy + delta;
|
||||||
|
if myy >= Height then myy := Height - 1;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
eraseKey := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if eraseKey then Key := 0;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -152,10 +215,10 @@ begin
|
|||||||
myy := y;
|
myy := y;
|
||||||
if Button = mbLeft then
|
if Button = mbLeft then
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF DELPHI}
|
||||||
R := ClientRect;
|
R := ClientRect;
|
||||||
R.TopLeft := ClientToScreen(R.TopLeft);
|
R.TopLeft := ClientToScreen(R.TopLeft);
|
||||||
R.BottomRight := ClientToScreen(R.BottomRight);
|
R.BottomRight := ClientToScreen(R.BottomRight);
|
||||||
{$IFDEF DELPHI}
|
|
||||||
ClipCursor(@R);
|
ClipCursor(@R);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FSelected := GetColorAtPoint(x, y);
|
FSelected := GetColorAtPoint(x, y);
|
||||||
@@ -168,14 +231,19 @@ end;
|
|||||||
procedure TGAxisColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure TGAxisColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
{$IFDEF DELPHI}
|
if ssLeft in Shift then
|
||||||
ClipCursor(nil);
|
begin
|
||||||
{$ENDIF}
|
{$IFDEF DELPHI}
|
||||||
mxx := X;
|
ClipCursor(nil);
|
||||||
myy := Y;
|
{$ENDIF}
|
||||||
FSelected := GetColorAtPoint(X, Y);
|
mxx := X;
|
||||||
FManual := true;
|
myy := Y;
|
||||||
Invalidate;
|
FSelected := GetColorAtPoint(X, Y);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGAxisColorPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
procedure TGAxisColorPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
@@ -188,9 +256,11 @@ begin
|
|||||||
FSelected := GetColorAtPoint(X, Y);
|
FSelected := GetColorAtPoint(X, Y);
|
||||||
FManual := true;
|
FManual := true;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then
|
||||||
|
FOnChange(Self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
(*
|
||||||
procedure TGAxisColorPicker.CNKeyDown(
|
procedure TGAxisColorPicker.CNKeyDown(
|
||||||
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
||||||
var
|
var
|
||||||
@@ -287,7 +357,7 @@ begin
|
|||||||
if Assigned(OnKeyDown) then
|
if Assigned(OnKeyDown) then
|
||||||
OnKeyDown(Self, Message.CharCode, Shift);
|
OnKeyDown(Self, Message.CharCode, Shift);
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
procedure TGAxisColorPicker.SetRValue(r: integer);
|
procedure TGAxisColorPicker.SetRValue(r: integer);
|
||||||
begin
|
begin
|
||||||
Clamp(r, 0, 255);
|
Clamp(r, 0, 255);
|
||||||
|
@@ -51,12 +51,15 @@ type
|
|||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
// procedure CreateWnd; override;
|
// procedure CreateWnd; override;
|
||||||
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
function MouseOnPicker(X, Y: Integer): Boolean; override;
|
function MouseOnPicker(X, Y: Integer): Boolean;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
|
(*
|
||||||
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
||||||
message CN_KEYDOWN;
|
message CN_KEYDOWN;
|
||||||
|
*)
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
function GetColorAtPoint(x, y: integer): TColor; override;
|
function GetColorAtPoint(x, y: integer): TColor; override;
|
||||||
@@ -185,7 +188,8 @@ end;
|
|||||||
|
|
||||||
procedure THRingPicker.SetHue(h: integer);
|
procedure THRingPicker.SetHue(h: integer);
|
||||||
begin
|
begin
|
||||||
Clamp(h, 0, FMaxHue);
|
if h > FMaxHue then h := h - (FMaxHue + 1);
|
||||||
|
if h < 0 then h := h + (FMaxHue + 1);
|
||||||
if GetHue() <> h then
|
if GetHue() <> h then
|
||||||
begin
|
begin
|
||||||
FHue := h / FMaxHue;
|
FHue := h / FMaxHue;
|
||||||
@@ -339,6 +343,42 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure THRingPicker.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
|
var
|
||||||
|
eraseKey: Boolean;
|
||||||
|
delta: Integer;
|
||||||
|
begin
|
||||||
|
eraseKey := true;
|
||||||
|
if ssCtrl in Shift then
|
||||||
|
delta := 10
|
||||||
|
else
|
||||||
|
delta := 1;
|
||||||
|
|
||||||
|
case Key of
|
||||||
|
VK_LEFT:
|
||||||
|
begin
|
||||||
|
FChange := false;
|
||||||
|
SetHue(RadHue(GetHue() + delta));
|
||||||
|
FChange := true;
|
||||||
|
FManual := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_RIGHT:
|
||||||
|
begin
|
||||||
|
FChange := false;
|
||||||
|
SetHue(RadHue(GetHue() - delta));
|
||||||
|
FChange := true;
|
||||||
|
FManual := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
erasekey := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if eraseKey then Key := 0;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure THRingPicker.MouseUp(Button: TMouseButton; Shift: TShiftState;
|
procedure THRingPicker.MouseUp(Button: TMouseButton; Shift: TShiftState;
|
||||||
X, Y: Integer);
|
X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
@@ -475,7 +515,7 @@ begin
|
|||||||
if New > (FMaxHue + 1) then New := New - (FMaxHue + 1);
|
if New > (FMaxHue + 1) then New := New - (FMaxHue + 1);
|
||||||
Result := New;
|
Result := New;
|
||||||
end;
|
end;
|
||||||
|
(*
|
||||||
procedure THRingPicker.CNKeyDown(
|
procedure THRingPicker.CNKeyDown(
|
||||||
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
||||||
var
|
var
|
||||||
@@ -516,5 +556,5 @@ begin
|
|||||||
if Assigned(OnKeyDown) then
|
if Assigned(OnKeyDown) then
|
||||||
OnKeyDown(Self, Message.CharCode, Shift);
|
OnKeyDown(Self, Message.CharCode, Shift);
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
end.
|
end.
|
||||||
|
@@ -39,8 +39,11 @@ type
|
|||||||
procedure CorrectCoords(var x, y: integer);
|
procedure CorrectCoords(var x, y: integer);
|
||||||
function GetGradientColor2D(X, Y: Integer): TColor; override;
|
function GetGradientColor2D(X, Y: Integer): TColor; override;
|
||||||
procedure SetSelectedColor(c: TColor); override;
|
procedure SetSelectedColor(c: TColor); override;
|
||||||
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
|
(*
|
||||||
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
||||||
message CN_KEYDOWN;
|
message CN_KEYDOWN;
|
||||||
|
*)
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
@@ -187,6 +190,63 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure THSColorPicker.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
|
var
|
||||||
|
eraseKey: Boolean;
|
||||||
|
delta: Integer;
|
||||||
|
begin
|
||||||
|
eraseKey := true;
|
||||||
|
if (ssCtrl in Shift) then
|
||||||
|
delta := 10
|
||||||
|
else
|
||||||
|
delta := 1;
|
||||||
|
case Key of
|
||||||
|
VK_LEFT:
|
||||||
|
begin
|
||||||
|
mxx := dx - delta;
|
||||||
|
myy := dy;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
if Assigned(OnChange) then OnChange(Self);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
VK_RIGHT:
|
||||||
|
begin
|
||||||
|
mxx := dx + delta;
|
||||||
|
myy := dy;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
if Assigned(OnChange) then OnChange(Self);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
VK_UP:
|
||||||
|
begin
|
||||||
|
mxx := dx;
|
||||||
|
myy := dy - delta;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
if Assigned(OnChange) then OnChange(Self);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
VK_DOWN:
|
||||||
|
begin
|
||||||
|
mxx := dx;
|
||||||
|
myy := dy + delta;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
if Assigned(OnChange) then OnChange(Self);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
eraseKey := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if eraseKey then
|
||||||
|
Key := 0;
|
||||||
|
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure THSColorPicker.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure THSColorPicker.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
{$IFDEF DELPHI}
|
{$IFDEF DELPHI}
|
||||||
var
|
var
|
||||||
@@ -249,6 +309,7 @@ begin
|
|||||||
Result := HSLToRGB(H, S, L);
|
Result := HSLToRGB(H, S, L);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
(*
|
||||||
procedure THSColorPicker.CNKeyDown(
|
procedure THSColorPicker.CNKeyDown(
|
||||||
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
||||||
var
|
var
|
||||||
@@ -306,6 +367,7 @@ begin
|
|||||||
if Assigned(OnKeyDown) then
|
if Assigned(OnKeyDown) then
|
||||||
OnKeyDown(Self, Message.CharCode, Shift);
|
OnKeyDown(Self, Message.CharCode, Shift);
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
|
|
||||||
procedure THSColorPicker.SetHue(H: integer);
|
procedure THSColorPicker.SetHue(H: integer);
|
||||||
begin
|
begin
|
||||||
|
@@ -137,6 +137,7 @@ begin
|
|||||||
FLumIncrement := 1;
|
FLumIncrement := 1;
|
||||||
FHSCursor := crDefault;
|
FHSCursor := crDefault;
|
||||||
FLCursor := crDefault;
|
FLCursor := crDefault;
|
||||||
|
|
||||||
with FHSPicker do
|
with FHSPicker do
|
||||||
begin
|
begin
|
||||||
{$IFDEF DELPHI}
|
{$IFDEF DELPHI}
|
||||||
@@ -155,6 +156,7 @@ begin
|
|||||||
OnChange := HSPickerChange;
|
OnChange := HSPickerChange;
|
||||||
OnMouseMove := DoMouseMove;
|
OnMouseMove := DoMouseMove;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FLPicker := TLColorPicker.Create(Self);
|
FLPicker := TLColorPicker.Create(Self);
|
||||||
InsertControl(FLPicker);
|
InsertControl(FLPicker);
|
||||||
with FLPicker do
|
with FLPicker do
|
||||||
@@ -177,6 +179,7 @@ begin
|
|||||||
OnChange := LPickerChange;
|
OnChange := LPickerChange;
|
||||||
OnMouseMove := DoMouseMove;
|
OnMouseMove := DoMouseMove;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Hue := 0;
|
Hue := 0;
|
||||||
Saturation := 240;
|
Saturation := 240;
|
||||||
Luminance := 120;
|
Luminance := 120;
|
||||||
@@ -190,8 +193,8 @@ end;
|
|||||||
destructor THSLColorPicker.Destroy;
|
destructor THSLColorPicker.Destroy;
|
||||||
begin
|
begin
|
||||||
PBack.Free;
|
PBack.Free;
|
||||||
FHSPicker.Free;
|
//FHSPicker.Free;
|
||||||
FLPicker.Free;
|
//FLPicker.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@@ -62,11 +62,14 @@ type
|
|||||||
procedure SLPickerChange(Sender: TObject);
|
procedure SLPickerChange(Sender: TObject);
|
||||||
procedure DoChange;
|
procedure DoChange;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
|
procedure SetFocus; override;
|
||||||
|
(*
|
||||||
{$IFDEF DELPHI}
|
{$IFDEF DELPHI}
|
||||||
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
|
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS;
|
procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
*)
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@@ -131,12 +134,16 @@ begin
|
|||||||
{$ELSE}
|
{$ELSE}
|
||||||
SetInitialBounds(0, 0, 245, 245);
|
SetInitialBounds(0, 0, 245, 245);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
TabStop := true;
|
TabStop := true;
|
||||||
FSelectedColor := clRed;
|
FSelectedColor := clRed;
|
||||||
FRingPicker := THRingPicker.Create(Self);
|
|
||||||
InsertControl(FRingPicker);
|
|
||||||
FRingCursor := crDefault;
|
FRingCursor := crDefault;
|
||||||
FSLCursor := crDefault;
|
FSLCursor := crDefault;
|
||||||
|
FRingHint := 'Hue: %h';
|
||||||
|
FSLHint := 'S: %hslS L: %l'#13'Hex: %hex';
|
||||||
|
|
||||||
|
FRingPicker := THRingPicker.Create(Self);
|
||||||
|
InsertControl(FRingPicker);
|
||||||
with FRingPicker do
|
with FRingPicker do
|
||||||
begin
|
begin
|
||||||
{$IFDEF DELPHI}
|
{$IFDEF DELPHI}
|
||||||
@@ -156,6 +163,7 @@ begin
|
|||||||
OnChange := RingPickerChange;
|
OnChange := RingPickerChange;
|
||||||
OnMouseMove := DoMouseMove;
|
OnMouseMove := DoMouseMove;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FSLPicker := TSLColorPicker.Create(Self);
|
FSLPicker := TSLColorPicker.Create(Self);
|
||||||
InsertControl(FSLPicker);
|
InsertControl(FSLPicker);
|
||||||
with FSLPicker do
|
with FSLPicker do
|
||||||
@@ -176,15 +184,13 @@ begin
|
|||||||
OnChange := SLPickerChange;
|
OnChange := SLPickerChange;
|
||||||
OnMouseMove := DoMouseMove;
|
OnMouseMove := DoMouseMove;
|
||||||
end;
|
end;
|
||||||
FRingHint := 'Hue: %h';
|
|
||||||
FSLHint := 'S: %hslS L: %l'#13'Hex: %hex';
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor THSLRingPicker.Destroy;
|
destructor THSLRingPicker.Destroy;
|
||||||
begin
|
begin
|
||||||
PBack.Free;
|
PBack.Free;
|
||||||
FRingPicker.Free;
|
//FRingPicker.Free;
|
||||||
FSLPicker.Free;
|
//FSLPicker.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -197,7 +203,7 @@ begin
|
|||||||
if (FRingPicker = nil) or (FSLPicker = nil) then
|
if (FRingPicker = nil) or (FSLPicker = nil) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
ctr := Min(Width, Height)/100;
|
ctr := Min(Width, Height) / 100;
|
||||||
circ.x := Min(Width, Height) div 2;
|
circ.x := Min(Width, Height) div 2;
|
||||||
circ.y := circ.x;
|
circ.y := circ.x;
|
||||||
|
|
||||||
@@ -350,13 +356,20 @@ begin
|
|||||||
FSLCursor := c;
|
FSLCursor := c;
|
||||||
FSLPicker.Cursor := c;
|
FSLPicker.Cursor := c;
|
||||||
end;
|
end;
|
||||||
|
(*
|
||||||
procedure THSLRingPicker.WMSetFocus(
|
procedure THSLRingPicker.WMSetFocus(
|
||||||
var Message: {$IFDEF DELPHI}TWMSetFocus{$ELSE}TLMSetFocus{$ENDIF} );
|
var Message: {$IFDEF DELPHI}TWMSetFocus{$ELSE}TLMSetFocus{$ENDIF} );
|
||||||
begin
|
begin
|
||||||
FRingPicker.SetFocus;
|
FRingPicker.SetFocus;
|
||||||
Message.Result := 1;
|
Message.Result := 1;
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
|
|
||||||
|
procedure THSLRingPicker.SetFocus;
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
FRingPicker.SetFocus;
|
||||||
|
end;
|
||||||
|
|
||||||
function THSLRingPicker.GetManual:boolean;
|
function THSLRingPicker.GetManual:boolean;
|
||||||
begin
|
begin
|
||||||
|
@@ -56,12 +56,15 @@ type
|
|||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
procedure CreateWnd; override;
|
procedure CreateWnd; override;
|
||||||
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
function MouseOnPicker(X, Y: Integer): Boolean; override;
|
// function MouseOnPicker(X, Y: Integer): Boolean; override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
|
(*
|
||||||
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
||||||
message CN_KEYDOWN;
|
message CN_KEYDOWN;
|
||||||
|
*)
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
function GetColorAtPoint(x, y: integer): TColor; override;
|
function GetColorAtPoint(x, y: integer): TColor; override;
|
||||||
@@ -223,7 +226,9 @@ end;
|
|||||||
|
|
||||||
procedure THSVColorPicker.SetHue(h: integer);
|
procedure THSVColorPicker.SetHue(h: integer);
|
||||||
begin
|
begin
|
||||||
Clamp(h, 0, FMaxHue);
|
if h > FMaxHue then h := h - (FMaxHue + 1);
|
||||||
|
if h < 0 then h := h + (FMaxHue + 1);
|
||||||
|
// Clamp(h, 0, FMaxHue);
|
||||||
if GetHue() <> h then
|
if GetHue() <> h then
|
||||||
begin
|
begin
|
||||||
FHue := h / FMaxHue;
|
FHue := h / FMaxHue;
|
||||||
@@ -419,6 +424,58 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure THSVColorPicker.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
|
var
|
||||||
|
eraseKey: Boolean;
|
||||||
|
delta: Integer;
|
||||||
|
begin
|
||||||
|
eraseKey := true;
|
||||||
|
if ssCtrl in shift then
|
||||||
|
delta := 10
|
||||||
|
else
|
||||||
|
delta := 1;
|
||||||
|
|
||||||
|
case Key of
|
||||||
|
VK_LEFT:
|
||||||
|
begin
|
||||||
|
FChange := false;
|
||||||
|
SetHue(RadHue(GetHue() + delta));
|
||||||
|
FChange := true;
|
||||||
|
FManual := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_RIGHT:
|
||||||
|
begin
|
||||||
|
FChange := false;
|
||||||
|
SetHue(RadHue(GetHue() - delta));
|
||||||
|
FChange := true;
|
||||||
|
FManual := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_UP:
|
||||||
|
begin
|
||||||
|
FChange := false;
|
||||||
|
SetSat(GetSat() + delta);
|
||||||
|
FChange := true;
|
||||||
|
FManual := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_DOWN:
|
||||||
|
begin
|
||||||
|
FChange := false;
|
||||||
|
SetSat(GetSat() - delta);
|
||||||
|
FChange := true;
|
||||||
|
FManual := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
eraseKey := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if eraseKey then Key := 0;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure THSVColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState;
|
procedure THSVColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState;
|
||||||
X, Y: Integer);
|
X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
@@ -480,7 +537,7 @@ begin
|
|||||||
FManual := true;
|
FManual := true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
(*
|
||||||
function THSVColorPicker.MouseOnPicker(X, Y: Integer): Boolean;
|
function THSVColorPicker.MouseOnPicker(X, Y: Integer): Boolean;
|
||||||
var
|
var
|
||||||
diameter, r: Integer;
|
diameter, r: Integer;
|
||||||
@@ -492,7 +549,7 @@ begin
|
|||||||
ctr := Point(r, r);
|
ctr := Point(r, r);
|
||||||
Result := PtInCircle(P, ctr, r);
|
Result := PtInCircle(P, ctr, r);
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
function THSVColorPicker.GetSelectedColor: TColor;
|
function THSVColorPicker.GetSelectedColor: TColor;
|
||||||
begin
|
begin
|
||||||
if FSelectedColor <> clNone then
|
if FSelectedColor <> clNone then
|
||||||
@@ -556,7 +613,7 @@ begin
|
|||||||
if New > (FMaxHue + 1) then New := New - (FMaxHue + 1);
|
if New > (FMaxHue + 1) then New := New - (FMaxHue + 1);
|
||||||
Result := New;
|
Result := New;
|
||||||
end;
|
end;
|
||||||
|
(*
|
||||||
procedure THSVColorPicker.CNKeyDown(
|
procedure THSVColorPicker.CNKeyDown(
|
||||||
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
||||||
var
|
var
|
||||||
@@ -614,5 +671,5 @@ begin
|
|||||||
if Assigned(OnKeyDown) then
|
if Assigned(OnKeyDown) then
|
||||||
OnKeyDown(Self, Message.CharCode, Shift);
|
OnKeyDown(Self, Message.CharCode, Shift);
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
end.
|
end.
|
||||||
|
@@ -238,7 +238,7 @@ destructor THexaColorPicker.Destroy;
|
|||||||
begin
|
begin
|
||||||
FBWCombs := nil;
|
FBWCombs := nil;
|
||||||
FColorCombs := nil;
|
FColorCombs := nil;
|
||||||
FBufferBmp.Free;
|
// FBufferBmp.Free; is already destroyed by ancestor TmbBasicPicker
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@@ -24,25 +24,28 @@ type
|
|||||||
procedure SetGValue(g: integer);
|
procedure SetGValue(g: integer);
|
||||||
procedure SetBValue(b: integer);
|
procedure SetBValue(b: integer);
|
||||||
protected
|
protected
|
||||||
|
procedure CorrectCoords(var x, y: integer);
|
||||||
|
procedure CreateWnd; override;
|
||||||
|
procedure DrawMarker(x, y: integer);
|
||||||
function GetGradientColor2D(x, y: Integer): TColor; override;
|
function GetGradientColor2D(x, y: Integer): TColor; override;
|
||||||
procedure SetSelectedColor(c: TColor); override;
|
(*
|
||||||
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
||||||
message CN_KEYDOWN;
|
message CN_KEYDOWN;
|
||||||
|
*)
|
||||||
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure DrawMarker(x, y: integer);
|
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
procedure CreateWnd; override;
|
procedure SetSelectedColor(c: TColor); override;
|
||||||
procedure CorrectCoords(var x, y: integer);
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
published
|
published
|
||||||
property SelectedColor default clRed;
|
property SelectedColor default clRed;
|
||||||
property RValue: integer read FR write SetRValue default 255;
|
property Red: integer read FR write SetRValue default 255;
|
||||||
property GValue: integer read FG write SetGValue default 0;
|
property Green: integer read FG write SetGValue default 0;
|
||||||
property BValue: integer read FB write SetBValue default 0;
|
property Blue: integer read FB write SetBValue default 0;
|
||||||
property MarkerStyle default msCircle;
|
property MarkerStyle default msCircle;
|
||||||
property OnChange;
|
property OnChange;
|
||||||
end;
|
end;
|
||||||
@@ -104,8 +107,6 @@ begin
|
|||||||
FR := GetRValue(FSelected);
|
FR := GetRValue(FSelected);
|
||||||
FG := GetGValue(FSelected);
|
FG := GetGValue(FSelected);
|
||||||
FB := GetBValue(FSelected);
|
FB := GetBValue(FSelected);
|
||||||
if Assigned(FOnChange) then
|
|
||||||
FOnChange(Self);
|
|
||||||
dx := x;
|
dx := x;
|
||||||
dy := y;
|
dy := y;
|
||||||
if Focused or (csDesigning in ComponentState) then
|
if Focused or (csDesigning in ComponentState) then
|
||||||
@@ -125,8 +126,8 @@ begin
|
|||||||
FManual := false;
|
FManual := false;
|
||||||
myy := Round((255-FG)*(Height/255));
|
myy := Round((255-FG)*(Height/255));
|
||||||
mxx := Round(FB*(Width/255));
|
mxx := Round(FB*(Width/255));
|
||||||
CreateGradient;
|
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRAxisColorPicker.Paint;
|
procedure TRAxisColorPicker.Paint;
|
||||||
@@ -139,8 +140,70 @@ end;
|
|||||||
procedure TRAxisColorPicker.Resize;
|
procedure TRAxisColorPicker.Resize;
|
||||||
begin
|
begin
|
||||||
FManual := false;
|
FManual := false;
|
||||||
myy := Round((255-FG)*(Height/255));
|
myy := Round((255 - FG) * Height / 255);
|
||||||
mxx := Round(FB*(Width/255));
|
mxx := Round(FB * Width / 255);
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TRAxisColorPicker.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
|
var
|
||||||
|
delta: Integer;
|
||||||
|
eraseKey: Boolean;
|
||||||
|
begin
|
||||||
|
eraseKey := true;
|
||||||
|
if ssCtrl in Shift then
|
||||||
|
delta := 10
|
||||||
|
else
|
||||||
|
delta := 1;
|
||||||
|
|
||||||
|
case Key of
|
||||||
|
VK_LEFT:
|
||||||
|
begin
|
||||||
|
mxx := dx - delta;
|
||||||
|
if mxx < 0 then mxx := 0;
|
||||||
|
myy := dy;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
|
end;
|
||||||
|
VK_RIGHT:
|
||||||
|
begin
|
||||||
|
mxx := dx + delta;
|
||||||
|
if mxx >= Width then mxx := Width - 1;
|
||||||
|
myy := dy;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
|
end;
|
||||||
|
VK_UP:
|
||||||
|
begin
|
||||||
|
mxx := dx;
|
||||||
|
myy := dy - delta;
|
||||||
|
if myy < 0 then myy := 0;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
|
end;
|
||||||
|
VK_DOWN:
|
||||||
|
begin
|
||||||
|
mxx := dx;
|
||||||
|
myy := dy + delta;
|
||||||
|
if myy >= Height then
|
||||||
|
myy := Height - 1;
|
||||||
|
FSelected := GetColorAtPoint(mxx, myy);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
eraseKey := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if eraseKey then Key := 0;
|
||||||
|
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -153,10 +216,10 @@ begin
|
|||||||
myy := y;
|
myy := y;
|
||||||
if Button = mbLeft then
|
if Button = mbLeft then
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF DELPHI}
|
||||||
R := ClientRect;
|
R := ClientRect;
|
||||||
R.TopLeft := ClientToScreen(R.TopLeft);
|
R.TopLeft := ClientToScreen(R.TopLeft);
|
||||||
R.BottomRight := ClientToScreen(R.BottomRight);
|
R.BottomRight := ClientToScreen(R.BottomRight);
|
||||||
{$IFDEF DELPHI}
|
|
||||||
ClipCursor(@R);
|
ClipCursor(@R);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FSelected := GetColorAtPoint(x, y);
|
FSelected := GetColorAtPoint(x, y);
|
||||||
@@ -169,14 +232,18 @@ end;
|
|||||||
procedure TRAxisColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure TRAxisColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
{$IFDEF DELPHI}
|
if ssLeft in Shift then
|
||||||
ClipCursor(nil);
|
begin
|
||||||
{$ENDIF}
|
{$IFDEF DELPHI}
|
||||||
mxx := x;
|
ClipCursor(nil);
|
||||||
myy := y;
|
{$ENDIF}
|
||||||
FSelected := GetColorAtPoint(x, y);
|
mxx := x;
|
||||||
FManual := true;
|
myy := y;
|
||||||
Invalidate;
|
FSelected := GetColorAtPoint(x, y);
|
||||||
|
FManual := true;
|
||||||
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRAxisColorPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
procedure TRAxisColorPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
@@ -189,9 +256,11 @@ begin
|
|||||||
FSelected := GetColorAtPoint(x, y);
|
FSelected := GetColorAtPoint(x, y);
|
||||||
FManual := true;
|
FManual := true;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
|
if Assigned(FOnChange) then FOnChange(self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
(*
|
||||||
procedure TRAxisColorPicker.CNKeyDown(
|
procedure TRAxisColorPicker.CNKeyDown(
|
||||||
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
||||||
var
|
var
|
||||||
@@ -288,7 +357,7 @@ begin
|
|||||||
if Assigned(OnKeyDown) then
|
if Assigned(OnKeyDown) then
|
||||||
OnKeyDown(Self, Message.CharCode, Shift);
|
OnKeyDown(Self, Message.CharCode, Shift);
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
procedure TRAxisColorPicker.SetRValue(r: integer);
|
procedure TRAxisColorPicker.SetRValue(r: integer);
|
||||||
begin
|
begin
|
||||||
Clamp(r, 0, 255);
|
Clamp(r, 0, 255);
|
||||||
|
@@ -40,11 +40,12 @@ type
|
|||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
procedure CreateWnd; override;
|
procedure CreateWnd; override;
|
||||||
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
// procedure CNKeyDown(var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
||||||
message CN_KEYDOWN;
|
// message CN_KEYDOWN;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
function GetColorAtPoint(x, y: integer): TColor; override;
|
function GetColorAtPoint(x, y: integer): TColor; override;
|
||||||
@@ -235,6 +236,61 @@ begin
|
|||||||
FChange := true;
|
FChange := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TSLColorPicker.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
|
var
|
||||||
|
eraseKey: Boolean;
|
||||||
|
delta: Integer;
|
||||||
|
begin
|
||||||
|
eraseKey := true;
|
||||||
|
if ssCtrl in Shift then
|
||||||
|
delta := 10
|
||||||
|
else
|
||||||
|
delta := 1;
|
||||||
|
|
||||||
|
case Key of
|
||||||
|
VK_LEFT:
|
||||||
|
if (mdx - delta >= 0) then
|
||||||
|
begin
|
||||||
|
Dec(mdx, delta);
|
||||||
|
SelectionChanged(mdx, mdy);
|
||||||
|
FManual := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_RIGHT:
|
||||||
|
if (mdx + delta < Width) then
|
||||||
|
begin
|
||||||
|
Inc(mdx, delta);
|
||||||
|
SelectionChanged(mdx, mdy);
|
||||||
|
FManual := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_UP:
|
||||||
|
if (mdy - delta >= 0) then
|
||||||
|
begin
|
||||||
|
Dec(mdy, delta);
|
||||||
|
SelectionChanged(mdx, mdy);
|
||||||
|
FManual := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_DOWN:
|
||||||
|
if (mdy + delta < Height) then
|
||||||
|
begin
|
||||||
|
Inc(mdy, delta);
|
||||||
|
SelectionChanged(mdx, mdy);
|
||||||
|
FManual := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
eraseKey := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if eraseKey then
|
||||||
|
Key := 0;
|
||||||
|
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSLColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState;
|
procedure TSLColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState;
|
||||||
X, Y: Integer);
|
X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
@@ -324,6 +380,7 @@ begin
|
|||||||
Result := GetWebSafe(Result);
|
Result := GetWebSafe(Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
(*
|
||||||
procedure TSLColorPicker.CNKeyDown(
|
procedure TSLColorPicker.CNKeyDown(
|
||||||
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF} );
|
||||||
var
|
var
|
||||||
@@ -382,5 +439,6 @@ begin
|
|||||||
if Assigned(OnKeyDown) then
|
if Assigned(OnKeyDown) then
|
||||||
OnKeyDown(Self, Message.CharCode, Shift);
|
OnKeyDown(Self, Message.CharCode, Shift);
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@@ -62,8 +62,11 @@ type
|
|||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
// procedure PaintParentBack; override;
|
// procedure PaintParentBack; override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
|
procedure SetFocus; override;
|
||||||
|
(*
|
||||||
procedure WMSetFocus(var Message: {$IFDEF FPC}TLMSetFocus{$ELSE}TWMSetFocus{$ENDIF});
|
procedure WMSetFocus(var Message: {$IFDEF FPC}TLMSetFocus{$ELSE}TWMSetFocus{$ENDIF});
|
||||||
message {$IFDEF FPC}LM_SETFOCUS{$ELSE}WM_SETFOCUS{$ENDIF};
|
message {$IFDEF FPC}LM_SETFOCUS{$ELSE}WM_SETFOCUS{$ENDIF};
|
||||||
|
*)
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@@ -140,6 +143,31 @@ begin
|
|||||||
FHCursor := crDefault;
|
FHCursor := crDefault;
|
||||||
FSLCursor := crDefault;
|
FSLCursor := crDefault;
|
||||||
|
|
||||||
|
// Saturation-Lightness picker
|
||||||
|
FSLPicker := TSLColorPicker.Create(Self);
|
||||||
|
InsertControl(FSLPicker);
|
||||||
|
with FSLPicker do
|
||||||
|
begin
|
||||||
|
{$IFDEF DELPHI}
|
||||||
|
Left := 0;
|
||||||
|
Top := DELTA;
|
||||||
|
Width := 255;
|
||||||
|
Height := self.Height - 2 * VDELTA;
|
||||||
|
{$ELSE}
|
||||||
|
SetInitialBounds(0, VDELTA, WSL, HSL);
|
||||||
|
{$ENDIF}
|
||||||
|
//Anchors := [akLeft, akRight, akTop, akBottom];
|
||||||
|
Visible := true;
|
||||||
|
SelectedColor := clRed;
|
||||||
|
MaxHue := FMaxH;
|
||||||
|
MaxSaturation := FMaxS;
|
||||||
|
MaxLuminance := FMaxL;
|
||||||
|
Saturation := FMaxS;
|
||||||
|
Luminance := FMaxL;
|
||||||
|
OnChange := SLPickerChange;
|
||||||
|
OnMouseMove := DoMouseMove;
|
||||||
|
end;
|
||||||
|
|
||||||
// Hue picker
|
// Hue picker
|
||||||
with FHPicker do
|
with FHPicker do
|
||||||
begin
|
begin
|
||||||
@@ -166,30 +194,6 @@ begin
|
|||||||
OnMouseMove := DoMouseMove;
|
OnMouseMove := DoMouseMove;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Saturation-Lightness picker
|
|
||||||
FSLPicker := TSLColorPicker.Create(Self);
|
|
||||||
InsertControl(FSLPicker);
|
|
||||||
with FSLPicker do
|
|
||||||
begin
|
|
||||||
{$IFDEF DELPHI}
|
|
||||||
Left := 0;
|
|
||||||
Top := DELTA;
|
|
||||||
Width := 255;
|
|
||||||
Height := self.Height - 2 * VDELTA;
|
|
||||||
{$ELSE}
|
|
||||||
SetInitialBounds(0, VDELTA, WSL, HSL);
|
|
||||||
{$ENDIF}
|
|
||||||
//Anchors := [akLeft, akRight, akTop, akBottom];
|
|
||||||
Visible := true;
|
|
||||||
SelectedColor := clRed;
|
|
||||||
MaxHue := FMaxH;
|
|
||||||
MaxSaturation := FMaxS;
|
|
||||||
MaxLuminance := FMaxL;
|
|
||||||
Saturation := FMaxS;
|
|
||||||
Luminance := FMaxL;
|
|
||||||
OnChange := SLPickerChange;
|
|
||||||
OnMouseMove := DoMouseMove;
|
|
||||||
end;
|
|
||||||
FHValue := 0;
|
FHValue := 0;
|
||||||
FSValue := 1.0;
|
FSValue := 1.0;
|
||||||
FLValue := 1.0;
|
FLValue := 1.0;
|
||||||
@@ -203,8 +207,8 @@ end;
|
|||||||
destructor TSLHColorPicker.Destroy;
|
destructor TSLHColorPicker.Destroy;
|
||||||
begin
|
begin
|
||||||
PBack.Free;
|
PBack.Free;
|
||||||
FHPicker.Free;
|
// FHPicker.Free;
|
||||||
FSLPicker.Free;
|
// FSLPicker.Free;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -368,12 +372,18 @@ begin
|
|||||||
FSLPicker.Cursor := c;
|
FSLPicker.Cursor := c;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSLHColorPicker.SetFocus;
|
||||||
|
begin
|
||||||
|
FSLPicker.SetFocus;
|
||||||
|
end;
|
||||||
|
(*
|
||||||
procedure TSLHColorPicker.WMSetFocus(
|
procedure TSLHColorPicker.WMSetFocus(
|
||||||
var Message: {$IFDEF FPC}TLMSetFocus{$ELSE}TWMSetFocus{$ENDIF} );
|
var Message: {$IFDEF FPC}TLMSetFocus{$ELSE}TWMSetFocus{$ENDIF} );
|
||||||
begin
|
begin
|
||||||
FHPicker.SetFocus;
|
FSLPicker.SetFocus;
|
||||||
Message.Result := 1;
|
Message.Result := 1;
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
|
|
||||||
function TSLHColorPicker.GetManual:boolean;
|
function TSLHColorPicker.GetManual:boolean;
|
||||||
begin
|
begin
|
||||||
|
@@ -58,7 +58,6 @@
|
|||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Linking>
|
<Linking>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
<UseHeaptrc Value="True"/>
|
|
||||||
<UseExternalDbgSyms Value="True"/>
|
<UseExternalDbgSyms Value="True"/>
|
||||||
</Debugging>
|
</Debugging>
|
||||||
<Options>
|
<Options>
|
||||||
|
@@ -43,9 +43,9 @@ object Form1: TForm1
|
|||||||
Height = 384
|
Height = 384
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 403
|
Width = 403
|
||||||
ActivePage = TabSheet1
|
ActivePage = TabSheet5
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
TabIndex = 0
|
TabIndex = 4
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
OnChange = PageControl1Change
|
OnChange = PageControl1Change
|
||||||
OnMouseMove = PageControl1MouseMove
|
OnMouseMove = PageControl1MouseMove
|
||||||
@@ -720,9 +720,9 @@ object Form1: TForm1
|
|||||||
Anchors = [akLeft, akRight, akBottom]
|
Anchors = [akLeft, akRight, akBottom]
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
Hue = 0
|
Hue = 0
|
||||||
Saturation = 51
|
Saturation = 0
|
||||||
Luminance = 240
|
Luminance = 240
|
||||||
SelectedColor = clWhite
|
SelectedColor = 6579300
|
||||||
end
|
end
|
||||||
object VColorPicker1: TVColorPicker
|
object VColorPicker1: TVColorPicker
|
||||||
Left = 34
|
Left = 34
|
||||||
@@ -1027,6 +1027,7 @@ object Form1: TForm1
|
|||||||
Width = 100
|
Width = 100
|
||||||
HintFormat = 'G: %g B: %b'#13'Hex: #%hex'
|
HintFormat = 'G: %g B: %b'#13'Hex: #%hex'
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
OnChange = RAxisColorPicker1Change
|
||||||
end
|
end
|
||||||
object GAxisColorPicker1: TGAxisColorPicker
|
object GAxisColorPicker1: TGAxisColorPicker
|
||||||
Left = 130
|
Left = 130
|
||||||
@@ -1036,6 +1037,7 @@ object Form1: TForm1
|
|||||||
HintFormat = 'R: %r B: %b'#13'Hex: #%hex'
|
HintFormat = 'R: %r B: %b'#13'Hex: #%hex'
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
MarkerStyle = msCross
|
MarkerStyle = msCross
|
||||||
|
OnChange = GAxisColorPicker1Change
|
||||||
end
|
end
|
||||||
object BAxisColorPicker1: TBAxisColorPicker
|
object BAxisColorPicker1: TBAxisColorPicker
|
||||||
Left = 250
|
Left = 250
|
||||||
@@ -1045,11 +1047,12 @@ object Form1: TForm1
|
|||||||
HintFormat = 'R: %r G: %g'#13'Hex: #%hex'
|
HintFormat = 'R: %r G: %g'#13'Hex: #%hex'
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
MarkerStyle = msCrossCirc
|
MarkerStyle = msCrossCirc
|
||||||
|
OnChange = BAxisColorPicker1Change
|
||||||
end
|
end
|
||||||
object CIELColorPicker1: TCIELColorPicker
|
object CIELColorPicker1: TCIELColorPicker
|
||||||
Left = 10
|
Left = 10
|
||||||
Height = 100
|
Height = 100
|
||||||
Top = 164
|
Top = 188
|
||||||
Width = 100
|
Width = 100
|
||||||
SelectedColor = 16119089
|
SelectedColor = 16119089
|
||||||
HintFormat = 'A: %cieA B: %cieB'#13'Hex: #%hex'
|
HintFormat = 'A: %cieA B: %cieB'#13'Hex: #%hex'
|
||||||
@@ -1057,11 +1060,12 @@ object Form1: TForm1
|
|||||||
LValue = 88
|
LValue = 88
|
||||||
AValue = -47
|
AValue = -47
|
||||||
BValue = -32
|
BValue = -32
|
||||||
|
OnChange = CIELColorPicker1Change
|
||||||
end
|
end
|
||||||
object CIEAColorPicker1: TCIEAColorPicker
|
object CIEAColorPicker1: TCIEAColorPicker
|
||||||
Left = 130
|
Left = 130
|
||||||
Height = 100
|
Height = 100
|
||||||
Top = 164
|
Top = 188
|
||||||
Width = 100
|
Width = 100
|
||||||
SelectedColor = 16515327
|
SelectedColor = 16515327
|
||||||
HintFormat = 'L: %cieL B: %cieB'#13'Hex: #%hex'
|
HintFormat = 'L: %cieL B: %cieB'#13'Hex: #%hex'
|
||||||
@@ -1070,11 +1074,12 @@ object Form1: TForm1
|
|||||||
AValue = 96
|
AValue = 96
|
||||||
BValue = -78
|
BValue = -78
|
||||||
MarkerStyle = msSquare
|
MarkerStyle = msSquare
|
||||||
|
OnChange = CIEAColorPicker1Change
|
||||||
end
|
end
|
||||||
object CIEBColorPicker1: TCIEBColorPicker
|
object CIEBColorPicker1: TCIEBColorPicker
|
||||||
Left = 250
|
Left = 250
|
||||||
Height = 100
|
Height = 100
|
||||||
Top = 164
|
Top = 188
|
||||||
Width = 100
|
Width = 100
|
||||||
SelectedColor = 130823
|
SelectedColor = 130823
|
||||||
HintFormat = 'L: %cieL A: %cieA'#13'Hex: #%hex'
|
HintFormat = 'L: %cieL A: %cieA'#13'Hex: #%hex'
|
||||||
@@ -1082,6 +1087,7 @@ object Form1: TForm1
|
|||||||
LValue = 88
|
LValue = 88
|
||||||
AValue = -88
|
AValue = -88
|
||||||
BValue = 74
|
BValue = 74
|
||||||
|
OnChange = CIEBColorPicker1Change
|
||||||
end
|
end
|
||||||
object Label10: TLabel
|
object Label10: TLabel
|
||||||
Left = 130
|
Left = 130
|
||||||
@@ -1110,7 +1116,7 @@ object Form1: TForm1
|
|||||||
object Label13: TLabel
|
object Label13: TLabel
|
||||||
Left = 10
|
Left = 10
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 144
|
Top = 168
|
||||||
Width = 84
|
Width = 84
|
||||||
Caption = 'CIELColorPicker'
|
Caption = 'CIELColorPicker'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
@@ -1118,7 +1124,7 @@ object Form1: TForm1
|
|||||||
object Label14: TLabel
|
object Label14: TLabel
|
||||||
Left = 130
|
Left = 130
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 144
|
Top = 168
|
||||||
Width = 86
|
Width = 86
|
||||||
Caption = 'CIEAColorPicker'
|
Caption = 'CIEAColorPicker'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
@@ -1126,11 +1132,47 @@ object Form1: TForm1
|
|||||||
object Label15: TLabel
|
object Label15: TLabel
|
||||||
Left = 250
|
Left = 250
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 144
|
Top = 168
|
||||||
Width = 85
|
Width = 85
|
||||||
Caption = 'CIEBColorPicker'
|
Caption = 'CIEBColorPicker'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
|
object RAxisIndicator: TShape
|
||||||
|
Left = 88
|
||||||
|
Height = 21
|
||||||
|
Top = 132
|
||||||
|
Width = 22
|
||||||
|
end
|
||||||
|
object GAxisIndicator: TShape
|
||||||
|
Left = 208
|
||||||
|
Height = 21
|
||||||
|
Top = 132
|
||||||
|
Width = 22
|
||||||
|
end
|
||||||
|
object BAxisIndicator: TShape
|
||||||
|
Left = 328
|
||||||
|
Height = 21
|
||||||
|
Top = 132
|
||||||
|
Width = 22
|
||||||
|
end
|
||||||
|
object CIEBIndicator: TShape
|
||||||
|
Left = 328
|
||||||
|
Height = 21
|
||||||
|
Top = 296
|
||||||
|
Width = 22
|
||||||
|
end
|
||||||
|
object CIEAIndicator: TShape
|
||||||
|
Left = 208
|
||||||
|
Height = 21
|
||||||
|
Top = 296
|
||||||
|
Width = 22
|
||||||
|
end
|
||||||
|
object CIELIndicator: TShape
|
||||||
|
Left = 88
|
||||||
|
Height = 21
|
||||||
|
Top = 296
|
||||||
|
Width = 22
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object sc: TmbColorPreview
|
object sc: TmbColorPreview
|
||||||
@@ -1182,7 +1224,7 @@ object Form1: TForm1
|
|||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = 'WebSafe'
|
Caption = 'WebSafe'
|
||||||
OnClick = CbWebSsafeClick
|
OnClick = CbWebSsafeClick
|
||||||
TabOrder = 5
|
TabOrder = 6
|
||||||
end
|
end
|
||||||
object CbSwatchStyle: TCheckBox
|
object CbSwatchStyle: TCheckBox
|
||||||
Left = 416
|
Left = 416
|
||||||
@@ -1192,7 +1234,7 @@ object Form1: TForm1
|
|||||||
Anchors = [akTop, akRight]
|
Anchors = [akTop, akRight]
|
||||||
Caption = 'SwatchStyle'
|
Caption = 'SwatchStyle'
|
||||||
OnClick = CbSwatchStyleClick
|
OnClick = CbSwatchStyleClick
|
||||||
TabOrder = 6
|
TabOrder = 5
|
||||||
end
|
end
|
||||||
object CbShowHints: TCheckBox
|
object CbShowHints: TCheckBox
|
||||||
Left = 416
|
Left = 416
|
||||||
|
@@ -5,7 +5,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
LCLIntf, LCLType, LMessages, SysUtils, Variants,Classes, Graphics, Controls,
|
LCLIntf, LCLType, LMessages, SysUtils, Variants,Classes, Graphics, Controls,
|
||||||
Forms, Dialogs, HSLColorPicker, ComCtrls, StdCtrls, mbColorPreview,
|
Forms, Dialogs, HSLColorPicker, ComCtrls, StdCtrls, ExtCtrls, mbColorPreview,
|
||||||
HexaColorPicker, mbColorPalette, HSLRingPicker, HSVColorPicker, PalUtils,
|
HexaColorPicker, mbColorPalette, HSLRingPicker, HSVColorPicker, PalUtils,
|
||||||
SLHColorPicker, mbDeskPickerButton, mbOfficeColorDialog, SColorPicker,
|
SLHColorPicker, mbDeskPickerButton, mbOfficeColorDialog, SColorPicker,
|
||||||
HColorPicker, VColorPicker, mbTrackBarPicker, LColorPicker, HRingPicker,
|
HColorPicker, VColorPicker, mbTrackBarPicker, LColorPicker, HRingPicker,
|
||||||
@@ -20,8 +20,10 @@ type
|
|||||||
{ TForm1 }
|
{ TForm1 }
|
||||||
|
|
||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
|
CIEBIndicator: TShape;
|
||||||
CbShowHints: TCheckBox;
|
CbShowHints: TCheckBox;
|
||||||
CbEnabled: TCheckBox;
|
CbEnabled: TCheckBox;
|
||||||
|
CIEAIndicator: TShape;
|
||||||
Label10: TLabel;
|
Label10: TLabel;
|
||||||
Label11: TLabel;
|
Label11: TLabel;
|
||||||
Label12: TLabel;
|
Label12: TLabel;
|
||||||
@@ -29,6 +31,10 @@ type
|
|||||||
Label14: TLabel;
|
Label14: TLabel;
|
||||||
Label15: TLabel;
|
Label15: TLabel;
|
||||||
PageControl1: TPageControl;
|
PageControl1: TPageControl;
|
||||||
|
RAxisIndicator: TShape;
|
||||||
|
GAxisIndicator: TShape;
|
||||||
|
BAxisIndicator: TShape;
|
||||||
|
CIELIndicator: TShape;
|
||||||
TabSheet1: TTabSheet;
|
TabSheet1: TTabSheet;
|
||||||
TabSheet2: TTabSheet;
|
TabSheet2: TTabSheet;
|
||||||
TabSheet3: TTabSheet;
|
TabSheet3: TTabSheet;
|
||||||
@@ -105,13 +111,19 @@ type
|
|||||||
Memo1: TMemo;
|
Memo1: TMemo;
|
||||||
Label9: TLabel;
|
Label9: TLabel;
|
||||||
CbSwatchStyle: TCheckBox;
|
CbSwatchStyle: TCheckBox;
|
||||||
|
procedure BAxisColorPicker1Change(Sender: TObject);
|
||||||
procedure CbEnabledChange(Sender: TObject);
|
procedure CbEnabledChange(Sender: TObject);
|
||||||
procedure CbShowHintsChange(Sender: TObject);
|
procedure CbShowHintsChange(Sender: TObject);
|
||||||
|
procedure CIEAColorPicker1Change(Sender: TObject);
|
||||||
|
procedure CIEBColorPicker1Change(Sender: TObject);
|
||||||
|
procedure CIELColorPicker1Change(Sender: TObject);
|
||||||
|
procedure GAxisColorPicker1Change(Sender: TObject);
|
||||||
procedure HColorPicker1GetHintStr(Sender: TObject; X, Y: Integer;
|
procedure HColorPicker1GetHintStr(Sender: TObject; X, Y: Integer;
|
||||||
var AText: String);
|
var AText: String);
|
||||||
procedure PageControl1Change(Sender: TObject);
|
procedure PageControl1Change(Sender: TObject);
|
||||||
procedure PageControl1MouseMove(Sender: TObject; Shift: TShiftState;
|
procedure PageControl1MouseMove(Sender: TObject; Shift: TShiftState;
|
||||||
X, Y: Integer);
|
X, Y: Integer);
|
||||||
|
procedure RAxisColorPicker1Change(Sender: TObject);
|
||||||
procedure tb1Change(Sender: TObject);
|
procedure tb1Change(Sender: TObject);
|
||||||
procedure tb2Change(Sender: TObject);
|
procedure tb2Change(Sender: TObject);
|
||||||
procedure HSLColorPicker1Change(Sender: TObject);
|
procedure HSLColorPicker1Change(Sender: TObject);
|
||||||
@@ -208,6 +220,11 @@ begin
|
|||||||
uc.color := hexacolorpicker1.ColorUnderCursor;
|
uc.color := hexacolorpicker1.ColorUnderCursor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.BAxisColorPicker1Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
BAxisIndicator.Brush.Color := BAxisColorPicker1.SelectedColor;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.Button1Click(Sender: TObject);
|
procedure TForm1.Button1Click(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
mbColorPalette1.GeneratePalette(clblue);
|
mbColorPalette1.GeneratePalette(clblue);
|
||||||
@@ -281,6 +298,11 @@ begin
|
|||||||
uc.color := HSLColorpicker1.ColorUnderCursor;
|
uc.color := HSLColorpicker1.ColorUnderCursor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.RAxisColorPicker1Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
RAxisIndicator.Brush.Color := RAxisColorPicker1.SelectedColor;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.OfficeColorDialogButtonClick(Sender: TObject);
|
procedure TForm1.OfficeColorDialogButtonClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if mbOfficeColorDialog1.Execute then
|
if mbOfficeColorDialog1.Execute then
|
||||||
@@ -341,6 +363,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.GAxisColorPicker1Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
GAxisIndicator.Brush.Color := GAxisColorPicker1.SelectedColor;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.HColorPicker1GetHintStr(Sender: TObject; X, Y: Integer;
|
procedure TForm1.HColorPicker1GetHintStr(Sender: TObject; X, Y: Integer;
|
||||||
var AText: String);
|
var AText: String);
|
||||||
begin
|
begin
|
||||||
@@ -362,6 +389,21 @@ begin
|
|||||||
hexacolorpicker1.NewArrowStyle := checkbox2.checked;
|
hexacolorpicker1.NewArrowStyle := checkbox2.checked;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.CIEAColorPicker1Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
CIEAIndicator.Brush.Color := CIEAColorPicker1.SelectedColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.CIEBColorPicker1Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
CIEBIndicator.Brush.Color := CIEBColorPicker1.SelectedColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.CIELColorPicker1Change(Sender: TObject);
|
||||||
|
begin
|
||||||
|
CIELIndicator.Brush.Color := CIELColorPicker1.SelectedColor;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.Button4Click(Sender: TObject);
|
procedure TForm1.Button4Click(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if opendialog1.Execute then
|
if opendialog1.Execute then
|
||||||
|
@@ -41,7 +41,6 @@ type
|
|||||||
function GetHintStr(X, Y: Integer): String; virtual;
|
function GetHintStr(X, Y: Integer): String; virtual;
|
||||||
procedure MouseLeave; override;
|
procedure MouseLeave; override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
function MouseOnPicker(X, Y: Integer): Boolean; virtual;
|
|
||||||
procedure PaintParentBack; virtual; overload;
|
procedure PaintParentBack; virtual; overload;
|
||||||
procedure PaintParentBack(ACanvas: TCanvas); overload;
|
procedure PaintParentBack(ACanvas: TCanvas); overload;
|
||||||
procedure PaintParentBack(ACanvas: TCanvas; ARect: TRect); overload;
|
procedure PaintParentBack(ACanvas: TCanvas; ARect: TRect); overload;
|
||||||
@@ -243,11 +242,6 @@ begin
|
|||||||
}
|
}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TmbBasicPicker.MouseOnPicker(X, Y: Integer): Boolean;
|
|
||||||
begin
|
|
||||||
Result := true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TmbBasicPicker.PaintParentBack;
|
procedure TmbBasicPicker.PaintParentBack;
|
||||||
begin
|
begin
|
||||||
PaintParentBack(Canvas);
|
PaintParentBack(Canvas);
|
||||||
|
@@ -91,19 +91,20 @@ type
|
|||||||
function GetHintPos(X, Y: Integer): TPoint; override;
|
function GetHintPos(X, Y: Integer): TPoint; override;
|
||||||
function GetHintStr(X, Y: Integer): String; override;
|
function GetHintStr(X, Y: Integer): String; override;
|
||||||
function GetSelectedValue: integer; virtual; abstract;
|
function GetSelectedValue: integer; virtual; abstract;
|
||||||
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure MouseLeave; override;
|
procedure MouseLeave; override;
|
||||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||||
function MouseOnPicker(X, Y: Integer): Boolean; override;
|
// function MouseOnPicker(X, Y: Integer): Boolean;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure WheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
|
procedure WheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
|
||||||
procedure WheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
|
procedure WheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
|
||||||
{$IFDEF DELPHI}
|
{$IFDEF DELPHI}
|
||||||
procedure CNKeyDown(var Message: TWMKeyDown); message CN_KEYDOWN;
|
// procedure CNKeyDown(var Message: TWMKeyDown); message CN_KEYDOWN;
|
||||||
procedure CMGotFocus(var Message: TCMGotFocus); message CM_ENTER;
|
procedure CMGotFocus(var Message: TCMGotFocus); message CM_ENTER;
|
||||||
procedure CMLostFocus(var Message: TCMLostFocus); message CM_EXIT;
|
procedure CMLostFocus(var Message: TCMLostFocus); message CM_EXIT;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
procedure CNKeyDown(var Message: TLMKeyDown); message CN_KEYDOWN;
|
// procedure CNKeyDown(var Message: TLMKeyDown); message CN_KEYDOWN;
|
||||||
procedure CMGotFocus(var Message: TLMessage); message CM_ENTER;
|
procedure CMGotFocus(var Message: TLMessage); message CM_ENTER;
|
||||||
procedure CMLostFocus(var Message: TLMessage); message CM_EXIT;
|
procedure CMLostFocus(var Message: TLMessage); message CM_EXIT;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@@ -608,6 +609,78 @@ begin
|
|||||||
Result := pos;
|
Result := pos;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TmbTrackBarPicker.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
|
var
|
||||||
|
eraseKey: Boolean;
|
||||||
|
begin
|
||||||
|
eraseKey := true;
|
||||||
|
case Key of
|
||||||
|
VK_UP:
|
||||||
|
if FLayout = lyHorizontal then
|
||||||
|
eraseKey := false
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
FChange := false;
|
||||||
|
if not (ssCtrl in Shift) then
|
||||||
|
Execute(TBA_VKUp)
|
||||||
|
else
|
||||||
|
Execute(TBA_VKCtrlUp);
|
||||||
|
FManual := true;
|
||||||
|
FChange := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_LEFT:
|
||||||
|
if FLayout = lyVertical then
|
||||||
|
eraseKey := false
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
FChange := false;
|
||||||
|
if not (ssCtrl in Shift) then
|
||||||
|
Execute(TBA_VKLeft)
|
||||||
|
else
|
||||||
|
Execute(TBA_VKCtrlLeft);
|
||||||
|
FManual := true;
|
||||||
|
FChange := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_RIGHT:
|
||||||
|
if FLayout = lyVertical then
|
||||||
|
eraseKey := false
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
FChange := false;
|
||||||
|
if not (ssCtrl in Shift) then
|
||||||
|
Execute(TBA_VKRight)
|
||||||
|
else
|
||||||
|
Execute(TBA_VKCtrlRight);
|
||||||
|
FManual := true;
|
||||||
|
FChange := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end;
|
||||||
|
VK_DOWN:
|
||||||
|
if FLayout = lyHorizontal then
|
||||||
|
eraseKey := false
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
FChange := false;
|
||||||
|
if not (ssCtrl in Shift) then
|
||||||
|
Execute(TBA_VKDown)
|
||||||
|
else
|
||||||
|
Execute(TBA_VKCtrlDown);
|
||||||
|
FManual := true;
|
||||||
|
FChange := true;
|
||||||
|
if Assigned(FOnChange) then FOnChange(Self);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
eraseKey := false;
|
||||||
|
end; // case
|
||||||
|
|
||||||
|
if eraseKey then
|
||||||
|
Key := 0;
|
||||||
|
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TmbTrackBarPicker.MouseLeave;
|
procedure TmbTrackBarPicker.MouseLeave;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
@@ -639,11 +712,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
(*
|
||||||
function TmbTrackBarPicker.MouseOnPicker(X, Y: Integer): Boolean;
|
function TmbTrackBarPicker.MouseOnPicker(X, Y: Integer): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := PtInRect(FPickRect, Point(X, Y));
|
Result := PtInRect(FPickRect, Point(X, Y));
|
||||||
end;
|
end; *)
|
||||||
|
|
||||||
procedure TmbTrackBarPicker.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure TmbTrackBarPicker.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
@@ -681,7 +754,7 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
(*
|
||||||
procedure TmbTrackBarPicker.CNKeyDown(
|
procedure TmbTrackBarPicker.CNKeyDown(
|
||||||
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
var Message: {$IFDEF FPC}TLMKeyDown{$ELSE}TWMKeyDown{$ENDIF});
|
||||||
var
|
var
|
||||||
@@ -764,7 +837,7 @@ begin
|
|||||||
if not FInherited and Assigned(OnKeyDown) then
|
if not FInherited and Assigned(OnKeyDown) then
|
||||||
OnKeyDown(Self, Message.CharCode, Shift);
|
OnKeyDown(Self, Message.CharCode, Shift);
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
function TmbTrackBarPicker.GetHintPos(X, Y: Integer): TPoint;
|
function TmbTrackBarPicker.GetHintPos(X, Y: Integer): TPoint;
|
||||||
begin
|
begin
|
||||||
case FLayout of
|
case FLayout of
|
||||||
|
Reference in New Issue
Block a user