You've already forked lazarus-ccr
tvplanit: Refactor dayview painting (FixFontHeight and CalcRowHeadWidth into separate procedures).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4911 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -705,7 +705,7 @@ object MainForm: TMainForm
|
||||
Version = 'v1.04'
|
||||
Caption.Caption = 'Current week'
|
||||
Caption.Font.Style = [fsItalic]
|
||||
DayOffset = 1
|
||||
DayOffset = 0
|
||||
DayOffsetUnits = duDay
|
||||
Height = 100
|
||||
Left = 0
|
||||
|
@ -86,16 +86,16 @@ type
|
||||
procedure CbGranularityChange(Sender: TObject);
|
||||
procedure CbLanguagesChange(Sender: TObject);
|
||||
procedure CbTimeFormatChange(Sender: TObject);
|
||||
procedure DaysTrackBarChange(Sender: TObject);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure MnuAboutClick(Sender: TObject);
|
||||
procedure MnuPrintPreviewClick(Sender: TObject);
|
||||
procedure MnuQuitClick(Sender: TObject);
|
||||
procedure MnuResourcesClick(Sender: TObject);
|
||||
procedure MnuSettingsClick(Sender: TObject);
|
||||
procedure MnuAboutClick(Sender: TObject);
|
||||
procedure RbAllTasksChange(Sender: TObject);
|
||||
procedure RbHideCompletedTasksChange(Sender: TObject);
|
||||
procedure DaysTrackBarChange(Sender: TObject);
|
||||
procedure VpNavBar1ItemClick(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; Index: Integer);
|
||||
private
|
||||
@ -368,6 +368,12 @@ begin
|
||||
t2 := t1 + 7 - VpDayView1.NumDays mod 7; // + 7;
|
||||
fmt.DayInc := VpDayView1.NumDays;
|
||||
|
||||
t1 := date;
|
||||
t2 := t1; // wp: just for debugging of prt to reduce painting calls
|
||||
fmt.dayInc := 0;
|
||||
|
||||
|
||||
|
||||
|
||||
// wp: !!!!!!!!!!!!!!!!!!!!!!!!!!!! bring back in !!!!!!!!!!!!!
|
||||
|
||||
|
@ -25,7 +25,6 @@ type
|
||||
private
|
||||
FDayView: TVpDayView;
|
||||
// local parameters of the old render procedure
|
||||
TextWidth: Integer;
|
||||
ColHeadRect: TRect;
|
||||
CellsRect: TRect;
|
||||
RowHeadRect: TRect;
|
||||
@ -77,6 +76,7 @@ type
|
||||
protected
|
||||
function BuildEventString(AEvent: TVpEvent; const AEventRect, AIconRect: TRect): String;
|
||||
procedure CalcRowHeadRect(out ARect: TRect);
|
||||
function CalcRowHeadWidth: Integer;
|
||||
function CountOverlappingEvents(Event: TVpEvent; const EArray: TVpDvEventArray): Integer;
|
||||
procedure CreateBitmaps;
|
||||
function DetermineIconRect(AEventRect: TRect): TRect;
|
||||
@ -95,6 +95,7 @@ type
|
||||
procedure DrawNavBtnBackground;
|
||||
procedure DrawRegularEvents;
|
||||
procedure DrawRowHeader(R: TRect);
|
||||
procedure FixFontHeights;
|
||||
procedure FreeBitmaps;
|
||||
procedure GetIcons(Event: TVpEvent);
|
||||
procedure InitColors;
|
||||
@ -1389,6 +1390,26 @@ begin
|
||||
inc(ARect.Left);
|
||||
end;
|
||||
|
||||
function TVpDayViewPainter.CalcRowHeadWidth: integer;
|
||||
var
|
||||
w: Integer;
|
||||
begin
|
||||
RenderCanvas.Font.Assign(FDayView.RowHeadAttributes.HourFont);
|
||||
w := RenderCanvas.TextWidth('33');
|
||||
Result := w * 2 + 10;
|
||||
end;
|
||||
|
||||
procedure TVpDayViewPainter.FixFontHeights;
|
||||
begin
|
||||
with FDayView do begin
|
||||
AllDayEventAttributes.Font.Height := GetRealFontHeight(AllDayEventAttributes.Font);
|
||||
Font.Height := GetRealFontHeight(Font);
|
||||
HeadAttributes.Font.Height := GetRealFontHeight(HeadAttributes.Font);
|
||||
RowHeadAttributes.HourFont.Height := GetRealFontHeight(RowHeadAttributes.HourFont);
|
||||
RowHeadAttributes.MinuteFont.Height := GetRealFontHeight(RowHeadAttributes.MinuteFont);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpDayViewPainter.FreeBitmaps;
|
||||
begin
|
||||
dvBmpRecurring.Free;
|
||||
@ -1600,21 +1621,12 @@ begin
|
||||
SelectClipRgn(RenderCanvas.Handle, Rgn);
|
||||
|
||||
// Fix zero font heights for printer
|
||||
with FDayView do begin
|
||||
AllDayEventAttributes.Font.Height := GetRealFontHeight(AllDayEventAttributes.Font);
|
||||
Font.Height := GetRealFontHeight(Font);
|
||||
HeadAttributes.Font.Height := GetRealFontHeight(HeadAttributes.Font);
|
||||
RowHeadAttributes.HourFont.Height := GetRealFontHeight(RowHeadAttributes.HourFont);
|
||||
RowHeadAttributes.MinuteFont.Height := GetRealFontHeight(RowHeadAttributes.MinuteFont);
|
||||
end;
|
||||
FixFontHeights;
|
||||
|
||||
{ Calculate Row Header }
|
||||
RealRowHeight := TVpDayViewOpener(FDayView).dvCalcRowHeight(Scale, UseGran);
|
||||
RealColHeadHeight := TVpDayViewOpener(FDayView).dvCalcColHeadHeight(Scale);
|
||||
|
||||
RenderCanvas.Font.Assign(FDayView.RowHeadAttributes.HourFont);
|
||||
TextWidth := RenderCanvas.TextWidth('33');
|
||||
RealRowHeadWidth := TextWidth * 2 + 10;
|
||||
RealRowHeadWidth := CalcRowHeadWidth;
|
||||
|
||||
{ initialize the All Day Events area... }
|
||||
ADEventsRect.Left := RealLeft + 3 + RealRowHeadWidth;
|
||||
|
@ -110,8 +110,8 @@ function DateOf(ADateTime: TDateTime): TDateTime;
|
||||
function GetJulianDate(Date: TDateTime): Word;
|
||||
function GetWeekOfYear(ADate: TDateTime): byte;
|
||||
function SameDate(dt1, dt2: TDateTime): Boolean;
|
||||
function DateInRange(ADate, StartDate, EndDate: TDateTime; Inclusive: Boolean): Boolean;
|
||||
function TimeInRange(ATime, StartTime, EndTime: TDateTime; Inclusive: Boolean): Boolean;
|
||||
function DateInRange(ADate, StartDate, EndDate: TDateTime; IncludeLimits: Boolean): Boolean;
|
||||
function TimeInRange(ATime, StartTime, EndTime: TDateTime; IncludeLimits: Boolean): Boolean;
|
||||
|
||||
function HourToLine(const Value: TVpHours; const Granularity: TVpGranularity): Integer;
|
||||
function GetStartLine(StartTime: TDateTime; Granularity: TVpGranularity): Integer;
|
||||
@ -502,25 +502,25 @@ end;
|
||||
{=====}
|
||||
|
||||
function DateInRange(ADate, StartDate, EndDate: TDateTime;
|
||||
Inclusive: Boolean): Boolean;
|
||||
IncludeLimits: Boolean): Boolean;
|
||||
begin
|
||||
ADate := trunc(ADate);
|
||||
StartDate := trunc(StartDate);
|
||||
EndDate := trunc(EndDate);
|
||||
Result := (StartDate < ADate) and (ADate < EndDate);
|
||||
if Inclusive and (not Result) then
|
||||
if IncludeLimits and (not Result) then
|
||||
Result := (StartDate = ADate) or (EndDate = ADate);
|
||||
end;
|
||||
|
||||
function TimeInRange(ATime, StartTime, EndTime: TDateTime;
|
||||
Inclusive: Boolean): Boolean;
|
||||
IncludeLimits: Boolean): Boolean;
|
||||
var
|
||||
equStart, equEnd: Boolean;
|
||||
begin
|
||||
equStart := abs(ATime - StartTime) < CompareTimeEps;
|
||||
equEnd := abs(ATime - EndTime) < CompareTimeEps;
|
||||
|
||||
if Inclusive then
|
||||
if IncludeLimits then
|
||||
Result := equStart or equEnd or ((ATime > StartTime) and (ATime < EndTime))
|
||||
else
|
||||
Result := (not equStart) and (not equEnd) and (ATime > StartTime) and (ATime < EndTime);
|
||||
|
Reference in New Issue
Block a user