jvcllaz: Fix scaling bug in TJvTFDays component of previous commit. Fix crash when TJvTFDaysPrinter is added to form.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7122 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-08-12 21:41:18 +00:00
parent 2916968451
commit e0c137b7ec

View File

@ -483,6 +483,7 @@ type
FGroupTitle: string; FGroupTitle: string;
FTitle: string; FTitle: string;
FWidth: Integer; FWidth: Integer;
function IsStoredWidth: Boolean;
procedure SetSchedDate(Value: TDate); procedure SetSchedDate(Value: TDate);
procedure SetSchedName(const Value: string); procedure SetSchedName(const Value: string);
procedure SetGroupTitle(const Value: string); procedure SetGroupTitle(const Value: string);
@ -490,13 +491,15 @@ type
procedure SetWidth(Value: Integer); procedure SetWidth(Value: Integer);
protected protected
FDisconnecting: Boolean; FDisconnecting: Boolean;
function GetDisplayName: string; override;
procedure CheckTemplate; procedure CheckTemplate;
function GetDisplayName: string; override;
procedure SetIndex(Value: Integer); override; procedure SetIndex(Value: Integer); override;
public public
constructor Create(ACollection: TCollection); override; constructor Create(ACollection: TCollection); override;
destructor Destroy; override; destructor Destroy; override;
procedure Assign(Source: TPersistent); override; procedure Assign(Source: TPersistent); override;
procedure AutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); virtual;
function ColCollection: TJvTFDaysCols; function ColCollection: TJvTFDaysCols;
property Schedule: TJvTFSched read FSchedule; property Schedule: TJvTFSched read FSchedule;
function Connected: Boolean; function Connected: Boolean;
@ -559,7 +562,10 @@ type
property SizingCols: Boolean read FSizingCols; property SizingCols: Boolean read FSizingCols;
procedure MoveCol(SourceIndex, TargetIndex: Integer); procedure MoveCol(SourceIndex, TargetIndex: Integer);
procedure AutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); virtual;
procedure Assign(Source: TPersistent); override; procedure Assign(Source: TPersistent); override;
property Items[Index: Integer]: TJvTFDaysCol read GetItem write SetItem; default; property Items[Index: Integer]: TJvTFDaysCol read GetItem write SetItem; default;
procedure UpdateTitles; procedure UpdateTitles;
end; end;
@ -2805,12 +2811,20 @@ begin
end; end;
end; end;
function TJvTFDaysCol.IsStoredWidth: Boolean;
begin
if Assigned(TJvTFDaysCols(Collection).ApptGrid) then
Result := FWidth <> TJvTFDaysCols(Collection).ApptGrid.Scale96ToFont(FWidth)
else
Result := true;
end;
procedure TJvTFDaysCol.SetWidth(Value: Integer); procedure TJvTFDaysCol.SetWidth(Value: Integer);
var var
ApptGrid: TJvTFDays; ApptGrid: TJvTFDays;
absMinColWidth: Integer; absMinColWidth: Integer;
begin begin
absMinColWidth := TJvTFDaysCols(Collection).ApptGrid.Scale96ToForm(DEFAULT_MIN_COL_WIDTH); absMinColWidth := TJvTFDaysCols(Collection).ApptGrid.Scale96ToFont(DEFAULT_MIN_COL_WIDTH);
if Value < absMinColWidth then if Value < absMinColWidth then
Value := absMinColWidth; Value := absMinColWidth;
@ -2892,6 +2906,16 @@ begin
inherited Assign(Source); inherited Assign(Source);
end; end;
procedure TJvTFDaysCol.AutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double);
begin
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin
if not IsStoredWidth then
FWidth := round(FWidth * AXProportion);
end;
end;
function TJvTFDaysCol.ColCollection: TJvTFDaysCols; function TJvTFDaysCol.ColCollection: TJvTFDaysCols;
begin begin
Result := TJvTFDaysCols(Collection); Result := TJvTFDaysCols(Collection);
@ -3424,6 +3448,15 @@ begin
Result := TJvTFDaysCol(inherited Add); Result := TJvTFDaysCol(inherited Add);
end; end;
procedure TJvTFDaysCols.AutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double);
var
i: Integer;
begin
for i := 0 to Count-1 do
Items[i].AutoAdjustLayout(AMode, AXProportion, AYProportion);
end;
procedure TJvTFDaysCols.EnsureMinColWidth; procedure TJvTFDaysCols.EnsureMinColWidth;
var var
I, MCW: Integer; I, MCW: Integer;
@ -3786,7 +3819,7 @@ procedure TJvTFDaysApptBar.AutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy
begin begin
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin begin
if not IsStoredWidth then if IsStoredWidth then
FWidth := round(FWidth * AXProportion); FWidth := round(FWidth * AXProportion);
end; end;
end; end;
@ -3844,7 +3877,10 @@ end;
function TJvTFDaysApptBar.IsStoredWidth: Boolean; function TJvTFDaysApptBar.IsStoredWidth: Boolean;
begin begin
Result := FWidth <> FApptGrid.Scale96ToFont(DEFAULT_APPT_BAR_WIDTH); if Assigned(FApptGrid) then
Result := FWidth <> FApptGrid.Scale96ToFont(DEFAULT_APPT_BAR_WIDTH)
else
Result := true;
end; end;
procedure TJvTFDaysApptBar.SetTimeStampColor(Value: TColor); procedure TJvTFDaysApptBar.SetTimeStampColor(Value: TColor);
@ -4055,14 +4091,17 @@ procedure TJvTFDaysGrabHandles.AutoAdjustLayout(
begin begin
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin begin
if not IsStoredHeight then if IsStoredHeight then
FHeight := round(FHeight * AYProportion); FHeight := round(FHeight * AYProportion);
end; end;
end; end;
function TJvTFDaysGrabHandles.IsStoredHeight: Boolean; function TJvTFDaysGrabHandles.IsStoredHeight: Boolean;
begin begin
Result := FHeight <> FApptGrid.Scale96ToFont(DEFAULT_GRAB_HANDLES_HEIGHT); if Assigned(FApptGrid) then
Result := FHeight <> FApptGrid.Scale96ToFont(DEFAULT_GRAB_HANDLES_HEIGHT)
else
Result := true;
end; end;
procedure TJvTFDaysGrabHandles.SetColor(Value: TColor); procedure TJvTFDaysGrabHandles.SetColor(Value: TColor);
@ -4326,33 +4365,24 @@ begin
inherited; inherited;
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin begin
if not IsStoredColHdrHeight then if IsStoredColHdrHeight then
FColHdrHeight := round(FColHdrHeight * AYProportion); FColHdrHeight := round(FColHdrHeight * AYProportion);
if not IsStoredDefColWidth then if IsStoredDefColWidth then
FDefColWidth := round(FDefColWidth * AXProportion); FDefColWidth := round(FDefColWidth * AXProportion);
if not IsStoredGroupHdrHeight then if IsStoredGroupHdrHeight then
FGroupHdrHeight := round(FGroupHdrHeight * AYProportion); FGroupHdrHeight := round(FGroupHdrHeight * AYProportion);
if not IsStoredMinColWidth then if IsStoredMinColWidth then
FMinColWidth := round(FMinColWidth * AXProportion); FMinColWidth := round(FMinColWidth * AXProportion);
if not IsStoredMinRowHeight then if IsStoredMinRowHeight then
FMinRowHeight := round(FMinRowHeight * AYProportion); FMinRowHeight := round(FMinRowHeight * AYProportion);
if not IsStoredRowHdrWidth then if IsStoredRowHdrWidth then
FRowHdrWidth := round(FRowHdrWidth * AXProportion); FRowHdrWidth := round(FRowHdrWidth * AXProportion);
if not IsStoredRowHeight then if IsStoredRowHeight then
FRowHeight := round(FRowHeight * AYProportion); FRowHeight := round(FRowHeight * AYProportion);
FApptBar.AutoAdjustLayout(AMode, AXProportion, AYProportion); FApptBar.AutoAdjustLayout(AMode, AXProportion, AYProportion);
FCols.AutoAdjustLayout(AMode, AXProportion, AYProportion);
FGrabHandles.AutoAdjustLayout(AMode, AXProportion, AYProportion); FGrabHandles.AutoAdjustLayout(AMode, AXProportion, AYProportion);
(*
{$IFDEF Jv_TIMEBLOCKS}
FWeekendFillPic.Height := 16;
FWeekendFillPic.Width := 16;
{$ENDIF Jv_TIMEBLOCKS}
*)
end; end;
end; end;
{$IFEND} {$IFEND}
@ -14626,7 +14656,10 @@ end;
function TJvTFDaysBlockProps.IsStoredBlockHdrWidth: Boolean; function TJvTFDaysBlockProps.IsStoredBlockHdrWidth: Boolean;
begin begin
Result := FBlockHdrWidth <> FDaysControl.Scale96ToFont(DEFAULT_BLOCK_HDR_WIDTH); if Assigned(FDaysControl) then
Result := FBlockHdrWidth <> FDaysControl.Scale96ToFont(DEFAULT_BLOCK_HDR_WIDTH)
else
Result := true;
end; end;
procedure TJvTFDaysBlockProps.SetBlockGran(Value: Integer); procedure TJvTFDaysBlockProps.SetBlockGran(Value: Integer);