tvplanit: Improved vertical text centering

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4977 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-07-15 12:29:06 +00:00
parent 5596841466
commit 4fbe3969b5
4 changed files with 18 additions and 14 deletions

View File

@ -106,6 +106,7 @@ object MainForm: TMainForm
TimeSlotColors.ActiveRange.RangeEnd = h_00 TimeSlotColors.ActiveRange.RangeEnd = h_00
HeadAttributes.Color = clBtnFace HeadAttributes.Color = clBtnFace
RowHeadAttributes.HourFont.Height = -24 RowHeadAttributes.HourFont.Height = -24
RowHeadAttributes.MinuteFont.Height = -12
RowHeadAttributes.Color = clBtnFace RowHeadAttributes.Color = clBtnFace
IconAttributes.AlarmBitmap.Data = { IconAttributes.AlarmBitmap.Data = {
76020000424D760200000000000036000000280000000C0000000C0000000100 76020000424D760200000000000036000000280000000C0000000C0000000100
@ -243,6 +244,7 @@ object MainForm: TMainForm
DateLabelFormat = 'dddd, mmmm dd, yyyy' DateLabelFormat = 'dddd, mmmm dd, yyyy'
DayHeadAttributes.Color = clBtnFace DayHeadAttributes.Color = clBtnFace
DayHeadAttributes.DateFormat = 'dddd mmmm, dd' DayHeadAttributes.DateFormat = 'dddd mmmm, dd'
DayHeadAttributes.Font.Height = -13
DayHeadAttributes.Bordered = True DayHeadAttributes.Bordered = True
DrawingStyle = dsFlat DrawingStyle = dsFlat
HeadAttributes.Color = clBtnFace HeadAttributes.Color = clBtnFace

View File

@ -785,7 +785,7 @@ begin
Angle, Angle,
RenderIn, RenderIn,
RealLeft + TVpMonthViewOpener(FMonthView).mvSpinButtons.Width + TextMargin * 2, RealLeft + TVpMonthViewOpener(FMonthView).mvSpinButtons.Width + TextMargin * 2,
HeadTextRect.Top, // + TextMargin, HeadTextRect.Top, // this vertical position is already centered
HeadStr HeadStr
); );
end; end;

View File

@ -148,7 +148,7 @@ type
wvClickTimer: TTimer; wvClickTimer: TTimer;
wvLoaded: Boolean; wvLoaded: Boolean;
wvRowHeight: Integer; wvRowHeight: Integer;
wvDayHeadHeight: Integer; // wvDayHeadHeight: Integer;
wvHeaderHeight: Integer; wvHeaderHeight: Integer;
wvStartDate: TDateTime; wvStartDate: TDateTime;
wvSpinButtons: TUpDown; wvSpinButtons: TUpDown;

View File

