You've already forked lazarus-ccr
tvplanit: Improved painting of all-day events. Some related refactoring.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4912 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -942,10 +942,6 @@ msgstr "Betreff:"
|
|||||||
msgid "Sunday"
|
msgid "Sunday"
|
||||||
msgstr "Sonntag"
|
msgstr "Sonntag"
|
||||||
|
|
||||||
#: vpsr.rstallshortchars
|
|
||||||
msgid "Wy"
|
|
||||||
msgstr "Wy"
|
|
||||||
|
|
||||||
#: vpsr.rstaskcomplete
|
#: vpsr.rstaskcomplete
|
||||||
msgctxt "vpsr.rstaskcomplete"
|
msgctxt "vpsr.rstaskcomplete"
|
||||||
msgid "Task complete"
|
msgid "Task complete"
|
||||||
@ -1385,3 +1381,4 @@ msgstr "Unbekannte Achsen-Spezifikation: %s"
|
|||||||
#: vpsr.sxmldecnotatbeg
|
#: vpsr.sxmldecnotatbeg
|
||||||
msgid "The XML declaration must appear before the first element"
|
msgid "The XML declaration must appear before the first element"
|
||||||
msgstr "Die XML-Deklaration muss vor dem ersten Element erscheinen."
|
msgstr "Die XML-Deklaration muss vor dem ersten Element erscheinen."
|
||||||
|
|
||||||
|
@ -942,10 +942,6 @@ msgstr "Onderwerp:"
|
|||||||
msgid "Sunday"
|
msgid "Sunday"
|
||||||
msgstr "Zondag"
|
msgstr "Zondag"
|
||||||
|
|
||||||
#: vpsr.rstallshortchars
|
|
||||||
msgid "Wy"
|
|
||||||
msgstr "Wy"
|
|
||||||
|
|
||||||
#: vpsr.rstaskcomplete
|
#: vpsr.rstaskcomplete
|
||||||
msgctxt "vpsr.rstaskcomplete"
|
msgctxt "vpsr.rstaskcomplete"
|
||||||
msgid "Task complete"
|
msgid "Task complete"
|
||||||
|
@ -932,10 +932,6 @@ msgstr ""
|
|||||||
msgid "Sunday"
|
msgid "Sunday"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: vpsr.rstallshortchars
|
|
||||||
msgid "Wy"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: vpsr.rstaskcomplete
|
#: vpsr.rstaskcomplete
|
||||||
msgctxt "vpsr.rstaskcomplete"
|
msgctxt "vpsr.rstaskcomplete"
|
||||||
msgid "Task complete"
|
msgid "Task complete"
|
||||||
|
@ -960,10 +960,6 @@ msgstr "Тема:"
|
|||||||
msgid "Sunday"
|
msgid "Sunday"
|
||||||
msgstr "Воскресенье"
|
msgstr "Воскресенье"
|
||||||
|
|
||||||
#: vpsr.rstallshortchars
|
|
||||||
msgid "Wy"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: vpsr.rstaskcomplete
|
#: vpsr.rstaskcomplete
|
||||||
msgctxt "vpsr.rstaskcomplete"
|
msgctxt "vpsr.rstaskcomplete"
|
||||||
msgid "Task complete"
|
msgid "Task complete"
|
||||||
|
@ -88,6 +88,9 @@ const
|
|||||||
ContactsTableName = 'Contacts';
|
ContactsTableName = 'Contacts';
|
||||||
RecordIDTableName = 'RecordIDS';
|
RecordIDTableName = 'RecordIDS';
|
||||||
|
|
||||||
|
TallShortChars = 'Wy';
|
||||||
|
|
||||||
|
|
||||||
{virtual key constants not already defined}
|
{virtual key constants not already defined}
|
||||||
VK_NONE = 0;
|
VK_NONE = 0;
|
||||||
VK_ALT = VK_MENU;
|
VK_ALT = VK_MENU;
|
||||||
|
@ -1879,9 +1879,9 @@ begin
|
|||||||
{ font, the standard client font, and a sample character string. }
|
{ font, the standard client font, and a sample character string. }
|
||||||
SaveFont := Canvas.Font;
|
SaveFont := Canvas.Font;
|
||||||
Canvas.Font := FContactHeadAttr.Font;
|
Canvas.Font := FContactHeadAttr.Font;
|
||||||
cgRowHeight := Canvas.TextHeight(RSTallShortChars);
|
cgRowHeight := Canvas.TextHeight(TallShortChars);
|
||||||
Canvas.Font.Assign(SaveFont);
|
Canvas.Font.Assign(SaveFont);
|
||||||
Temp := Canvas.TextHeight(RSTallShortChars);
|
Temp := Canvas.TextHeight(TallShortChars);
|
||||||
if Temp > cgRowHeight then
|
if Temp > cgRowHeight then
|
||||||
cgRowHeight := Temp;
|
cgRowHeight := Temp;
|
||||||
cgRowHeight := cgRowHeight + TextMargin * 2;
|
cgRowHeight := cgRowHeight + TextMargin * 2;
|
||||||
|
@ -1232,9 +1232,9 @@ begin
|
|||||||
Canvas.Font.Assign(FHeadAttr.Font);
|
Canvas.Font.Assign(FHeadAttr.Font);
|
||||||
|
|
||||||
if FShowResourceName and (DataStore <> nil) and (DataStore.Resource <> nil) then
|
if FShowResourceName and (DataStore <> nil) and (DataStore.Resource <> nil) then
|
||||||
TextHeight := Canvas.TextHeight(RSTallShortChars) * 2 + TextMargin * 3
|
TextHeight := Canvas.TextHeight(TallShortChars) * 2 + TextMargin * 3
|
||||||
else
|
else
|
||||||
TextHeight := Canvas.TextHeight(RSTallShortChars) + TextMargin * 2;
|
TextHeight := Canvas.TextHeight(TallShortChars) + TextMargin * 2;
|
||||||
Result := Round(TextHeight * Scale);
|
Result := Round(TextHeight * Scale);
|
||||||
dvColHeadHeight := Result;
|
dvColHeadHeight := Result;
|
||||||
end;
|
end;
|
||||||
@ -1344,9 +1344,9 @@ begin
|
|||||||
SaveFont := Canvas.Font;
|
SaveFont := Canvas.Font;
|
||||||
Canvas.Font.Assign(FRowHeadAttr.FMinuteFont);
|
Canvas.Font.Assign(FRowHeadAttr.FMinuteFont);
|
||||||
Canvas.Font.Height := GetRealFontHeight(Canvas.Font);
|
Canvas.Font.Height := GetRealFontHeight(Canvas.Font);
|
||||||
Result := Canvas.TextHeight(RSTallShortChars);
|
Result := Canvas.TextHeight(TallShortChars);
|
||||||
Canvas.Font.Assign(SaveFont);
|
Canvas.Font.Assign(SaveFont);
|
||||||
Temp := Canvas.TextHeight(RSTallShortChars);
|
Temp := Canvas.TextHeight(TallShortChars);
|
||||||
if Temp > Result then
|
if Temp > Result then
|
||||||
Result := Temp;
|
Result := Temp;
|
||||||
Result := Result + TextMargin * 2;
|
Result := Result + TextMargin * 2;
|
||||||
@ -1371,7 +1371,7 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
i := 0;
|
i := 0;
|
||||||
while i < FNumDays do begin
|
while i < FNumDays do begin
|
||||||
if (DayOfWeek (WorkDate) <> 1) and (DayOfWeek (WorkDate) <> 7) then
|
if (DayOfWeek(WorkDate) <> 1) and (DayOfWeek(WorkDate) <> 7) then
|
||||||
Inc(i);
|
Inc(i);
|
||||||
WorkDate := WorkDate + 1;
|
WorkDate := WorkDate + 1;
|
||||||
Inc (Result);
|
Inc (Result);
|
||||||
|
@ -98,6 +98,7 @@ type
|
|||||||
procedure FixFontHeights;
|
procedure FixFontHeights;
|
||||||
procedure FreeBitmaps;
|
procedure FreeBitmaps;
|
||||||
procedure GetIcons(Event: TVpEvent);
|
procedure GetIcons(Event: TVpEvent);
|
||||||
|
function InitAllDayEventsRect: TRect;
|
||||||
procedure InitColors;
|
procedure InitColors;
|
||||||
procedure InitializeEventRectangles;
|
procedure InitializeEventRectangles;
|
||||||
procedure PopulateEventArray(ARenderDate: TDateTime);
|
procedure PopulateEventArray(ARenderDate: TDateTime);
|
||||||
@ -280,7 +281,7 @@ var
|
|||||||
TempList: TList;
|
TempList: TList;
|
||||||
I, J, K: Integer;
|
I, J, K: Integer;
|
||||||
Event: TVpEvent;
|
Event: TVpEvent;
|
||||||
ADEventRect: TRect;
|
ADEvRect: TRect;
|
||||||
StartsBeforeRange : Boolean;
|
StartsBeforeRange : Boolean;
|
||||||
MaxADEvents: Integer;
|
MaxADEvents: Integer;
|
||||||
Skip: Boolean;
|
Skip: Boolean;
|
||||||
@ -290,7 +291,11 @@ var
|
|||||||
DI: Integer;
|
DI: Integer;
|
||||||
AllDayWidth: Integer;
|
AllDayWidth: Integer;
|
||||||
OldTop: LongInt;
|
OldTop: LongInt;
|
||||||
|
txtDist: Integer;
|
||||||
begin
|
begin
|
||||||
|
{ Initialize the rectangle to be used for all-day events }
|
||||||
|
ADEventsRect := InitAllDayEventsRect;
|
||||||
|
|
||||||
if (FDayView.DataStore = nil) or (FDayView.DataStore.Resource = nil) then
|
if (FDayView.DataStore = nil) or (FDayView.DataStore.Resource = nil) then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
@ -298,7 +303,7 @@ begin
|
|||||||
{ number of all day events for the range of days covered by the control. }
|
{ number of all day events for the range of days covered by the control. }
|
||||||
MaxADEvents := 0;
|
MaxADEvents := 0;
|
||||||
|
|
||||||
AllDayWidth := RealWidth - RealRowHeadWidth - 1 - ScrollBarOffset;
|
AllDayWidth := RealWidth - RealRowHeadWidth - TextMargin - ScrollBarOffset;
|
||||||
DayWidth := AllDayWidth div FDayView.NumDays;
|
DayWidth := AllDayWidth div FDayView.NumDays;
|
||||||
|
|
||||||
ADEventsList := TList.Create;
|
ADEventsList := TList.Create;
|
||||||
@ -339,74 +344,70 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if MaxADEvents > 0 then begin
|
if MaxADEvents > 0 then begin
|
||||||
RenderCanvas.Brush.Color := RealADEventBkgColor;
|
// Measure the AllDayEvent text height
|
||||||
RenderCanvas.Font.Assign(FDayView.AllDayEventAttributes.Font);
|
RenderCanvas.Font.Assign(FDayView.AllDayEventAttributes.Font);
|
||||||
|
|
||||||
{ Measure the AllDayEvent TextHeight }
|
|
||||||
ADTextHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin;
|
ADTextHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin;
|
||||||
|
|
||||||
{ set the top of the event's rect }
|
// Distance between text and border
|
||||||
|
txtDist := TextMargin div 2;
|
||||||
|
|
||||||
|
// Store the top of the event's rect
|
||||||
OldTop := ADEventsRect.Top;
|
OldTop := ADEventsRect.Top;
|
||||||
AdEventRect.Top := OldTop + TextMargin + I * ADTextHeight;
|
|
||||||
|
|
||||||
{ Build the AllDayEvent rect based on the value of MaxADEvents }
|
// Build the AllDayEventsRect based on the value of MaxADEvents
|
||||||
ADEventsRect.Bottom := AdEventsRect.Top + MaxADEvents * ADTextHeight + TextMargin * 2;
|
ADEventsRect.Bottom := AdEventsRect.Top + TextMargin + MaxADEvents * (ADTextHeight + txtDist);
|
||||||
|
|
||||||
{ Clear the AllDayEvents area }
|
// Clear the AllDayEvents area using its background color
|
||||||
|
RenderCanvas.Brush.Color := RealADEventBkgColor;
|
||||||
TpsFillRect(RenderCanvas, Angle, RenderIn, ADEventsRect);
|
TpsFillRect(RenderCanvas, Angle, RenderIn, ADEventsRect);
|
||||||
|
|
||||||
for I := 0 to pred(RealNumDays) do begin
|
for I := 0 to pred(RealNumDays) do begin
|
||||||
{ Set attributes }
|
{ Set attributes }
|
||||||
StartsBeforeRange := false;
|
StartsBeforeRange := false;
|
||||||
DI := 0;
|
DI := 0;
|
||||||
{ Cycle through the all day events and draw them appropriately }
|
// Cycle through the all day events and draw them appropriately
|
||||||
for I2 := 0 to pred(ADEventsList.Count) do begin
|
for I2 := 0 to pred(ADEventsList.Count) do begin
|
||||||
Event := ADEventsList[I2];
|
Event := ADEventsList[I2];
|
||||||
if (trunc(Event.StartTime)<=(trunc(RenderDate)+I)) and
|
if DateInRange(RenderDate + I, Event.StartTime, Event.EndTime, true) then
|
||||||
(trunc(Event.EndTime)>=(trunc(RenderDate)+I))
|
begin
|
||||||
then begin
|
// See if the event began before the start of the range
|
||||||
{ set the top of the event's rect }
|
|
||||||
AdEventRect.Top := OldTop + TextMargin + DI * ADTextHeight;
|
|
||||||
inc(DI);
|
|
||||||
|
|
||||||
{ see if the event began before the start of the range }
|
|
||||||
if (Event.StartTime < trunc(RenderDate)) then
|
if (Event.StartTime < trunc(RenderDate)) then
|
||||||
StartsBeforeRange := true;
|
StartsBeforeRange := true;
|
||||||
|
|
||||||
AdEventRect.Bottom := ADEventRect.Top + ADTextHeight;
|
// Set the event's rect
|
||||||
AdEventRect.Left := AdEventsRect.Left + DayWidth*I + TextMargin div 2;
|
AdEvRect.Top := OldTop + txtDist + DI * (ADTextHeight + txtDist);
|
||||||
AdEventRect.Right := AdEventRect.Left+DayWidth;
|
AdEvRect.Bottom := ADEvRect.Top + ADTextHeight + txtDist;
|
||||||
|
AdEvRect.Left := AdEventsRect.Left + DayWidth * I + txtDist;
|
||||||
if StartsBeforeRange then
|
AdEvRect.Right := AdEventsRect.Left + DayWidth * (I + 1) - txtDist;
|
||||||
EventStr := '>> '
|
|
||||||
else
|
|
||||||
EventStr := '';
|
|
||||||
|
|
||||||
EventStr := EventStr + Event.Description;
|
|
||||||
|
|
||||||
RenderCanvas.Brush.Color := ADEventAttrBkgColor;
|
RenderCanvas.Brush.Color := ADEventAttrBkgColor;
|
||||||
RenderCanvas.Pen.Color := ADEventBorderColor;
|
RenderCanvas.Pen.Color := ADEventBorderColor;
|
||||||
TPSRectangle(RenderCanvas, Angle, RenderIn,
|
TPSRectangle(RenderCanvas, Angle, RenderIn,
|
||||||
ADEventRect.Left + TextMargin,
|
ADEvRect.Left + txtDist,
|
||||||
ADEventRect.Top + TextMargin div 2,
|
ADEvRect.Top + txtDist,
|
||||||
ADEventRect.Right - TextMargin,
|
ADEvRect.Right - txtDist,
|
||||||
ADEventRect.Top + ADTextHeight + TextMargin div 2
|
ADEvRect.Top + ADTextHeight + txtDist
|
||||||
);
|
);
|
||||||
|
|
||||||
|
EventStr := IfThen(StartsBeforeRange, '>> ', '') + Event.Description;
|
||||||
|
EventStr := GetDisplayString(RenderCanvas, EventStr, 0, WidthOf(ADEvRect) - 2*TextMargin);
|
||||||
|
|
||||||
TPSTextOut(RenderCanvas,Angle, RenderIn,
|
TPSTextOut(RenderCanvas,Angle, RenderIn,
|
||||||
AdEventRect.Left + TextMargin * 2 + TextMargin div 2,
|
AdEvRect.Left + TextMargin,
|
||||||
AdEventRect.Top + TextMargin div 2,
|
AdEvRect.Top + TextMargin,
|
||||||
EventStr
|
EventStr
|
||||||
);
|
);
|
||||||
|
|
||||||
TVpDayViewOpener(FDayView).dvEventArray[EventCount].Rec := Rect(
|
TVpDayViewOpener(FDayView).dvEventArray[EventCount].Rec := Rect(
|
||||||
ADEventRect.Left,
|
ADEvRect.Left,
|
||||||
ADEventRect.Top - 2,
|
ADEvRect.Top - 2,
|
||||||
ADEventRect.Right - TextMargin,
|
ADEvRect.Right - TextMargin,
|
||||||
ADEventRect.Bottom
|
ADEvRect.Bottom
|
||||||
);
|
);
|
||||||
TVpDayViewOpener(FDayView).dvEventArray[EventCount].Event := Event;
|
TVpDayViewOpener(FDayView).dvEventArray[EventCount].Event := Event;
|
||||||
|
|
||||||
Inc(EventCount);
|
Inc(EventCount);
|
||||||
|
inc(DI);
|
||||||
end;
|
end;
|
||||||
end; { for I2 := 0 to pred(ADEventsList.Count) do ... }
|
end; { for I2 := 0 to pred(ADEventsList.Count) do ... }
|
||||||
end;
|
end;
|
||||||
@ -1522,6 +1523,15 @@ begin
|
|||||||
CustomH := dvBmpCustom.Height;
|
CustomH := dvBmpCustom.Height;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ initialize the all-day events area }
|
||||||
|
function TVpDayViewPainter.InitAllDayEventsRect: TRect;
|
||||||
|
begin
|
||||||
|
Result.Left := RealLeft + 3 + RealRowHeadWidth;
|
||||||
|
Result.Top := RealTop + RealColHeadHeight;
|
||||||
|
Result.Right := FDayView.ClientRect.Right;
|
||||||
|
Result.Bottom := Result.Top;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpDayViewPainter.InitColors;
|
procedure TVpDayViewPainter.InitColors;
|
||||||
begin
|
begin
|
||||||
if DisplayOnly then begin
|
if DisplayOnly then begin
|
||||||
@ -1588,6 +1598,8 @@ begin
|
|||||||
InitColors;
|
InitColors;
|
||||||
SavePenBrush;
|
SavePenBrush;
|
||||||
InitPenBrush;
|
InitPenBrush;
|
||||||
|
InitializeEventRectangles;
|
||||||
|
FixFontHeights;
|
||||||
|
|
||||||
SetMeasurements;
|
SetMeasurements;
|
||||||
|
|
||||||
@ -1620,25 +1632,14 @@ begin
|
|||||||
try
|
try
|
||||||
SelectClipRgn(RenderCanvas.Handle, Rgn);
|
SelectClipRgn(RenderCanvas.Handle, Rgn);
|
||||||
|
|
||||||
// Fix zero font heights for printer
|
// Calculate row and column header
|
||||||
FixFontHeights;
|
|
||||||
|
|
||||||
{ Calculate Row Header }
|
|
||||||
RealRowHeight := TVpDayViewOpener(FDayView).dvCalcRowHeight(Scale, UseGran);
|
RealRowHeight := TVpDayViewOpener(FDayView).dvCalcRowHeight(Scale, UseGran);
|
||||||
RealColHeadHeight := TVpDayViewOpener(FDayView).dvCalcColHeadHeight(Scale);
|
|
||||||
RealRowHeadWidth := CalcRowHeadWidth;
|
RealRowHeadWidth := CalcRowHeadWidth;
|
||||||
|
RealColHeadHeight := TVpDayViewOpener(FDayView).dvCalcColHeadHeight(Scale);
|
||||||
{ initialize the All Day Events area... }
|
|
||||||
ADEventsRect.Left := RealLeft + 3 + RealRowHeadWidth;
|
|
||||||
ADEventsRect.Top := RealTop + RealColHeadHeight;
|
|
||||||
ADEventsRect.Right := FDayView.ClientRect.Right;
|
|
||||||
ADEventsRect.Bottom := AdEventsRect.Top;
|
|
||||||
|
|
||||||
{ Calculate the RealNumDays (The number of days the control covers) }
|
{ Calculate the RealNumDays (The number of days the control covers) }
|
||||||
RealNumDays := TVpDayViewOpener(FDayView).GetRealNumDays(RenderDate);
|
RealNumDays := TVpDayViewOpener(FDayView).GetRealNumDays(RenderDate);
|
||||||
|
|
||||||
InitializeEventRectangles;
|
|
||||||
|
|
||||||
{ Draw the all-day events }
|
{ Draw the all-day events }
|
||||||
DrawAllDayEvents;
|
DrawAllDayEvents;
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ resourcestring
|
|||||||
RSNo = 'N';
|
RSNo = 'N';
|
||||||
RSTrue = 'T';
|
RSTrue = 'T';
|
||||||
RSFalse = 'F';
|
RSFalse = 'F';
|
||||||
RSTallShortChars = 'Wy';
|
|
||||||
RSDelete = 'Delete';
|
RSDelete = 'Delete';
|
||||||
RSNotDoneYet = 'This feature is not implemented at this time.';
|
RSNotDoneYet = 'This feature is not implemented at this time.';
|
||||||
RSNoTimersAvail = 'No Window''s timers are available.';
|
RSNoTimersAvail = 'No Window''s timers are available.';
|
||||||
|
@ -1213,9 +1213,9 @@ begin
|
|||||||
{ font, the standard client font, and a sample character string. }
|
{ font, the standard client font, and a sample character string. }
|
||||||
SaveFont := Canvas.Font;
|
SaveFont := Canvas.Font;
|
||||||
Canvas.Font := FTaskHeadAttr.Font;
|
Canvas.Font := FTaskHeadAttr.Font;
|
||||||
tlRowHeight := Canvas.TextHeight(RSTallShortChars);
|
tlRowHeight := Canvas.TextHeight(TallShortChars);
|
||||||
Canvas.Font.Assign(SaveFont);
|
Canvas.Font.Assign(SaveFont);
|
||||||
Temp := Canvas.TextHeight(RSTallShortChars);
|
Temp := Canvas.TextHeight(TallShortChars);
|
||||||
if Temp > tlRowHeight then
|
if Temp > tlRowHeight then
|
||||||
tlRowHeight := Temp;
|
tlRowHeight := Temp;
|
||||||
tlRowHeight := tlRowHeight + TextMargin * 2;
|
tlRowHeight := tlRowHeight + TextMargin * 2;
|
||||||
|
Reference in New Issue
Block a user