jvcllaz: Fix high-dpi awareness of TJvGammaPanel.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7157 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
03e52c2b0e
commit
fe2097bc43
@ -1,21 +1,27 @@
|
|||||||
object DemoForm: TDemoForm
|
object DemoForm: TDemoForm
|
||||||
Left = 340
|
Left = 440
|
||||||
Height = 393
|
Height = 265
|
||||||
Top = 128
|
Top = 205
|
||||||
Width = 431
|
Width = 334
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
Caption = 'JvGammaPanel demo'
|
Caption = 'JvGammaPanel demo'
|
||||||
ClientHeight = 393
|
ClientHeight = 265
|
||||||
ClientWidth = 431
|
ClientWidth = 334
|
||||||
|
OnCreate = FormCreate
|
||||||
LCLVersion = '2.1.0.0'
|
LCLVersion = '2.1.0.0'
|
||||||
object JvGammaPanel1: TJvGammaPanel
|
object JvGammaPanel1: TJvGammaPanel
|
||||||
AnchorSideLeft.Control = Owner
|
|
||||||
AnchorSideTop.Control = Owner
|
AnchorSideTop.Control = Owner
|
||||||
|
AnchorSideBottom.Control = Owner
|
||||||
|
AnchorSideBottom.Side = asrBottom
|
||||||
Left = 8
|
Left = 8
|
||||||
|
Height = 249
|
||||||
Top = 8
|
Top = 8
|
||||||
|
Anchors = [akTop, akLeft, akBottom]
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Top = 8
|
||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
|
ForegroundColor = clWhite
|
||||||
|
BackgroundColor = clBlack
|
||||||
OnChangeColor = JvGammaPanel1ChangeColor
|
OnChangeColor = JvGammaPanel1ChangeColor
|
||||||
end
|
end
|
||||||
object DemoLabel: TLabel
|
object DemoLabel: TLabel
|
||||||
@ -25,7 +31,7 @@ object DemoForm: TDemoForm
|
|||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrCenter
|
||||||
Left = 105
|
Left = 105
|
||||||
Height = 45
|
Height = 45
|
||||||
Top = 111
|
Top = 110
|
||||||
Width = 214
|
Width = 214
|
||||||
BorderSpacing.Left = 32
|
BorderSpacing.Left = 32
|
||||||
BorderSpacing.Right = 16
|
BorderSpacing.Right = 16
|
||||||
@ -34,4 +40,38 @@ object DemoForm: TDemoForm
|
|||||||
ParentColor = False
|
ParentColor = False
|
||||||
ParentFont = False
|
ParentFont = False
|
||||||
end
|
end
|
||||||
|
object FgColorBtn: TColorButton
|
||||||
|
AnchorSideLeft.Control = DemoLabel
|
||||||
|
AnchorSideTop.Control = JvGammaPanel1
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
Left = 105
|
||||||
|
Height = 25
|
||||||
|
Top = 8
|
||||||
|
Width = 207
|
||||||
|
BorderWidth = 2
|
||||||
|
ButtonColorAutoSize = False
|
||||||
|
ButtonColorSize = 16
|
||||||
|
ButtonColor = clBlack
|
||||||
|
Caption = 'Foreground color'
|
||||||
|
OnColorChanged = FgColorBtnColorChanged
|
||||||
|
end
|
||||||
|
object BgColorBtn: TColorButton
|
||||||
|
AnchorSideLeft.Control = DemoLabel
|
||||||
|
AnchorSideTop.Control = FgColorBtn
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = FgColorBtn
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
|
Left = 105
|
||||||
|
Height = 25
|
||||||
|
Top = 37
|
||||||
|
Width = 207
|
||||||
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
BorderSpacing.Top = 4
|
||||||
|
BorderWidth = 2
|
||||||
|
ButtonColorAutoSize = False
|
||||||
|
ButtonColorSize = 16
|
||||||
|
ButtonColor = clBlack
|
||||||
|
Caption = 'Background color'
|
||||||
|
OnColorChanged = BgColorBtnColorChanged
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -13,10 +13,14 @@ type
|
|||||||
{ TDemoForm }
|
{ TDemoForm }
|
||||||
|
|
||||||
TDemoForm = class(TForm)
|
TDemoForm = class(TForm)
|
||||||
|
FgColorBtn: TColorButton;
|
||||||
|
BgColorBtn: TColorButton;
|
||||||
JvGammaPanel1: TJvGammaPanel;
|
JvGammaPanel1: TJvGammaPanel;
|
||||||
DemoLabel: TLabel;
|
DemoLabel: TLabel;
|
||||||
procedure JvGammaPanel1ChangeColor(Sender: TObject; Foreground,
|
procedure BgColorBtnColorChanged(Sender: TObject);
|
||||||
Background: TColor);
|
procedure FgColorBtnColorChanged(Sender: TObject);
|
||||||
|
procedure FormCreate(Sender: TObject);
|
||||||
|
procedure JvGammaPanel1ChangeColor(Sender: TObject; FgColor, BgColor: TColor);
|
||||||
private
|
private
|
||||||
|
|
||||||
public
|
public
|
||||||
@ -32,11 +36,29 @@ implementation
|
|||||||
|
|
||||||
{ TDemoForm }
|
{ TDemoForm }
|
||||||
|
|
||||||
procedure TDemoForm.JvGammaPanel1ChangeColor(Sender: TObject; Foreground,
|
procedure TDemoForm.BgColorBtnColorChanged(Sender: TObject);
|
||||||
Background: TColor);
|
|
||||||
begin
|
begin
|
||||||
DemoLabel.Color := Background;
|
JvGammaPanel1.BackgroundColor := BgColorBtn.ButtonColor;
|
||||||
DemoLabel.Font.Color := Foreground;
|
end;
|
||||||
|
|
||||||
|
procedure TDemoForm.FgColorBtnColorChanged(Sender: TObject);
|
||||||
|
begin
|
||||||
|
JvGammaPanel1.ForegroundColor := FgColorBtn.ButtonColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDemoForm.FormCreate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
FgColorBtn.ButtonColor := JvGammaPanel1.ForegroundColor;
|
||||||
|
BgColorBtn.ButtonColor := JvGammaPanel1.BackgroundColor;
|
||||||
|
|
||||||
|
DemoLabel.Color := JvGammaPanel1.BackgroundColor;
|
||||||
|
Demolabel.Font.Color := JvGammaPanel1.ForegroundColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDemoForm.JvGammaPanel1ChangeColor(Sender: TObject; FgColor, BgColor: TColor);
|
||||||
|
begin
|
||||||
|
DemoLabel.Color := BgColor;
|
||||||
|
DemoLabel.Font.Color := FgColor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -942,8 +942,8 @@ resourcestring
|
|||||||
RsGreenFormat = 'G : %3D';
|
RsGreenFormat = 'G : %3D';
|
||||||
RsBlueFormat = 'B : %3D';
|
RsBlueFormat = 'B : %3D';
|
||||||
|
|
||||||
RsHint1 = 'Background Color';
|
RsHintBg = 'Background Color';
|
||||||
RsHint2 = 'Foreground Color';
|
RsHintFg = 'Foreground Color';
|
||||||
RsXCaption = 'X';
|
RsXCaption = 'X';
|
||||||
RsLabelHint = 'Exchange colors';
|
RsLabelHint = 'Exchange colors';
|
||||||
|
|
||||||
|
@ -29,63 +29,61 @@ Known Issues:
|
|||||||
|
|
||||||
unit JvGammaPanel;
|
unit JvGammaPanel;
|
||||||
|
|
||||||
//{$I jvcl.inc}
|
|
||||||
{$MODE OBJFPC}{$H+}
|
{$MODE OBJFPC}{$H+}
|
||||||
|
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Types, SysUtils, Classes,
|
Types, SysUtils, Classes, Graphics, Controls, Dialogs, ExtCtrls, StdCtrls,
|
||||||
//Windows, Messages,
|
|
||||||
Graphics, Controls, Dialogs,
|
|
||||||
ExtCtrls, StdCtrls,
|
|
||||||
JvTypes;
|
JvTypes;
|
||||||
// JvTypes, JvComponent;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TJvGammaPanel = class(TWinControl) //TJvWinControl)
|
TJvGammaPanel = class(TWinControl)
|
||||||
private
|
private
|
||||||
FForegroundColor: TColor;
|
|
||||||
FBackgroundColor: TColor;
|
|
||||||
LastCol: TColor;
|
|
||||||
FPanel1: TPanel;
|
FPanel1: TPanel;
|
||||||
FPanel2: TPanel;
|
FPanel2: TPanel;
|
||||||
FPanel3: TPanel;
|
FPanel3: TPanel;
|
||||||
FPanel4: TPanel;
|
FPanel4: TPanel;
|
||||||
|
FGamma: TImage;
|
||||||
|
FForegroundColorImg: TShape;
|
||||||
|
FBackgroundColorImg: TShape;
|
||||||
|
FChosen: TShape;
|
||||||
|
FXLabel: TLabel;
|
||||||
FRLabel: TLabel;
|
FRLabel: TLabel;
|
||||||
FGLabel: TLabel;
|
FGLabel: TLabel;
|
||||||
FBLabel: TLabel;
|
FBLabel: TLabel;
|
||||||
FXLabel: TLabel;
|
FLastColor: TColor;
|
||||||
FGamma: TImage;
|
|
||||||
FChoosed: TImage;
|
|
||||||
FForegroundColorImg: TImage;
|
|
||||||
FBackgroundColorImg: TImage;
|
|
||||||
FOnChangeColor: TJvChangeColorEvent;
|
FOnChangeColor: TJvChangeColorEvent;
|
||||||
procedure ChangeColor(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure BgColorClick(Sender: TObject);
|
||||||
|
procedure ChangeColor(Sender: TObject; Button: TMouseButton;
|
||||||
|
Shift: TShiftState; X, Y: Integer);
|
||||||
procedure ColorSeek(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
procedure ColorSeek(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
||||||
procedure Exchange(Sender: TObject);
|
procedure Exchange(Sender: TObject);
|
||||||
procedure SetForegroundColor(const Value: TColor);
|
procedure FgColorClick(Sender: TObject);
|
||||||
procedure SetBackgroundColor(const Value: TColor);
|
function GetBackgroundColor: TColor;
|
||||||
procedure Color1Click(Sender: TObject);
|
function GetForegroundColor: TColor;
|
||||||
procedure Color2Click(Sender: TObject);
|
function IsHeightStored: Boolean;
|
||||||
|
function IsWidthStored: Boolean;
|
||||||
|
procedure SetBackgroundColor(const AValue: TColor);
|
||||||
|
procedure SetForegroundColor(const AValue: TColor);
|
||||||
protected
|
protected
|
||||||
procedure BoundsChanged; override;
|
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
||||||
|
const AXProportion, AYProportion: Double); override;
|
||||||
procedure DoChangeColor(AForegroundColor, ABackgroundColor: TColor); virtual;
|
procedure DoChangeColor(AForegroundColor, ABackgroundColor: TColor); virtual;
|
||||||
|
procedure Resize; override;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
published
|
published
|
||||||
property Align;
|
property Align;
|
||||||
property AutoSize;
|
property Anchors;
|
||||||
property BorderSpacing;
|
property BorderSpacing;
|
||||||
property Height default 250;
|
property Height stored IsHeightStored;
|
||||||
property Width default 65;
|
property Width stored IsWidthStored;
|
||||||
property ForegroundColor: TColor read FForegroundColor write SetForegroundColor default clBlack;
|
property ForegroundColor: TColor read GetForegroundColor write SetForegroundColor default clBlack;
|
||||||
property BackgroundColor: TColor read FBackgroundColor write SetBackgroundColor default clWhite;
|
property BackgroundColor: TColor read GetBackgroundColor write SetBackgroundColor default clWhite;
|
||||||
property OnChangeColor: TJvChangeColorEvent read FOnChangeColor write FOnChangeColor;
|
property OnChangeColor: TJvChangeColorEvent read FOnChangeColor write FOnChangeColor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -94,122 +92,69 @@ uses
|
|||||||
|
|
||||||
{$R ../../resource/jvgammapanel.res}
|
{$R ../../resource/jvgammapanel.res}
|
||||||
|
|
||||||
|
const
|
||||||
|
DEFAULT_WIDTH = 65;
|
||||||
|
DEFAULT_HEIGHT = 250;
|
||||||
|
|
||||||
|
MARGIN_1 = 5;
|
||||||
|
MARGIN_2 = 2;
|
||||||
|
IMG_SIZE = 30;
|
||||||
|
|
||||||
constructor TJvGammaPanel.Create(AOwner: TComponent);
|
constructor TJvGammaPanel.Create(AOwner: TComponent);
|
||||||
var
|
|
||||||
p5: Integer;
|
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
Width := 65;
|
Width := DEFAULT_WIDTH; // Scaling of outer dimensions is done automatically
|
||||||
Height := 250;
|
Height := DEFAULT_HEIGHT;
|
||||||
FForegroundColor := clBlack;
|
|
||||||
FBackgroundColor := clWhite;
|
|
||||||
|
|
||||||
FPanel1 := TPanel.Create(Self);
|
FPanel1 := TPanel.Create(Self);
|
||||||
with FPanel1 do
|
with FPanel1 do
|
||||||
begin
|
begin
|
||||||
Parent := Self;
|
Parent := Self;
|
||||||
// Width := 65;
|
|
||||||
// Height := 250;
|
|
||||||
Align := alClient;
|
Align := alClient;
|
||||||
BevelInner := bvLowered;
|
BevelInner := bvLowered;
|
||||||
BevelOuter := bvRaised;
|
BevelOuter := bvRaised;
|
||||||
Visible := True;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FPanel2 := TPanel.Create(FPanel1);
|
FPanel2 := TPanel.Create(FPanel1);
|
||||||
with FPanel2 do
|
with FPanel2 do
|
||||||
begin
|
begin
|
||||||
Parent := FPanel1;
|
Parent := FPanel1;
|
||||||
Left := 5;
|
Align := alClient;
|
||||||
Top := 5;
|
BorderSpacing.Around := Scale96ToFont(MARGIN_1); // Scale inner dimensions manually
|
||||||
Width := 55;
|
|
||||||
Height := 105;
|
|
||||||
BevelInner := bvLowered;
|
BevelInner := bvLowered;
|
||||||
BevelOuter := bvRaised;
|
BevelOuter := bvRaised;
|
||||||
Visible := True;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FPanel3 := TPanel.Create(FPanel1);
|
FPanel3 := TPanel.Create(FPanel1);
|
||||||
with FPanel3 do
|
with FPanel3 do
|
||||||
begin
|
begin
|
||||||
Parent := FPanel1;
|
Parent := FPanel1;
|
||||||
Left := 5;
|
Align := alBottom;
|
||||||
Top := 115;
|
BorderSpacing.Left := Scale96ToFont(MARGIN_1);
|
||||||
Width := 55;
|
BorderSpacing.Right := Scale96ToFont(MARGIN_1);
|
||||||
Height := 50;
|
Height := Scale96ToFont(3*IMG_SIZE div 2 + 2 * MARGIN_2);
|
||||||
BevelInner := bvLowered;
|
BevelInner := bvLowered;
|
||||||
BevelOuter := bvRaised;
|
BevelOuter := bvRaised;
|
||||||
Visible := True;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FPanel4 := TPanel.Create(FPanel1);
|
FPanel4 := TPanel.Create(FPanel1);
|
||||||
with FPanel4 do
|
with FPanel4 do
|
||||||
begin
|
begin
|
||||||
Parent := FPanel1;
|
Parent := FPanel1;
|
||||||
Left := 5;
|
Align := alBottom;
|
||||||
Top := 170;
|
BorderSpacing.Around := Scale96ToFont(MARGIN_1);
|
||||||
Width := 55;
|
|
||||||
Height := 75;
|
|
||||||
BevelInner := bvLowered;
|
BevelInner := bvLowered;
|
||||||
BevelOuter := bvRaised;
|
BevelOuter := bvRaised;
|
||||||
Visible := True;
|
AutoSize := true;
|
||||||
end;
|
Top := self.Height; // Force to be at very bottom
|
||||||
|
|
||||||
FRLabel := TLabel.Create(FPanel4);
|
|
||||||
with FRLabel do
|
|
||||||
begin
|
|
||||||
Top := 2;
|
|
||||||
Left := 5;
|
|
||||||
AutoSize := True;
|
|
||||||
{
|
|
||||||
Font.Size := 8;
|
|
||||||
Font.Name := 'Arial';
|
|
||||||
}
|
|
||||||
Caption := RsDefaultR;
|
|
||||||
Transparent := True;
|
|
||||||
Parent := FPanel4;
|
|
||||||
end;
|
|
||||||
|
|
||||||
FGLabel := TLabel.Create(FPanel4);
|
|
||||||
with FGLabel do
|
|
||||||
begin
|
|
||||||
Top := 14;
|
|
||||||
Left := 5;
|
|
||||||
AutoSize := True;
|
|
||||||
{
|
|
||||||
Font.Name := 'Arial';
|
|
||||||
Font.Size := 8;
|
|
||||||
}
|
|
||||||
Caption := RsDefaultG;
|
|
||||||
Transparent := True;
|
|
||||||
Parent := FPanel4;
|
|
||||||
end;
|
|
||||||
|
|
||||||
FBLabel := TLabel.Create(FPanel4);
|
|
||||||
with FBLabel do
|
|
||||||
begin
|
|
||||||
Top := 26;
|
|
||||||
Left := 5;
|
|
||||||
{
|
|
||||||
Font.Size := 8;
|
|
||||||
Font.Name := 'arial';
|
|
||||||
}
|
|
||||||
AutoSize := True;
|
|
||||||
Caption := RsDefaultB;
|
|
||||||
Transparent := True;
|
|
||||||
Parent := FPanel4;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FGamma := TImage.Create(FPanel2);
|
FGamma := TImage.Create(FPanel2);
|
||||||
with FGamma do
|
with FGamma do
|
||||||
begin
|
begin
|
||||||
Parent := FPanel2;
|
Parent := FPanel2;
|
||||||
Stretch := False;
|
Align := alClient;
|
||||||
Center := True;
|
Stretch := true;
|
||||||
AutoSize := True;
|
|
||||||
Picture.Bitmap.PixelFormat := pf24bit;
|
|
||||||
Width := 55;
|
|
||||||
Height := 105;
|
|
||||||
OnMouseDown := @ChangeColor;
|
OnMouseDown := @ChangeColor;
|
||||||
OnMouseMove := @ColorSeek;
|
OnMouseMove := @ColorSeek;
|
||||||
Align := alClient;
|
Align := alClient;
|
||||||
@ -217,112 +162,93 @@ begin
|
|||||||
Cursor := crCross;
|
Cursor := crCross;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FChoosed := TImage.Create(FPanel4);
|
FBackgroundColorImg := TShape.Create(FPanel3);
|
||||||
with FChoosed do
|
|
||||||
begin
|
|
||||||
Top := 40;
|
|
||||||
Left := 12;
|
|
||||||
Width := 30;
|
|
||||||
Height := 30;
|
|
||||||
Parent := FPanel4;
|
|
||||||
Visible := True;
|
|
||||||
Stretch := False;
|
|
||||||
Align := alNone;
|
|
||||||
// Picture.Bitmap := TBitmap.Create;
|
|
||||||
Picture.Bitmap.Width := Width;
|
|
||||||
Picture.Bitmap.Height := Height;
|
|
||||||
Canvas.Brush.Color := clBlack;
|
|
||||||
Canvas.Brush.Style := bsSolid;
|
|
||||||
Canvas.FillRect(Rect(0, 0, Width, Height));
|
|
||||||
end;
|
|
||||||
|
|
||||||
FForegroundColorImg := TImage.Create(FPanel3);
|
|
||||||
with FForegroundColorImg do
|
|
||||||
begin
|
|
||||||
Left := 5;
|
|
||||||
Top := 5;
|
|
||||||
Width := 25;
|
|
||||||
Height := 25;
|
|
||||||
// Picture.Bitmap := TBitmap.Create;
|
|
||||||
Picture.Bitmap.Width := FChoosed.Width;
|
|
||||||
Picture.Bitmap.Height := FChoosed.Height;
|
|
||||||
Canvas.Brush.Color := clBlack;
|
|
||||||
Canvas.Brush.Style := bsSolid;
|
|
||||||
Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height));
|
|
||||||
Hint := RsHint2;
|
|
||||||
ShowHint := True;
|
|
||||||
OnClick := @Color1Click;
|
|
||||||
Parent := FPanel3;
|
|
||||||
Visible := True;
|
|
||||||
end;
|
|
||||||
|
|
||||||
FBackgroundColorImg := TImage.Create(FPanel3);
|
|
||||||
with FBackgroundColorImg do
|
with FBackgroundColorImg do
|
||||||
begin
|
begin
|
||||||
Left := 25;
|
|
||||||
Top := 20;
|
|
||||||
Height := 25;
|
|
||||||
Width := 25;
|
|
||||||
// Picture.Bitmap := TBitmap.Create;
|
|
||||||
Picture.Bitmap.Width := FChoosed.Width;
|
|
||||||
Picture.Bitmap.Height := FChoosed.Height;
|
|
||||||
Canvas.Brush.Color := clWhite;
|
|
||||||
Canvas.Brush.Style := bsSolid;
|
|
||||||
Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height));
|
|
||||||
Hint := RsHint1;
|
|
||||||
ShowHint := True;
|
|
||||||
OnClick := @Color2Click;
|
|
||||||
Parent := FPanel3;
|
Parent := FPanel3;
|
||||||
Visible := True;
|
Height := Scale96ToFont(IMG_SIZE);
|
||||||
|
Width := Height;
|
||||||
|
Top := Scale96ToFont(MARGIN_2) + Height div 2;
|
||||||
|
Left := Scale96ToFont(MARGIN_2) + Width div 2;
|
||||||
|
Brush.Color := clBlack;
|
||||||
|
Hint := RsHintBg;
|
||||||
|
ShowHint := True;
|
||||||
|
OnClick := @BgColorClick;
|
||||||
|
end;
|
||||||
|
|
||||||
|
FForegroundColorImg := TShape.Create(FPanel3);
|
||||||
|
with FForegroundColorImg do
|
||||||
|
begin
|
||||||
|
Parent := FPanel3;
|
||||||
|
Height := Scale96ToFont(IMG_SIZE);
|
||||||
|
Width := Height;
|
||||||
|
Left := Scale96ToFont(MARGIN_2);
|
||||||
|
Top := Scale96ToFont(MARGIN_2);
|
||||||
|
Brush.Color := clWhite;
|
||||||
|
Hint := RsHintFg;
|
||||||
|
ShowHint := True;
|
||||||
|
OnClick := @FgColorClick;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FXLabel := TLabel.Create(FPanel3);
|
FXLabel := TLabel.Create(FPanel3);
|
||||||
with FXLabel do
|
with FXLabel do
|
||||||
begin
|
begin
|
||||||
Left := 7;
|
Parent := FPanel3;
|
||||||
Top := 32;
|
BorderSpacing.Left := Scale96ToFont(MARGIN_1);
|
||||||
|
BorderSpacing.Bottom := 0;
|
||||||
|
Alignment := taCenter;
|
||||||
AutoSize := True;
|
AutoSize := True;
|
||||||
Caption := RsXCaption;
|
Caption := RsXCaption;
|
||||||
Hint := RsLabelHint;
|
Hint := RsLabelHint;
|
||||||
OnClick := @Exchange;
|
OnClick := @Exchange;
|
||||||
ShowHint := True;
|
ShowHint := True;
|
||||||
Visible := True;
|
end;
|
||||||
Parent := FPanel3;
|
|
||||||
|
FRLabel := TLabel.Create(FPanel4);
|
||||||
|
with FRLabel do
|
||||||
|
begin
|
||||||
|
Parent := FPanel4;
|
||||||
|
Align := alTop;
|
||||||
|
BorderSpacing.Left := Scale96ToFont(2);
|
||||||
|
Caption := RsDefaultR;
|
||||||
|
Transparent := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
FGLabel := TLabel.Create(FPanel4);
|
||||||
|
with FGLabel do
|
||||||
|
begin
|
||||||
|
Parent := FPanel4;
|
||||||
|
Align := alTop;
|
||||||
|
Top := FRLabel.Top + FRLabel.Height;
|
||||||
|
BorderSpacing.Left := FRLabel.BorderSpacing.Left;
|
||||||
|
Caption := RsDefaultG;
|
||||||
|
Transparent := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
FBLabel := TLabel.Create(FPanel4);
|
||||||
|
with FBLabel do
|
||||||
|
begin
|
||||||
|
Parent := FPanel4;
|
||||||
|
Align := alTop;
|
||||||
|
Top := FGLabel.Top + FGLabel.Height;
|
||||||
|
BorderSpacing.Left := FRLabel.BorderSpacing.Left;
|
||||||
|
Caption := RsDefaultB;
|
||||||
|
Transparent := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
FChosen := TShape.Create(FPanel4);
|
||||||
|
with FChosen do
|
||||||
|
begin
|
||||||
|
Parent := FPanel4;
|
||||||
|
Align := alTop;
|
||||||
|
Top := FBLabel.Top + FBLabel.Height;
|
||||||
|
Height := FBLabel.Height * 2;
|
||||||
|
BorderSpacing.Around := Scale96ToFont(MARGIN_1);
|
||||||
|
Brush.Color := clBlack;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJvGammaPanel.ChangeColor(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure TJvGammaPanel.BgColorClick(Sender: TObject);
|
||||||
begin
|
|
||||||
if Button = mbLeft then
|
|
||||||
begin
|
|
||||||
FForegroundColor := LastCol;
|
|
||||||
FForegroundColorImg.Canvas.Brush.Color := FForegroundColor;
|
|
||||||
FForegroundColorImg.Canvas.Brush.Style := bsSolid;
|
|
||||||
FForegroundColorImg.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height));
|
|
||||||
DoChangeColor(FForegroundColor, FBackgroundColor);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if Button = mbRight then
|
|
||||||
begin
|
|
||||||
FBackgroundColor := LastCol;
|
|
||||||
FBackgroundColorImg.Canvas.Brush.Color := FBackgroundColor;
|
|
||||||
FBackgroundColorImg.Canvas.Brush.Style := bsSolid;
|
|
||||||
FBackgroundColorImg.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height));
|
|
||||||
DoChangeColor(FForegroundColor, FBackgroundColor);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TJvGammaPanel.Color1Click(Sender: TObject);
|
|
||||||
begin
|
|
||||||
with TColorDialog.Create(Self) do
|
|
||||||
begin
|
|
||||||
if Execute then
|
|
||||||
SetForegroundColor(Color);
|
|
||||||
Free;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TJvGammaPanel.Color2Click(Sender: TObject);
|
|
||||||
begin
|
begin
|
||||||
with TColorDialog.Create(Self) do
|
with TColorDialog.Create(Self) do
|
||||||
begin
|
begin
|
||||||
@ -332,69 +258,68 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJvGammaPanel.ColorSeek(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
procedure TJvGammaPanel.ChangeColor(Sender: TObject; Button: TMouseButton;
|
||||||
|
Shift: TShiftState; X, Y: Integer);
|
||||||
|
begin
|
||||||
|
if Button = mbLeft then
|
||||||
|
begin
|
||||||
|
FForegroundColorImg.Brush.Color := FLastColor;
|
||||||
|
DoChangeColor(FLastColor, FBackgroundColorImg.Brush.Color);
|
||||||
|
end else
|
||||||
|
if Button = mbRight then
|
||||||
|
begin
|
||||||
|
FBackgroundColorImg.Brush.Color := FLastColor;
|
||||||
|
DoChangeColor(FForegroundColorImg.Brush.Color, FLastColor);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJvGammaPanel.ColorSeek(Sender: TObject; Shift: TShiftState;
|
||||||
|
X, Y: Integer);
|
||||||
var
|
var
|
||||||
Col: TColor;
|
col: TColor;
|
||||||
|
xbmp, ybmp: Integer;
|
||||||
begin
|
begin
|
||||||
if not PtInRect(Bounds(0, 0, FGamma.Picture.Width, FGamma.Picture.Height), Point(X,Y)) then
|
if not PtInRect(Bounds(0, 0, FGamma.Width, FGamma.Height), Point(X,Y)) then
|
||||||
Exit; // asn for Linux/X11
|
Exit;
|
||||||
Col := FGamma.Picture.Bitmap.Canvas.Pixels[X, Y];
|
|
||||||
LastCol := Col;
|
xbmp := round(X * FGamma.Picture.Bitmap.Width / FGamma.Width);
|
||||||
FRLabel.Caption := Format(RsRedFormat, [GetRValue(Col)]);
|
ybmp := round(Y * FGamma.Picture.Bitmap.Height / FGamma.Height);
|
||||||
FGLabel.Caption := Format(RsGreenFormat, [GetGValue(Col)]);
|
col := FGamma.Picture.Bitmap.Canvas.Pixels[xbmp, ybmp];
|
||||||
FBLabel.Caption := Format(RsBlueFormat, [GetBValue(Col)]);
|
FLastColor := col;
|
||||||
FChoosed.Canvas.Brush.Color := Col;
|
FRLabel.Caption := Format(RsRedFormat, [GetRValue(col)]);
|
||||||
FChoosed.Canvas.Brush.Style := bsSolid;
|
FGLabel.Caption := Format(RsGreenFormat, [GetGValue(col)]);
|
||||||
FChoosed.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height));
|
FBLabel.Caption := Format(RsBlueFormat, [GetBValue(col)]);
|
||||||
|
FChosen.Brush.Color := col;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJvGammaPanel.Exchange(Sender: TObject);
|
procedure TJvGammaPanel.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
|
||||||
var
|
const AXProportion, AYProportion: Double);
|
||||||
Col: TColor;
|
|
||||||
begin
|
begin
|
||||||
// exchange colors
|
inherited;
|
||||||
Col := FForegroundColor;
|
|
||||||
FForegroundColor := FBackgroundColor;
|
|
||||||
FBackgroundColor := Col;
|
|
||||||
|
|
||||||
FForegroundColorImg.Canvas.Brush.Color := FForegroundColor;
|
FPanel2.BorderSpacing.Around := round(MARGIN_1 * AXProportion);
|
||||||
FForegroundColorImg.Canvas.Brush.Style := bsSolid;
|
FPanel3.BorderSpacing.Left := round(MARGIN_1 * AXProportion);
|
||||||
FForegroundColorImg.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height));
|
FPanel3.BorderSpacing.Right := round(MARGIN_1 * AXProportion);
|
||||||
|
FPanel3.Height := round((IMG_SIZE * 3 div 2 + 2 * MARGIN_2) * AYProportion);
|
||||||
|
|
||||||
FBackgroundColorImg.Canvas.Brush.Color := FBackgroundColor;
|
FPanel4.BorderSpacing.Around := round(MARGIN_1 * AXProportion);
|
||||||
FBackgroundColorImg.Canvas.Brush.Style := bsSolid;
|
|
||||||
FBackgroundColorImg.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height));
|
|
||||||
|
|
||||||
if Assigned(FOnChangeColor) then
|
FBackgroundColorImg.Height := round(IMG_SIZE * AYProportion);
|
||||||
FOnChangeColor(Self, FForegroundColor, FBackgroundColor);
|
FBackgroundColorImg.Width := round(IMG_SIZE * AXProportion);
|
||||||
end;
|
FBackgroundColorImg.Top := round((MARGIN_2 + IMG_SIZE div 2) * AYProportion);
|
||||||
|
FBackgroundColorImg.Left := round((MARGIN_2 + IMG_SIZE div 2) * AXProportion);
|
||||||
|
|
||||||
procedure TJvGammaPanel.SetForegroundColor(const Value: TColor);
|
FForegroundColorImg.Height := round(IMG_SIZE * AYProportion);
|
||||||
begin
|
FBackgroundColorImg.Width := round(IMG_SIZE * AXProportion);
|
||||||
FForegroundColor := Value;
|
FBackgroundColorImg.Left := round(MARGIN_2 * AXProportion);
|
||||||
FForegroundColorImg.Canvas.Brush.Color := FForegroundColor;
|
FBackgroundColorImg.Top := round(MARGIN_2 * AYProportion);
|
||||||
FForegroundColorImg.Canvas.Brush.Style := bsSolid;
|
|
||||||
FForegroundColorImg.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height));
|
|
||||||
if Assigned(FOnChangeColor) then
|
|
||||||
FOnChangeColor(Self, FForegroundColor, FBackgroundColor);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TJvGammaPanel.SetBackgroundColor(const Value: TColor);
|
FXLabel.BorderSpacing.Left := round(MARGIN_1 * AXProportion);
|
||||||
begin
|
|
||||||
FBackgroundColor := Value;
|
|
||||||
FBackgroundColorImg.Canvas.Brush.Color := FBackgroundColor;
|
|
||||||
FBackgroundColorImg.Canvas.Brush.Style := bsSolid;
|
|
||||||
FBackgroundColorImg.Canvas.FillRect(Rect(0, 0, FChoosed.Width, FChoosed.Height));
|
|
||||||
if Assigned(FOnChangeColor) then
|
|
||||||
FOnChangeColor(Self, FForegroundColor, FBackgroundColor);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TJvGammaPanel.BoundsChanged;
|
FRLabel.BorderSpacing.Left := round(MARGIN_2 * AXProportion);
|
||||||
begin
|
FGLabel.BorderSpacing.Left := round(MARGIN_2 * AXProportion);
|
||||||
Width := 65;
|
FBLabel.BorderSpacing.Left := round(MARGIN_2 * AXProportion);
|
||||||
Height := 250;
|
FChosen.BorderSpacing.Left := round(MARGIN_1 * AXProportion);
|
||||||
if Assigned(FForegroundColorImg) then
|
|
||||||
FForegroundColorImg.BringToFront;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TJvGammaPanel.DoChangeColor(AForegroundColor, ABackgroundColor: TColor);
|
procedure TJvGammaPanel.DoChangeColor(AForegroundColor, ABackgroundColor: TColor);
|
||||||
@ -403,5 +328,100 @@ begin
|
|||||||
FOnChangeColor(Self, AForegroundColor, ABackgroundColor);
|
FOnChangeColor(Self, AForegroundColor, ABackgroundColor);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TJvGammaPanel.Exchange(Sender: TObject);
|
||||||
|
var
|
||||||
|
col: TColor;
|
||||||
|
savedOnChangeColor: TJvChangeColorEvent;
|
||||||
|
begin
|
||||||
|
savedOnChangeColor := FOnChangeColor;
|
||||||
|
FOnChangeColor := nil;
|
||||||
|
|
||||||
|
// exchange colors
|
||||||
|
col := GetForegroundColor;
|
||||||
|
SetForegroundColor(GetBackgroundColor);
|
||||||
|
SetBackgroundColor(col);
|
||||||
|
|
||||||
|
FOnChangeColor := savedOnChangeColor;
|
||||||
|
DoChangeColor(GetForegroundColor, GetBackgroundColor);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJvGammaPanel.FgColorClick(Sender: TObject);
|
||||||
|
begin
|
||||||
|
with TColorDialog.Create(Self) do
|
||||||
|
begin
|
||||||
|
if Execute then
|
||||||
|
SetForegroundColor(Color);
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJvGammaPanel.GetBackgroundColor: TColor;
|
||||||
|
begin
|
||||||
|
Result := FBackgroundColorImg.Brush.Color;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJvGammaPanel.GetForegroundColor: TColor;
|
||||||
|
begin
|
||||||
|
Result := FForegroundColorImg.Brush.Color;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJvGammaPanel.IsHeightStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result := Height <> Scale96ToFont(DEFAULT_HEIGHT);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TJvGammaPanel.IsWidthStored: Boolean;
|
||||||
|
begin
|
||||||
|
Result := Width <> Scale96ToFont(DEFAULT_WIDTH);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJvGammaPanel.Resize;
|
||||||
|
var
|
||||||
|
imgSize: Integer;
|
||||||
|
p: Integer;
|
||||||
|
m: Integer;
|
||||||
|
hx: Integer;
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
if FPanel3 = nil then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
m := Scale96ToFont(MARGIN_1);
|
||||||
|
if FPanel3.Width > FPanel3.Height then begin
|
||||||
|
imgSize := (FPanel3.ClientHeight - 2*m) div 3 * 2;
|
||||||
|
p := (FPanel3.ClientWidth - imgSize*3 div 2) div 2;
|
||||||
|
FBackgroundColorImg.SetBounds(
|
||||||
|
p + imgSize*3 div 2 - imgSize, FPanel3.ClientHeight - imgSize - m, imgSize, imgSize);
|
||||||
|
FForegroundColorImg.SetBounds(p, m, imgSize, imgSize);
|
||||||
|
FXLabel.Left := FForegroundColorImg.Left;
|
||||||
|
FXLabel.AnchorSideBottom.Control := FPanel3;
|
||||||
|
FXLabel.AnchorSideBottom.Side := asrBottom;
|
||||||
|
FXLabel.Anchors := [akLeft, akBottom];
|
||||||
|
FXLabel.BorderSpacing.Bottom := 0;
|
||||||
|
end else begin
|
||||||
|
imgSize := (FPanel3.ClientWidth - 2*m) div 3 * 2;
|
||||||
|
p := (FPanel3.ClientHeight - imgSize*3 div 2) div 2;
|
||||||
|
FBackgroundColorImg.SetBounds(
|
||||||
|
FPanel3.ClientWidth - imgSize - m, p + imgSize*3 div 2 - imgSize, imgSize, imgSize);
|
||||||
|
FForegroundColorImg.SetBounds(
|
||||||
|
m, p, imgSize, imgSize);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJvGammaPanel.SetBackgroundColor(const AValue: TColor);
|
||||||
|
begin
|
||||||
|
if GetBackgroundColor = AValue then
|
||||||
|
exit;
|
||||||
|
FBackgroundColorImg.Brush.Color := AValue;
|
||||||
|
DoChangeColor(GetForegroundColor, AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TJvGammaPanel.SetForegroundColor(const AValue: TColor);
|
||||||
|
begin
|
||||||
|
if GetForegroundColor = AValue then
|
||||||
|
exit;
|
||||||
|
FForegroundColorImg.Brush.Color := AValue;
|
||||||
|
DoChangeColor(AValue, GetBackgroundColor);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user