tvplanit: New property KBNavigation for TVpDayView and TVpMonthView to disable keyboard navigation, like in TVpMonthView

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8766 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-03-15 22:39:29 +00:00
parent 0ceb87ed80
commit a09c467161
4 changed files with 153 additions and 135 deletions

View File

@@ -240,6 +240,7 @@ type
FHintMode: TVpHintMode; FHintMode: TVpHintMode;
FIconAttributes: TVpDayViewIconAttributes; FIconAttributes: TVpDayViewIconAttributes;
FIncludeWeekends: Boolean; FIncludeWeekends: Boolean;
FKBNavigate: Boolean;
FLineColor: TColor; FLineColor: TColor;
FLineCount: Integer; FLineCount: Integer;
FMouseEvent: TVpEvent; FMouseEvent: TVpEvent;
@@ -518,6 +519,7 @@ 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 KBNavigation: Boolean read FKBNavigate write FKBNavigate default true;
property ShowNavButtons: Boolean read FShowNavButtons write SetShowNavButtons default true; property ShowNavButtons: Boolean read FShowNavButtons write SetShowNavButtons default true;
property FixedDate: Boolean read FFixedDate write FFixedDate default false; property FixedDate: Boolean read FFixedDate write FFixedDate default false;
property RowHeight: Integer read FCustomRowHeight write SetCustomRowHeight default 0; property RowHeight: Integer read FCustomRowHeight write SetCustomRowHeight default 0;
@@ -808,6 +810,7 @@ begin
FIncludeWeekends := True; FIncludeWeekends := True;
FAllowInplaceEdit := true; FAllowInplaceEdit := true;
FShowEventTimes := true; FShowEventTimes := true;
FKBNavigate := true;
{ set up fonts and colors } { set up fonts and colors }
FHeadAttr.Font.Size := 10; FHeadAttr.Font.Size := 10;
@@ -2362,60 +2365,65 @@ procedure TVpDayView.KeyDown(var Key: Word; Shift: TShiftState);
var var
PopupPoint : TPoint; PopupPoint : TPoint;
begin begin
case Key of if FKBNavigate then
VK_UP: case Key of
ActiveRow := ActiveRow - 1; VK_UP:
VK_DOWN: ActiveRow := ActiveRow - 1;
ActiveRow := ActiveRow + 1; VK_DOWN:
VK_NEXT: ActiveRow := ActiveRow + 1;
ActiveRow := ActiveRow + FVisibleLines; VK_NEXT:
VK_PRIOR: ActiveRow := ActiveRow + FVisibleLines;
ActiveRow := ActiveRow - FVisibleLines; VK_PRIOR:
VK_LEFT: ActiveRow := ActiveRow - FVisibleLines;
Date := Date - 1; VK_LEFT:
VK_RIGHT: Date := Date - 1;
Date := Date + 1; VK_RIGHT:
VK_HOME: Date := Date + 1;
ActiveRow := 0; VK_HOME:
VK_END: ActiveRow := 0;
ActiveRow := LineCount; VK_END:
VK_DELETE: ActiveRow := LineCount;
if not ReadOnly then VK_DELETE:
DeleteActiveEvent(true); if not ReadOnly then
{$IFNDEF LCL} DeleteActiveEvent(true);
VK_TAB: {$IFNDEF LCL}
if ssShift in Shift then VK_TAB:
Windows.SetFocus (GetNextDlgTabItem(GetParent(Handle), Handle, False)) if ssShift in Shift then
else Windows.SetFocus (GetNextDlgTabItem(GetParent(Handle), Handle, False))
Windows.SetFocus (GetNextDlgTabItem(GetParent(Handle), Handle, True)); else
{$ENDIF} Windows.SetFocus (GetNextDlgTabItem(GetParent(Handle), Handle, True));
VK_F10: {$ENDIF}
if (ssShift in Shift) and not (Assigned (PopupMenu)) then begin VK_F10:
PopupPoint := GetClientOrigin; if (ssShift in Shift) and not (Assigned (PopupMenu)) then begin
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); PopupPoint := GetClientOrigin;
end; FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
VK_APPS : end;
if not Assigned(PopupMenu) then begin VK_APPS :
PopupPoint := GetClientOrigin; if not Assigned(PopupMenu) then begin
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); PopupPoint := GetClientOrigin;
end; FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
VK_RETURN: end;
PopupEditEvent(Self); VK_RETURN:
VK_INSERT: PopupEditEvent(Self);
PopupAddEvent(Self); VK_INSERT:
VK_F2: PopupAddEvent(Self);
if Assigned(FActiveEvent) then VK_F2:
dvEditInPlace(Self)
else
begin
PopupPoint := dvLineMatrix[ActiveCol, ActiveRow].Rec.TopLeft;
PopupPoint.x := PopupPoint.x + 1;
PopupPoint.y := PopupPoint.y + 1;
SetActiveEventByCoord (PopupPoint);
if Assigned(FActiveEvent) then if Assigned(FActiveEvent) then
dvEditInPlace(Self); dvEditInPlace(Self)
end; else
end; begin
PopupPoint := dvLineMatrix[ActiveCol, ActiveRow].Rec.TopLeft;
PopupPoint.x := PopupPoint.x + 1;
PopupPoint.y := PopupPoint.y + 1;
SetActiveEventByCoord (PopupPoint);
if Assigned(FActiveEvent) then
dvEditInPlace(Self);
end;
end
else
Key := 0;
inherited;
end; end;
{$IFNDEF LCL} {$IFNDEF LCL}