@ -12,6 +12,8 @@ type
TVpWeekViewPainter = class(TVpBasePainter) TVpWeekViewPainter = class(TVpBasePainter)
private private
FWeekView: TVpWeekView; FWeekView: TVpWeekView;
FDayHeadHeight: Integer;
// local parameters of the old TVpWeekView method // local parameters of the old TVpWeekView method
// HeadRect: TRect; // HeadRect: TRect;
DayRectHeight: Integer; DayRectHeight: Integer;
@ -264,7 +266,7 @@ begin
then begin then begin
tmpRect := DayRect; tmpRect := DayRect;
InflateRect(tmpRect, -2, -2); InflateRect(tmpRect, -2, -2);
tmpRect.Top := tmpRect.Top + TVpWeekViewOpener(FWeekView).wvDayHeadHeight; tmpRect.Top := tmpRect.Top + FDayHeadHeight;
TPSDrawFocusRect(RenderCanvas, Angle, RenderIn, tmpRect); TPSDrawFocusRect(RenderCanvas, Angle, RenderIn, tmpRect);
end; end;
end; end;
@ -275,19 +277,19 @@ var
TextRect: TRect; TextRect: TRect;
J: Integer; J: Integer;
EventList: TList; EventList: TList;
dayHeadHeight: Integer; // dayHeadHeight: Integer;
rowHeight: Integer; rowHeight: Integer;
headerHeight: Integer; headerHeight: Integer;
tmpRect: TRect; tmpRect: TRect;
begin begin
// Abbreviations // Abbreviations
dayHeadHeight := TVpWeekviewOpener(FWeekView).wvDayHeadHeight; // dayHeadHeight := TVpWeekviewOpener(FWeekView).wvDayHeadHeight;
rowHeight := TVpWeekViewOpener(FWeekView).wvRowHeight; rowHeight := TVpWeekViewOpener(FWeekView).wvRowHeight;
headerHeight := TVpWeekViewOpener(FWeekView).wvHeaderHeight; headerHeight := TVpWeekViewOpener(FWeekView).wvHeaderHeight;
// Get header rectangle // Get header rectangle
TextRect := DayRect; TextRect := DayRect;
TextRect.Bottom := DayRect.Top + dayHeadHeight; TextRect.Bottom := DayRect.Top + FDayHeadHeight;
// Draw day header // Draw day header
tmpRect := TextRect; tmpRect := TextRect;
@ -303,7 +305,7 @@ begin
if (FWeekView.DataStore <> nil) and (FWeekView.DataStore.Resource <> nil) and if (FWeekView.DataStore <> nil) and (FWeekView.DataStore.Resource <> nil) and
(FWeekView.DataStore.Resource.Schedule.EventCountByDay(StartDate + ADayIndex) > 0) and (FWeekView.DataStore.Resource.Schedule.EventCountByDay(StartDate + ADayIndex) > 0) and
(HeightOf(DayRect) >= TextMargin * 2 + dayHeadHeight) (HeightOf(DayRect) >= TextMargin * 2 + FDayHeadHeight)
then begin then begin
// Events exist for this day // Events exist for this day
EventList := TList.Create; EventList := TList.Create;
@ -317,7 +319,7 @@ begin
// Initialize TextRect for this day // Initialize TextRect for this day
TextRect := DayRect; TextRect := DayRect;
TextRect.Top := DayRect.Top + dayHeadHeight; TextRect.Top := DayRect.Top + FDayHeadHeight;
TextRect.Bottom := TextRect.Top + rowHeight; TextRect.Bottom := TextRect.Top + rowHeight;
// Handle all-day events // Handle all-day events
@ -404,6 +406,7 @@ procedure TVpWeekViewPainter.DrawDayHeader(ADayIndex: Integer; var TextRect: TRe
var var
dayStr: String; dayStr: String;
strWid: Integer; strWid: Integer;
strH: Integer;
begin begin
dayStr := FormatDateTime(FWeekView.DayHeadAttributes.DateFormat, StartDate + ADayIndex); dayStr := FormatDateTime(FWeekView.DayHeadAttributes.DateFormat, StartDate + ADayIndex);
{$IFDEF LCL} {$IFDEF LCL}
@ -414,15 +417,15 @@ begin
if strWid > WidthOf(TextRect) then if strWid > WidthOf(TextRect) then
dayStr := GetDisplayString(RenderCanvas, dayStr, 0, WidthOf(TextRect) - TextMargin); dayStr := GetDisplayString(RenderCanvas, dayStr, 0, WidthOf(TextRect) - TextMargin);
strWid := RenderCanvas.TextWidth(dayStr); strWid := RenderCanvas.TextWidth(dayStr);
strH := RenderCanvas.TextHeight(dayStr);
TextRect.Left := TextRect.Right - strWid - TextMargin; TextRect.Left := TextRect.Right - strWid - TextMargin;
TPSTextOut( TPSTextOut(
RenderCanvas, RenderCanvas,
Angle, Angle,
RenderIn, RenderIn,
TextRect.Left, TextRect.Left,
TextRect.Top + TextMargin - 1, (TextRect.Top + TextRect.Bottom - strH) div 2,
dayStr dayStr
); );
end; end;
@ -532,7 +535,7 @@ var
HeadRect: TRect; HeadRect: TRect;
HeadTextRect: TRect; HeadTextRect: TRect;
HeadStr: string; HeadStr: string;
HeadStrLen : Integer; HeadStrLen: Integer;
weekNo: Integer; weekNo: Integer;
begin begin
RenderCanvas.Brush.Color := RealHeadAttrColor; RenderCanvas.Brush.Color := RealHeadAttrColor;
@ -598,7 +601,7 @@ begin
end; end;
TPSTextOut(RenderCanvas, Angle, RenderIn, TPSTextOut(RenderCanvas, Angle, RenderIn,
HeadTextRect.Left + TextMargin, HeadTextRect.Left + TextMargin,
HeadTextRect.Top + TextMargin, (HeadTextRect.Top + HeadTextRect.Bottom - RenderCanvas.TextHeight('Tg')) div 2, //HeadTextRect.Top + TextMargin,
HeadStr HeadStr
); );
end; end;
@ -694,8 +697,7 @@ begin
StartDate := GetStartOfWeek(RenderDate, WeekStartsOn); StartDate := GetStartOfWeek(RenderDate, WeekStartsOn);
RenderCanvas.Font.Assign(FWeekView.DayHeadAttributes.Font); RenderCanvas.Font.Assign(FWeekView.DayHeadAttributes.Font);
with TVpWeekViewOpener(FWeekView) do FDayHeadHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin + 2 ;
wvDayHeadHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin + 2 ;
RenderCanvas.Font.Assign(FWeekView.EventFont); RenderCanvas.Font.Assign(FWeekView.EventFont);
with TVpWeekViewOpener(FWeekView) do with TVpWeekViewOpener(FWeekView) do
wvRowHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin div 2; wvRowHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin div 2;