jvcllaz: Fix LCL scaling always being active in TJvRuler.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7288 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-01-14 23:37:20 +00:00
parent 001c4a6db2
commit 931d3ba977

View File

@ -30,15 +30,15 @@ unit JvRuler;
interface interface
uses uses lazlogger,
LCLIntf, LCLType, LCLVersion, Types, LCLIntf, LCLType, LCLVersion, Types,
Classes, SysUtils, Graphics, Controls, Classes, SysUtils, Graphics, Controls,
JvComponent; JvComponent;
const const
DEFAULT_JVRULER_MAJOR_TICKLENGTH = 8; DEFAULT_JVR_MAJOR_TICKLENGTH = 8;
DEFAULT_JVRULER_MINOR_TICKLENGTH = 3; DEFAULT_JVR_MINOR_TICKLENGTH = 3;
DEFAULT_JVRULER_MARKER_SIZE = 6; DEFAULT_JVR_MARKER_SIZE = 6;
type type
TJvRulerUnit = (ruCentimeters, ruInches, ruPixels); TJvRulerUnit = (ruCentimeters, ruInches, ruPixels);
@ -58,9 +58,6 @@ type
FMinorTickLength: Integer; FMinorTickLength: Integer;
FShowBaseline: Boolean; FShowBaseline: Boolean;
FShowPositionMarker: Boolean; FShowPositionMarker: Boolean;
function IsStoredMarkerSize: Boolean;
function IsStoredMajorTickLength: Boolean;
function IsStoredMinorTickLength: Boolean;
procedure SetMarkerColor(const Value: TColor); procedure SetMarkerColor(const Value: TColor);
procedure SetMarkerFilled(const Value: Boolean); procedure SetMarkerFilled(const Value: Boolean);
procedure SetMarkerSize(const Value: Integer); procedure SetMarkerSize(const Value: Integer);
@ -74,10 +71,8 @@ type
procedure SetTickColor(const Value: TColor); procedure SetTickColor(const Value: TColor);
procedure SetUseUnit(const Value: TJvRulerUnit); procedure SetUseUnit(const Value: TJvRulerUnit);
protected protected
{$IF LCL_FullVersion >= 1080000}
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override; const AXProportion, AYProportion: Double); override;
{$IFEND}
class function GetControlClassDefaultSize: TSize; override; class function GetControlClassDefaultSize: TSize; override;
procedure Paint; override; procedure Paint; override;
public public
@ -88,10 +83,10 @@ type
property Font; property Font;
property MarkerColor: TColor read FMarkerColor write SetMarkerColor default clBlack; property MarkerColor: TColor read FMarkerColor write SetMarkerColor default clBlack;
property MarkerFilled: Boolean read FMarkerFilled write SetMarkerFilled default true; property MarkerFilled: Boolean read FMarkerFilled write SetMarkerFilled default true;
property MarkerSize: Integer read FMarkerSize write SetMarkerSize stored IsStoredMarkerSize; property MarkerSize: Integer read FMarkerSize write SetMarkerSize default DEFAULT_JVR_MARKER_SIZE;
property MajorTickLength: Integer read FMajorTickLength write SetMajorTickLength stored IsStoredMajorTickLength; property MajorTickLength: Integer read FMajorTickLength write SetMajorTickLength default DEFAULT_JVR_MAJOR_TICKLENGTH;
property MinorTickCount: Integer read FMinorTickCount write SetMinorTickCount default 1; property MinorTickCount: Integer read FMinorTickCount write SetMinorTickCount default 1;
property MinorTickLength: Integer read FMinorTickLength write SetMinorTicklength stored IsStoredMinorTickLength; property MinorTickLength: Integer read FMinorTickLength write SetMinorTicklength default DEFAULT_JVR_MINOR_TICKLENGTH;
property Orientation: TJvRulerOrientation read FOrientation write SetOrientation default roHorizontal; property Orientation: TJvRulerOrientation read FOrientation write SetOrientation default roHorizontal;
property Position: Double read FPosition write SetPosition; property Position: Double read FPosition write SetPosition;
property ShowBaseline: Boolean read FShowBaseline write SetShowBaseLine default false; property ShowBaseline: Boolean read FShowBaseline write SetShowBaseLine default false;
@ -137,15 +132,14 @@ begin
FTickColor := clBlack; FTickColor := clBlack;
FUseUnit := ruCentimeters; FUseUnit := ruCentimeters;
FMarkerFilled := true; FMarkerFilled := true;
FMarkerSize := Scale96ToFont(DEFAULT_JVRULER_MARKER_SIZE); FMarkerSize := DEFAULT_JVR_MARKER_SIZE;
FMajorTickLength := Scale96ToFont(DEFAULT_JVRULER_MAJOR_TICKLENGTH); FMajorTickLength := DEFAULT_JVR_MAJOR_TICKLENGTH;
FMinorTickLength := Scale96ToFont(DEFAULT_JVRULER_MINOR_TICKLENGTH); FMinorTickLength := DEFAULT_JVR_MINOR_TICKLENGTH;
FMinorTickCount := 1; FMinorTickCount := 1;
with GetControlClassDefaultSize do with GetControlClassDefaultSize do
SetInitialBounds(0, 0, CX, CY); SetInitialBounds(0, 0, CX, CY);
end; end;
{$IF LCL_FullVersion >= 1080000}
procedure TJvRuler.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; procedure TJvRuler.DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); const AXProportion, AYProportion: Double);
var var
@ -158,15 +152,11 @@ begin
roHorizontal: proportion := AYProportion; roHorizontal: proportion := AYProportion;
roVertical: proportion := AXProportion; roVertical: proportion := AXProportion;
end; end;
if IsStoredMarkerSize then FMarkerSize := round(FMarkerSize * proportion);
FMarkerSize := round(FMarkerSize * proportion); FMajorTickLength := round(FMajorTickLength * proportion);
if IsStoredMajorTickLength then FMinorTicklength := round(FMinorTickLength * proportion);
FMajorTickLength := round(FMajorTickLength * proportion);
if IsStoredMinorTickLength then
FMinorTicklength := round(FMinorTickLength * proportion);
end; end;
end; end;
{$IFEND}
class function TJvRuler.GetControlClassDefaultSize: TSize; class function TJvRuler.GetControlClassDefaultSize: TSize;
begin begin
@ -174,21 +164,6 @@ begin
Result.CY := 25; Result.CY := 25;
end; end;
function TJvRuler.IsStoredMarkerSize: Boolean;
begin
Result := FMarkerSize <> Scale96ToFont(DEFAULT_JVRULER_MARKER_SIZE);
end;
function TJvRuler.IsStoredMajorTickLength: Boolean;
begin
Result := FMajorTickLength <> Scale96ToFont(DEFAULT_JVRULER_MAJOR_TICKLENGTH);
end;
function TJvRuler.IsStoredMinorTickLength: Boolean;
begin
Result := FMinorTickLength <> Scale96ToFont(DEFAULT_JVRULER_MINOR_TICKLENGTH);
end;
procedure TJvRuler.Paint; procedure TJvRuler.Paint;
const const
MAJOR_DIST: array[TJvRulerUnit] of Double = (1.0, 1.0, 100.0); MAJOR_DIST: array[TJvRulerUnit] of Double = (1.0, 1.0, 100.0);
@ -414,7 +389,7 @@ begin
if FOrientation <> Value then if FOrientation <> Value then
begin begin
FOrientation := Value; FOrientation := Value;
if csDesigning in ComponentState then if ([csDesigning, csLoading] * ComponentState = [csDesigning]) then
SetBounds(Left, Top, Height, Width); SetBounds(Left, Top, Height, Width);
Invalidate; Invalidate;
end; end;