mColorLib: Refactor mouse coordinates (mx, mxx, mdx etc).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5579 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-01-02 00:34:45 +00:00
parent 454f0baf7b
commit fe87aadcd8
10 changed files with 105 additions and 196 deletions

View File

@@ -23,30 +23,20 @@ type
protected
FManual: Boolean;
FSelected: TColor;
mx, my, mdx, mdy: integer;
mx, my: integer;
procedure CreateGradient; override;
function GetHintStr(X, Y: Integer): String; override;
function GetSelectedColor: TColor; virtual;
procedure InternalDrawMarker(X, Y: Integer; C: TColor);
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure SetSelectedColor(C: TColor); virtual;
procedure WebSafeChanged; dynamic;
{$IFDEF DELPHI}
procedure CMGotFocus(var Message: TCMGotFocus); message CM_ENTER;
procedure CMLostFocus(var Message: TCMLostFocus); message CM_EXIT;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
{$ELSE}
procedure CMGotFocus(var Message: TLMessage); message CM_ENTER;
procedure CMLostFocus(var Message: TLMessage); message CM_EXIT;
procedure CMMouseLeave(var Message: TLMessage); message CM_MOUSELEAVE;
{$ENDIF}
property MarkerStyle: TMarkerStyle read FMarkerStyle write SetMarkerStyle;
public
constructor Create(AOwner: TComponent); override;
property ColorUnderCursor;
property Manual: boolean read FManual;
published
property SelectedColor: TColor read GetSelectedColor write SetSelectedColor;
property HintFormat: string read FHintFormat write FHintFormat;
@@ -67,9 +57,6 @@ type
property TabStop default true;
property Color;
property ParentColor;
{$IFDEF DELPHI_7_UP}{$IFDEF DELPHI}
property ParentBackground default true;
{$ENDIF}{$ENDIF}
property DragCursor;
property DragMode;
property DragKind;
@@ -94,9 +81,7 @@ type
implementation
uses
{$IFDEF FPC}
IntfGraphics, fpimage,
{$ENDIF}
ScanLines, PalUtils, SelPropUtils;
constructor TmbCustomPicker.Create(AOwner: TComponent);
@@ -107,28 +92,23 @@ begin
TabStop := true;
mx := 0;
my := 0;
mdx := 0;
mdy := 0;
FHintFormat := 'Hex #%hex'#10#13'RGB[%r, %g, %b]'#10#13'HSL[%hslH, %hslS, %hslL]'#10#13'HSV[%hsvH, %hsvS, %hsvV]'#10#13'CMYK[%c, %m, %y, %k]'#10#13'L*a*b*[%cieL, %cieA, %cieB]'#10#13'XYZ[%cieX, %cieY, %cieZ]';
FWebSafe := false;
end;
procedure TmbCustomPicker.CMGotFocus(
var Message: {$IFDEF FPC}TLMessage{$ELSE}TCMGotFocus{$ENDIF} );
procedure TmbCustomPicker.CMGotFocus(var Message: TLMessage);
begin
inherited;
Invalidate;
end;
procedure TmbCustomPicker.CMLostFocus(
var Message: {$IFDEF FPC}TLMessage{$ELSE}TCMLostFocus{$ENDIF} );
procedure TmbCustomPicker.CMLostFocus(var Message: TLMessage);
begin
inherited;
Invalidate;
end;
procedure TmbCustomPicker.CMMouseLeave(
var Message: {$IFDEF FPC}TLMessage{$ELSE}TMessage{$ENDIF});
procedure TmbCustomPicker.CMMouseLeave(var Message: TLMessage);
begin
mx := 0;
my := 0;
@@ -195,29 +175,6 @@ begin
end;
end;
procedure TmbCustomPicker.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
inherited;
mx := x;
my := y;
end;
procedure TmbCustomPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
inherited;
mx := x;
my := y;
end;
procedure TmbCustomPicker.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
inherited;
mx := x;
my := y;
end;
procedure TmbCustomPicker.SetMarkerStyle(s: TMarkerStyle);
begin
if FMarkerStyle <> s then