View File

@@ -1495,7 +1495,11 @@ begin
PopupPoint := GetClientOrigin; PopupPoint := GetClientOrigin;
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
end; end;
end; end
else
Key := 0;
inherited;
end; end;
procedure TVpMonthView.MouseDown(Button: TMouseButton; Shift: TShiftState; procedure TVpMonthView.MouseDown(Button: TMouseButton; Shift: TShiftState;

View File

@@ -117,8 +117,6 @@ begin
todayDate := Date(); todayDate := Date();
DecodeDate(ADate, Y, M, D); DecodeDate(ADate, Y, M, D);
WriteLn(ATextRect.Top, ', ', ATextRect.Bottom, ', ', RealBottom);
if (ACol = 6) then if (ACol = 6) then
ATextRect.Right := ATextRect.Right + 8; ATextRect.Right := ATextRect.Right + 8;

View File

@@ -157,6 +157,7 @@ type
FHeadAttr: TVpWvHeadAttributes; FHeadAttr: TVpWvHeadAttributes;
FHeaderMargin: Integer; FHeaderMargin: Integer;
FHintMode: TVpHintMode; FHintMode: TVpHintMode;
FKBNavigate: Boolean;
FLineColor: TColor; FLineColor: TColor;
FMouseEvent: TVpEvent; FMouseEvent: TVpEvent;
FLayout: TVpWeekviewLayout; FLayout: TVpWeekviewLayout;
@@ -353,6 +354,7 @@ type
property HeadAttributes: TVpWvHeadAttributes read FHeadAttr write FHeadAttr; property HeadAttributes: TVpWvHeadAttributes read FHeadAttr write FHeadAttr;
property HeaderMargin: Integer read FHeaderMargin write SetHeaderMargin default TEXT_MARGIN; property HeaderMargin: Integer read FHeaderMargin write SetHeaderMargin default TEXT_MARGIN;
property HintMode: TVpHintMode read FHintMode write FHintMode default hmPlannerHint; 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 LineColor: TColor read FLineColor write SetLineColor default DEFAULT_LINECOLOR;
property Layout: TVpWeekviewLayout read FLayout write SetLayout default wvlVertical; property Layout: TVpWeekviewLayout read FLayout write SetLayout default wvlVertical;
property TextMargin: Integer read FTextMargin write SetTextMargin default 2; property TextMargin: Integer read FTextMargin write SetTextMargin default 2;
@@ -629,6 +631,7 @@ begin
wvClickTimer.OnTimer := wvEditInPlace; wvClickTimer.OnTimer := wvEditInPlace;
wvCreatingEditor := false; wvCreatingEditor := false;
FDrawingStyle := ds3d; FDrawingStyle := ds3d;
FKBNavigate := true;
wvPainting := false; wvPainting := false;
FColor := DEFAULT_COLOR; FColor := DEFAULT_COLOR;
FLineColor := DEFAULT_LINECOLOR; FLineColor := DEFAULT_LINECOLOR;
@@ -1801,89 +1804,94 @@ procedure TVpWeekView.KeyDown(var Key: Word; Shift: TShiftState);
var var
PopupPoint : TPoint; PopupPoint : TPoint;
begin begin
case Key of if FKBNavigate then
VK_DELETE : DeleteActiveEvent(true); case Key of
VK_RIGHT : if Shift = [ssShift] then VK_DELETE : DeleteActiveEvent(true);
PopupNextWeek (Self) VK_RIGHT : if Shift = [ssShift] then
else if (Shift = [ssCtrl]) then PopupNextWeek (Self)
PopupNextMonth (Self) else if (Shift = [ssCtrl]) then
else if (Shift = [ssShift, ssCtrl]) then PopupNextMonth (Self)
PopupNextYear (Self) else if (Shift = [ssShift, ssCtrl]) then
else if Shift = [] then begin PopupNextYear (Self)
case DayOfWeek (FActiveDate) of else if Shift = [] then begin
1 : FActiveDate := FActiveDate - 4;
2 : FActiveDate := FActiveDate + 3;
3 : FActiveDate := FActiveDate + 3;
4 : FActiveDate := FActiveDate + 3;
5 : FActiveDate := FActiveDate - 3;
6 : FActiveDate := FActiveDate - 3;
7 : FActiveDate := FActiveDate - 3;
end;
Invalidate;
end;
VK_LEFT : if Shift = [ssShift] then
PopupPrevWeek (Self)
else if (Shift = [ssCtrl]) then
PopupPrevMonth (Self)
else if (Shift = [ssShift, ssCtrl]) then
PopupPrevYear (Self)
else if Shift = [] then begin
case DayOfWeek (FActiveDate) of
1 : FActiveDate := FActiveDate - 4;
2 : FActiveDate := FActiveDate + 3;
3 : FActiveDate := FActiveDate + 3;
4 : FActiveDate := FActiveDate + 3;
5 : FActiveDate := FActiveDate - 3;
6 : FActiveDate := FActiveDate - 3;
7 : FActiveDate := FActiveDate - 3;
end;
Invalidate;
end;
VK_UP : begin
if Shift = [] then
case DayOfWeek (FActiveDate) of case DayOfWeek (FActiveDate) of
1 : FActiveDate := FActiveDate - 1; 1 : FActiveDate := FActiveDate - 4;
2 : FActiveDate := FActiveDate + 2; 2 : FActiveDate := FActiveDate + 3;
3 : FActiveDate := FActiveDate - 1; 3 : FActiveDate := FActiveDate + 3;
4 : FActiveDate := FActiveDate - 1; 4 : FActiveDate := FActiveDate + 3;
5 : FActiveDate := FActiveDate + 3; 5 : FActiveDate := FActiveDate - 3;
6 : FActiveDate := FActiveDate - 1; 6 : FActiveDate := FActiveDate - 3;
7 : FActiveDate := FActiveDate - 1; 7 : FActiveDate := FActiveDate - 3;
end; end;
Invalidate; Invalidate;
end; end;
VK_DOWN : begin VK_LEFT : if Shift = [ssShift] then
if Shift = [] then PopupPrevWeek (Self)
else if (Shift = [ssCtrl]) then
PopupPrevMonth (Self)
else if (Shift = [ssShift, ssCtrl]) then
PopupPrevYear (Self)
else if Shift = [] then begin
case DayOfWeek (FActiveDate) of case DayOfWeek (FActiveDate) of
1 : FActiveDate := FActiveDate - 3; 1 : FActiveDate := FActiveDate - 4;
2 : FActiveDate := FActiveDate + 1; 2 : FActiveDate := FActiveDate + 3;
3 : FActiveDate := FActiveDate + 1; 3 : FActiveDate := FActiveDate + 3;
4 : FActiveDate := FActiveDate - 2; 4 : FActiveDate := FActiveDate + 3;
5 : FActiveDate := FActiveDate + 1; 5 : FActiveDate := FActiveDate - 3;
6 : FActiveDate := FActiveDate + 1; 6 : FActiveDate := FActiveDate - 3;
7 : FActiveDate := FActiveDate + 1; 7 : FActiveDate := FActiveDate - 3;
end; end;
Invalidate; Invalidate;
end; end;
VK_INSERT : PopupAddEvent(Self); VK_UP : begin
{$IFNDEF LCL} if Shift = [] then
VK_TAB : case DayOfWeek (FActiveDate) of
if ssShift in Shift then 1 : FActiveDate := FActiveDate - 1;
Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, False)) 2 : FActiveDate := FActiveDate + 2;
else 3 : FActiveDate := FActiveDate - 1;
Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, True)); 4 : FActiveDate := FActiveDate - 1;
{$ENDIF} 5 : FActiveDate := FActiveDate + 3;
VK_F10: 6 : FActiveDate := FActiveDate - 1;
if (ssShift in Shift) and not Assigned(PopupMenu) then begin 7 : FActiveDate := FActiveDate - 1;
PopupPoint := GetClientOrigin; end;
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); Invalidate;
end; end;
VK_APPS: VK_DOWN : begin
if not Assigned (PopupMenu) then begin if Shift = [] then
PopupPoint := GetClientOrigin; case DayOfWeek (FActiveDate) of
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); 1 : FActiveDate := FActiveDate - 3;
end; 2 : FActiveDate := FActiveDate + 1;
end; 3 : FActiveDate := FActiveDate + 1;
4 : FActiveDate := FActiveDate - 2;
5 : FActiveDate := FActiveDate + 1;
6 : FActiveDate := FActiveDate + 1;
7 : FActiveDate := FActiveDate + 1;
end;
Invalidate;
end;
VK_INSERT : PopupAddEvent(Self);
{$IFNDEF LCL}
VK_TAB :
if ssShift in Shift then
Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, False))
else
Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, True));
{$ENDIF}
VK_F10:
if (ssShift in Shift) and not Assigned(PopupMenu) then begin
PopupPoint := GetClientOrigin;
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
end;
VK_APPS:
if not Assigned (PopupMenu) then begin
PopupPoint := GetClientOrigin;
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
end;
end
else
Key := 0;
inherited;
end; end;
procedure TVpWeekView.EndEdit(Sender: TObject); procedure TVpWeekView.EndEdit(Sender: TObject);