jvcllaz: Fix LCL scaling of TJvTMTimeLine.ButtonWidth

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6617 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-08-28 16:48:15 +00:00
parent 5d76cc9d8c
commit b9a474c8ca

View File

@ -39,6 +39,7 @@ uses
const const
cTMTimeLineDayWidth = 19; cTMTimeLineDayWidth = 19;
cTMTimeLineButtonWidth = 16;
type type
TJvTLSelFrame = class(TPersistent) TJvTLSelFrame = class(TPersistent)
@ -100,7 +101,9 @@ type
FLineColor: TColor; FLineColor: TColor;
FShift: TShiftState; FShift: TShiftState;
FShowTodayIcon: Boolean; FShowTodayIcon: Boolean;
function ButtonWidthStored: Boolean;
function DayWidthStored: Boolean; function DayWidthStored: Boolean;
function GetButtonWidth: Integer;
function GetDayWidth: Integer; function GetDayWidth: Integer;
function GetRectForDate(ADate: TDate): TRect; function GetRectForDate(ADate: TDate): TRect;
function DateFromPos(APos: Integer): TDate; function DateFromPos(APos: Integer): TDate;
@ -174,7 +177,7 @@ type
procedure SetBorderStyle(Value: TBorderStyle); override; procedure SetBorderStyle(Value: TBorderStyle); override;
property BorderStyle: TBorderStyle read GetBorderStyle write SetBorderStyle; property BorderStyle: TBorderStyle read GetBorderStyle write SetBorderStyle;
property ButtonWidth: Integer read FButtonWidth write SetButtonWidth default 16; property ButtonWidth: Integer read GetButtonWidth write SetButtonWidth stored ButtonWidthStored;
property Cursor; property Cursor;
property DayWidth: Integer read GetDayWidth write SetDayWidth stored DayWidthStored; property DayWidth: Integer read GetDayWidth write SetDayWidth stored DayWidthStored;
property ObjectsFontStyle: TFontStyles read FObjectsFontStyle write SetObjectsFontStyle default [fsUnderline]; property ObjectsFontStyle: TFontStyles read FObjectsFontStyle write SetObjectsFontStyle default [fsUnderline];
@ -423,10 +426,10 @@ begin
FMonthFont.Size := 18; FMonthFont.Size := 18;
FObjectsFontStyle := [fsUnderline]; FObjectsFontStyle := [fsUnderline];
FButtonWidth := 16; FButtonWidth := -1;
FDayWidth := -1;
FDate := SysUtils.Date - 7; FDate := SysUtils.Date - 7;
FSelDate := FDate - 1; FSelDate := FDate - 1;
FDayWidth := -1;
FImageCursor := crHandPoint; FImageCursor := crHandPoint;
FSmallChange := 7; FSmallChange := 7;
FLargeChange := 30; FLargeChange := 30;
@ -443,7 +446,7 @@ begin
with FLeftBtn do with FLeftBtn do
begin begin
Align := alLeft; Align := alLeft;
Width := FButtonWidth; Width := ButtonWidth;
Parent := Self; Parent := Self;
Transparent := False; Transparent := False;
Layout := blGlyphTop; Layout := blGlyphTop;
@ -464,7 +467,7 @@ begin
with FRightBtn do with FRightBtn do
begin begin
Align := alRight; Align := alRight;
Width := FButtonWidth; Width := ButtonWidth;
Parent := Self; Parent := Self;
Transparent := False; Transparent := False;
Layout := blGlyphTop; Layout := blGlyphTop;
@ -878,11 +881,24 @@ begin
end; end;
end; end;
function TJvCustomTMTimeLine.ButtonWidthStored: Boolean;
begin
Result := FButtonWidth >= 0;
end;
function TJvCustomTMTimeLine.DayWidthStored: Boolean; function TJvCustomTMTimeLine.DayWidthStored: Boolean;
begin begin
Result := FDayWidth >= 0; Result := FDayWidth >= 0;
end; end;
function TJvCustomTMTimeLine.GetButtonWidth: Integer;
begin
if ButtonWidthStored then
Result := FButtonWidth
else
Result := Scale96ToFont(cTMTimeLineButtonWidth);
end;
function TJvCustomTMTimeLine.GetDayWidth: Integer; function TJvCustomTMTimeLine.GetDayWidth: Integer;
begin begin
if DayWidthStored then if DayWidthStored then
@ -1012,6 +1028,8 @@ begin
begin begin
if FDayWidthStored then if FDayWidthStored then
FDayWidth := Round(FDayWidth * AXProportion); FDayWidth := Round(FDayWidth * AXProportion);
if FButtonWidthStored then
FButtonWidth := Round(FButtonWidth * aXProportion);
Invalidate; Invalidate;
end; end;
end; end;
@ -1178,7 +1196,7 @@ var
Tmp: Integer; Tmp: Integer;
begin begin
if not ReadOnly then if not ReadOnly then
Tmp := FButtonWidth * 2 Tmp := ButtonWidth * 2
else else
Tmp := 1; Tmp := 1;
Result := FDate + ((Width - Tmp) div DayWidth) - 1; Result := FDate + ((Width - Tmp) div DayWidth) - 1;
@ -1186,11 +1204,11 @@ end;
procedure TJvCustomTMTimeline.SetButtonWidth(const Value: Integer); procedure TJvCustomTMTimeline.SetButtonWidth(const Value: Integer);
begin begin
if FButtonWidth <> Value then if (FButtonWidth <> Value) and (Value <> 0) and (Value >= -1) then
begin begin
FButtonWidth := Value; FButtonWidth := Value;
FLeftBtn.Width := FButtonWidth; FLeftBtn.Width := ButtonWidth;
FRightBtn.Width := FButtonWidth; FRightBtn.Width := ButtonWidth;
Invalidate; Invalidate;
end; end;
end; end;