You've already forked lazarus-ccr
tvplanit: Fix dayview icons not being printed (new property DayView.IconAttributes.ShowInPrint). Some refactoring in DayView (GutterWidth).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4985 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -197,6 +197,7 @@ type
|
|||||||
FShowRecurringBitmap: Boolean;
|
FShowRecurringBitmap: Boolean;
|
||||||
FAlarmBitmap: TBitmap;
|
FAlarmBitmap: TBitmap;
|
||||||
FRecurringBitmap: TBitmap;
|
FRecurringBitmap: TBitmap;
|
||||||
|
FShowInPrint: Boolean;
|
||||||
FOwner: TVpLinkableControl;
|
FOwner: TVpLinkableControl;
|
||||||
|
|
||||||
protected
|
protected
|
||||||
@ -221,6 +222,8 @@ type
|
|||||||
read FShowCategoryBitmap write SetShowCategoryBitmap default True;
|
read FShowCategoryBitmap write SetShowCategoryBitmap default True;
|
||||||
property ShowRecurringBitmap : Boolean
|
property ShowRecurringBitmap : Boolean
|
||||||
read FShowRecurringBitmap write SetShowRecurringBitmap default True;
|
read FShowRecurringBitmap write SetShowRecurringBitmap default True;
|
||||||
|
property ShowInPrint: Boolean
|
||||||
|
read FShowInPrint write FShowInPrint default True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TVpDayView }
|
{ TVpDayView }
|
||||||
@ -610,6 +613,7 @@ begin
|
|||||||
FShowAlarmBitmap := True;
|
FShowAlarmBitmap := True;
|
||||||
FShowCategoryBitmap := True;
|
FShowCategoryBitmap := True;
|
||||||
FShowRecurringBitmap := True;
|
FShowRecurringBitmap := True;
|
||||||
|
FShowInPrint := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TVpDayViewIconAttributes.Destroy;
|
destructor TVpDayViewIconAttributes.Destroy;
|
||||||
|
@ -24,6 +24,8 @@ type
|
|||||||
TVpDayViewPainter = class(TVpBasePainter)
|
TVpDayViewPainter = class(TVpBasePainter)
|
||||||
private
|
private
|
||||||
FDayView: TVpDayView;
|
FDayView: TVpDayView;
|
||||||
|
FScaledGutterWidth: Integer;
|
||||||
|
FScaledIconMargin: Integer;
|
||||||
// local parameters of the old render procedure
|
// local parameters of the old render procedure
|
||||||
ColHeadRect: TRect;
|
ColHeadRect: TRect;
|
||||||
CellsRect: TRect;
|
CellsRect: TRect;
|
||||||
@ -148,7 +150,6 @@ function TVpDayViewPainter.BuildEventString(AEvent: TVpEvent;
|
|||||||
var
|
var
|
||||||
maxW: Integer;
|
maxW: Integer;
|
||||||
timeFmt: String;
|
timeFmt: String;
|
||||||
gutter: Integer;
|
|
||||||
begin
|
begin
|
||||||
if FDayView.ShowEventTimes then begin
|
if FDayView.ShowEventTimes then begin
|
||||||
timeFmt := IfThen(FDayView.TimeFormat = tf24Hour, 'h:nn', 'h:nnam/pm');
|
timeFmt := IfThen(FDayView.TimeFormat = tf24Hour, 'h:nn', 'h:nnam/pm');
|
||||||
@ -163,8 +164,7 @@ begin
|
|||||||
if FDayView.WrapStyle = wsNone then begin
|
if FDayView.WrapStyle = wsNone then begin
|
||||||
{ if the string is longer than the availble space then chop off the end
|
{ if the string is longer than the availble space then chop off the end
|
||||||
and place those little '...'s at the end }
|
and place those little '...'s at the end }
|
||||||
gutter := Round(FDayView.GutterWidth * Scale);
|
maxW := AEventRect.Right - AIconRect.Right - FScaledGutterWidth - TextMargin;
|
||||||
maxW := AEventRect.Right - AIconRect.Right - gutter - TextMargin;
|
|
||||||
if RenderCanvas.TextWidth(Result) > maxW then
|
if RenderCanvas.TextWidth(Result) > maxW then
|
||||||
Result := GetDisplayString(RenderCanvas, Result, 0, maxW);
|
Result := GetDisplayString(RenderCanvas, Result, 0, maxW);
|
||||||
end;
|
end;
|
||||||
@ -236,14 +236,14 @@ begin
|
|||||||
Result.Left := AEventRect.Left;
|
Result.Left := AEventRect.Left;
|
||||||
Result.Top := AEventRect.Top;
|
Result.Top := AEventRect.Top;
|
||||||
Result.Bottom := AEventRect.Bottom;
|
Result.Bottom := AEventRect.Bottom;
|
||||||
Result.Right := AEventRect.Left + AlarmW + RecurringW + CategoryW + CustomW + ICON_MARGIN + 2;
|
Result.Right := AEventRect.Left + AlarmW + RecurringW + CategoryW + CustomW + FScaledIconMargin + 2;
|
||||||
|
|
||||||
MaxHeight := AlarmH + ICON_MARGIN;
|
MaxHeight := AlarmH + FScaledIconMargin;
|
||||||
if RecurringH + ICON_MARGIN > MaxHeight then
|
if RecurringH + FScaledIconMargin > MaxHeight then
|
||||||
MaxHeight := dvBmpRecurring.Height;
|
MaxHeight := dvBmpRecurring.Height;
|
||||||
if CategoryH + ICON_MARGIN > MaxHeight then
|
if CategoryH + FScaledIconMargin > MaxHeight then
|
||||||
MaxHeight := dvBmpCategory.Height;
|
MaxHeight := dvBmpCategory.Height;
|
||||||
if CustomH + ICON_MARGIN > MaxHeight then
|
if CustomH + FScaledIconMargin > MaxHeight then
|
||||||
MaxHeight := dvBmpCustom.Height;
|
MaxHeight := dvBmpCustom.Height;
|
||||||
if MaxHeight > AEventRect.Bottom - AEventRect.Top then
|
if MaxHeight > AEventRect.Bottom - AEventRect.Top then
|
||||||
MaxHeight := AEventRect.Bottom - AEventRect.Top;
|
MaxHeight := AEventRect.Bottom - AEventRect.Top;
|
||||||
@ -464,8 +464,8 @@ begin
|
|||||||
GutterRect.Left := R.Left;
|
GutterRect.Left := R.Left;
|
||||||
GutterRect.Top := R.Top;
|
GutterRect.Top := R.Top;
|
||||||
GutterRect.Bottom := R.Bottom;
|
GutterRect.Bottom := R.Bottom;
|
||||||
GutterRect.Right := GutterRect.Left + Round(FDayView.GutterWidth * Scale);
|
GutterRect.Right := GutterRect.Left + FScaledGutterWidth;
|
||||||
R.Left := R.Left + Round(FDayView.GutterWidth * Scale) + 1;
|
R.Left := R.Left + FScaledGutterWidth + 1;
|
||||||
|
|
||||||
{ paint gutter area }
|
{ paint gutter area }
|
||||||
RenderCanvas.Brush.Color := RealColor;
|
RenderCanvas.Brush.Color := RealColor;
|
||||||
@ -860,10 +860,10 @@ begin
|
|||||||
|
|
||||||
{ Paint the gutter inside the EventRect of all events }
|
{ Paint the gutter inside the EventRect of all events }
|
||||||
if (AEventRec.Level = 0) then
|
if (AEventRec.Level = 0) then
|
||||||
GutterRect.Left := EventRect.Left - Trunc(FDayView.GutterWidth * Scale)
|
GutterRect.Left := EventRect.Left - Trunc(FDayView.GutterWidth * Scale) // wp: use FGutterWidth? It uses round, though...
|
||||||
else
|
else
|
||||||
GutterRect.Left := EventRect.Left;
|
GutterRect.Left := EventRect.Left;
|
||||||
GutterRect.Right := GutterRect.Left + Round(FDayView.GutterWidth * Scale);
|
GutterRect.Right := GutterRect.Left + FScaledGutterWidth;
|
||||||
GutterRect.Top := EventRect.Top + StartPixelOffset;
|
GutterRect.Top := EventRect.Top + StartPixelOffset;
|
||||||
GutterRect.Bottom := EventRect.Bottom - EndPixelOffset + 1;
|
GutterRect.Bottom := EventRect.Bottom - EndPixelOffset + 1;
|
||||||
TPSFillRect(RenderCanvas, Angle, RenderIn, GutterRect);
|
TPSFillRect(RenderCanvas, Angle, RenderIn, GutterRect);
|
||||||
@ -874,7 +874,7 @@ begin
|
|||||||
IconRect.Top := EventRect.Top;
|
IconRect.Top := EventRect.Top;
|
||||||
IconRect.Right := EventRect.Left;
|
IconRect.Right := EventRect.Left;
|
||||||
IconRect.Bottom := EventRect.Top;
|
IconRect.Bottom := EventRect.Top;
|
||||||
if not DisplayOnly then begin
|
if FDayView.IconAttributes.ShowInPrint then begin
|
||||||
GetIcons(AEvent);
|
GetIcons(AEvent);
|
||||||
if AEventRec.Level = 0 then begin
|
if AEventRec.Level = 0 then begin
|
||||||
ScaleIcons(EventRect);
|
ScaleIcons(EventRect);
|
||||||
@ -898,7 +898,7 @@ begin
|
|||||||
FDayView.OnBeforeDrawEvent(Self, AEvent, FDayView.ActiveEvent = AEvent, RenderCanvas, tmpRect, IconRect);
|
FDayView.OnBeforeDrawEvent(Self, AEvent, FDayView.ActiveEvent = AEvent, RenderCanvas, tmpRect, IconRect);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if not DisplayOnly then
|
if FDayView.IconAttributes.ShowInPrint then
|
||||||
DrawIcons(IconRect);
|
DrawIcons(IconRect);
|
||||||
|
|
||||||
{ build the event string }
|
{ build the event string }
|
||||||
@ -918,8 +918,8 @@ begin
|
|||||||
|
|
||||||
{ don't paint gutter area on level 0 items }
|
{ don't paint gutter area on level 0 items }
|
||||||
if AEventRec.Level > 0 then begin
|
if AEventRec.Level > 0 then begin
|
||||||
TPSMoveTo(RenderCanvas, Angle, RenderIn, EventRect.Left + Round(FDayView.GutterWidth * Scale), EventRect.Top);
|
TPSMoveTo(RenderCanvas, Angle, RenderIn, EventRect.Left + FScaledGutterWidth, EventRect.Top);
|
||||||
TPSLineTo(RenderCanvas, Angle, RenderIn, EventRect.Left + Round(FDayView.GutterWidth * Scale), EventRect.Bottom);
|
TPSLineTo(RenderCanvas, Angle, RenderIn, EventRect.Left + FScaledGutterWidth, EventRect.Bottom);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if Assigned(FDayView.OnAfterDrawEvent) then begin
|
if Assigned(FDayView.OnAfterDrawEvent) then begin
|
||||||
@ -1052,16 +1052,29 @@ procedure TVpDayViewPainter.DrawIcons(AIconRect: TRect);
|
|||||||
var
|
var
|
||||||
DrawPos: Integer;
|
DrawPos: Integer;
|
||||||
|
|
||||||
procedure DrawIcon(bmp: TBitmap; w, h: Integer; IncDrawPos: Boolean = false);
|
procedure DrawIcon(ABitmap: TBitmap; w, h: Integer; IncDrawPos: Boolean = false);
|
||||||
var
|
var
|
||||||
R: TRect;
|
R: TRect;
|
||||||
|
bmp: TBitmap;
|
||||||
begin
|
begin
|
||||||
if (bmp.Width <> 0) and (bmp.Height <> 0) then
|
if (ABitmap.Width <> 0) and (ABitmap.Height <> 0) then
|
||||||
begin
|
begin
|
||||||
bmp.Transparent := True;
|
ABitmap.Transparent := True;
|
||||||
R := Rect(0, 0, w, h);
|
R := Rect(0, 0, w, h);
|
||||||
OffsetRect(R, AIconRect.Left + ICON_MARGIN, AIconRect.Top + ICON_MARGIN);
|
OffsetRect(R, AIconRect.Left + FScaledIconMargin, AIconRect.Top + FScaledIconMargin);
|
||||||
RenderCanvas.StretchDraw(R, bmp);
|
|
||||||
|
bmp := TBitmap.Create;
|
||||||
|
try
|
||||||
|
bmp.Assign(ABitmap);
|
||||||
|
{$IFDEF FPC}
|
||||||
|
RotateBitmap(Bmp, Angle);
|
||||||
|
{$ENDIF}
|
||||||
|
TPSStretchDraw(RenderCanvas, Angle, RenderIn, R, Bmp);
|
||||||
|
finally
|
||||||
|
bmp.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// RenderCanvas.StretchDraw(R, ABitmap);
|
||||||
{
|
{
|
||||||
RenderCanvas.CopyRect( // wp: was FDayview.Canvas -- does not look correct...
|
RenderCanvas.CopyRect( // wp: was FDayview.Canvas -- does not look correct...
|
||||||
Rect(AIconRect.Left + 1, AIconRect.Top + 1, AIconRect.Left + w + 1, AIconRect.Top + h + 1),
|
Rect(AIconRect.Left + 1, AIconRect.Top + 1, AIconRect.Left + w + 1, AIconRect.Top + h + 1),
|
||||||
@ -1070,7 +1083,7 @@ var
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if IncDrawPos then
|
if IncDrawPos then
|
||||||
inc(DrawPos, w + ICON_MARGIN);
|
inc(DrawPos, w + FScaledIconMargin);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1634,14 +1647,14 @@ begin
|
|||||||
dvBmpCustom.Height := 0;
|
dvBmpCustom.Height := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
AlarmW := dvBmpAlarm.Width;
|
AlarmW := Round(dvBmpAlarm.Width * Scale);
|
||||||
RecurringW := dvBmpRecurring.Width;
|
RecurringW := Round(dvBmpRecurring.Width * Scale);
|
||||||
CategoryW := dvBmpCategory.Width;
|
CategoryW := Round(dvBmpCategory.Width * Scale);
|
||||||
CustomW := dvBmpCustom.Width;
|
CustomW := Round(dvBmpCustom.Width);
|
||||||
AlarmH := dvBmpAlarm.Height;
|
AlarmH := Round(dvBmpAlarm.Height * Scale);
|
||||||
RecurringH := dvBmpRecurring.Height;
|
RecurringH := Round(dvBmpRecurring.Height * Scale);
|
||||||
CategoryH := dvBmpCategory.Height;
|
CategoryH := Round(dvBmpCategory.Height * Scale);
|
||||||
CustomH := dvBmpCustom.Height;
|
CustomH := Round(dvBmpCustom.Height * Scale);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ initialize the all-day events area }
|
{ initialize the all-day events area }
|
||||||
@ -1971,6 +1984,8 @@ procedure TVpDayViewPainter.SetMeasurements;
|
|||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
TVpDayViewOpener(FDayView).dvCalcColHeadHeight(Scale);
|
TVpDayViewOpener(FDayView).dvCalcColHeadHeight(Scale);
|
||||||
|
FScaledGutterWidth := Round(FDayView.GutterWidth * Scale);
|
||||||
|
FScaledIconMargin := Round(ICON_MARGIN * Scale);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TVpDayViewPainter.VerifyMaxWidthDevisors;
|
procedure TVpDayViewPainter.VerifyMaxWidthDevisors;
|
||||||
|
Reference in New Issue
Block a user