You've already forked lazarus-ccr
mbColorLib: Improved handling of hints.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5464 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -65,7 +65,7 @@ begin
|
|||||||
FChange := false;
|
FChange := false;
|
||||||
Layout := lyVertical;
|
Layout := lyVertical;
|
||||||
SetBlue(255);
|
SetBlue(255);
|
||||||
HintFormat := 'Blue: %value';
|
HintFormat := 'Blue: %value (selected)';
|
||||||
FManual := false;
|
FManual := false;
|
||||||
FChange := true;
|
FChange := true;
|
||||||
end;
|
end;
|
||||||
|
@ -63,7 +63,7 @@ begin
|
|||||||
FChange := false;
|
FChange := false;
|
||||||
Layout := lyVertical;
|
Layout := lyVertical;
|
||||||
SetCyan(255);
|
SetCyan(255);
|
||||||
HintFormat := 'Cyan: %value';
|
HintFormat := 'Selected cyan value: %value';
|
||||||
FManual := false;
|
FManual := false;
|
||||||
FChange := true;
|
FChange := true;
|
||||||
end;
|
end;
|
||||||
|
@ -58,7 +58,7 @@ begin
|
|||||||
FChange := false;
|
FChange := false;
|
||||||
Layout := lyVertical;
|
Layout := lyVertical;
|
||||||
SetGreen(255);
|
SetGreen(255);
|
||||||
HintFormat := 'Green: %value';
|
HintFormat := 'Green: %value (selected)';
|
||||||
FManual := false;
|
FManual := false;
|
||||||
FChange := true;
|
FChange := true;
|
||||||
end;
|
end;
|
||||||
|
@ -58,7 +58,7 @@ begin
|
|||||||
FArrowPos := ArrowPosFromHue(0);
|
FArrowPos := ArrowPosFromHue(0);
|
||||||
FChange := false;
|
FChange := false;
|
||||||
SetHue(0);
|
SetHue(0);
|
||||||
HintFormat := 'Hue: %value';
|
HintFormat := 'Hue: %value (selected)';
|
||||||
FManual := false;
|
FManual := false;
|
||||||
FChange := true;
|
FChange := true;
|
||||||
end;
|
end;
|
||||||
|
@ -45,6 +45,7 @@ type
|
|||||||
procedure CreateWnd; override;
|
procedure CreateWnd; 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;
|
||||||
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;
|
||||||
@ -87,6 +88,7 @@ begin
|
|||||||
FChange := true;
|
FChange := true;
|
||||||
FRadius := 40;
|
FRadius := 40;
|
||||||
FDoChange := false;
|
FDoChange := false;
|
||||||
|
HintFormat := 'Hue: %h (selected)';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure THRingPicker.CreateGradient;
|
procedure THRingPicker.CreateGradient;
|
||||||
@ -336,6 +338,18 @@ begin
|
|||||||
SetFocus;
|
SetFocus;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function THRingPicker.MouseOnPicker(X, Y: Integer): Boolean;
|
||||||
|
var
|
||||||
|
diameter, r: Integer;
|
||||||
|
P, ctr: TPoint;
|
||||||
|
begin
|
||||||
|
diameter := Min(Width, Height);
|
||||||
|
r := diameter div 2; // outer radius
|
||||||
|
P := Point(x, y);
|
||||||
|
ctr := Point(r, r);
|
||||||
|
Result := PtInCircle(P, ctr, r) and not PtInCircle(P, ctr, Radius);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure THRingPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
procedure THRingPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
@ -128,13 +128,14 @@ begin
|
|||||||
FLCursor := crDefault;
|
FLCursor := crDefault;
|
||||||
with FHSPicker do
|
with FHSPicker do
|
||||||
begin
|
begin
|
||||||
SetInitialBounds(0, 6, 174, 134);
|
{$IFDEF DELPHI}
|
||||||
{
|
|
||||||
Height := 134;
|
|
||||||
Width := 174;
|
|
||||||
Top := 6;
|
|
||||||
Left := 0;
|
Left := 0;
|
||||||
}
|
Top := 6;
|
||||||
|
Width := 174;
|
||||||
|
Height := 134;
|
||||||
|
{$ELSE}
|
||||||
|
SetInitialBounds(0, 6, 174, 134);
|
||||||
|
{$ENDIF}
|
||||||
Anchors := [akLeft, akTop, akRight, akBottom];
|
Anchors := [akLeft, akTop, akRight, akBottom];
|
||||||
Visible := true;
|
Visible := true;
|
||||||
OnChange := HSPickerChange;
|
OnChange := HSPickerChange;
|
||||||
@ -145,12 +146,14 @@ begin
|
|||||||
with FLPicker do
|
with FLPicker do
|
||||||
begin
|
begin
|
||||||
Layout := lyVertical;
|
Layout := lyVertical;
|
||||||
SetInitialBounds(184, 0, 25, 146);
|
{$IFDEF DELPHI}
|
||||||
{
|
|
||||||
Height := 146;
|
|
||||||
Top := 0;
|
|
||||||
Left := 184;
|
Left := 184;
|
||||||
}
|
Top := 0;
|
||||||
|
Width := 25;
|
||||||
|
Height := 146;
|
||||||
|
{$ELSE}
|
||||||
|
SetInitialBounds(184, 0, 25, 146);
|
||||||
|
{$ENDIF}
|
||||||
Anchors := [akRight, akTop, akBottom];
|
Anchors := [akRight, akTop, akBottom];
|
||||||
Visible := true;
|
Visible := true;
|
||||||
OnChange := LPickerChange;
|
OnChange := LPickerChange;
|
||||||
|
@ -51,6 +51,7 @@ type
|
|||||||
procedure CreateWnd; override;
|
procedure CreateWnd; 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;
|
||||||
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;
|
||||||
@ -417,6 +418,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function THSVColorPicker.MouseOnPicker(X, Y: Integer): Boolean;
|
||||||
|
var
|
||||||
|
diameter, r: Integer;
|
||||||
|
P, ctr: TPoint;
|
||||||
|
begin
|
||||||
|
diameter := Min(Width, Height);
|
||||||
|
r := diameter div 2;
|
||||||
|
P := Point(x, y);
|
||||||
|
ctr := Point(r, r);
|
||||||
|
Result := PtInCircle(P, ctr, r);
|
||||||
|
end;
|
||||||
|
|
||||||
function THSVColorPicker.GetSelectedColor: TColor;
|
function THSVColorPicker.GetSelectedColor: TColor;
|
||||||
begin
|
begin
|
||||||
if FSelectedColor <> clNone then
|
if FSelectedColor <> clNone then
|
||||||
|
@ -63,7 +63,7 @@ begin
|
|||||||
FChange := false;
|
FChange := false;
|
||||||
Layout := lyVertical;
|
Layout := lyVertical;
|
||||||
SetBlack(255);
|
SetBlack(255);
|
||||||
HintFormat := 'Black: %value';
|
HintFormat := 'Black: %value (selected)';
|
||||||
FManual := false;
|
FManual := false;
|
||||||
FChange := true;
|
FChange := true;
|
||||||
end;
|
end;
|
||||||
|
@ -57,7 +57,7 @@ begin
|
|||||||
FArrowPos := ArrowPosFromLum(MaxLum div 2);
|
FArrowPos := ArrowPosFromLum(MaxLum div 2);
|
||||||
FChange := false;
|
FChange := false;
|
||||||
SetLuminance(MaxLum div 2);
|
SetLuminance(MaxLum div 2);
|
||||||
HintFormat := 'Luminance: %value';
|
HintFormat := 'Luminance: %value (selected)';
|
||||||
FManual := false;
|
FManual := false;
|
||||||
FChange := true;
|
FChange := true;
|
||||||
end;
|
end;
|
||||||
|
@ -63,7 +63,7 @@ begin
|
|||||||
FChange := false;
|
FChange := false;
|
||||||
Layout := lyVertical;
|
Layout := lyVertical;
|
||||||
SetMagenta(255);
|
SetMagenta(255);
|
||||||
HintFormat := 'Magenta: %value';
|
HintFormat := 'Magenta: %value (selected)';
|
||||||
FManual := false;
|
FManual := false;
|
||||||
FChange := true;
|
FChange := true;
|
||||||
end;
|
end;
|
||||||
|
@ -65,7 +65,7 @@ begin
|
|||||||
FChange := false;
|
FChange := false;
|
||||||
Layout := lyVertical;
|
Layout := lyVertical;
|
||||||
SetRed(255);
|
SetRed(255);
|
||||||
HintFormat := 'Red: %value';
|
HintFormat := 'Red: %value (selected)';
|
||||||
FManual := false;
|
FManual := false;
|
||||||
FChange := true;
|
FChange := true;
|
||||||
end;
|
end;
|
||||||
|
@ -58,7 +58,7 @@ begin
|
|||||||
FArrowPos := ArrowPosFromSat(0);
|
FArrowPos := ArrowPosFromSat(0);
|
||||||
FChange := false;
|
FChange := false;
|
||||||
SetSat(255);
|
SetSat(255);
|
||||||
HintFormat := 'Saturation: %value';
|
HintFormat := 'Saturation: %value (selected)';
|
||||||
FManual := false;
|
FManual := false;
|
||||||
FChange := true;
|
FChange := true;
|
||||||
end;
|
end;
|
||||||
|
@ -54,7 +54,7 @@ begin
|
|||||||
FArrowPos := ArrowPosFromVal(255);
|
FArrowPos := ArrowPosFromVal(255);
|
||||||
FChange := false;
|
FChange := false;
|
||||||
SetValue(255);
|
SetValue(255);
|
||||||
HintFormat := 'Value: %value';
|
HintFormat := 'Value: %value (selected)';
|
||||||
FManual := false;
|
FManual := false;
|
||||||
FChange := true;
|
FChange := true;
|
||||||
end;
|
end;
|
||||||
|
@ -64,7 +64,7 @@ begin
|
|||||||
FChange := false;
|
FChange := false;
|
||||||
Layout := lyVertical;
|
Layout := lyVertical;
|
||||||
SetYellow(255);
|
SetYellow(255);
|
||||||
HintFormat := 'Yellow: %value';
|
HintFormat := 'Yellow: %value (selected)';
|
||||||
FManual := false;
|
FManual := false;
|
||||||
FChange := true;
|
FChange := true;
|
||||||
end;
|
end;
|
||||||
|
@ -42,9 +42,9 @@ object Form1: TForm1
|
|||||||
Height = 331
|
Height = 331
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 399
|
Width = 399
|
||||||
ActivePage = TabSheet1
|
ActivePage = TabSheet8
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
TabIndex = 0
|
TabIndex = 8
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
OnMouseMove = PageControl1MouseMove
|
OnMouseMove = PageControl1MouseMove
|
||||||
object TabSheet1: TTabSheet
|
object TabSheet1: TTabSheet
|
||||||
@ -56,7 +56,7 @@ object Form1: TForm1
|
|||||||
Height = 287
|
Height = 287
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 377
|
Width = 377
|
||||||
SelectedColor = 424966
|
SelectedColor = 422918
|
||||||
HSPickerHintFormat = 'H: %h S: %s'#13'Hex: %hex'
|
HSPickerHintFormat = 'H: %h S: %s'#13'Hex: %hex'
|
||||||
LPickerHintFormat = 'Luminance: %l'
|
LPickerHintFormat = 'Luminance: %l'
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
@ -218,7 +218,7 @@ object Form1: TForm1
|
|||||||
Left = 0
|
Left = 0
|
||||||
Height = 234
|
Height = 234
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 364
|
Width = 360
|
||||||
Align = alTop
|
Align = alTop
|
||||||
Colors.Strings = (
|
Colors.Strings = (
|
||||||
'clBlack'
|
'clBlack'
|
||||||
@ -605,7 +605,7 @@ object Form1: TForm1
|
|||||||
Height = 302
|
Height = 302
|
||||||
Top = 2
|
Top = 2
|
||||||
Width = 22
|
Width = 22
|
||||||
HintFormat = 'Value: %v'
|
HintFormat = 'Value: %v (selected)'
|
||||||
Layout = lyVertical
|
Layout = lyVertical
|
||||||
NewArrowStyle = True
|
NewArrowStyle = True
|
||||||
Anchors = [akTop, akRight, akBottom]
|
Anchors = [akTop, akRight, akBottom]
|
||||||
@ -624,7 +624,7 @@ object Form1: TForm1
|
|||||||
Height = 291
|
Height = 291
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 381
|
Width = 381
|
||||||
HPickerHintFormat = 'Hue: %h'
|
HPickerHintFormat = 'Hue: %h (selected)'
|
||||||
SLPickerHintFormat = 'S: %s L: %l'#13'Hex: %hex'
|
SLPickerHintFormat = 'S: %s L: %l'#13'Hex: %hex'
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
@ -702,7 +702,7 @@ object Form1: TForm1
|
|||||||
Height = 25
|
Height = 25
|
||||||
Top = 192
|
Top = 192
|
||||||
Width = 343
|
Width = 343
|
||||||
HintFormat = 'Luminance: %l'
|
HintFormat = 'Luminance: %l (selected)'
|
||||||
SelectionIndicator = siRect
|
SelectionIndicator = siRect
|
||||||
Anchors = [akLeft, akRight, akBottom]
|
Anchors = [akLeft, akRight, akBottom]
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
@ -715,7 +715,7 @@ object Form1: TForm1
|
|||||||
Height = 21
|
Height = 21
|
||||||
Top = 160
|
Top = 160
|
||||||
Width = 343
|
Width = 343
|
||||||
HintFormat = 'Value: %v'
|
HintFormat = 'Value: %v (selected)'
|
||||||
ArrowPlacement = spBefore
|
ArrowPlacement = spBefore
|
||||||
NewArrowStyle = True
|
NewArrowStyle = True
|
||||||
SelectionIndicator = siRect
|
SelectionIndicator = siRect
|
||||||
@ -731,7 +731,7 @@ object Form1: TForm1
|
|||||||
Height = 61
|
Height = 61
|
||||||
Top = 231
|
Top = 231
|
||||||
Width = 343
|
Width = 343
|
||||||
HintFormat = 'Hue: %h'
|
HintFormat = 'Hue: %h (selected)'
|
||||||
Increment = 5
|
Increment = 5
|
||||||
ArrowPlacement = spBoth
|
ArrowPlacement = spBoth
|
||||||
SelectionIndicator = siRect
|
SelectionIndicator = siRect
|
||||||
@ -745,7 +745,7 @@ object Form1: TForm1
|
|||||||
Height = 222
|
Height = 222
|
||||||
Top = 70
|
Top = 70
|
||||||
Width = 19
|
Width = 19
|
||||||
HintFormat = 'Saturation: %s'
|
HintFormat = 'Saturation: %s (selected)'
|
||||||
Layout = lyVertical
|
Layout = lyVertical
|
||||||
ArrowPlacement = spBefore
|
ArrowPlacement = spBefore
|
||||||
NewArrowStyle = True
|
NewArrowStyle = True
|
||||||
@ -805,8 +805,8 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
object TabSheet8: TTabSheet
|
object TabSheet8: TTabSheet
|
||||||
Caption = 'Other'
|
Caption = 'Other'
|
||||||
ClientHeight = 292
|
ClientHeight = 303
|
||||||
ClientWidth = 372
|
ClientWidth = 391
|
||||||
ImageIndex = 7
|
ImageIndex = 7
|
||||||
object HSColorPicker1: THSColorPicker
|
object HSColorPicker1: THSColorPicker
|
||||||
Left = 6
|
Left = 6
|
||||||
@ -837,7 +837,7 @@ object Form1: TForm1
|
|||||||
Height = 130
|
Height = 130
|
||||||
Top = 164
|
Top = 164
|
||||||
Width = 133
|
Width = 133
|
||||||
HintFormat = 'Hue: %h'
|
HintFormat = 'Hue: %h (selected)'
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
OnMouseMove = HRingPicker1MouseMove
|
OnMouseMove = HRingPicker1MouseMove
|
||||||
OnChange = HRingPicker1Change
|
OnChange = HRingPicker1Change
|
||||||
@ -861,7 +861,7 @@ object Form1: TForm1
|
|||||||
Height = 267
|
Height = 267
|
||||||
Top = 18
|
Top = 18
|
||||||
Width = 22
|
Width = 22
|
||||||
HintFormat = 'Cyan: %c'
|
HintFormat = 'Cyan: %c (selected)'
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
SelectedColor = clAqua
|
SelectedColor = clAqua
|
||||||
end
|
end
|
||||||
@ -870,7 +870,7 @@ object Form1: TForm1
|
|||||||
Height = 267
|
Height = 267
|
||||||
Top = 18
|
Top = 18
|
||||||
Width = 22
|
Width = 22
|
||||||
HintFormat = 'Magenta: %m'
|
HintFormat = 'Magenta: %m (selected)'
|
||||||
ArrowPlacement = spBefore
|
ArrowPlacement = spBefore
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
SelectedColor = clFuchsia
|
SelectedColor = clFuchsia
|
||||||
@ -880,7 +880,7 @@ object Form1: TForm1
|
|||||||
Height = 267
|
Height = 267
|
||||||
Top = 19
|
Top = 19
|
||||||
Width = 31
|
Width = 31
|
||||||
HintFormat = 'Yellow: %y'
|
HintFormat = 'Yellow: %y (selected)'
|
||||||
ArrowPlacement = spBoth
|
ArrowPlacement = spBoth
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
SelectedColor = clYellow
|
SelectedColor = clYellow
|
||||||
@ -890,7 +890,7 @@ object Form1: TForm1
|
|||||||
Height = 267
|
Height = 267
|
||||||
Top = 18
|
Top = 18
|
||||||
Width = 22
|
Width = 22
|
||||||
HintFormat = 'Black: %k'
|
HintFormat = 'Black: %k (selected)'
|
||||||
NewArrowStyle = True
|
NewArrowStyle = True
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
Cyan = 0
|
Cyan = 0
|
||||||
@ -902,7 +902,7 @@ object Form1: TForm1
|
|||||||
Height = 268
|
Height = 268
|
||||||
Top = 18
|
Top = 18
|
||||||
Width = 22
|
Width = 22
|
||||||
HintFormat = 'Red: %r'
|
HintFormat = 'Red: %r (selected)'
|
||||||
ArrowPlacement = spBefore
|
ArrowPlacement = spBefore
|
||||||
NewArrowStyle = True
|
NewArrowStyle = True
|
||||||
TabOrder = 4
|
TabOrder = 4
|
||||||
@ -913,7 +913,7 @@ object Form1: TForm1
|
|||||||
Height = 268
|
Height = 268
|
||||||
Top = 18
|
Top = 18
|
||||||
Width = 34
|
Width = 34
|
||||||
HintFormat = 'Green: %g'
|
HintFormat = 'Green: %g (selected)'
|
||||||
ArrowPlacement = spBoth
|
ArrowPlacement = spBoth
|
||||||
NewArrowStyle = True
|
NewArrowStyle = True
|
||||||
TabOrder = 5
|
TabOrder = 5
|
||||||
@ -924,7 +924,7 @@ object Form1: TForm1
|
|||||||
Height = 268
|
Height = 268
|
||||||
Top = 18
|
Top = 18
|
||||||
Width = 22
|
Width = 22
|
||||||
HintFormat = 'Blue: %b'
|
HintFormat = 'Blue: %b (selected)'
|
||||||
SelectionIndicator = siRect
|
SelectionIndicator = siRect
|
||||||
TabOrder = 6
|
TabOrder = 6
|
||||||
SelectedColor = 16743034
|
SelectedColor = 16743034
|
||||||
@ -937,7 +937,7 @@ object Form1: TForm1
|
|||||||
BevelInner = bvRaised
|
BevelInner = bvRaised
|
||||||
BevelOuter = bvRaised
|
BevelOuter = bvRaised
|
||||||
BorderStyle = bsSingle
|
BorderStyle = bsSingle
|
||||||
HintFormat = 'Black: %k'
|
HintFormat = 'Black: %k (selected)'
|
||||||
ArrowPlacement = spBoth
|
ArrowPlacement = spBoth
|
||||||
NewArrowStyle = True
|
NewArrowStyle = True
|
||||||
TabOrder = 7
|
TabOrder = 7
|
||||||
@ -953,7 +953,7 @@ object Form1: TForm1
|
|||||||
BevelInner = bvLowered
|
BevelInner = bvLowered
|
||||||
BevelOuter = bvRaised
|
BevelOuter = bvRaised
|
||||||
BorderStyle = bsSingle
|
BorderStyle = bsSingle
|
||||||
HintFormat = 'Magenta: %m'
|
HintFormat = 'Magenta: %m (selected)'
|
||||||
Layout = lyHorizontal
|
Layout = lyHorizontal
|
||||||
ArrowPlacement = spBoth
|
ArrowPlacement = spBoth
|
||||||
NewArrowStyle = True
|
NewArrowStyle = True
|
||||||
@ -968,7 +968,7 @@ object Form1: TForm1
|
|||||||
BevelInner = bvRaised
|
BevelInner = bvRaised
|
||||||
BevelOuter = bvLowered
|
BevelOuter = bvLowered
|
||||||
BorderStyle = bsSingle
|
BorderStyle = bsSingle
|
||||||
HintFormat = 'Cyan: %c'
|
HintFormat = 'Cyan: %c (selected)'
|
||||||
ArrowPlacement = spBoth
|
ArrowPlacement = spBoth
|
||||||
NewArrowStyle = True
|
NewArrowStyle = True
|
||||||
TabOrder = 9
|
TabOrder = 9
|
||||||
@ -982,7 +982,7 @@ object Form1: TForm1
|
|||||||
BevelInner = bvLowered
|
BevelInner = bvLowered
|
||||||
BevelOuter = bvLowered
|
BevelOuter = bvLowered
|
||||||
BorderStyle = bsSingle
|
BorderStyle = bsSingle
|
||||||
HintFormat = 'Yellow: %y'
|
HintFormat = 'Yellow: %y (selected)'
|
||||||
ArrowPlacement = spBoth
|
ArrowPlacement = spBoth
|
||||||
NewArrowStyle = True
|
NewArrowStyle = True
|
||||||
TabOrder = 10
|
TabOrder = 10
|
||||||
|
@ -10,23 +10,36 @@ uses
|
|||||||
{$ELSE}
|
{$ELSE}
|
||||||
Messages,
|
Messages,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils, Graphics, Controls;
|
Classes, SysUtils, Graphics, Controls, ExtCtrls, Forms;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
THintState = (hsOff, hsWaitingToShow, hsWaitingToHide);
|
||||||
|
|
||||||
{ TmbBasicPicker }
|
{ TmbBasicPicker }
|
||||||
|
|
||||||
TmbBasicPicker = class(TCustomControl)
|
TmbBasicPicker = class(TCustomControl)
|
||||||
|
private
|
||||||
|
FHintWindow: THintWindow;
|
||||||
|
FHintTimer: TTimer;
|
||||||
|
FHintState: THintState;
|
||||||
|
procedure HintTimer(Sender: TObject);
|
||||||
protected
|
protected
|
||||||
FGradientBmp: TBitmap;
|
FGradientBmp: TBitmap;
|
||||||
FGradientWidth: Integer;
|
FGradientWidth: Integer;
|
||||||
FGradientHeight: Integer;
|
FGradientHeight: Integer;
|
||||||
|
FHintShown: Boolean;
|
||||||
procedure CreateGradient; virtual;
|
procedure CreateGradient; virtual;
|
||||||
function GetGradientColor(AValue: Integer): TColor; virtual;
|
function GetGradientColor(AValue: Integer): TColor; virtual;
|
||||||
function GetGradientColor2D(X, Y: Integer): TColor; virtual;
|
function GetGradientColor2D(X, Y: Integer): TColor; virtual;
|
||||||
|
function GetHintText: String; virtual;
|
||||||
|
procedure HideHintWindow; virtual;
|
||||||
|
procedure MouseLeave; 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(ABitmap: TBitmap); overload;
|
procedure PaintParentBack(ABitmap: TBitmap); overload;
|
||||||
|
function ShowHintWindow(APoint: TPoint; AText: String): Boolean; virtual;
|
||||||
{$IFDEF DELPHI}
|
{$IFDEF DELPHI}
|
||||||
procedure CMParentColorChanged(var Message: TMessage); message CM_PARENTCOLORCHANGED;
|
procedure CMParentColorChanged(var Message: TMessage); message CM_PARENTCOLORCHANGED;
|
||||||
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
|
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
|
||||||
@ -36,6 +49,7 @@ type
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
function GetDefaultColor(const DefaultColorType: TDefaultColorType): TColor; override;
|
function GetDefaultColor(const DefaultColorType: TDefaultColorType): TColor; override;
|
||||||
published
|
published
|
||||||
property ParentColor default true;
|
property ParentColor default true;
|
||||||
@ -43,11 +57,29 @@ type
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
LCLIntf;
|
||||||
|
|
||||||
|
const
|
||||||
|
HINT_SHOW_DELAY = 50;
|
||||||
|
HINT_HIDE_DELAY = 3000;
|
||||||
|
|
||||||
constructor TmbBasicPicker.Create(AOwner: TComponent);
|
constructor TmbBasicPicker.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
ControlStyle := ControlStyle - [csOpaque];
|
ControlStyle := ControlStyle - [csOpaque];
|
||||||
ParentColor := true;
|
ParentColor := true;
|
||||||
|
FHintTimer := TTimer.Create(self);
|
||||||
|
FHintTimer.Interval := HINT_SHOW_DELAY;
|
||||||
|
FHintTimer.Enabled := false;
|
||||||
|
FHintTimer.OnTimer := @HintTimer;
|
||||||
|
FHintState := hsOff;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TmbBasicPicker.Destroy;
|
||||||
|
begin
|
||||||
|
HideHintWindow;
|
||||||
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TmbBasicPicker.CMParentColorChanged(var Message: TLMessage);
|
procedure TmbBasicPicker.CMParentColorChanged(var Message: TLMessage);
|
||||||
@ -79,6 +111,58 @@ begin
|
|||||||
Result := clNone;
|
Result := clNone;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TmbBasicPicker.GetHintText: String;
|
||||||
|
begin
|
||||||
|
Result := Hint;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TmbBasicPicker.HideHintWindow;
|
||||||
|
begin
|
||||||
|
FHintTimer.Enabled := false;
|
||||||
|
FHintState := hsOff;
|
||||||
|
FreeAndNil(FHintWindow);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TmbBasicPicker.HintTimer(Sender: TObject);
|
||||||
|
begin
|
||||||
|
case FHintState of
|
||||||
|
hsWaitingToShow:
|
||||||
|
ShowHintWindow(Mouse.CursorPos, GetHintText);
|
||||||
|
hsWaitingToHide:
|
||||||
|
HideHintWindow;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TmbBasicPicker.MouseLeave;
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
HideHintWindow;
|
||||||
|
FHintTimer.Enabled := false;
|
||||||
|
FHintState := hsOff;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TmbBasicPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
if ShowHint and not FHintShown then
|
||||||
|
begin
|
||||||
|
if MouseOnPicker(X, Y) then //and not FHintShown then
|
||||||
|
begin
|
||||||
|
FHintTimer.Enabled := false;
|
||||||
|
FHintState := hsWaitingToShow;
|
||||||
|
FHintTimer.Interval := HINT_SHOW_DELAY;
|
||||||
|
FHintTimer.Enabled := true;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
HideHintWindow;
|
||||||
|
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);
|
||||||
@ -123,6 +207,44 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// Build and show the hint window
|
||||||
|
function TmbBasicPicker.ShowHintWindow(APoint: TPoint; AText: String): Boolean;
|
||||||
|
const
|
||||||
|
MAXWIDTH = 400;
|
||||||
|
var
|
||||||
|
RScr, RHint, R: TRect;
|
||||||
|
begin
|
||||||
|
FHintTimer.Enabled := false;
|
||||||
|
|
||||||
|
if AText = '' then
|
||||||
|
begin
|
||||||
|
HideHintWindow;
|
||||||
|
exit(false);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if FHintWindow = nil then
|
||||||
|
FHintWindow := THintWindow.Create(nil);
|
||||||
|
RScr := Screen.WorkAreaRect;
|
||||||
|
RHint := FHintWindow.CalcHintRect(MAXWIDTH, AText, nil);
|
||||||
|
OffsetRect(RHint, APoint.X, APoint.Y);
|
||||||
|
OffsetRect(RHint, 0, -(RHint.Bottom - RHint.Top));
|
||||||
|
R := RHint;
|
||||||
|
if R.Left < RScr.Left then
|
||||||
|
R := RHint;
|
||||||
|
RHint := R;
|
||||||
|
if (R.Bottom > RScr.Bottom) then begin
|
||||||
|
R := RHint;
|
||||||
|
OffsetRect(R, 0, R.Bottom - RScr.Bottom);
|
||||||
|
end;
|
||||||
|
FHintWindow.ActivateHint(R, AText);
|
||||||
|
|
||||||
|
FHintState := hsWaitingToHide;
|
||||||
|
FHintTimer.Interval := HINT_HIDE_DELAY;
|
||||||
|
FHintTimer.Enabled := true;
|
||||||
|
|
||||||
|
Result := true;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TmbBasicPicker.WMEraseBkgnd(
|
procedure TmbBasicPicker.WMEraseBkgnd(
|
||||||
var Message: {$IFDEF DELPHI}TWMEraseBkgnd{$ELSE}TLMEraseBkgnd{$ENDIF} );
|
var Message: {$IFDEF DELPHI}TWMEraseBkgnd{$ELSE}TLMEraseBkgnd{$ENDIF} );
|
||||||
begin
|
begin
|
||||||
|
@ -21,6 +21,8 @@ uses
|
|||||||
type
|
type
|
||||||
TMarkerStyle = (msCircle, msSquare, msCross, msCrossCirc);
|
TMarkerStyle = (msCircle, msSquare, msCross, msCrossCirc);
|
||||||
|
|
||||||
|
{ TmbCustomPicker }
|
||||||
|
|
||||||
TmbCustomPicker = class(TmbBasicPicker)
|
TmbCustomPicker = class(TmbBasicPicker)
|
||||||
private
|
private
|
||||||
FHintFormat: string;
|
FHintFormat: string;
|
||||||
@ -34,6 +36,7 @@ type
|
|||||||
mx, my, mdx, mdy: integer;
|
mx, my, mdx, mdy: integer;
|
||||||
FOnChange: TNotifyEvent;
|
FOnChange: TNotifyEvent;
|
||||||
procedure CreateGradient; override;
|
procedure CreateGradient; override;
|
||||||
|
function GetHintText: String; override;
|
||||||
function GetSelectedColor: TColor; virtual;
|
function GetSelectedColor: TColor; virtual;
|
||||||
procedure SetSelectedColor(C: TColor); virtual;
|
procedure SetSelectedColor(C: TColor); virtual;
|
||||||
procedure InternalDrawMarker(X, Y: Integer; C: TColor);
|
procedure InternalDrawMarker(X, Y: Integer; C: TColor);
|
||||||
@ -42,7 +45,7 @@ type
|
|||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure CreateWnd; override;
|
procedure CreateWnd; override;
|
||||||
procedure WebSafeChanged; dynamic;
|
procedure WebSafeChanged; dynamic;
|
||||||
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
|
// procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
|
||||||
{$IFDEF DELPHI}
|
{$IFDEF DELPHI}
|
||||||
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;
|
||||||
@ -208,6 +211,11 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TmbCustomPicker.GetHintText: String;
|
||||||
|
begin
|
||||||
|
Result := FormatHint(FHintFormat, GetColorUnderCursor)
|
||||||
|
end;
|
||||||
|
|
||||||
function TmbCustomPicker.GetSelectedColor: TColor;
|
function TmbCustomPicker.GetSelectedColor: TColor;
|
||||||
begin
|
begin
|
||||||
Result := FSelected; // valid for most descendents
|
Result := FSelected; // valid for most descendents
|
||||||
@ -248,7 +256,7 @@ begin
|
|||||||
msCrossCirc: DrawSelCrossCirc(x, y, Canvas, c);
|
msCrossCirc: DrawSelCrossCirc(x, y, Canvas, c);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
(*
|
||||||
procedure TmbCustomPicker.CMHintShow(var Message: TCMHintShow);
|
procedure TmbCustomPicker.CMHintShow(var Message: TCMHintShow);
|
||||||
begin
|
begin
|
||||||
if GetColorUnderCursor <> clNone then
|
if GetColorUnderCursor <> clNone then
|
||||||
@ -264,7 +272,7 @@ begin
|
|||||||
HintStr := FormatHint(FHintFormat, GetColorUnderCursor);;
|
HintStr := FormatHint(FHintFormat, GetColorUnderCursor);;
|
||||||
end;
|
end;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end; *)
|
||||||
|
|
||||||
procedure TmbCustomPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
procedure TmbCustomPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
|
@ -84,12 +84,15 @@ type
|
|||||||
procedure CreateWnd; override;
|
procedure CreateWnd; override;
|
||||||
procedure Execute(tbaAction: integer); dynamic;
|
procedure Execute(tbaAction: integer); dynamic;
|
||||||
function GetArrowPos: integer; dynamic;
|
function GetArrowPos: integer; dynamic;
|
||||||
function GetHintStr: string;
|
function GetHintText: string; override;
|
||||||
function GetSelectedValue: integer; virtual; abstract;
|
function GetSelectedValue: integer; virtual; abstract;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 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;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
|
function ShowHintWindow(APoint: TPoint; AText: String): Boolean; override;
|
||||||
|
// procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
|
||||||
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}
|
||||||
@ -597,6 +600,12 @@ begin
|
|||||||
Result := pos;
|
Result := pos;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TmbTrackBarPicker.MouseLeave;
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
FHintShown := false;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TmbTrackBarPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
procedure TmbTrackBarPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||||
var
|
var
|
||||||
R: TRect;
|
R: TRect;
|
||||||
@ -623,6 +632,11 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TmbTrackBarPicker.MouseOnPicker(X, Y: Integer): Boolean;
|
||||||
|
begin
|
||||||
|
Result := PtInRect(FPickRect, Point(X, Y));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TmbTrackBarPicker.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure TmbTrackBarPicker.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
if Button <> mbLeft then Exit;
|
if Button <> mbLeft then Exit;
|
||||||
@ -742,7 +756,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;
|
||||||
|
(*
|
||||||
procedure TmbTrackBarPicker.CMHintShow(var Message: TCMHintShow);
|
procedure TmbTrackBarPicker.CMHintShow(var Message: TCMHintShow);
|
||||||
begin
|
begin
|
||||||
with TCMHintShow(Message) do
|
with TCMHintShow(Message) do
|
||||||
@ -761,7 +775,7 @@ begin
|
|||||||
HintStr := GetHintStr;
|
HintStr := GetHintStr;
|
||||||
end;
|
end;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end; *)
|
||||||
|
|
||||||
procedure TmbTrackBarPicker.CMGotFocus(
|
procedure TmbTrackBarPicker.CMGotFocus(
|
||||||
var Message: {$IFDEF FPC}TLMessage{$ELSE}TCMGotFocus{$ENDIF});
|
var Message: {$IFDEF FPC}TLMessage{$ELSE}TCMGotFocus{$ENDIF});
|
||||||
@ -865,7 +879,7 @@ begin
|
|||||||
//handled in descendants
|
//handled in descendants
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TmbTrackBarPicker.GetHintStr: string;
|
function TmbTrackBarPicker.GetHintText: string;
|
||||||
begin
|
begin
|
||||||
Result := ReplaceFlags(FHintFormat, ['%value', '%h', '%s', '%l', '%v', '%c',
|
Result := ReplaceFlags(FHintFormat, ['%value', '%h', '%s', '%l', '%v', '%c',
|
||||||
'%m', '%y', '%k', '%r', '%g', '%b'], GetSelectedValue);
|
'%m', '%y', '%k', '%r', '%g', '%b'], GetSelectedValue);
|
||||||
@ -907,4 +921,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TmbTrackbarPicker.ShowHintWindow(APoint: TPoint; AText: String): Boolean;
|
||||||
|
begin
|
||||||
|
Result := inherited;
|
||||||
|
if Result then
|
||||||
|
FHintShown := true;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -9,6 +9,7 @@ uses
|
|||||||
|
|
||||||
procedure Clamp(var AValue:Integer; AMin, AMax: Integer);
|
procedure Clamp(var AValue:Integer; AMin, AMax: Integer);
|
||||||
function PointInCircle(p: TPoint; Size: integer): boolean;
|
function PointInCircle(p: TPoint; Size: integer): boolean;
|
||||||
|
function PtInCircle(p, ctr: TPoint; Radius: Integer): Boolean;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -26,6 +27,11 @@ begin
|
|||||||
Result := (sqr(p.x - r) + sqr(p.y - r) <= sqr(r));
|
Result := (sqr(p.x - r) + sqr(p.y - r) <= sqr(r));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function PtInCircle(p, ctr: TPoint; Radius: Integer): Boolean;
|
||||||
|
begin
|
||||||
|
Result := sqr(p.x - ctr.x) + sqr(p.y - ctr.y) <= sqr(Radius);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user