tvplanit: Fix double-click on monthview finding events in wrong month.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8535 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-10-11 18:12:38 +00:00
parent 9f05d1ba41
commit d42c10d9af

View File

@ -94,39 +94,6 @@ type
property Color default WEEKEND_COLOR;
end;
(*
TVpMvHeadAttr = class(TPersistent)
protected{ private }
FOwner: TVpMonthView;
FColor: TColor;
FFont: TVpFont;
procedure SetColor(const Value: TColor);
procedure SetFont(Value: TVpFont);
public
constructor Create(AOwner: TVpMonthView);
destructor Destroy; override;
property Owner: TVpMonthView read FOwner;
published
property Font: TVpFont read FFont write SetFont;
property Color: TColor read FColor write SetColor;
end;
TVpDayHeadAttr = class(TPersistent)
protected{private}
FMonthView: TVpMonthView;
FFont: TVpFont;
FColor: TColor;
procedure SetColor(Value: TColor);
procedure SetFont(Value: TVpFont);
public
constructor Create(AOwner: TVpMonthView);
destructor Destroy; override;
property MonthView: TVpMonthView read FMonthView;
published
property Color: TColor read FColor write SetColor;
property Font: TVpFont read FFont write SetFont;
end;
*)
TVpMvTodayAttr = class(TVpMonthViewAttr)
private
FBorderPen: TPen;
@ -1385,41 +1352,51 @@ end;
function TVpMonthView.SelectEventAtCoord(Point: TPoint): Boolean;
var
I: Integer;
y1, m1, d1: Word;
y2, m2, d2: Word;
begin
result := false;
Result := false;
DecodeDate(FDate, y1, m1, d1);
I := 0;
while I < Length(mvEventArray) do begin
if mvEventArray[I].Event = nil then begin
Inc(I);
Break;
end else begin
if (Point.X > mvEventArray[I].Rec.Left)
and (Point.X < mvEventArray[I].Rec.Right)
and (Point.Y > mvEventArray[I].Rec.Top)
and (Point.Y < mvEventArray[I].Rec.Bottom) then begin
result := true;
Break;
end else
Inc(I);
end;
end;
if result then begin
if PtInRect(mvEventArray[I].Rec, Point) then
begin
DecodeDate(TVpEvent(mvEventArray[I].Event).StartTime, y2, m2, d2);
if (y1 = y2) and (m1 = m2) then
begin
mvActiveEvent := TVpEvent(mvEventArray[I].Event);
mvActiveEventRec := mvEventArray[I].Rec;
Result := true;
Break;
end;
end;
Inc(I);
end;
end;
end;
procedure TVpMonthView.mvSetDateByCoord(APoint: TPoint);
var
I: Integer;
d1, m1, y1: Word;
d2, m2, y2: Word;
begin
for I := 0 to pred(Length(mvMonthdayArray)) do
if PointInRect(APoint, mvMonthdayArray[I].Rec) then
DecodeDate(FDate, y1, m1, d1);
for I := 0 to pred(Length(mvMonthDayArray)) do
if PointInRect(APoint, mvMonthDayArray[I].Rec) then
begin
DecodeDate(mvMonthDayArray[I].Date, y2, m2, d2);
if (y1 = y2) and (m1 = m2) then
begin
Date := mvMonthdayArray[I].Date;
break;
end;
end;
end;
function TVpMonthView.GetDateAtCoord(APoint: TPoint): TDateTime;