You've already forked lazarus-ccr
tvplanit: Fix TVpWeekView drawing glitches. Add Alignment property for weekview's day names.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8442 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
{$I vp.inc}
|
||||
|
||||
unit VpDayViewPainter;
|
||||
|
||||
{$I vp.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
|
@ -116,35 +116,14 @@ var
|
||||
R: TRect;
|
||||
begin
|
||||
R := Rect(RealLeft, RealTop, RealRight - 1, RealBottom - 1);
|
||||
|
||||
R := TPSRotateRectangle(Angle, RenderIn, R);
|
||||
case FGanttView.DrawingStyle of
|
||||
dsNoBorder:
|
||||
; // no border
|
||||
dsFlat: // Draw a simple rectangular border
|
||||
DrawBevelRect(
|
||||
RenderCanvas,
|
||||
TPSRotateRectangle(Angle, RenderIn, R),
|
||||
BevelShadow,
|
||||
BevelShadow
|
||||
);
|
||||
ds3D: // Draw a 3d bevel
|
||||
begin
|
||||
DrawBevelRect(
|
||||
RenderCanvas,
|
||||
TPSRotateRectangle(Angle, RenderIn, R),
|
||||
BevelShadow,
|
||||
BevelHighlight
|
||||
);
|
||||
(*
|
||||
InflateRect(R, -1, -1);
|
||||
DrawBevelRect(
|
||||
RenderCanvas,
|
||||
TPSRotateRectangle(Angle, RenderIn, R),
|
||||
BevelDarkShadow,
|
||||
clRed //BevelFace
|
||||
);
|
||||
*)
|
||||
end;
|
||||
DrawBevelRect(RenderCanvas, R, BevelShadow, BevelShadow);
|
||||
ds3D: // Draw a 3d bevel (recessed)
|
||||
DrawBevelRect(RenderCanvas, R, BevelShadow, BevelHighlight);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -152,6 +152,7 @@ type
|
||||
FDayHeadAttr: TVpMonthViewAttr;
|
||||
FDayNameStyle: TVpMVDayNameStyle;
|
||||
FDayNumberFont: TVpFont;
|
||||
FDaysMargin: Integer;
|
||||
FDefaultPopup: TPopupMenu;
|
||||
FDragDropTransparent: Boolean;
|
||||
FDrawingStyle: TVpDrawingStyle;
|
||||
@ -162,6 +163,7 @@ type
|
||||
FHintMode: TVpHintMode;
|
||||
FHolidayAttr: TVpMvHolidayAttr;
|
||||
FKBNavigate: Boolean;
|
||||
FMonthMargin: Integer;
|
||||
FLineColor: TColor;
|
||||
FMouseDate: TDateTime;
|
||||
FOffDayColor: TColor;
|
||||
@ -170,7 +172,6 @@ type
|
||||
FSelectedDayColor: TColor;
|
||||
FShowEvents: Boolean;
|
||||
FShowEventTime: Boolean;
|
||||
FTextMargin: Integer;
|
||||
FTimeFormat: TVpTimeFormat;
|
||||
FTodayAttr: TVpMvTodayAttr;
|
||||
FWeekendAttr: TVpMvWeekendAttr;
|
||||
@ -201,10 +202,12 @@ type
|
||||
procedure SetDateLabelFormat(Value: string);
|
||||
procedure SetDayNameStyle(Value: TVpMVDayNameStyle);
|
||||
procedure SetDayNumberFont(Value: TVpFont);
|
||||
procedure SetDaysMargin(Value: Integer);
|
||||
procedure SetDrawingStyle(Value: TVpDrawingStyle);
|
||||
procedure SetEventDayStyle(Value: TFontStyles);
|
||||
procedure SetEventFont(Value: TVpFont);
|
||||
procedure SetLineColor(Value: TColor);
|
||||
procedure SetMonthMargin(Value: Integer);
|
||||
procedure SetOffDayColor(Value: TColor);
|
||||
procedure SetOffDayFontColor(Value: TColor);
|
||||
procedure SetPopupMenu(AValue: TPopupMenu);
|
||||
@ -212,7 +215,6 @@ type
|
||||
procedure SetSelectedDayColor(Value: TColor);
|
||||
procedure SetShowEvents(Value: Boolean);
|
||||
procedure SetShowEventTime(Value: Boolean);
|
||||
procedure SetTextMargin(Value: Integer);
|
||||
procedure SetTimeFormat(Value: TVpTimeFormat);
|
||||
procedure SetWeekStartsOn(Value: TVpDayType);
|
||||
|
||||
@ -339,6 +341,7 @@ type
|
||||
property DayHeadAttributes: TVpMonthviewAttr read FDayHeadAttr write FDayHeadAttr;
|
||||
property DayNameStyle: TVpMVDayNameStyle read FDayNameStyle write SetDayNameStyle default dsShort;
|
||||
property DayNumberFont: TVpFont read FDayNumberFont write SetDayNumberFont;
|
||||
property DaysMargin: Integer read FDaysMargin write SetDaysMargin default 2;
|
||||
property DragDropTransparent: Boolean read FDragDropTransparent write FDragDropTransparent default false;
|
||||
property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle default ds3d;
|
||||
property EventDayStyle: TFontStyles read FEventDayStyle write SetEventDayStyle default [];
|
||||
@ -348,6 +351,7 @@ type
|
||||
property HintMode: TVpHintMode read FHintMode write FHintMode default hmPlannerHint;
|
||||
property KBNavigation: Boolean read FKBNavigate write FKBNavigate default true;
|
||||
property LineColor: TColor read FLineColor write SetLineColor default DEFAULT_LINECOLOR;
|
||||
property MonthMargin: Integer read FMonthMargin write SetMonthMargin default TEXT_MARGIN;
|
||||
property OffDayColor: TColor read FOffDayColor write SetOffDayColor default OFF_COLOR;
|
||||
property OffDayFontColor: TColor read FOffDayFontColor write SetOffDayFontColor default clGray;
|
||||
property OwnerDrawCells: TVpOwnerDrawDayEvent read FOwnerDrawCells write FOwnerDrawCells;
|
||||
@ -356,7 +360,6 @@ type
|
||||
property SelectedDayColor: TColor read FSelectedDayColor write SetSelectedDayColor default clRed;
|
||||
property ShowEvents: Boolean read FShowEvents write SetShowEvents default true;
|
||||
property ShowEventTime: Boolean read FShowEventTime write SetShowEventTime default false;
|
||||
property TextMargin: Integer read FTextMargin write SetTextMargin default TEXT_MARGIN;
|
||||
property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat default tf12Hour;
|
||||
property TodayAttributes: TVpMvTodayAttr read FTodayAttr write FTodayAttr;
|
||||
property WeekendAttributes: TVpMvWeekendAttr read FWeekendAttr write FWeekendAttr;
|
||||
@ -518,16 +521,14 @@ begin
|
||||
// mvCreatingEditor := false;
|
||||
FSelectedDayColor := clRed;
|
||||
FDrawingStyle := ds3d;
|
||||
// mvPainting := false;
|
||||
FColor := DEFAULT_COLOR;
|
||||
FLineColor := DEFAULT_LINECOLOR;
|
||||
FDate := Trunc(Now);
|
||||
FTimeFormat := tf12Hour;
|
||||
FDateLabelFormat := 'mmmm yyyy';
|
||||
// FColumnWidth := 200;
|
||||
FRightClickChangeDate := vpDefWVRClickChangeDate;
|
||||
FTextMargin := TEXT_MARGIN;
|
||||
// mvVisibleEvents := 0;
|
||||
FDaysMargin := 2;
|
||||
FMonthMargin := TEXT_MARGIN;
|
||||
|
||||
{ set up fonts and colors }
|
||||
FDayHeadAttr.Color := clBtnFace;
|
||||
@ -873,12 +874,30 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TVpMonthView.SetDaysMargin(Value: Integer);
|
||||
begin
|
||||
if Value <> FDaysMargin then
|
||||
begin
|
||||
FDaysMargin := Value;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpMonthView.SetEventFont(Value: TVpFont);
|
||||
begin
|
||||
FEventFont.Assign(Value);
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TVpMonthView.SetMonthMargin(Value: Integer);
|
||||
begin
|
||||
if Value <> FMonthMargin then
|
||||
begin
|
||||
FMonthMargin := Value;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpMonthView.SetSelectedDayColor(Value: TColor);
|
||||
begin
|
||||
if Value <> FSelectedDayColor then begin
|
||||
@ -895,15 +914,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpMonthView.SetTextMargin(Value: Integer);
|
||||
begin
|
||||
if Value <> FTextMargin then
|
||||
begin
|
||||
FTextMargin := Value;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpMonthView.SetTimeFormat(Value: TVpTimeFormat);
|
||||
begin
|
||||
if Value <> FTimeFormat then begin
|
||||
@ -1608,7 +1618,8 @@ begin
|
||||
inherited;
|
||||
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
|
||||
begin
|
||||
FTextMargin := round(FTextMargin * AXProportion);
|
||||
FDaysMargin := round(FDaysMargin * AXProportion);
|
||||
FMonthMargin := round(FMonthMargin * AXProportion);
|
||||
end;
|
||||
end;
|
||||
{$IFEND}
|
||||
|
@ -230,12 +230,12 @@ begin
|
||||
|
||||
{ Calculate size of rect for the day number at the top of the TextRect. }
|
||||
if ACol = 6 then
|
||||
tmpRect.Left := ATextRect.Left + mvColWidth - TextAdjust - FMonthView.TextMargin
|
||||
tmpRect.Left := ATextRect.Left + mvColWidth - TextAdjust - FMonthView.DaysMargin
|
||||
else
|
||||
tmpRect.Left := ATextRect.Right - TextAdjust - FMonthView.TextMargin + 2;
|
||||
tmpRect.Left := ATextRect.Right - TextAdjust - FMonthView.DaysMargin + 2;
|
||||
if fsItalic in RenderCanvas.Font.Style then
|
||||
dec(tmpRect.Left, 2);
|
||||
tmpRect.Top := ATextRect.Top + FMonthView.TextMargin div 2;
|
||||
tmpRect.Top := ATextRect.Top + FMonthView.DaysMargin div 2;
|
||||
tmpRect.Right := tmpRect.Left + textAdjust;
|
||||
tmpRect.Bottom := tmpRect.Top + textHeight;
|
||||
|
||||
@ -383,8 +383,8 @@ begin
|
||||
|
||||
{ Fix header string }
|
||||
strLen := RenderCanvas.TextWidth(str);
|
||||
if (strLen > mvColWidth - FMonthView.TextMargin * 2) then
|
||||
str := GetDisplayString(RenderCanvas, str, 0, mvColWidth - FMonthView.TextMargin * 2);
|
||||
if (strLen > mvColWidth - FMonthView.DaysMargin * 2) then
|
||||
str := GetDisplayString(RenderCanvas, str, 0, mvColWidth - FMonthView.DaysMargin * 2);
|
||||
strLen := RenderCanvas.TextWidth(str);
|
||||
|
||||
{ Draw header text }
|
||||
@ -516,7 +516,7 @@ begin
|
||||
RenderCanvas.Pen.Style := psSolid;
|
||||
RenderCanvas.Brush.Color := RealColor;
|
||||
|
||||
txtMargin := FMonthView.TextMargin;
|
||||
txtMargin := FMonthView.DaysMargin;
|
||||
|
||||
{ write the events }
|
||||
if (FMonthView.DataStore <> nil) and FMonthView.ShowEvents and
|
||||
@ -659,16 +659,16 @@ begin
|
||||
InflateRect(headRect, -1, -1);
|
||||
dec(headRect.Right);
|
||||
headRect.Bottom := headRect.Top + FMonthHeadHeight;
|
||||
TPSFillRect(RenderCanvas, Angle, RenderIn, HeadRect);
|
||||
R := TPSRotateRectangle(Angle, RenderIn, HeadRect);
|
||||
TPSFillRect(RenderCanvas, Angle, RenderIn, headRect);
|
||||
R := TPSRotateRectangle(Angle, RenderIn, headRect);
|
||||
DrawBevelRect(RenderCanvas, R, BevelHighlight, BevelShadow);
|
||||
end else
|
||||
TPSFillRect(RenderCanvas, Angle, RenderIn, HeadRect);
|
||||
TPSFillRect(RenderCanvas, Angle, RenderIn, headRect);
|
||||
|
||||
// Position the spinner buttons
|
||||
with TVpMonthViewOpener(FMonthView) do begin
|
||||
FPrevYearBtn.Width := FPrevYearBtn.Height;
|
||||
FPrevYearBtn.Left := TextMargin;
|
||||
FPrevYearBtn.Left := MonthMargin;
|
||||
FPrevYearBtn.Top := (HeadRect.Top + HeadRect.Bottom - FPrevYearBtn.Height) div 2 + 1;
|
||||
|
||||
FPrevMonthBtn.Height := FPrevYearBtn.Height;
|
||||
@ -686,7 +686,7 @@ begin
|
||||
FNextYearBtn.Left := FNextMonthBtn.Left + FNextMonthBtn.Width;
|
||||
FNextYearBtn.Top := FPrevYearBtn.Top;
|
||||
|
||||
txtStart := FNextYearBtn.Left + FNextYearBtn.Width + 2*TextMargin;
|
||||
txtStart := FNextYearBtn.Left + FNextYearBtn.Width + 2*MonthMargin;
|
||||
end;
|
||||
|
||||
{ Acquire startdate and end date }
|
||||
@ -701,12 +701,12 @@ begin
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= RealWidth) then
|
||||
HeadTextRect.Left := RealLeft + FMonthView.TextMargin * 2
|
||||
HeadTextRect.Left := RealLeft + FMonthView.MonthMargin * 2
|
||||
else
|
||||
if DisplayOnly then
|
||||
HeadTextRect.Left := RealLeft + (RealWidth - RenderCanvas.TextWidth(HeadStr)) div 2
|
||||
else
|
||||
HeadTextRect.Left := RealLeft + 30 + FMonthView.TextMargin * 2;
|
||||
HeadTextRect.Left := RealLeft + 30 + FMonthView.MonthMargin * 2;
|
||||
HeadTextRect.Top := (HeadRect.Top + HeadRect.Bottom - RenderCanvas.TextHeight('Tg')) div 2;
|
||||
HeadTextRect.BottomRight := HeadRect.BottomRight;
|
||||
|
||||
@ -718,7 +718,7 @@ begin
|
||||
RenderCanvas,
|
||||
HeadStr,
|
||||
0,
|
||||
HeadTextRect.Right - HeadTextRect.Left - FMonthView.TextMargin
|
||||
HeadTextRect.Right - HeadTextRect.Left - FMonthView.MonthMargin
|
||||
);
|
||||
end;
|
||||
|
||||
@ -844,10 +844,10 @@ begin
|
||||
with TVpMonthViewOpener(FMonthView) do
|
||||
begin
|
||||
h := GetCanvasTextHeight(RenderCanvas, HeadAttributes.Font, txt);
|
||||
mvMonthHeadHeight := Max(h, FPrevYearBtn.Height) + TextMargin;
|
||||
mvMonthHeadHeight := Max(h, FPrevYearBtn.Height) + MonthMargin;
|
||||
|
||||
h := GetCanvasTextHeight(RenderCanvas, DayHeadAttributes.Font, txt);
|
||||
mvDayHeadHeight := Max(h, FPrevYearBtn.Height) + TextMargin;
|
||||
mvDayHeadHeight := Max(h, FPrevYearBtn.Height) + DaysMargin;
|
||||
|
||||
mvHeaderHeight := mvMonthHeadHeight + mvDayHeadHeight;
|
||||
|
||||
|
@ -107,18 +107,21 @@ type
|
||||
FFont: TVpFont;
|
||||
FDateFormat: string;
|
||||
FColor: TColor;
|
||||
FAlignment: TAlignment;
|
||||
FBordered: Boolean;
|
||||
function IsStoredDateFormat: Boolean;
|
||||
procedure SetColor(Value: TColor);
|
||||
procedure SetFont(Value: TVpFont);
|
||||
procedure SetAlignment(Value: TAlignment);
|
||||
procedure SetBordered(Value: Boolean);
|
||||
procedure SetColor(Value: TColor);
|
||||
procedure SetDateFormat(Value: string);
|
||||
procedure SetFont(Value: TVpFont);
|
||||
protected
|
||||
public
|
||||
constructor Create(AOwner: TVpWeekView);
|
||||
destructor Destroy; override;
|
||||
property WeekView: TVpWeekView read FWeekView;
|
||||
published
|
||||
property Alignment: TAlignment read FAlignment write SetAlignment default taRightJustify;
|
||||
property Bordered: Boolean read FBordered write SetBordered default true;
|
||||
property Color: TColor read FColor write SetColor default DEFAULT_COLOR;
|
||||
property DateFormat: string read FDateFormat write SetDateFormat stored IsStoredDateFormat;
|
||||
@ -136,7 +139,6 @@ type
|
||||
FAllowDragAndDrop: Boolean;
|
||||
FApplyCategoryInfos: Boolean;
|
||||
FColor: TColor;
|
||||
// FColumnWidth: Integer;
|
||||
FComponentHint: TTranslateString;
|
||||
FDateLabelFormat: string;
|
||||
FDayHeadAttributes: TVpDayHeadAttr;
|
||||
@ -146,6 +148,7 @@ type
|
||||
FEventFont: TVpFont; // was: TFont
|
||||
FExternalPopup: TPopupMenu;
|
||||
FHeadAttr: TVpWvHeadAttributes;
|
||||
FHeaderMargin: Integer;
|
||||
FHintMode: TVpHintMode;
|
||||
FLineColor: TColor;
|
||||
FMouseEvent: TVpEvent;
|
||||
@ -186,8 +189,9 @@ type
|
||||
procedure SetDateLabelFormat(Value: string);
|
||||
procedure SetDrawingStyle(Value: TVpDrawingStyle);
|
||||
procedure SetEventFont(Value: TVpFont);
|
||||
procedure SetHeaderMargin(AValue: Integer);
|
||||
procedure SetLayout(AValue: TVpWeekviewLayout);
|
||||
procedure SetLineColor(Value: TColor);
|
||||
procedure SetLineColor(AValue: TColor);
|
||||
procedure SetPopupMenu(AValue: TPopupMenu);
|
||||
procedure SetShowEventTime(Value: Boolean);
|
||||
procedure SetTextMargin(Value: Integer);
|
||||
@ -318,6 +322,11 @@ type
|
||||
property Date: TDateTime read FActiveDate write SetActiveDate;
|
||||
property VisibleLines: Integer read FVisibleLines;
|
||||
|
||||
property PrevWeekBtn: TSpeedButton read FPrevWeekBtn;
|
||||
property PrevMonthBtn: TSpeedButton read FPrevMonthBtn;
|
||||
property NextMonthBtn: TSpeedButton read FNextMonthBtn;
|
||||
property NextWeekBtn: TSpeedButton read FNextWeekBtn;
|
||||
|
||||
published
|
||||
property AllDayEventAttributes: TVpAllDayEventAttributes read FAllDayEventAttr write FAllDayEventAttr;
|
||||
property AllowDragAndDrop: Boolean read FAllowDragAndDrop write FAllowDragAndDrop default false;
|
||||
@ -330,10 +339,11 @@ type
|
||||
property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle default ds3d;
|
||||
property EventFont: TVpFont read FEventFont write SetEventFont;
|
||||
property HeadAttributes: TVpWvHeadAttributes read FHeadAttr write FHeadAttr;
|
||||
property HeaderMargin: Integer read FHeaderMargin write SetHeaderMargin default TEXT_MARGIN;
|
||||
property HintMode: TVpHintMode read FHintMode write FHintMode default hmPlannerHint;
|
||||
property LineColor: TColor read FLineColor write SetLineColor default DEFAULT_LINECOLOR;
|
||||
property Layout: TVpWeekviewLayout read FLayout write SetLayout default wvlVertical;
|
||||
property TextMargin: Integer read FTextMargin write SetTextMargin default TEXT_MARGIN;
|
||||
property TextMargin: Integer read FTextMargin write SetTextMargin default 2;
|
||||
property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat default tf12Hour;
|
||||
property ShowEventTime: Boolean read FShowEventTime write SetShowEventTime default true;
|
||||
property WeekStartsOn: TVpDayType read FWeekStartsOn write SetWeekStartsOn default dtSunday;
|
||||
@ -439,6 +449,7 @@ begin
|
||||
FFont := TVpFont.Create(AOwner);
|
||||
FColor := DEFAULT_COLOR;
|
||||
FBordered := true;
|
||||
FAlignment := taRightJustify;
|
||||
end;
|
||||
|
||||
destructor TVpDayHeadAttr.Destroy;
|
||||
@ -451,6 +462,15 @@ begin
|
||||
Result := FDateFormat = 'ddddd';
|
||||
end;
|
||||
|
||||
procedure TVpDayHeadAttr.SetAlignment(Value: TAlignment);
|
||||
begin
|
||||
if Value <> FAlignment then
|
||||
begin
|
||||
FAlignment := Value;
|
||||
WeekView.Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpDayHeadAttr.SetBordered(Value: Boolean);
|
||||
begin
|
||||
if Value <> FBordered then begin
|
||||
@ -582,7 +602,8 @@ begin
|
||||
wvPainting := false;
|
||||
FColor := DEFAULT_COLOR;
|
||||
FLineColor := DEFAULT_LINECOLOR;
|
||||
FTextMargin := TEXT_MARGIN;
|
||||
FTextMargin := 2;
|
||||
FHeaderMargin := TEXT_MARGIN;
|
||||
wvStartDate := trunc(GetStartOfWeek(Now, FWeekStartsOn));
|
||||
FTimeFormat := tf12Hour;
|
||||
FDateLabelFormat := 'ddddd';
|
||||
@ -902,10 +923,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpWeekView.SetLineColor(Value: TColor);
|
||||
procedure TVpWeekView.SetLineColor(AValue: TColor);
|
||||
begin
|
||||
if FLineColor <> Value then begin
|
||||
FLineColor := Value;
|
||||
if FLineColor <> AValue then begin
|
||||
FLineColor := AValue;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
@ -929,6 +950,15 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TVpWeekView.SetHeaderMargin(AValue: Integer);
|
||||
begin
|
||||
if AValue <> FHeaderMargin then
|
||||
begin
|
||||
FHeaderMargin := AValue;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpWeekView.SetLayout(AValue: TVpWeekviewLayout);
|
||||
begin
|
||||
if AValue <> FLayout then begin
|
||||
@ -1954,6 +1984,7 @@ begin
|
||||
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
|
||||
begin
|
||||
FTextMargin := round(FTextMargin * AXProportion);
|
||||
FHeaderMargin := round(FHeaderMargin * AXProportion);
|
||||
end;
|
||||
end;
|
||||
{$IFEND}
|
||||
|
@ -12,6 +12,7 @@ type
|
||||
TVpWeekViewPainter = class(TVpBasePainter)
|
||||
private
|
||||
FWeekView: TVpWeekView;
|
||||
FHeaderHeight: Integer;
|
||||
FDayHeadHeight: Integer;
|
||||
|
||||
// local parameters of the old TVpWeekView method
|
||||
@ -84,24 +85,26 @@ function TVpWeekViewPainter.DrawAllDayEvents(ADate: TDateTime; DayRect: TRect;
|
||||
var EAIndex: Integer): Boolean;
|
||||
var
|
||||
ADEventsList: TList;
|
||||
TempList: TList;
|
||||
tempList: TList;
|
||||
I, J, K: Integer;
|
||||
Event: TVpEvent;
|
||||
ADEvRect: TRect;
|
||||
StartsBeforeRange: Boolean;
|
||||
NumADEvents: Integer;
|
||||
Skip: Boolean;
|
||||
startsBeforeRange: Boolean;
|
||||
numADEvents: Integer;
|
||||
skip: Boolean;
|
||||
ADTextHeight: Integer;
|
||||
EventStr: string;
|
||||
event: TVpEvent;
|
||||
eventStr: string;
|
||||
txtDist: Integer;
|
||||
txtMargin: Integer;
|
||||
txtHeight: Integer;
|
||||
totalHeight: Integer;
|
||||
cat: TVpCategoryInfo;
|
||||
savedBrushColor: TColor;
|
||||
savedPenColor: TColor;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
{ initialize the All Day Events area... }
|
||||
// Initialize the All Day Events area...
|
||||
ADEventsRect := DayRect;
|
||||
|
||||
if (FWeekView.DataStore = nil) or (FWeekView.DataStore.Resource = nil) then
|
||||
@ -109,125 +112,115 @@ begin
|
||||
|
||||
{ Collect all of the events for this range and determine the maximum }
|
||||
{ number of all day events for the range of days covered by the control. }
|
||||
NumADEvents := 0;
|
||||
numADEvents := 0;
|
||||
|
||||
// txtMargin is the interal margin in the all-day box, distance of text from border
|
||||
txtMargin := FWeekView.TextMargin;
|
||||
// txtDist is the distance of the all-day box to the day rect
|
||||
txtDist := FWeekView.Textmargin * 2;
|
||||
|
||||
savedPenColor := RenderCanvas.Pen.Color;
|
||||
savedBrushColor := RenderCanvas.Brush.Color;
|
||||
|
||||
ADEventsList := TList.Create;
|
||||
try
|
||||
TempList := TList.Create;
|
||||
tempList := TList.Create;
|
||||
try
|
||||
{ get the all day events for the day specified by ADate + I }
|
||||
FWeekView.DataStore.Resource.Schedule.AllDayEventsByDate(ADate, TempList);
|
||||
// Get the all day events for the day specified by ADate + I
|
||||
FWeekView.DataStore.Resource.Schedule.AllDayEventsByDate(ADate, tempList);
|
||||
|
||||
{ Iterate through these events and place them in ADEventsList }
|
||||
Skip := false;
|
||||
for J := 0 to pred(TempList.Count) do begin
|
||||
// Iterate through these events and place them in ADEventsList
|
||||
skip := false;
|
||||
for J := 0 to pred(tempList.Count) do begin
|
||||
if AdEventsList.Count > 0 then begin
|
||||
for K := 0 to pred(AdEventsList.Count) do begin
|
||||
if TVpEvent(AdEventsList[K]) = TVpEvent(TempList[J]) then begin
|
||||
Skip := true;
|
||||
if TVpEvent(AdEventsList[K]) = TVpEvent(tempList[J]) then begin
|
||||
skip := true;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
if not Skip then
|
||||
AdEventsList.Add(TempList[J]);
|
||||
if not skip then
|
||||
AdEventsList.Add(tempList[J]);
|
||||
end else
|
||||
AdEventsList.Add(TempList[J]);
|
||||
AdEventsList.Add(tempList[J]);
|
||||
end;
|
||||
|
||||
if TempList.Count > NumADEvents then
|
||||
NumADEvents := TempList.Count;
|
||||
if tempList.Count > numADEvents then
|
||||
numADEvents := tempList.Count;
|
||||
finally
|
||||
TempList.Free;
|
||||
tempList.Free;
|
||||
end;
|
||||
|
||||
if NumADEvents > 0 then begin
|
||||
{ Set attributes }
|
||||
RenderCanvas.Brush.Color := ADBackgroundColor;
|
||||
|
||||
{ Measure the AllDayEvent TextHeight }
|
||||
txtDist := FWeekView.TextMargin div 2;
|
||||
if numADEvents > 0 then begin
|
||||
// Measure the AllDayEvent TextHeight
|
||||
RenderCanvas.Font.Assign(FWeekView.AllDayEventAttributes.Font);
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
ADTextHeight := RenderCanvas.TextHeight(VpProductName) + txtMargin + txtDist;
|
||||
// Pure text height
|
||||
txtHeight := RenderCanvas.TextHeight(VpProductName);
|
||||
// All-day box height
|
||||
ADTextHeight := txtHeight + txtMargin * 2;
|
||||
|
||||
{ Build the AllDayEvent rect based on the value of NumADEvents }
|
||||
if AdEventsRect.Top + (NumADEvents * ADTextHeight) + txtMargin * 2 > DayRect.Bottom
|
||||
then
|
||||
ADEventsRect.Bottom := DayRect.Bottom
|
||||
else
|
||||
ADEventsRect.Bottom := AdEventsRect.Top + NumADEvents * ADTextHeight + txtMargin * 2;
|
||||
// Build the AllDayEvent rect based on the value of NumADEvents
|
||||
totalHeight := numADEvents * ADTextHeight + txtDist * 2;
|
||||
ADEventsRect.Bottom := Min(ADEventsRect.Top + totalHeight, DayRect.Bottom);
|
||||
|
||||
// Clear the AllDayEvents area
|
||||
TpsFillRect(RenderCanvas, Angle, RenderIn, ADEventsRect);
|
||||
|
||||
StartsBeforeRange := false;
|
||||
startsBeforeRange := false;
|
||||
|
||||
// Cycle through the all day events and draw them appropriately
|
||||
// Cycle through the all-day events and draw them appropriately
|
||||
for I := 0 to pred(ADEventsList.Count) do begin
|
||||
Event := ADEventsList[I];
|
||||
event := ADEventsList[I];
|
||||
|
||||
// Draw "..."
|
||||
if ADEventsRect.Top + ((I + 1) * ADTextHeight) > DayRect.Bottom then
|
||||
// Draw "..." if next event would not fit into ADEventsRect any more
|
||||
if ADEventsRect.Top + (I + 1) * ADTextHeight + txtDist > DayRect.Bottom then
|
||||
begin
|
||||
DrawDotDotDot(DayRect, DotDotDotColor);
|
||||
break;
|
||||
end;
|
||||
|
||||
// See if the event began before the start of the range
|
||||
if (Event.StartTime < DayOf(RenderDate)) then
|
||||
StartsBeforeRange := true;
|
||||
|
||||
// Set the event's rect
|
||||
ADEvRect.Top := ADEventsRect.Top + txtMargin + I * ADTextHeight;
|
||||
ADEvRect.Bottom := ADEvRect.Top + ADTextHeight;
|
||||
ADEvRect.Left := AdEventsRect.Left + txtDist;
|
||||
ADEvRect.Right := DayRect.Right;
|
||||
ADEvRect.Top := ADEventsRect.Top + txtDist + I * ADTextHeight;
|
||||
ADEvRect.Bottom := ADEvRect.Top + ADTextHeight + 1;
|
||||
ADEvRect.Left := AdEventsRect.Left + txtDist + 1;
|
||||
ADEvRect.Right := DayRect.Right - txtDist;
|
||||
|
||||
// Paint the background of the event rect
|
||||
RenderCanvas.Brush.Color := ADEventBackgroundColor;
|
||||
RenderCanvas.Pen.Color := ADEventBorderColor;
|
||||
if FWeekView.ApplyCategoryInfos then
|
||||
begin
|
||||
cat := FWeekView.Datastore.CategoryColorMap.GetCategory(Event.Category);
|
||||
cat := FWeekView.Datastore.CategoryColorMap.GetCategory(event.Category);
|
||||
if cat.UseForAllDayEvents then
|
||||
begin
|
||||
RenderCanvas.Brush.Color := cat.BackgroundColor;
|
||||
RenderCanvas.Pen.Color := cat.Color;
|
||||
end;
|
||||
end;
|
||||
TPSRectangle(RenderCanvas, Angle, RenderIn,
|
||||
ADEvRect.Left + txtMargin,
|
||||
ADEvRect.Top + txtDist,
|
||||
ADEvRect.Right - txtMargin,
|
||||
ADEvRect.Top + ADTextHeight + txtDist
|
||||
);
|
||||
TPSRectangle(RenderCanvas, Angle, RenderIn, ADEvRect);
|
||||
|
||||
// See if the event began before the start of the range
|
||||
if event.StartTime < trunc(RenderDate) then // wp: was DayOf(RenderDate) ???
|
||||
startsBeforeRange := true;
|
||||
|
||||
// Paint the event string
|
||||
EventStr := IfThen(StartsBeforeRange, '>> ', '') + Event.Description;
|
||||
EventStr := GetDisplayString(RenderCanvas, EventStr, 0, WidthOf(ADEvRect) - 3*txtMargin);
|
||||
eventStr := IfThen(startsBeforeRange, '>> ', '') + event.Description;
|
||||
eventStr := GetDisplayString(RenderCanvas, eventStr, 0, WidthOf(ADEvRect) - 2 * txtMargin);
|
||||
|
||||
TPSTextOut(RenderCanvas, Angle, RenderIn,
|
||||
ADEvRect.Left + txtMargin * 2 + txtDist,
|
||||
ADEvRect.Top + txtMargin,
|
||||
EventStr
|
||||
);
|
||||
|
||||
Result := True;
|
||||
|
||||
TVpWeekViewOpener(FWeekView).wvEventArray[EAIndex].Rec := Rect(
|
||||
ADEvRect.Left + txtMargin,
|
||||
ADEvRect.Top + txtMargin,
|
||||
ADEvRect.Right - txtMargin,
|
||||
ADEvRect.Bottom
|
||||
(ADEvRect.Top + ADEvRect.Bottom - txtHeight) div 2,
|
||||
eventStr
|
||||
);
|
||||
TVpWeekViewOpener(FWeekView).wvEventArray[EAIndex].Event := Event;
|
||||
|
||||
TVpWeekViewOpener(FWeekView).wvEventArray[EAIndex].Rec := ADEvRect;
|
||||
TVpWeekViewOpener(FWeekView).wvEventArray[EAIndex].Event := event;
|
||||
|
||||
Inc(EAIndex);
|
||||
Result := True;
|
||||
end; { for I := 0 to pred(ADEventsList.Count) do ... }
|
||||
end; { if NumADEvents > 0 }
|
||||
|
||||
@ -239,33 +232,15 @@ begin
|
||||
end;
|
||||
|
||||
procedure TVpWeekViewPainter.DrawBorders;
|
||||
var
|
||||
R: TRect;
|
||||
begin
|
||||
if FWeekView.DrawingStyle = dsFlat then begin
|
||||
{
|
||||
DrawBevelRect(RenderCanvas,
|
||||
TPSRotateRectangle(Angle, RenderIn, Rect(RealLeft, RealTop, RealRight - 1, RealBottom - 1)),
|
||||
BevelShadowColor,
|
||||
BevelShadowColor
|
||||
);
|
||||
}
|
||||
DrawBevelRect(RenderCanvas,
|
||||
TPSRotateRectangle(Angle, RenderIn, Rect(RealLeft + 1, RealTop + 1, RealRight - 2, RealBottom - 2)),
|
||||
BevelShadowColor,
|
||||
BevelShadowColor // use the same color --> no bevel in flat mode!
|
||||
);
|
||||
end else
|
||||
if FWeekView.DrawingStyle = ds3d then begin
|
||||
{ draw a 3d bevel }
|
||||
DrawBevelRect(RenderCanvas,
|
||||
TPSRotateRectangle(Angle, RenderIn, Rect(RealLeft, RealTop, RealRight - 1, RealBottom - 1)),
|
||||
BevelShadowColor,
|
||||
BevelShadowColor
|
||||
);
|
||||
DrawBevelRect(RenderCanvas,
|
||||
TPSRotateRectangle(Angle, RenderIn, Rect(RealLeft + 1, RealTop + 1, RealRight - 2, RealBottom - 2)),
|
||||
BevelDarkShadow,
|
||||
BevelButtonFace
|
||||
);
|
||||
R := Rect(RealLeft, RealTop, RealRight - 1, RealBottom - 1);
|
||||
R := TPSRotateRectangle(Angle, RenderIn, R);
|
||||
case FWeekView.DrawingStyle of
|
||||
dsNoBorder: ;
|
||||
dsFlat: DrawBevelRect(RenderCanvas, R, BevelShadowColor, BevelShadowColor);
|
||||
ds3D: DrawBevelRect(RenderCanvas, R, BevelShadowColor, BevelHighlightColor);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -286,16 +261,16 @@ procedure TVpWeekViewPainter.DrawDay(ADayIndex: Integer; var DayRect: TRect;
|
||||
var EAIndex: Integer);
|
||||
var
|
||||
TextRect: TRect;
|
||||
delta: Integer;
|
||||
J: Integer;
|
||||
EventList: TList;
|
||||
rowHeight: Integer;
|
||||
headerHeight: Integer;
|
||||
tmpRect: TRect;
|
||||
holiday: String;
|
||||
begin
|
||||
// Abbreviations
|
||||
rowHeight := TVpWeekViewOpener(FWeekView).wvRowHeight;
|
||||
headerHeight := TVpWeekViewOpener(FWeekView).wvHeaderHeight;
|
||||
delta := IfThen(FWeekView.DrawingStyle = ds3D, 1, 0);
|
||||
|
||||
// Check for holiday
|
||||
FWeekView.IsHoliday(StartDate + ADayIndex, holiday);
|
||||
@ -305,18 +280,16 @@ begin
|
||||
TextRect.Bottom := DayRect.Top + FDayHeadHeight;
|
||||
|
||||
// Draw day header
|
||||
tmpRect := TextRect;
|
||||
inc(tmpRect.Right);
|
||||
RenderCanvas.Brush.Color := RealDayHeadAttrColor;
|
||||
TPSFillRect(RenderCanvas, Angle, RenderIn, TextRect);
|
||||
tmpRect := TPSRotateRectangle(Angle, RenderIn, TextRect);
|
||||
DrawBevelRect(RenderCanvas, tmpRect, BevelShadowColor, BevelShadowColor);
|
||||
|
||||
// Fix header string and paint it
|
||||
RenderCanvas.Font.Assign(FWeekView.DayHeadAttributes.Font);
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
RenderCanvas.Brush.Color := RealDayHeadAttrColor;
|
||||
TPSFillRect(RenderCanvas, Angle, RenderIn, tmpRect);
|
||||
if FWeekView.DayHeadAttributes.Bordered and (FWeekView.DrawingStyle <> dsNoBorder) then
|
||||
TPSRectangle(RenderCanvas, Angle, RenderIn, tmpRect);
|
||||
|
||||
// Fix header string and paint it
|
||||
DrawDayHeader(ADayIndex, holiday, TextRect);
|
||||
|
||||
if (FWeekView.DataStore <> nil) and (FWeekView.DataStore.Resource <> nil) and
|
||||
@ -335,7 +308,7 @@ begin
|
||||
|
||||
// Initialize TextRect for this day
|
||||
TextRect := DayRect;
|
||||
TextRect.Top := DayRect.Top + FDayHeadHeight;
|
||||
TextRect.Top := DayRect.Top + FDayHeadHeight + 1;
|
||||
TextRect.Bottom := TextRect.Top + rowHeight;
|
||||
|
||||
// Handle all-day events
|
||||
@ -394,56 +367,57 @@ begin
|
||||
{ adjust the DayRect for the next day }
|
||||
case FWeekView.Layout of
|
||||
wvlVertical:
|
||||
{ 0 3
|
||||
|
||||
1 4
|
||||
|
||||
2 5
|
||||
6 }
|
||||
if (ADayIndex = 2) then begin
|
||||
{ move the dayrect to the top of the next column }
|
||||
// Move the dayrect to the top of the next column
|
||||
DayRect := Rect(
|
||||
RealLeft + DayRectWidth, //(RealRight - RealLeft) div 2,
|
||||
RealTop + headerHeight + 2,
|
||||
RealRight - 2,
|
||||
RealTop + headerHeight + DayRectHeight
|
||||
);
|
||||
if FWeekView.DrawingStyle = ds3D then begin
|
||||
inc(DayRect.Top);
|
||||
dec(DayRect.Right);
|
||||
end;
|
||||
end
|
||||
else
|
||||
if (ADayIndex = 4 {Friday}) then begin
|
||||
{ shrink DayRect for weekend days }
|
||||
DayRectHeight := DayRectHeight div 2;
|
||||
RealLeft + DayRectWidth,
|
||||
RealTop + FHeaderHeight,
|
||||
RealRight - 1 - delta,
|
||||
RealTop + FHeaderHeight + DayRectHeight
|
||||
)
|
||||
end else
|
||||
if (ADayIndex = 4) then
|
||||
begin
|
||||
// Friday: shrink DayRect for weekend days
|
||||
DayRect.Top := DayRect.Bottom;
|
||||
DayRect.Bottom := DayRect.Top + DayRectHeight;
|
||||
DayRect.Bottom := DayRect.Top + DayRectHeight div 2;
|
||||
end
|
||||
else begin
|
||||
else if (ADayIndex = 5) then
|
||||
begin
|
||||
DayRect.Top := DayRect.Bottom;
|
||||
DayRect.Bottom := RealTop + FHeaderHeight + DayRectHeight;
|
||||
end else
|
||||
begin
|
||||
DayRect.Top := DayRect.Bottom;
|
||||
DayRect.Bottom := DayRect.Top + DayRectHeight;
|
||||
end;
|
||||
|
||||
wvlHorizontal:
|
||||
if (ADayIndex = 1) or (ADayIndex = 3) then begin
|
||||
{ move the day rect to the left of the next row }
|
||||
DayRect := Rect(
|
||||
RealLeft + 1,
|
||||
DayRect.Bottom,
|
||||
RealLeft + DayRectWidth + 1,
|
||||
DayRect.Bottom + DayRectHeight);
|
||||
if FWeekView.DrawingStyle = ds3D then begin
|
||||
inc(DayRect.Top);
|
||||
dec(DayRect.Right);
|
||||
end;
|
||||
end else
|
||||
if (ADayIndex in [4, 5]) {Friday or Saturday} then begin
|
||||
if ADayIndex = 4 then begin
|
||||
DayRectHeight := DayRectHeight div 2;
|
||||
DayRect.Left := DayRect.Right - 1;
|
||||
DayRect.Right := RealRight - 2;
|
||||
end else
|
||||
DayRect.Top := DayRect.Bottom;
|
||||
DayRect.Bottom := DayRect.Top + DayRectHeight;
|
||||
end else
|
||||
begin
|
||||
DayRect.Left := DayRect.Right - 1;
|
||||
DayRect.Right := RealRight - 2;
|
||||
if (ADayIndex in [0, 2, 4]) then
|
||||
begin
|
||||
DayRect.Left := RealLeft + DayRectWidth;
|
||||
DayRect.Right := RealRight - 1 - delta;
|
||||
end else if (ADayIndex <> 5) then
|
||||
begin
|
||||
DayRect.Right := RealLeft + DayRectWidth;
|
||||
DayRect.Left := RealLeft;
|
||||
end;
|
||||
if (ADayIndex in [1, 3]) then
|
||||
begin
|
||||
DayRect.Top := DayRect.Bottom;
|
||||
DayRect.Bottom := DayRect.Top + DayRectHeight; // - 8;
|
||||
end else
|
||||
if ADayIndex = 4 then
|
||||
DayRect.Bottom := DayRect.Top + DayRectHeight div 2
|
||||
else if ADayIndex = 5 then
|
||||
DayRect.Top := DayRect.Top + DayRectHeight div 2;
|
||||
end;
|
||||
end; // case
|
||||
end;
|
||||
@ -461,11 +435,18 @@ begin
|
||||
RenderCanvas.Font.Style := RenderCanvas.Font.Style + [fsBold];
|
||||
|
||||
dayStr := GetDateDisplayString(RenderCanvas, StartDate + ADayIndex,
|
||||
FWeekView.DayHeadAttributes.DateFormat, AHolidayName, WidthOf(TextRect) - FWeekView.TextMargin);
|
||||
FWeekView.DayHeadAttributes.DateFormat, AHolidayName, WidthOf(TextRect) - FWeekView.HeaderMargin*2);
|
||||
strWid := RenderCanvas.TextWidth(dayStr);
|
||||
strH := RenderCanvas.TextHeight(dayStr);
|
||||
|
||||
TextRect.Left := TextRect.Right - strWid - FWeekView.TextMargin;
|
||||
case FWeekView.DayHeadAttributes.Alignment of
|
||||
taLeftJustify:
|
||||
TextRect.Left := TextRect.Left + FWeekView.HeaderMargin;
|
||||
taCenter:
|
||||
TextRect.Left := (TextRect.Left + TextRect.Right - strWid) div 2;
|
||||
taRightJustify:
|
||||
TextRect.Left := TextRect.Right - strWid - FWeekView.HeaderMargin;
|
||||
end;
|
||||
TPSTextOut(
|
||||
RenderCanvas,
|
||||
Angle,
|
||||
@ -483,51 +464,49 @@ var
|
||||
DayRect: TRect;
|
||||
EAIndex: Integer; // Index of last-used item in wvEventArray
|
||||
I: Integer;
|
||||
headerHeight: Integer;
|
||||
realCenter: Integer;
|
||||
delta: Integer;
|
||||
begin
|
||||
with TVpWeekViewOpener(FWeekView) do begin
|
||||
|
||||
{ Initialize weekday array }
|
||||
// Initialize weekday array
|
||||
for I := 0 to pred(Length(wvWeekdayArray)) do begin
|
||||
wvWeekdayArray[I].Rec.TopLeft := Point(-1, -1);
|
||||
wvWeekdayArray[I].Rec.BottomRight := Point(-1, -1);
|
||||
wvWeekdayArray[I].Day := 0;
|
||||
end;
|
||||
|
||||
{ initialize event array }
|
||||
// Initialize event array
|
||||
EAIndex := 0;
|
||||
for I := 0 to pred(Length(wvEventArray)) do begin
|
||||
wvEventArray[I].Rec.TopLeft := Point(-1, -1);
|
||||
wvEventArray[I].Rec.BottomRight := Point(-1, -1);
|
||||
wvEventArray[I].Event := nil;
|
||||
end;
|
||||
|
||||
if DrawingStyle = ds3D then delta := 1 else delta := 0;
|
||||
end;
|
||||
|
||||
RenderCanvas.Pen.Color := RealLineColor;
|
||||
RenderCanvas.Pen.Style := psSolid;
|
||||
|
||||
{ build the first day rect }
|
||||
headerHeight := TVpWeekViewOpener(FWeekView).wvHeaderHeight;
|
||||
DayRectHeight := (RealBottom - RealTop - headerHeight) div 3;
|
||||
// Build the first day rect
|
||||
DayRectHeight := (RealBottom - RealTop - FHeaderHeight) div 3;
|
||||
DayRectWidth := (RealRight - RealLeft) div 2;
|
||||
DayRect := Rect(
|
||||
RealLeft + 1,
|
||||
RealTop + headerHeight + 2,
|
||||
RealLeft + DayRectWidth + 1,
|
||||
RealTop + headerHeight + DayRectHeight
|
||||
RealLeft,
|
||||
RealTop + FHeaderHeight,
|
||||
RealLeft + DayRectWidth,
|
||||
RealTop + FHeaderHeight + DayRectHeight
|
||||
);
|
||||
if FWeekView.DrawingStyle = ds3D then
|
||||
inc(DayRect.Top, 1);
|
||||
|
||||
{ Draw the day frames and texts }
|
||||
// Draw the day frames and texts
|
||||
for I := 0 to 6 do
|
||||
DrawDay(I, DayRect, EAIndex);
|
||||
|
||||
{ Draw the center vertical line }
|
||||
// Draw the center vertical line
|
||||
RenderCanvas.Pen.Color := RealLineColor;
|
||||
realCenter := RealLeft + (RealRight - RealLeft) div 2;
|
||||
TPSMoveTo(RenderCanvas, Angle, RenderIn, realCenter, RealTop + headerHeight + 2);
|
||||
TPSMoveTo(RenderCanvas, Angle, RenderIn, realCenter, RealTop + FHeaderHeight + 1);
|
||||
TPSLineTo(RenderCanvas, Angle, RenderIn, realCenter, RealBottom - 1);
|
||||
end;
|
||||
|
||||
@ -546,7 +525,6 @@ var
|
||||
R: TRect;
|
||||
begin
|
||||
oldFontColor := RenderCanvas.Font.Color;
|
||||
|
||||
txtmargin := FWeekView.TextMargin;
|
||||
|
||||
{ format the display text }
|
||||
@ -561,13 +539,15 @@ begin
|
||||
todayEndTime := 0.9999;
|
||||
end;
|
||||
|
||||
{ set the event font }
|
||||
// Set the event font
|
||||
RenderCanvas.Font.Assign(FWeekView.EventFont);
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
if AEvent.IsOverlayed then
|
||||
RenderCanvas.Font.Color := clGray;
|
||||
|
||||
// Draw event background
|
||||
RenderCanvas.Brush.Color := RealColor;
|
||||
if Assigned(FWeekView.Datastore) and FWeekView.ApplyCategoryInfos then
|
||||
begin
|
||||
@ -588,13 +568,13 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Build the event text }
|
||||
// Build the event text
|
||||
dayStr := FWeekView.BuildEventString(AEvent, todayStartTime, todayEndTime, false);
|
||||
strLen := RenderCanvas.TextWidth(dayStr);
|
||||
if (strLen > WidthOf(TextRect) - txtMargin * 2) then
|
||||
dayStr := GetDisplayString(RenderCanvas, dayStr, 0, WidthOf(TextRect) - txtMargin * 2);
|
||||
|
||||
{ Write the event text }
|
||||
// Write out the event text
|
||||
TPSTextOut(RenderCanvas, Angle, RenderIn,
|
||||
TextRect.Left + txtMargin, TextRect.Top + txtMargin div 2,
|
||||
dayStr
|
||||
@ -605,102 +585,102 @@ end;
|
||||
|
||||
procedure TVpWeekViewPainter.DrawHeader;
|
||||
var
|
||||
HeadRect: TRect;
|
||||
HeadTextRect: TRect;
|
||||
HeadStr: string = '';
|
||||
HeadStrLen: Integer;
|
||||
headRect, R: TRect;
|
||||
headTextRect: TRect;
|
||||
headStr: string = '';
|
||||
headStrLen: Integer;
|
||||
weekNo: Integer;
|
||||
startStr, endStr: String;
|
||||
txtStart: Integer;
|
||||
txtMargin: Integer;
|
||||
begin
|
||||
txtMargin := FWeekView.TextMargin;
|
||||
|
||||
RenderCanvas.Brush.Color := RealHeadAttrColor;
|
||||
RenderCanvas.Font.Assign(TFont(FWeekView.HeadAttributes.Font));
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
|
||||
txtMargin := FWeekView.TextMargin;
|
||||
|
||||
{ draw the header cell and borders }
|
||||
if FWeekView.DrawingStyle = ds3d then begin
|
||||
{ draw a 3d bevel }
|
||||
HeadRect.Left := RealLeft + 2;
|
||||
HeadRect.Top := RealTop + 2;
|
||||
HeadRect.Right := RealRight - 3;
|
||||
HeadRect.Bottom := RealTop + TVpWeekViewOpener(FWeekView).wvHeaderHeight + 2;
|
||||
TPSFillRect(RenderCanvas, Angle, RenderIn, HeadRect);
|
||||
DrawBevelRect(
|
||||
RenderCanvas,
|
||||
TPSRotateRectangle(Angle, RenderIn, HeadRect),
|
||||
BevelHighlightColor,
|
||||
BevelDarkShadow
|
||||
);
|
||||
end else begin
|
||||
{ draw simple border rectangle }
|
||||
HeadRect := Rect(RealLeft, RealTop, RealRight, RealTop + TVpWeekViewOpener(FWeekView).wvHeaderHeight + 2);
|
||||
TPSFillRect(RenderCanvas, Angle, RenderIn, HeadRect);
|
||||
// Draw the header cell and borders
|
||||
headRect := Rect(RealLeft, RealTop, RealRight, RealTop + FHeaderHeight);
|
||||
case FWeekView.DrawingStyle of
|
||||
dsNoBorder:
|
||||
TPSFillRect(RenderCanvas, Angle, RenderIn, headRect);
|
||||
dsFlat:
|
||||
begin // Draw simple border rectangle
|
||||
TPSFillRect(RenderCanvas, Angle, RenderIn, headRect);
|
||||
R := TPSRotateRectangle(Angle, RenderIn, headRect);
|
||||
DrawBevelRect(RenderCanvas, R, BevelShadowColor, BevelShadowColor);
|
||||
end;
|
||||
ds3D:
|
||||
begin // Draw a 3D bevel (raised)
|
||||
R := Rect(headRect.Left+1, headRect.Top+1, headRect.Right-2, headRect.Bottom);
|
||||
TPSFillRect(RenderCanvas, Angle, RenderIn, headRect);
|
||||
R := TPSRotateRectangle(Angle, RenderIn, R);
|
||||
DrawBevelRect(RenderCanvas, R, BevelHighlightColor, BevelShadowColor);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ build header caption }
|
||||
// Build header caption
|
||||
weekNo := GetWeekOfYear(StartDate);
|
||||
startStr := FormatDateTime(FWeekView.DateLabelFormat, StartDate);
|
||||
endStr := FormatDateTime(FWeekView.DateLabelFormat, StartDate+6);
|
||||
HeadStr := Format('%s %d (%s - %s)', [RSCalendarWeek, weekNo, startStr, endStr]);
|
||||
headStr := Format('%s %d (%s - %s)', [RSCalendarWeek, weekNo, startStr, endStr]);
|
||||
|
||||
{ draw the text }
|
||||
if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= WidthOf(RenderIn)) then
|
||||
HeadTextRect.TopLeft:= Point(RealLeft + txtMargin * 2, HeadRect.Top)
|
||||
headTextRect.TopLeft := Point(RealLeft + txtMargin * 2, HeadRect.Top)
|
||||
else
|
||||
if DisplayOnly then
|
||||
HeadTextRect.TopLeft := Point(
|
||||
RealLeft + (RealRight - RealLeft - RenderCanvas.TextWidth(HeadStr)) div 2,
|
||||
HeadRect.Top
|
||||
headTextRect.TopLeft := Point(
|
||||
RealLeft + (RealRight - RealLeft - RenderCanvas.TextWidth(headStr)) div 2,
|
||||
headRect.Top
|
||||
)
|
||||
else
|
||||
HeadTextRect.TopLeft := Point(
|
||||
headTextRect.TopLeft := Point(
|
||||
RealLeft + Trunc(TVpWeekViewOpener(FWeekView).wvHeaderHeight * 0.8) * 2 + txtMargin * 2,
|
||||
HeadRect.Top
|
||||
headRect.Top
|
||||
);
|
||||
HeadTextRect.BottomRight := HeadRect.BottomRight;
|
||||
headTextRect.BottomRight := headRect.BottomRight;
|
||||
dec(headTextRect.Right, txtMargin);
|
||||
|
||||
{ Fix Header String }
|
||||
HeadStrLen := RenderCanvas.TextWidth(HeadStr);
|
||||
if HeadStrLen > HeadTextRect.Right - HeadTextRect.Left - txtMargin then
|
||||
// Fix header string
|
||||
headStrLen := RenderCanvas.TextWidth(headStr);
|
||||
if headStrLen > headTextRect.Right - headTextRect.Left - txtMargin then
|
||||
begin
|
||||
HeadStr := GetDisplayString(RenderCanvas, HeadStr, 0,
|
||||
HeadTextRect.Right - HeadTextRect.Left - txtMargin );
|
||||
headStr := GetDisplayString(RenderCanvas, headStr, 0,
|
||||
headTextRect.Right - headTextRect.Left - txtMargin);
|
||||
end;
|
||||
|
||||
{ Position the spinner }
|
||||
with TVpWeekViewOpener(FWeekView) do begin
|
||||
FPrevMonthBtn.Height := Trunc(wvHeaderHeight * 0.8);;
|
||||
FPrevMonthBtn.Width := FPrevMonthBtn.Height;
|
||||
FPrevMonthBtn.Left := TextMargin;
|
||||
FPrevMonthBtn.Top := (wvHeaderHeight - FPrevMonthBtn.Height) div 2 + 2;
|
||||
// Position the spinner buttons
|
||||
with FWeekView do begin
|
||||
PrevMonthBtn.Width := PrevMonthBtn.Height;
|
||||
PrevMonthBtn.Left := TextMargin;
|
||||
PrevMonthBtn.Top := (headRect.Top + headRect.Bottom - PrevMonthBtn.Height) div 2;
|
||||
|
||||
FPrevWeekBtn.Height := FPrevMonthBtn.Height;
|
||||
FPrevWeekBtn.Width := FPrevMonthBtn.Height;
|
||||
FPrevWeekBtn.Left := FPrevMonthBtn.Left + FPrevMonthBtn.Width;
|
||||
FPrevWeekBtn.Top := FPrevMonthBtn.Top;
|
||||
PrevWeekBtn.Height := PrevMonthBtn.Height;
|
||||
PrevWeekBtn.Width := PrevMonthBtn.Height;
|
||||
PrevWeekBtn.Left := PrevMonthBtn.Left + PrevMonthBtn.Width;
|
||||
PrevWeekBtn.Top := PrevMonthBtn.Top;
|
||||
|
||||
FNextWeekBtn.Height := FPrevMonthBtn.Height;
|
||||
FNextWeekBtn.Width := FPrevMonthBtn.Height;
|
||||
FNextWeekBtn.Left := FPrevWeekBtn.Left + FPrevWeekBtn.Width;
|
||||
FNextWeekBtn.Top := FPrevMonthBtn.Top;
|
||||
NextWeekBtn.Height := PrevMonthBtn.Height;
|
||||
NextWeekBtn.Width := PrevMonthBtn.Height;
|
||||
NextWeekBtn.Left := PrevWeekBtn.Left + PrevWeekBtn.Width;
|
||||
NextWeekBtn.Top := PrevMonthBtn.Top;
|
||||
|
||||
FNextMonthBtn.Height := FPrevMonthBtn.Height;
|
||||
FNextMonthBtn.Width := FPrevMonthBtn.Height;
|
||||
FNextMonthBtn.Left := FNextWeekBtn.Left + FNextWeekBtn.Width;
|
||||
FNextMonthBtn.Top := FPrevMonthBtn.Top;
|
||||
NextMonthBtn.Height := PrevMonthBtn.Height;
|
||||
NextMonthBtn.Width := PrevMonthBtn.Height;
|
||||
NextMonthBtn.Left := NextWeekBtn.Left + NextWeekBtn.Width;
|
||||
NextMonthBtn.Top := PrevMonthBtn.Top;
|
||||
|
||||
txtStart := FNextMonthBtn.Left + FNextMonthBtn.Width + TextMargin;
|
||||
txtStart := NextMonthBtn.Left + NextMonthBtn.Width + txtMargin;
|
||||
end;
|
||||
|
||||
TPSTextOut(RenderCanvas, Angle, RenderIn,
|
||||
txtStart,
|
||||
(HeadTextRect.Top + HeadTextRect.Bottom - RenderCanvas.TextHeight('Tg')) div 2,
|
||||
HeadStr
|
||||
(headTextRect.Top + headTextRect.Bottom - RenderCanvas.TextHeight('Tg')) div 2,
|
||||
headStr
|
||||
);
|
||||
end;
|
||||
|
||||
@ -793,34 +773,26 @@ begin
|
||||
end;
|
||||
|
||||
procedure TVpWeekViewPainter.SetMeasurements;
|
||||
var
|
||||
h: Integer;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
with TVpWeekViewOpener(FWeekView) do
|
||||
begin
|
||||
if RenderDate = 0 then
|
||||
StartDate := GetStartOfWeek(wvStartDate, WeekStartsOn)
|
||||
else
|
||||
StartDate := GetStartOfWeek(RenderDate, WeekStartsOn);
|
||||
|
||||
RenderCanvas.Font.Assign(FWeekView.DayHeadAttributes.Font);
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
FDayHeadHeight := RenderCanvas.TextHeight(VpProductName) + FWeekView.TextMargin + 2 ;
|
||||
wvRowHeight := GetCanvasTextHeight(RenderCanvas, EventFont, VpProductName);
|
||||
|
||||
RenderCanvas.Font.Assign(FWeekView.EventFont);
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
with TVpWeekViewOpener(FWeekView) do
|
||||
wvRowHeight := RenderCanvas.TextHeight(VpProductName) + FWeekView.TextMargin div 2;
|
||||
Self.FDayHeadHeight := GetCanvasTextHeight(RenderCanvas, DayHeadAttributes.Font) + TextMargin * 2;
|
||||
|
||||
RenderCanvas.Font.Assign(TFont(FWeekView.HeadAttributes.Font));
|
||||
{$IF VP_LCL_SCALING = 0}
|
||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||
{$ENDIF}
|
||||
with TVpWeekViewOpener(FWeekView) do
|
||||
wvHeaderHeight := RenderCanvas.TextHeight(VpProductName) + FWeekView.TextMargin * 2;
|
||||
h := GetCanvasTextHeight(RenderCanvas, HeadAttributes.Font, VpProductName);
|
||||
Self.FHeaderHeight := Max(h, PrevMonthBtn.Height) + HeaderMargin * 2;
|
||||
wvHeaderHeight := FHeaderHeight;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user