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