You've already forked lazarus-ccr
tvplanit: Add new properties to TVpDayView: ShowNavButtons, FixedDate, CustomRowHeight, RowLinesStep, SimpleRowTime (slightly modified patch by "linux-man", issue #33723).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6413 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -261,6 +261,11 @@ type
|
|||||||
FAllowDragAndDrop: Boolean;
|
FAllowDragAndDrop: Boolean;
|
||||||
FNumDays: Integer;
|
FNumDays: Integer;
|
||||||
FIncludeWeekends: Boolean;
|
FIncludeWeekends: Boolean;
|
||||||
|
FRowLinesStep: Integer;
|
||||||
|
FShowNavButtons: Boolean;
|
||||||
|
FFixedDate: Boolean;
|
||||||
|
FCustomRowHeight: Integer;
|
||||||
|
FSimpleRowTime: Boolean;
|
||||||
{ event variables }
|
{ event variables }
|
||||||
FOwnerDrawRowHead: TVpOwnerDrawRowEvent;
|
FOwnerDrawRowHead: TVpOwnerDrawRowEvent;
|
||||||
FOwnerDrawCells: TVpOwnerDrawRowEvent;
|
FOwnerDrawCells: TVpOwnerDrawRowEvent;
|
||||||
@ -323,7 +328,11 @@ type
|
|||||||
procedure SetIncludeWeekends(Value: Boolean);
|
procedure SetIncludeWeekends(Value: Boolean);
|
||||||
procedure SetDisplayDate(Value: TDateTime);
|
procedure SetDisplayDate(Value: TDateTime);
|
||||||
procedure SetVScrollPos;
|
procedure SetVScrollPos;
|
||||||
|
procedure SetCustomRowHeight(Value: Integer);
|
||||||
|
procedure SetRowLinesStep(Value: Integer);
|
||||||
|
procedure SetShowNavButtons(Value: Boolean);
|
||||||
procedure SetShowResourceName(Value: Boolean);
|
procedure SetShowResourceName(Value: Boolean);
|
||||||
|
procedure SetSimpleRowTime(Value: Boolean);
|
||||||
procedure SetActiveRow(Value: Integer);
|
procedure SetActiveRow(Value: Integer);
|
||||||
procedure SetActiveCol(Value: Integer);
|
procedure SetActiveCol(Value: Integer);
|
||||||
procedure SetWrapStyle(const v: TVpDVWrapStyle);
|
procedure SetWrapStyle(const v: TVpDVWrapStyle);
|
||||||
@ -486,6 +495,11 @@ type
|
|||||||
property NumDays: Integer read FNumDays write SetNumDays default 1;
|
property NumDays: Integer read FNumDays write SetNumDays default 1;
|
||||||
property WrapStyle: TVpDVWrapStyle read FWrapStyle Write SetWrapStyle default wsIconFlow;
|
property WrapStyle: TVpDVWrapStyle read FWrapStyle Write SetWrapStyle default wsIconFlow;
|
||||||
property HintMode: TVpHintMode read FHintMode write SetHintMode default hmPlannerHint;
|
property HintMode: TVpHintMode read FHintMode write SetHintMode default hmPlannerHint;
|
||||||
|
property ShowNavButtons: Boolean read FShowNavButtons write SetShowNavButtons default true;
|
||||||
|
property FixedDate: Boolean read FFixedDate write FFixedDate default false;
|
||||||
|
property CustomRowHeight: Integer read FCustomRowHeight write SetCustomRowHeight default 0;
|
||||||
|
property RowLinesStep: Integer read FRowLinesStep write SetRowLinesStep default 1;
|
||||||
|
property SimpleRowTime: Boolean read FSimpleRowTime write SetSimpleRowTime default false;
|
||||||
{events}
|
{events}
|
||||||
property AfterEdit: TVpAfterEditEvent read FAfterEdit write FAfterEdit;
|
property AfterEdit: TVpAfterEditEvent read FAfterEdit write FAfterEdit;
|
||||||
property BeforeEdit: TVpBeforeEditEvent read FBeforeEdit write FBeforeEdit;
|
property BeforeEdit: TVpBeforeEditEvent read FBeforeEdit write FBeforeEdit;
|
||||||
@ -768,12 +782,17 @@ begin
|
|||||||
dvCreatingEditor := false;
|
dvCreatingEditor := false;
|
||||||
FDrawingStyle := ds3d;
|
FDrawingStyle := ds3d;
|
||||||
dvPainting := false;
|
dvPainting := false;
|
||||||
|
FShowNavButtons := true;
|
||||||
FShowResourceName := true;
|
FShowResourceName := true;
|
||||||
FColor := clWindow;
|
FColor := clWindow;
|
||||||
FLineColor := clGray;
|
FLineColor := clGray;
|
||||||
Granularity := gr30min;
|
Granularity := gr30min;
|
||||||
FDefTopHour := h_07;
|
FDefTopHour := h_07;
|
||||||
FDisplayDate := Now;
|
FDisplayDate := Now;
|
||||||
|
FFixedDate := false;
|
||||||
|
FCustomRowHeight := 0;
|
||||||
|
FRowLinesStep := 1;
|
||||||
|
FSimpleRowTime := false;
|
||||||
TopHour := FDefTopHour;
|
TopHour := FDefTopHour;
|
||||||
FTimeFormat := tf12Hour;
|
FTimeFormat := tf12Hour;
|
||||||
FDateLabelFormat := 'dddddd'; //'dddd, mmmm dd, yyyy';
|
FDateLabelFormat := 'dddddd'; //'dddd, mmmm dd, yyyy';
|
||||||
@ -1231,7 +1250,7 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
StartTime := trunc(FDisplayDate + ActiveCol) + dvLineMatrix[ActiveCol, ActiveRow].Time;
|
StartTime := trunc(FDisplayDate + ActiveCol) + dvLineMatrix[ActiveCol, ActiveRow].Time;
|
||||||
EndTime := StartTime + dvTimeIncSize;
|
EndTime := StartTime + dvTimeIncSize * FRowLinesStep;
|
||||||
FActiveEvent := DataStore.Resource.Schedule.AddEvent(
|
FActiveEvent := DataStore.Resource.Schedule.AddEvent(
|
||||||
DataStore.GetNextID(EventsTableName),
|
DataStore.GetNextID(EventsTableName),
|
||||||
StartTime,
|
StartTime,
|
||||||
@ -1603,7 +1622,10 @@ begin
|
|||||||
Temp := Canvas.TextHeight(TallShortChars);
|
Temp := Canvas.TextHeight(TallShortChars);
|
||||||
if Temp > Result then
|
if Temp > Result then
|
||||||
Result := Temp;
|
Result := Temp;
|
||||||
Result := Result + TextMargin * 2;
|
if FCustomRowHeight = 0 then
|
||||||
|
Result := Result + TextMargin * 2
|
||||||
|
else
|
||||||
|
Result := FCustomRowHeight;
|
||||||
|
|
||||||
Result := Round(Result * Scale);
|
Result := Round(Result * Scale);
|
||||||
dvClientVArea := Result * MinutesInDay div GranularityMinutes[UseGran];
|
dvClientVArea := Result * MinutesInDay div GranularityMinutes[UseGran];
|
||||||
@ -1762,7 +1784,7 @@ end;
|
|||||||
|
|
||||||
procedure TVpDayView.SetDisplayDate(Value: TDateTime);
|
procedure TVpDayView.SetDisplayDate(Value: TDateTime);
|
||||||
begin
|
begin
|
||||||
if FDisplayDate <> Value then begin
|
if (not FFixedDate) and (FDisplayDate <> Value) then begin
|
||||||
EndEdit(self);
|
EndEdit(self);
|
||||||
FDisplayDate := Value;
|
FDisplayDate := Value;
|
||||||
if dvLoaded then
|
if dvLoaded then
|
||||||
@ -1963,7 +1985,7 @@ begin
|
|||||||
{ otherwise, we must want to create a new event }
|
{ otherwise, we must want to create a new event }
|
||||||
StartTime := trunc(FDisplayDate + ActiveCol)
|
StartTime := trunc(FDisplayDate + ActiveCol)
|
||||||
+ dvLineMatrix[ActiveCol, ActiveRow].Time;
|
+ dvLineMatrix[ActiveCol, ActiveRow].Time;
|
||||||
EndTime := StartTime + dvTimeIncSize;
|
EndTime := StartTime + dvTimeIncSize * FRowLinesStep;
|
||||||
FActiveEvent := DataStore.Resource.Schedule.AddEvent(
|
FActiveEvent := DataStore.Resource.Schedule.AddEvent(
|
||||||
DataStore.GetNextID(EventsTableName), StartTime, EndTime);
|
DataStore.GetNextID(EventsTableName), StartTime, EndTime);
|
||||||
{ edit this new event }
|
{ edit this new event }
|
||||||
@ -2363,6 +2385,34 @@ begin
|
|||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
|
procedure TVpDayView.SetCustomRowHeight(Value: Integer);
|
||||||
|
begin
|
||||||
|
if Value <> FCustomRowHeight then begin
|
||||||
|
if (Value <> 0) and (Value < TextMargin)
|
||||||
|
then FCustomRowHeight := TextMargin
|
||||||
|
else FCustomRowHeight := Value;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TVpDayView.SetRowLinesStep(Value: Integer);
|
||||||
|
begin
|
||||||
|
if Value <> FRowLinesStep then begin
|
||||||
|
if Value < 1
|
||||||
|
then FRowLinesStep := 1
|
||||||
|
else FRowLinesStep := Value;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TVpDayView.SetShowNavButtons(Value: Boolean);
|
||||||
|
begin
|
||||||
|
if Value <> FShowNavButtons then begin
|
||||||
|
FShowNavButtons := Value;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpDayView.SetShowResourceName(Value: Boolean);
|
procedure TVpDayView.SetShowResourceName(Value: Boolean);
|
||||||
begin
|
begin
|
||||||
if Value <> FShowResourceName then begin
|
if Value <> FShowResourceName then begin
|
||||||
@ -2371,6 +2421,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TVpDayView.SetSimpleRowTime(Value: Boolean);
|
||||||
|
begin
|
||||||
|
if Value <> FSimpleRowTime then begin
|
||||||
|
FSimpleRowTime := Value;
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpDayView.SetNumDays(Value: Integer);
|
procedure TVpDayView.SetNumDays(Value: Integer);
|
||||||
begin
|
begin
|
||||||
if (Value <> FNumDays) and (Value > 0) and (Value < 31) then begin
|
if (Value <> FNumDays) and (Value > 0) and (Value < 31) then begin
|
||||||
|
@ -557,11 +557,9 @@ begin
|
|||||||
|
|
||||||
{ Draw the lines }
|
{ Draw the lines }
|
||||||
RenderCanvas.Pen.Color := FDayView.LineColor;
|
RenderCanvas.Pen.Color := FDayView.LineColor;
|
||||||
TPSMoveTo(RenderCanvas, Angle, RenderIn, LineRect.Left, LineRect.Top);
|
TPSMoveTo(RenderCanvas, Angle, RenderIn, LineRect.Left, LineRect.Bottom - 1);
|
||||||
TPSLineTo(RenderCanvas, Angle, RenderIn, LineRect.Right - 1, LineRect.Top);
|
if (lineIndex + 1) mod FDayView.RowLinesStep = 0 then
|
||||||
TPSMoveTo(RenderCanvas, Angle, RenderIn, LineRect.Left, LineRect.Bottom);
|
TPSLineTo(RenderCanvas, Angle, RenderIn, LineRect.Right - 1, LineRect.Bottom - 1);
|
||||||
TPSLineTo(RenderCanvas, Angle, RenderIn, LineRect.Right - 1, LineRect.Bottom);
|
|
||||||
|
|
||||||
inc(I);
|
inc(I);
|
||||||
end; // while true ...
|
end; // while true ...
|
||||||
|
|
||||||
@ -1120,6 +1118,11 @@ var
|
|||||||
begin
|
begin
|
||||||
{ size and place the Today button first. }
|
{ size and place the Today button first. }
|
||||||
with TVpDayViewOpener(FDayView) do begin
|
with TVpDayViewOpener(FDayView) do begin
|
||||||
|
dvDayUpBtn.Visible := FShowNavButtons;
|
||||||
|
dvDayDownBtn.Visible := FShowNavButtons;
|
||||||
|
dvTodayBtn.Visible := FShowNavButtons;
|
||||||
|
dvWeekUpBtn.Visible := FShowNavButtons;
|
||||||
|
dvWeekDownBtn.Visible := FShowNavButtons;
|
||||||
{ Calculate width of buttons }
|
{ Calculate width of buttons }
|
||||||
dvTodayBtn.Height := trunc(RealColHeadHeight div 2);
|
dvTodayBtn.Height := trunc(RealColHeadHeight div 2);
|
||||||
dvTodayBtn.Width := RealRowHeadWidth;
|
dvTodayBtn.Width := RealRowHeadWidth;
|
||||||
@ -1373,7 +1376,7 @@ begin
|
|||||||
hourStr := '12';
|
hourStr := '12';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if UseGran = gr60Min then
|
if (UseGran = gr60Min) or FDayView.SimpleRowTime then
|
||||||
begin
|
begin
|
||||||
// In case of 60-min granularity paint time as simple string
|
// In case of 60-min granularity paint time as simple string
|
||||||
RenderCanvas.Font.Assign(FDayView.RowHeadAttributes.MinuteFont);
|
RenderCanvas.Font.Assign(FDayView.RowHeadAttributes.MinuteFont);
|
||||||
@ -1381,7 +1384,7 @@ begin
|
|||||||
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
RenderCanvas.Font.Size := ScaleY(RenderCanvas.Font.Size, DesignTimeDPI);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
timeStr := Format('%s:%s', [hourStr, minuteStr]);
|
timeStr := Format('%s:%s', [hourStr, minuteStr]);
|
||||||
x := lineRect.Right - RenderCanvas.TextWidth(timeStr) - MINUTES_BORDER;
|
x := lineRect.Left + TICK_DIST;
|
||||||
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + TextMargin, timeStr);
|
TPSTextOut(RenderCanvas, Angle, RenderIn, x, y + TextMargin, timeStr);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
@ -1473,13 +1476,14 @@ begin
|
|||||||
else
|
else
|
||||||
isFullHour := TVpDayViewOpener(FDayView).dvLineMatrix[0, lineIndex].Minute = 0;
|
isFullHour := TVpDayViewOpener(FDayView).dvLineMatrix[0, lineIndex].Minute = 0;
|
||||||
|
|
||||||
TPSMoveTo(RenderCanvas, Angle, RenderIn, lineRect.Right - TICK_DIST, y);
|
TPSMoveTo(RenderCanvas, Angle, RenderIn, lineRect.Right - TICK_DIST, y - 1);
|
||||||
if isFullHour then
|
if lineIndex mod FDayView.RowLinesStep = 0 then
|
||||||
// Hour tick line
|
if isFullHour then
|
||||||
TPSLineTo(RenderCanvas, Angle, RenderIn, lineRect.Left + TICK_DIST, y)
|
// Hour tick line
|
||||||
else
|
TPSLineTo(RenderCanvas, Angle, RenderIn, lineRect.Left + TICK_DIST, y - 1)
|
||||||
// Minutes tick lines
|
else
|
||||||
TPSLineTo(RenderCanvas, Angle, RenderIn, lineRect.Right - MinutesLen, y);
|
// Minutes tick lines
|
||||||
|
TPSLineTo(RenderCanvas, Angle, RenderIn, lineRect.Right - MinutesLen, y - 1);
|
||||||
|
|
||||||
inc(I);
|
inc(I);
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user