2008-02-03 12:05:55 +00:00
|
|
|
{*********************************************************}
|
|
|
|
{* VPTASKLIST.PAS 1.03 *}
|
|
|
|
{*********************************************************}
|
|
|
|
|
|
|
|
{* ***** BEGIN LICENSE BLOCK ***** *}
|
|
|
|
{* Version: MPL 1.1 *}
|
|
|
|
{* *}
|
|
|
|
{* The contents of this file are subject to the Mozilla Public License *}
|
|
|
|
{* Version 1.1 (the "License"); you may not use this file except in *}
|
|
|
|
{* compliance with the License. You may obtain a copy of the License at *}
|
|
|
|
{* http://www.mozilla.org/MPL/ *}
|
|
|
|
{* *}
|
|
|
|
{* Software distributed under the License is distributed on an "AS IS" basis, *}
|
|
|
|
{* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License *}
|
|
|
|
{* for the specific language governing rights and limitations under the *}
|
|
|
|
{* License. *}
|
|
|
|
{* *}
|
|
|
|
{* The Original Code is TurboPower Visual PlanIt *}
|
|
|
|
{* *}
|
|
|
|
{* The Initial Developer of the Original Code is TurboPower Software *}
|
|
|
|
{* *}
|
|
|
|
{* Portions created by TurboPower Software Inc. are Copyright (C) 2002 *}
|
|
|
|
{* TurboPower Software Inc. All Rights Reserved. *}
|
|
|
|
{* *}
|
|
|
|
{* Contributor(s): *}
|
|
|
|
{* *}
|
|
|
|
{* ***** END LICENSE BLOCK ***** *}
|
|
|
|
|
2016-06-22 07:59:17 +00:00
|
|
|
{$I vp.inc}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
unit VpTaskList;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF LCL}
|
2016-06-22 07:59:17 +00:00
|
|
|
LMessages, LCLProc, LCLType, LCLIntf,
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ELSE}
|
2016-06-22 07:59:17 +00:00
|
|
|
Windows, Messages,
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
2016-11-21 17:12:05 +00:00
|
|
|
Classes, Graphics, Controls, ExtCtrls, StdCtrls, Menus,
|
2017-05-22 08:11:27 +00:00
|
|
|
VpConst, VpBase, VpBaseDS, VpMisc, VpData, VpSR, VpCanvasUtils;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
TVpTaskRec = packed record
|
2016-07-14 16:13:22 +00:00
|
|
|
Task: Pointer;
|
|
|
|
LineRect: TRect;
|
2008-02-03 12:05:55 +00:00
|
|
|
CheckRect: TRect;
|
|
|
|
end;
|
|
|
|
|
|
|
|
type
|
|
|
|
TVpTaskArray = array of TVpTaskRec;
|
|
|
|
|
|
|
|
{ forward declarations }
|
|
|
|
TVpTaskList = class;
|
|
|
|
|
|
|
|
TVpTaskDisplayOptions = class(TPersistent)
|
|
|
|
protected{private}
|
2016-07-14 16:13:22 +00:00
|
|
|
FTaskList: TVpTaskList;
|
|
|
|
FShowAll: Boolean;
|
|
|
|
FShowCompleted: Boolean;
|
|
|
|
FShowDueDate: Boolean;
|
|
|
|
FDueDateFormat: string;
|
|
|
|
FCheckColor: TColor;
|
|
|
|
FCheckBGColor: TColor;
|
|
|
|
FCheckStyle: TVpCheckStyle;
|
|
|
|
FOverdueColor: TColor;
|
|
|
|
FNormalColor: TColor;
|
|
|
|
FCompletedColor: TColor;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure SetCheckColor(Value: TColor);
|
|
|
|
procedure SetCheckBGColor(Value: TColor);
|
|
|
|
procedure SetCheckStyle(Value: TVpCheckStyle);
|
|
|
|
procedure SetDueDateFormat(Value: string);
|
|
|
|
procedure SetShowCompleted(Value: Boolean);
|
|
|
|
procedure SetShowDueDate(Value: Boolean);
|
|
|
|
procedure SetShowAll(Value: Boolean);
|
|
|
|
procedure SetOverdueColor(Value: TColor);
|
|
|
|
procedure SetNormalColor(Value: TColor);
|
|
|
|
procedure SetCompletedColor(Value: TColor);
|
|
|
|
public
|
2016-07-14 16:13:22 +00:00
|
|
|
constructor Create(Owner: TVpTaskList);
|
2008-02-03 12:05:55 +00:00
|
|
|
destructor Destroy; override;
|
|
|
|
published
|
2016-07-14 16:13:22 +00:00
|
|
|
property CheckBGColor: TColor read FCheckBGColor write SetCheckBGColor;
|
|
|
|
property CheckColor: TColor read FCheckColor write SetCheckColor;
|
|
|
|
property CheckStyle: TVpCheckStyle read FCheckStyle write SetCheckStyle;
|
|
|
|
property DueDateFormat: string read FDueDateFormat write SetDueDateFormat;
|
|
|
|
property ShowCompletedTasks: Boolean read FShowCompleted write SetShowCompleted;
|
|
|
|
property ShowAll: Boolean read FShowAll write SetShowAll;
|
|
|
|
property ShowDueDate: Boolean read FShowDueDate write SetShowDueDate;
|
|
|
|
property OverdueColor: TColor read FOverdueColor write SetOverdueColor;
|
|
|
|
property NormalColor: TColor read FNormalColor write SetNormalColor;
|
|
|
|
property CompletedColor: TColor read FCompletedColor write SetCompletedColor;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
{ InPlace Editor }
|
|
|
|
TVpTLInPlaceEdit = class(TCustomEdit)
|
|
|
|
protected{private}
|
|
|
|
procedure CreateParams(var Params: TCreateParams); override;
|
|
|
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
2016-06-10 21:20:06 +00:00
|
|
|
// procedure Move(const Loc: TRect; Redraw: Boolean);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
TVpTaskHeadAttr = class(TVpPersistent)
|
|
|
|
protected{private}
|
|
|
|
FTaskList: TVpTaskList;
|
2016-07-15 11:52:21 +00:00
|
|
|
FFont: TVpFont;
|
2008-02-03 12:05:55 +00:00
|
|
|
FColor: TColor;
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure SetColor(Value: TColor);
|
2016-07-15 11:52:21 +00:00
|
|
|
procedure SetFont(Value: TVpFont);
|
2008-02-03 12:05:55 +00:00
|
|
|
public
|
|
|
|
constructor Create(AOwner: TVpTaskList);
|
|
|
|
destructor Destroy; override;
|
|
|
|
procedure Invalidate; override;
|
|
|
|
{ The Invalidate method is used as a bridge between FFont & FTaskList. }
|
|
|
|
property TaskList: TVpTaskList read FTaskList;
|
|
|
|
published
|
2016-07-14 16:13:22 +00:00
|
|
|
property Color: TColor read FColor write SetColor;
|
2016-07-15 11:52:21 +00:00
|
|
|
property Font: TVpFont read FFont write SetFont;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
{ Task List }
|
|
|
|
TVpTaskList = class(TVpLinkableControl)
|
|
|
|
protected{ private }
|
2016-07-14 16:13:22 +00:00
|
|
|
FColor: TColor;
|
|
|
|
FCaption: string;
|
|
|
|
FDisplayOptions: TVpTaskDisplayOptions;
|
|
|
|
FLineColor: TColor;
|
|
|
|
FActiveTask: TVpTask;
|
|
|
|
FShowResourceName: Boolean;
|
|
|
|
FTaskIndex: Integer;
|
|
|
|
FScrollBars: TScrollStyle;
|
|
|
|
FTaskHeadAttr: TVpTaskHeadAttr;
|
|
|
|
FMaxVisibleTasks: Word;
|
|
|
|
FDrawingStyle: TVpDrawingStyle;
|
|
|
|
FTaskID: Integer;
|
|
|
|
FDefaultPopup: TPopupMenu;
|
|
|
|
FShowIcon: Boolean;
|
|
|
|
FAllowInplaceEdit: Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
{ task variables }
|
2016-07-14 16:13:22 +00:00
|
|
|
FOwnerDrawTask: TVpOwnerDrawTask;
|
|
|
|
FBeforeEdit: TVpBeforeEditTask;
|
|
|
|
FAfterEdit: TVpAfterEditTask;
|
|
|
|
FOwnerEditTask: TVpEditTask;
|
2008-02-03 12:05:55 +00:00
|
|
|
{ internal variables }
|
2016-07-14 16:13:22 +00:00
|
|
|
tlVisibleTaskArray: TVpTaskArray;
|
|
|
|
tlAllTaskList: TList;
|
|
|
|
tlItemsBefore: Integer;
|
|
|
|
tlItemsAfter: Integer;
|
|
|
|
tlVisibleItems: Integer;
|
|
|
|
tlHitPoint: TPoint;
|
|
|
|
tlClickTimer: TTimer;
|
|
|
|
tlLoaded: Boolean;
|
|
|
|
tlRowHeight: Integer;
|
|
|
|
tlInPlaceEditor: TVpTLInPlaceEdit;
|
|
|
|
tlCreatingEditor: Boolean;
|
|
|
|
tlPainting: Boolean;
|
|
|
|
tlVScrollDelta: Integer;
|
|
|
|
tlHotPoint: TPoint;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
{ property methods }
|
|
|
|
function GetTaskIndex: Integer;
|
|
|
|
procedure SetLineColor(Value: TColor);
|
|
|
|
procedure SetMaxVisibleTasks(Value: Word);
|
|
|
|
procedure SetTaskIndex(Value: Integer);
|
|
|
|
procedure SetDrawingStyle(const Value: TVpDrawingStyle);
|
2016-07-14 11:18:59 +00:00
|
|
|
procedure SetColor(const Value: TColor); reintroduce;
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure SetShowIcon(const v: Boolean);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure SetShowResourceName(Value: Boolean);
|
|
|
|
{ internal methods }
|
|
|
|
procedure InitializeDefaultPopup;
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure PopupAddTask(Sender: TObject);
|
2018-06-17 20:27:58 +00:00
|
|
|
procedure PopupAddFromICalFile(Sender: TObject);
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure PopupDeleteTask(Sender: TObject);
|
2022-06-11 21:24:49 +00:00
|
|
|
procedure PopupDropdownEvent(Sender: TObject);
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure PopupEditTask(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure tlSetVScrollPos;
|
|
|
|
procedure tlCalcRowHeight;
|
|
|
|
procedure tlEditInPlace(Sender: TObject);
|
|
|
|
procedure tlHookUp;
|
|
|
|
procedure Paint; override;
|
|
|
|
procedure Loaded; override;
|
2018-05-17 16:35:44 +00:00
|
|
|
procedure tlSpawnTaskEditDialog(IsNewTask: Boolean);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure tlSetActiveTaskByCoord(Pnt: TPoint);
|
2016-07-14 16:13:22 +00:00
|
|
|
function tlVisibleTaskToTaskIndex(const VisTaskIndex: Integer) : Integer;
|
|
|
|
function tlTaskIndexToVisibleTask(const ATaskIndex: Integer) : Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure CreateParams(var Params: TCreateParams); override;
|
|
|
|
procedure CreateWnd; override;
|
|
|
|
procedure EditTask;
|
|
|
|
procedure EndEdit(Sender: TObject);
|
|
|
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
2017-05-22 08:11:27 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{ message handlers }
|
|
|
|
{$IFNDEF LCL}
|
2017-05-22 08:11:27 +00:00
|
|
|
procedure WMLButtonDown(var Msg: TWMLButtonDown); message WM_LBUTTONDOWN;
|
|
|
|
procedure WMLButtonDblClk(var Msg: TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
|
|
|
|
procedure WMRButtonDown (var Msg: TWMRButtonDown); message WM_RBUTTONDOWN;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure WMSize(var Msg: TWMSize); message WM_SIZE;
|
|
|
|
procedure WMVScroll(var Msg: TWMVScroll); message WM_VSCROLL;
|
|
|
|
procedure CMWantSpecialKey(var Msg: TCMWantSpecialKey);
|
|
|
|
message CM_WANTSPECIALKEY;
|
|
|
|
{$ELSE}
|
2017-05-22 08:11:27 +00:00
|
|
|
procedure WMLButtonDown(var Msg: TLMLButtonDown); message LM_LBUTTONDOWN;
|
|
|
|
procedure WMLButtonDblClk(var Msg: TLMLButtonDblClk); message LM_LBUTTONDBLCLK;
|
|
|
|
procedure WMRButtonDown (var Msg: TLMRButtonDown); message LM_RBUTTONDOWN;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure WMSize(var Msg: TLMSize); message LM_SIZE;
|
|
|
|
procedure WMVScroll(var Msg: TLMVScroll); message LM_VSCROLL;
|
|
|
|
{$ENDIF}
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
destructor Destroy; override;
|
|
|
|
procedure DeleteActiveTask(Verify: Boolean);
|
2016-06-24 22:34:38 +00:00
|
|
|
procedure LoadLanguage;
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure LinkHandler(Sender: TComponent; NotificationType: TVpNotificationType;
|
2008-02-03 12:05:55 +00:00
|
|
|
const Value: Variant); override;
|
2016-07-12 18:00:32 +00:00
|
|
|
function GetControlType: TVpItemType; override;
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure PaintToCanvas(ACanvas: TCanvas; ARect: TRect; Angle: TVpRotationAngle);
|
2016-07-12 18:00:32 +00:00
|
|
|
procedure RenderToCanvas(RenderCanvas: TCanvas; RenderIn: TRect;
|
|
|
|
Angle: TVpRotationAngle; Scale: Extended; RenderDate: TDateTime;
|
|
|
|
StartLine, StopLine: Integer; UseGran: TVpGranularity; DisplayOnly: Boolean); override;
|
2016-07-14 16:13:22 +00:00
|
|
|
|
2018-01-12 12:42:12 +00:00
|
|
|
{$IF VP_LCL_SCALING = 2}
|
|
|
|
procedure ScaleFontsPPI(const AToPPI: Integer; const AProportion: Double); override;
|
|
|
|
{$ELSEIF VP_LCL_SCALING = 1}
|
|
|
|
procedure ScaleFontsPPI(const AProportion: Double); override;
|
|
|
|
{$ENDIF}
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
property ActiveTask: TVpTask read FActiveTask;
|
|
|
|
property TaskIndex: Integer read GetTaskIndex write SetTaskIndex;
|
2016-07-14 16:13:22 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
published
|
|
|
|
{inherited properties}
|
|
|
|
property Align;
|
|
|
|
property Anchors;
|
|
|
|
property Font;
|
|
|
|
property TabStop;
|
|
|
|
property TabOrder;
|
|
|
|
property ReadOnly;
|
2017-05-22 08:11:27 +00:00
|
|
|
{$IFDEF LCL}
|
|
|
|
property BorderSpacing;
|
|
|
|
{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-23 23:16:34 +00:00
|
|
|
property AllowInplaceEditing: Boolean
|
|
|
|
read FAllowInplaceEdit write FAllowInplaceEdit default true;
|
2016-07-14 16:13:22 +00:00
|
|
|
property DisplayOptions: TVpTaskDisplayOptions read FDisplayOptions write FDisplayOptions;
|
|
|
|
property LineColor: TColor read FLineColor write SetLineColor;
|
|
|
|
property MaxVisibleTasks: Word read FMaxVisibleTasks write SetMaxVisibleTasks;
|
|
|
|
property TaskHeadAttributes: TVpTaskHeadAttr read FTaskHeadAttr write FTaskHeadAttr;
|
|
|
|
property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle;
|
|
|
|
property Color: TColor read FColor write SetColor;
|
|
|
|
property ShowIcon: Boolean read FShowIcon write SetShowIcon default True;
|
|
|
|
property ShowResourceName: Boolean read FShowResourceName write SetShowResourceName;
|
2008-02-03 12:05:55 +00:00
|
|
|
{ events }
|
2016-07-14 16:13:22 +00:00
|
|
|
property BeforeEdit: TVpBeforeEditTask read FBeforeEdit write FBeforeEdit;
|
|
|
|
property AfterEdit: TVpAfterEditTask read FAfterEdit write FAfterEdit;
|
|
|
|
property OnOwnerEditTask: TVpEditTask read FOwnerEditTask write FOwnerEditTask;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2018-06-17 20:27:58 +00:00
|
|
|
SysUtils, Forms, Dialogs,
|
|
|
|
VpDlg, VpTaskEditDlg, VpTasklistPainter, VpICal;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
(*****************************************************************************)
|
|
|
|
|
|
|
|
{ TVpTaskDisplayOptions }
|
|
|
|
constructor TVpTaskDisplayOptions.Create(Owner: TVpTaskList);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
2016-07-14 11:18:59 +00:00
|
|
|
FTaskList := Owner;
|
2016-07-14 16:13:22 +00:00
|
|
|
FDueDateFormat := DefaultFormatSettings.ShortDateFormat;
|
2016-07-14 11:18:59 +00:00
|
|
|
FShowDueDate := true;
|
|
|
|
FCheckColor := cl3DDkShadow;
|
|
|
|
FCheckBGColor := clWindow;
|
|
|
|
FCheckStyle := csCheck;
|
|
|
|
FOverdueColor := clRed;
|
2008-02-03 12:05:55 +00:00
|
|
|
FCompletedColor := clGray;
|
2016-07-14 11:18:59 +00:00
|
|
|
FNormalColor := clBlack;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
destructor TVpTaskDisplayOptions.Destroy;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskDisplayOptions.SetOverdueColor(Value : TColor);
|
|
|
|
begin
|
|
|
|
if FOverdueColor <> Value then begin
|
|
|
|
FOverdueColor := Value;
|
|
|
|
FTaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskDisplayOptions.SetNormalColor(Value: TColor);
|
|
|
|
begin
|
|
|
|
if FNormalColor <> Value then begin
|
|
|
|
FNormalColor := Value;
|
|
|
|
FTaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskDisplayOptions.SetCompletedColor(Value: TColor);
|
|
|
|
begin
|
|
|
|
if FCompletedColor <> Value then begin
|
|
|
|
FCompletedColor := Value;
|
|
|
|
FTaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskDisplayOptions.SetCheckColor(Value: TColor);
|
|
|
|
begin
|
|
|
|
if FCheckColor <> Value then begin
|
|
|
|
FCheckColor := Value;
|
|
|
|
FTaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskDisplayOptions.SetCheckBGColor(Value: TColor);
|
|
|
|
begin
|
|
|
|
if FCheckBGColor <> Value then begin
|
|
|
|
FCheckBGColor := Value;
|
|
|
|
FTaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskDisplayOptions.SetCheckStyle(Value: TVpCheckStyle);
|
|
|
|
begin
|
|
|
|
if Value <> FCheckStyle then begin
|
|
|
|
FCheckStyle := Value;
|
|
|
|
FTaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskDisplayOptions.SetDueDateFormat(Value: string);
|
|
|
|
begin
|
|
|
|
if FDueDateFormat <> Value then begin
|
|
|
|
FDueDateFormat := Value;
|
|
|
|
FTaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskDisplayOptions.SetShowCompleted(Value : Boolean);
|
|
|
|
begin
|
|
|
|
if FShowCompleted <> Value then begin
|
|
|
|
FShowCompleted := Value;
|
|
|
|
FTaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskDisplayOptions.SetShowDueDate(Value: Boolean);
|
|
|
|
begin
|
|
|
|
if FShowDueDate <> Value then begin
|
|
|
|
FShowDueDate := Value;
|
|
|
|
FTaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskDisplayOptions.SetShowAll(Value: Boolean);
|
|
|
|
begin
|
|
|
|
if FShowAll <> Value then begin
|
|
|
|
FShowAll := Value;
|
|
|
|
FTaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
{ TVpTaskHeadAttr }
|
|
|
|
constructor TVpTaskHeadAttr.Create(AOwner: TVpTaskList);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
FTaskList := AOwner;
|
|
|
|
FFont := TVpFont.Create(self);
|
|
|
|
FFont.Assign(FTaskList.Font);
|
|
|
|
FColor := clSilver;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
destructor TVpTaskHeadAttr.Destroy;
|
|
|
|
begin
|
|
|
|
FFont.Free;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskHeadAttr.Invalidate;
|
|
|
|
begin
|
|
|
|
if Assigned(FTaskList) then
|
|
|
|
FTaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskHeadAttr.SetColor(Value: TColor);
|
|
|
|
begin
|
|
|
|
if Value <> FColor then begin
|
|
|
|
FColor := Value;
|
|
|
|
TaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-07-15 11:52:21 +00:00
|
|
|
procedure TVpTaskHeadAttr.SetFont(Value: TVpFont);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if Value <> FFont then begin
|
|
|
|
FFont.Assign(Value);
|
|
|
|
TaskList.Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
|
|
|
|
{ TVpCGInPlaceEdit }
|
|
|
|
|
|
|
|
constructor TVpTLInPlaceEdit.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited Create(AOwner);
|
|
|
|
TabStop := False;
|
|
|
|
BorderStyle := bsNone;
|
|
|
|
{$IFDEF VERSION4}
|
2018-06-04 10:36:57 +00:00
|
|
|
// DoubleBuffered := False;
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
|
|
|
end;
|
|
|
|
{=====}
|
2016-06-10 21:20:06 +00:00
|
|
|
{
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TVpTLInPlaceEdit.Move(const Loc: TRect; Redraw: Boolean);
|
|
|
|
begin
|
|
|
|
CreateHandle;
|
|
|
|
Redraw := Redraw or not IsWindowVisible(Handle);
|
|
|
|
Invalidate;
|
2016-06-10 21:20:06 +00:00
|
|
|
SetBounds(Loc.Left, Loc.Top, Loc.Right-Loc.Left, Loc.Bottom-Loc.Top);
|
2008-02-03 12:05:55 +00:00
|
|
|
if Redraw then Invalidate;
|
|
|
|
SetFocus;
|
2016-06-10 21:20:06 +00:00
|
|
|
end; }
|
2008-02-03 12:05:55 +00:00
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTLInPlaceEdit.CreateParams(var Params: TCreateParams);
|
|
|
|
begin
|
|
|
|
inherited CreateParams(Params);
|
|
|
|
Params.Style := Params.Style{ or ES_MULTILINE};
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTLInPlaceEdit.KeyDown(var Key: Word; Shift: TShiftState);
|
|
|
|
var
|
2016-07-14 16:13:22 +00:00
|
|
|
TaskList: TVpTaskList;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
TaskList := TVpTaskList(Owner);
|
|
|
|
|
|
|
|
case Key of
|
2016-07-14 16:13:22 +00:00
|
|
|
VK_RETURN:
|
|
|
|
begin
|
|
|
|
Key := 0;
|
|
|
|
TaskList.EndEdit(Self);
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
VK_UP:
|
|
|
|
begin
|
|
|
|
Key := 0;
|
|
|
|
TaskList.TaskIndex := TaskList.TaskIndex - 1;
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
VK_DOWN:
|
|
|
|
begin
|
|
|
|
Key := 0;
|
|
|
|
TaskList.TaskIndex := TaskList.TaskIndex + 1;
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
VK_ESCAPE:
|
|
|
|
begin
|
|
|
|
Key := 0;
|
2018-06-09 11:42:09 +00:00
|
|
|
Hide;
|
|
|
|
TaskList.SetFocus;
|
|
|
|
// TaskList.EndEdit(Self);
|
2016-07-14 16:13:22 +00:00
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
(*****************************************************************************)
|
|
|
|
{ TVpTaskList }
|
|
|
|
|
|
|
|
constructor TVpTaskList.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
ControlStyle := [csCaptureMouse, csOpaque, csDoubleClicks];
|
|
|
|
{ Create internal classes and stuff }
|
|
|
|
tlClickTimer := TTimer.Create(self);
|
|
|
|
FTaskHeadAttr := TVpTaskHeadAttr.Create(Self);
|
|
|
|
FDisplayOptions := TVpTaskDisplayOptions.Create(self);
|
|
|
|
tlAllTaskList := TList.Create;
|
|
|
|
|
|
|
|
{ Set styles and initialize internal variables }
|
|
|
|
{$IFDEF VERSION4}
|
2018-06-04 10:36:57 +00:00
|
|
|
// DoubleBuffered := true;
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
2016-07-14 16:13:22 +00:00
|
|
|
tlItemsBefore := 0;
|
|
|
|
tlItemsAfter := 0;
|
|
|
|
tlVisibleItems := 0;
|
|
|
|
tlClickTimer.Enabled := false;
|
|
|
|
FMaxVisibleTasks := 250;
|
2008-02-03 12:05:55 +00:00
|
|
|
tlClickTimer.Interval := ClickDelay;
|
2016-07-14 16:13:22 +00:00
|
|
|
tlClickTimer.OnTimer := tlEditInPlace;
|
|
|
|
tlCreatingEditor := false;
|
|
|
|
FDrawingStyle := ds3d;
|
|
|
|
tlPainting := false;
|
|
|
|
FShowResourceName := true;
|
|
|
|
FColor := clWindow;
|
|
|
|
FLineColor := clGray;
|
|
|
|
FScrollBars := ssVertical;
|
|
|
|
FTaskIndex := -1;
|
|
|
|
FShowIcon := True;
|
|
|
|
FAllowInplaceEdit := true;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
SetLength(tlVisibleTaskArray, MaxVisibleTasks);
|
|
|
|
|
|
|
|
{ size }
|
|
|
|
Height := 225;
|
2016-07-14 16:13:22 +00:00
|
|
|
Width := 169;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
FDefaultPopup := TPopupMenu.Create(Self);
|
2022-06-11 21:24:49 +00:00
|
|
|
FDefaultPopup.OnPopup := PopupDropDownEvent;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
tlHookUp;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
destructor TVpTaskList.Destroy;
|
|
|
|
begin
|
2016-06-10 21:20:06 +00:00
|
|
|
FreeAndNil(tlInplaceEditor);
|
2008-02-03 12:05:55 +00:00
|
|
|
tlClickTimer.Free;
|
|
|
|
FDisplayOptions.Free;
|
|
|
|
tlAllTaskList.Free;
|
|
|
|
FTaskHeadAttr.Free;
|
|
|
|
FDefaultPopup.Free;
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.DeleteActiveTask(Verify: Boolean);
|
|
|
|
var
|
|
|
|
DoIt: Boolean;
|
|
|
|
begin
|
|
|
|
DoIt := not Verify;
|
|
|
|
if FActiveTask <> nil then begin
|
|
|
|
if Verify then
|
2022-06-12 16:12:31 +00:00
|
|
|
DoIt := (MessageDlg(RSConfirmDeleteTask + LineEnding2 + RSPermanent,
|
2016-06-24 21:55:47 +00:00
|
|
|
mtConfirmation, [mbYes, mbNo], 0) = mrYes);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
if DoIt then begin
|
|
|
|
FActiveTask.Deleted := true;
|
2016-07-14 16:13:22 +00:00
|
|
|
if Assigned(DataStore) then
|
|
|
|
if Assigned(DataStore.Resource) then
|
2008-02-03 12:05:55 +00:00
|
|
|
DataStore.Resource.TasksDirty := True;
|
|
|
|
DataStore.PostTasks;
|
|
|
|
DataStore.RefreshTasks;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-06-24 22:34:38 +00:00
|
|
|
procedure TVpTaskList.LoadLanguage;
|
|
|
|
begin
|
|
|
|
FDefaultPopup.Items.Clear;
|
|
|
|
InitializeDefaultPopup;
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TVpTaskList.LinkHandler(Sender: TComponent;
|
|
|
|
NotificationType: TVpNotificationType; const Value: Variant);
|
|
|
|
begin
|
2016-07-12 18:00:32 +00:00
|
|
|
Unused(Value);
|
2008-02-03 12:05:55 +00:00
|
|
|
case NotificationType of
|
2016-07-12 18:00:32 +00:00
|
|
|
neDataStoreChange : Invalidate;
|
|
|
|
neInvalidate : Invalidate;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.tlHookUp;
|
|
|
|
var
|
|
|
|
I: Integer;
|
|
|
|
begin
|
|
|
|
{ If the component is being dropped on a form at designtime, then }
|
|
|
|
{ automatically hook up to the first datastore component found }
|
|
|
|
if csDesigning in ComponentState then
|
|
|
|
for I := 0 to pred(Owner.ComponentCount) do begin
|
|
|
|
if (Owner.Components[I] is TVpCustomDataStore) then begin
|
|
|
|
DataStore := TVpCustomDataStore(Owner.Components[I]);
|
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.Loaded;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
tlLoaded := true;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
function TVpTaskList.GetControlType: TVpItemType;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
Result := itTasks;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.Paint;
|
|
|
|
begin
|
|
|
|
{ paint simply calls RenderToCanvas and passes in the screen canvas. }
|
2016-07-14 16:13:22 +00:00
|
|
|
RenderToCanvas(
|
|
|
|
Canvas, { Screen Canvas}
|
|
|
|
Rect(0, 0, Width, Height), { Clipping Rectangle }
|
|
|
|
ra0, { Rotation Angle }
|
|
|
|
1, { Scale }
|
|
|
|
Now, { Render Date }
|
|
|
|
tlItemsBefore, { Starting Line }
|
|
|
|
-1, { Stop Line }
|
|
|
|
gr30Min, { Granularity - Not used int the task list }
|
|
|
|
False { Display Only - True for a printed version, }
|
|
|
|
); { False for an interactive version }
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure TVpTaskList.PaintToCanvas(ACanvas: TCanvas; ARect: TRect;
|
|
|
|
Angle: TVpRotationAngle);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-07-14 16:13:22 +00:00
|
|
|
RenderToCanvas(ACanvas, ARect, Angle, 1, Now, -1, -1, gr30Min, True);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-06-24 09:22:38 +00:00
|
|
|
procedure TVpTaskList.RenderToCanvas(RenderCanvas: TCanvas; RenderIn: TRect;
|
|
|
|
Angle: TVpRotationAngle; Scale: Extended; RenderDate : TDateTime;
|
|
|
|
StartLine, StopLine: Integer; UseGran: TVpGranularity; DisplayOnly: Boolean);
|
|
|
|
var
|
|
|
|
painter: TVpTaskListPainter;
|
|
|
|
begin
|
|
|
|
tlPainting := true;
|
|
|
|
painter := TVpTaskListPainter.Create(Self, RenderCanvas);
|
|
|
|
try
|
|
|
|
painter.RenderToCanvas(RenderIn, Angle, Scale, RenderDate, StartLine,
|
|
|
|
StopLine, UseGran, DisplayOnly);
|
|
|
|
finally
|
|
|
|
painter.Free;
|
|
|
|
tlPainting := false;
|
|
|
|
end;
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
procedure TVpTaskList.SetColor(const Value: TColor);
|
|
|
|
begin
|
|
|
|
if FColor <> Value then begin
|
|
|
|
FColor := Value;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.tlCalcRowHeight;
|
|
|
|
var
|
|
|
|
SaveFont: TFont;
|
|
|
|
Temp: Integer;
|
|
|
|
begin
|
|
|
|
{ Calculates row height based on the largest of the RowHead's Minute }
|
|
|
|
{ font, the standard client font, and a sample character string. }
|
|
|
|
SaveFont := Canvas.Font;
|
2016-07-15 11:52:21 +00:00
|
|
|
Canvas.Font.Assign(FTaskHeadAttr.Font);
|
2016-07-04 20:30:36 +00:00
|
|
|
tlRowHeight := Canvas.TextHeight(TallShortChars);
|
2008-02-03 12:05:55 +00:00
|
|
|
Canvas.Font.Assign(SaveFont);
|
2016-07-04 20:30:36 +00:00
|
|
|
Temp := Canvas.TextHeight(TallShortChars);
|
2008-02-03 12:05:55 +00:00
|
|
|
if Temp > tlRowHeight then
|
|
|
|
tlRowHeight := Temp;
|
|
|
|
tlRowHeight := tlRowHeight + TextMargin * 2;
|
2016-07-15 11:52:21 +00:00
|
|
|
Canvas.Font.Assign(SaveFont);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.SetDrawingStyle(const Value: TVpDrawingStyle);
|
|
|
|
begin
|
|
|
|
if FDrawingStyle <> Value then begin
|
|
|
|
FDrawingStyle := Value;
|
|
|
|
Repaint;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.SetTaskIndex(Value: Integer);
|
|
|
|
begin
|
2016-06-10 19:59:00 +00:00
|
|
|
if (tlInPlaceEditor <> nil) and tlInplaceEditor.Visible then
|
2008-02-03 12:05:55 +00:00
|
|
|
EndEdit(self);
|
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
if (Value < DataStore.Resource.Tasks.Count) and (FTaskIndex <> Value) then
|
|
|
|
begin
|
2008-02-03 12:05:55 +00:00
|
|
|
FTaskIndex := Value;
|
|
|
|
if FTaskIndex > -1 then
|
|
|
|
FActiveTask := DataStore.Resource.Tasks.GetTask(Value)
|
|
|
|
else
|
|
|
|
FActiveTask := nil;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function TVpTaskList.GetTaskIndex: Integer;
|
|
|
|
begin
|
|
|
|
if FActiveTask = nil then
|
2016-09-05 14:04:22 +00:00
|
|
|
Result := -1
|
2008-02-03 12:05:55 +00:00
|
|
|
else
|
2016-09-05 14:04:22 +00:00
|
|
|
Result := FActiveTask.Owner.IndexOf(FActiveTask);
|
|
|
|
// result := FActiveTask.ItemIndex;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.SetLineColor(Value: TColor);
|
|
|
|
begin
|
|
|
|
if Value <> FLineColor then begin
|
|
|
|
FLineColor := Value;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.SetMaxVisibleTasks(Value: Word);
|
|
|
|
begin
|
|
|
|
if Value <> FMaxVisibleTasks then begin
|
|
|
|
FMaxVisibleTasks := Value;
|
|
|
|
SetLength(tlVisibleTaskArray, FMaxVisibleTasks);
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
{$IFNDEF LCL}
|
|
|
|
procedure TVpTaskList.WMSize(var Msg: TWMSize);
|
|
|
|
{$ELSE}
|
|
|
|
procedure TVpTaskList.WMSize(var Msg: TLMSize);
|
|
|
|
{$ENDIF}
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
{ force a repaint on resize }
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.CreateParams(var Params: TCreateParams);
|
|
|
|
begin
|
|
|
|
inherited CreateParams(Params);
|
|
|
|
with Params do
|
|
|
|
begin
|
|
|
|
Style := Style or WS_TABSTOP;
|
|
|
|
Style := Style or WS_VSCROLL;
|
|
|
|
{$IFNDEF LCL}
|
|
|
|
WindowClass.style := CS_DBLCLKS;
|
|
|
|
{$ENDIF}
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.CreateWnd;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
tlCalcRowHeight;
|
|
|
|
tlSetVScrollPos;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
{$IFNDEF LCL}
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure TVpTaskList.WMLButtonDown(var Msg: TWMLButtonDown);
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ELSE}
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure TVpTaskList.WMLButtonDown(var Msg: TLMLButtonDown);
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
if not Focused then SetFocus;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
if not (csDesigning in ComponentState) then begin
|
|
|
|
{See if the user clicked on a checkbox}
|
|
|
|
tlSetActiveTaskByCoord (Point(Msg.XPos, Msg.YPos));
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
{$IFNDEF LCL}
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure TVpTaskList.WMRButtonDown(var Msg: TWMRButtonDown);
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ELSE}
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure TVpTaskList.WMRButtonDown(var Msg: TLMRButtonDown);
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
|
|
|
var
|
2016-07-14 16:13:22 +00:00
|
|
|
ClientOrigin: TPoint;
|
|
|
|
i: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
if not Assigned (PopupMenu) then begin
|
|
|
|
if not Focused then
|
|
|
|
SetFocus;
|
|
|
|
tlSetActiveTaskByCoord(Point(Msg.XPos, Msg.YPos));
|
|
|
|
tlClickTimer.Enabled := False;
|
|
|
|
ClientOrigin := GetClientOrigin;
|
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
if not Assigned(FActiveTask) then
|
2008-02-03 12:05:55 +00:00
|
|
|
for i := 0 to FDefaultPopup.Items.Count - 1 do begin
|
|
|
|
if (FDefaultPopup.Items[i].Tag = 1) or (ReadOnly) then
|
|
|
|
FDefaultPopup.Items[i].Enabled := False;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
for i := 0 to FDefaultPopup.Items.Count - 1 do
|
|
|
|
FDefaultPopup.Items[i].Enabled := True;
|
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
FDefaultPopup.Popup(Msg.XPos + ClientOrigin.x, Msg.YPos + ClientOrigin.y);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
{$IFNDEF LCL}
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure TVpTaskList.WMLButtonDblClk(var Msg: TWMLButtonDblClk);
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ELSE}
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure TVpTaskList.WMLButtonDblClk(var Msg: TLMLButtonDblClk);
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
tlClickTimer.Enabled := false;
|
|
|
|
{ if the mouse was pressed down in the client area, then select the cell. }
|
|
|
|
if not Focused then
|
|
|
|
SetFocus;
|
|
|
|
{ The mouse click landed inside the client area }
|
2016-07-14 16:13:22 +00:00
|
|
|
tlSetActiveTaskByCoord(Point(Msg.XPos, Msg.YPos));
|
2008-02-03 12:05:55 +00:00
|
|
|
{ Spawn the TaskList editor }
|
|
|
|
if not ReadOnly then
|
2016-07-14 16:13:22 +00:00
|
|
|
tlSpawnTaskEditDialog(FActiveTask = nil);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.InitializeDefaultPopup;
|
|
|
|
var
|
2016-07-14 16:13:22 +00:00
|
|
|
NewItem: TMenuItem;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2022-06-11 21:24:49 +00:00
|
|
|
FDefaultPopup.Items.Clear;
|
|
|
|
|
2018-06-17 20:27:58 +00:00
|
|
|
if RSTaskPopupAdd <> '' then begin // "Add"
|
2016-07-14 16:13:22 +00:00
|
|
|
NewItem := TMenuItem.Create(Self);
|
2008-02-03 12:05:55 +00:00
|
|
|
NewItem.Caption := RSTaskPopupAdd;
|
|
|
|
NewItem.OnClick := PopupAddTask;
|
|
|
|
NewItem.Tag := 0;
|
2016-07-14 16:13:22 +00:00
|
|
|
FDefaultPopup.Items.Add(NewItem);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
2018-06-17 20:27:58 +00:00
|
|
|
if RSPopupAddTaskFromICal <> '' then begin // Import from iCal
|
|
|
|
NewItem := TMenuItem.Create(Self);
|
|
|
|
NewItem.Caption := RSPopupAddTaskFromICal;
|
|
|
|
NewItem.OnClick := PopupAddFromICalFile;
|
|
|
|
NewItem.Tag := 0;
|
|
|
|
FDefaultPopup.Items.Add(NewItem);
|
|
|
|
end;
|
|
|
|
|
|
|
|
if RSTaskPopupEdit <> '' then begin // "Edit"
|
2016-07-14 16:13:22 +00:00
|
|
|
NewItem := TMenuItem.Create(Self);
|
2008-02-03 12:05:55 +00:00
|
|
|
NewItem.Caption := RSTaskPopupEdit;
|
|
|
|
NewItem.OnClick := PopupEditTask;
|
|
|
|
NewItem.Tag := 1;
|
2016-07-14 16:13:22 +00:00
|
|
|
FDefaultPopup.Items.Add(NewItem);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
2018-06-17 20:27:58 +00:00
|
|
|
if RSTaskPopupDelete <> '' then begin // "Delete"
|
2016-07-14 16:13:22 +00:00
|
|
|
NewItem := TMenuItem.Create(Self);
|
2008-02-03 12:05:55 +00:00
|
|
|
NewItem.Caption := RSTaskPopupDelete;
|
|
|
|
NewItem.OnClick := PopupDeleteTask;
|
|
|
|
NewItem.Tag := 1;
|
2016-07-14 16:13:22 +00:00
|
|
|
FDefaultPopup.Items.Add(NewItem);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure TVpTaskList.PopupAddTask(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if ReadOnly then
|
|
|
|
Exit;
|
|
|
|
if not CheckCreateResource then
|
|
|
|
Exit;
|
|
|
|
{ Allow the user to fill in all the new information }
|
|
|
|
Repaint;
|
2016-07-14 16:13:22 +00:00
|
|
|
tlSpawnTaskEditDialog(True);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2018-06-17 20:27:58 +00:00
|
|
|
procedure TVpTaskList.PopupAddFromICalFile(Sender: TObject);
|
|
|
|
var
|
|
|
|
dlg: TOpenDialog;
|
|
|
|
ical: TVpICalendar;
|
|
|
|
fn: String;
|
|
|
|
i: Integer;
|
|
|
|
id: Integer;
|
|
|
|
begin
|
2018-06-18 20:01:53 +00:00
|
|
|
if ReadOnly or (not CheckCreateResource) or
|
|
|
|
(not Assigned(DataStore)) or (not Assigned(DataStore.Resource))
|
|
|
|
then
|
|
|
|
Exit;
|
2018-06-17 20:27:58 +00:00
|
|
|
|
|
|
|
dlg := TOpenDialog.Create(nil);
|
|
|
|
try
|
|
|
|
dlg.Title := RSLoadICalTitle;
|
|
|
|
dlg.Filter := RSICalFilter;
|
|
|
|
dlg.FileName := '';
|
|
|
|
dlg.Options := dlg.Options + [ofAllowMultiSelect, ofFileMustExist];
|
|
|
|
if dlg.Execute then begin
|
|
|
|
Screen.Cursor := crHourGlass;
|
|
|
|
Application.ProcessMessages;
|
|
|
|
ical := TVpICalendar.Create;
|
|
|
|
try
|
|
|
|
for fn in dlg.Files do begin
|
|
|
|
ical.LoadFromFile(fn);
|
|
|
|
for i := 0 to ical.Count-1 do begin
|
|
|
|
if not (ical[i] is TVpICalToDo) then
|
|
|
|
Continue;
|
|
|
|
id := DataStore.GetNextID(EventsTableName);
|
|
|
|
FActiveTask := Datastore.Resource.Tasks.AddTask(id);
|
|
|
|
FActiveTask.LoadFromICalendar(TVpICalToDo(ical[i]));
|
|
|
|
Datastore.PostTasks;
|
|
|
|
Datastore.NotifyDependents;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
Invalidate;
|
|
|
|
finally
|
|
|
|
ical.Free;
|
|
|
|
Screen.Cursor := crDefault;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
dlg.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure TVpTaskList.PopupDeleteTask(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if ReadOnly then
|
|
|
|
Exit;
|
|
|
|
if FActiveTask <> nil then begin
|
|
|
|
Repaint;
|
2016-06-24 21:55:47 +00:00
|
|
|
DeleteActiveTask(True);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
2022-06-11 21:24:49 +00:00
|
|
|
|
|
|
|
procedure TVpTaskList.PopupDropdownEvent(Sender: TObject);
|
|
|
|
begin
|
|
|
|
InitializeDefaultPopup;
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure TVpTaskList.PopupEditTask(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if ReadOnly then
|
|
|
|
Exit;
|
|
|
|
if FActiveTask <> nil then begin
|
|
|
|
Repaint;
|
|
|
|
{ edit this Task }
|
2016-06-24 21:55:47 +00:00
|
|
|
tlSpawnTaskEditDialog(False);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2018-05-17 16:35:44 +00:00
|
|
|
procedure TVpTaskList.tlSpawnTaskEditDialog(IsNewTask: Boolean);
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-07-14 16:13:22 +00:00
|
|
|
AllowIt: Boolean;
|
|
|
|
Task: TVpTask;
|
|
|
|
TaskDlg: TVpTaskEditDialog;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
tlClickTimer.Enabled := false;
|
|
|
|
if not CheckCreateResource then
|
|
|
|
Exit;
|
|
|
|
if (DataStore = nil) or (DataStore.Resource = nil) then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
AllowIt := false;
|
2018-05-17 16:35:44 +00:00
|
|
|
if IsNewTask then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
Task := DataStore.Resource.Tasks.AddTask(DataStore.GetNextID('Tasks'));
|
|
|
|
Task.CreatedOn := now;
|
|
|
|
Task.DueDate := Now + 7;
|
|
|
|
end else
|
|
|
|
Task := FActiveTask;
|
|
|
|
|
|
|
|
if Assigned(FOwnerEditTask) then
|
2018-05-17 16:35:44 +00:00
|
|
|
FOwnerEditTask(self, Task, IsNewTask, DataStore.Resource, AllowIt)
|
2008-02-03 12:05:55 +00:00
|
|
|
else begin
|
|
|
|
TaskDlg := TVpTaskEditDialog.Create(nil);
|
|
|
|
try
|
|
|
|
TaskDlg.Options := TaskDlg.Options + [doSizeable];
|
|
|
|
TaskDlg.DataStore := DataStore;
|
|
|
|
AllowIt := TaskDlg.Execute(Task);
|
|
|
|
finally
|
|
|
|
TaskDlg.Free;
|
|
|
|
end;
|
|
|
|
end;
|
2016-06-28 14:03:35 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
if AllowIt then begin
|
|
|
|
DataStore.PostTasks();
|
2016-06-18 19:45:43 +00:00
|
|
|
DataStore.NotifyDependents;
|
2008-02-03 12:05:55 +00:00
|
|
|
end else begin
|
2018-05-17 16:35:44 +00:00
|
|
|
if IsNewTask then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
DataStore.Resource.Tasks.DeleteTask(Task);
|
|
|
|
end;
|
|
|
|
DataStore.PostTasks;
|
|
|
|
end;
|
2018-05-17 16:35:44 +00:00
|
|
|
Invalidate;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
{$IFNDEF LCL}
|
|
|
|
procedure TVpTaskList.CMWantSpecialKey(var Msg: TCMWantSpecialKey);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
Msg.Result := 1;
|
|
|
|
end;
|
|
|
|
{$ENDIF}
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.tlEditInPlace(Sender: TObject);
|
|
|
|
begin
|
|
|
|
{ this is the timer Task which spawns an in-place editor }
|
|
|
|
{ if the task is doublecliked before this timer fires, then the }
|
|
|
|
{ task is edited in a dialog based editor. }
|
|
|
|
tlClickTimer.Enabled := false;
|
|
|
|
EditTask;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.EditTask;
|
|
|
|
var
|
2016-07-14 16:13:22 +00:00
|
|
|
AllowIt: Boolean;
|
|
|
|
R: TRect;
|
|
|
|
VisTask: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
{don't allow a user to edit a completed task in place.}
|
|
|
|
if FActiveTask.Complete then
|
|
|
|
Exit;
|
|
|
|
|
2016-06-23 23:16:34 +00:00
|
|
|
if not FAllowInplaceEdit then
|
|
|
|
exit;
|
|
|
|
|
2016-06-24 09:50:05 +00:00
|
|
|
if Assigned(tlInplaceEditor) and tlInplaceEditor.Visible then
|
|
|
|
exit;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
AllowIt := true;
|
|
|
|
|
2016-06-24 09:50:05 +00:00
|
|
|
VisTask := tlTaskIndexToVisibleTask(TaskIndex);
|
2008-02-03 12:05:55 +00:00
|
|
|
if VisTask < 0 then
|
2016-06-24 09:50:05 +00:00
|
|
|
Exit;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
{ call the user defined BeforeEdit task }
|
|
|
|
if Assigned(FBeforeEdit) then
|
|
|
|
FBeforeEdit(Self, FActiveTask, AllowIt);
|
|
|
|
|
|
|
|
if AllowIt then begin
|
|
|
|
{ build the editor's rectangle }
|
|
|
|
R := tlVisibleTaskArray[VisTask].LineRect;
|
|
|
|
R.Top := R.Top + TextMargin;
|
|
|
|
R.Left := R.Left + TextMargin - 1;
|
|
|
|
{ create and spawn the in-place editor }
|
2016-06-10 19:59:00 +00:00
|
|
|
if tlInplaceEditor = nil then begin
|
|
|
|
tlInPlaceEditor := TVpTLInPlaceEdit.Create(Self);
|
|
|
|
tlInPlaceEditor.Parent := self;
|
|
|
|
tlInPlaceEditor.OnExit := EndEdit;
|
|
|
|
end;
|
2016-06-24 09:50:05 +00:00
|
|
|
tlInPlaceEditor.Font.Assign(Font);
|
2016-06-23 23:16:34 +00:00
|
|
|
tlInPlaceEditor.SetBounds(R.Left, R.Top, WidthOf(R), HeightOf(R));
|
2008-02-03 12:05:55 +00:00
|
|
|
tlInPlaceEditor.Text := FActiveTask.Description;
|
2016-06-24 09:50:05 +00:00
|
|
|
tlInplaceEditor.Show;
|
|
|
|
tlInplaceEditor.SetFocus;
|
2008-02-03 12:05:55 +00:00
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.EndEdit(Sender: TObject);
|
|
|
|
begin
|
2016-06-10 19:59:00 +00:00
|
|
|
if (tlInPlaceEditor <> nil) and tlInplaceEditor.Visible then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
if tlInPlaceEditor.Text <> FActiveTask.Description then begin
|
|
|
|
FActiveTask.Description := tlInPlaceEditor.Text;
|
|
|
|
FActiveTask.Changed := true;
|
|
|
|
DataStore.Resource.TasksDirty := true;
|
|
|
|
DataStore.PostTasks;
|
|
|
|
if Assigned(FAfterEdit) then
|
|
|
|
FAfterEdit(self, FActiveTask);
|
|
|
|
end;
|
2016-06-10 19:59:00 +00:00
|
|
|
tlInPlaceEditor.Hide;
|
2008-02-03 12:05:55 +00:00
|
|
|
SetFocus;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.KeyDown(var Key: Word; Shift: TShiftState);
|
|
|
|
var
|
2016-07-14 16:13:22 +00:00
|
|
|
PopupPoint: TPoint;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
case Key of
|
2016-07-14 16:13:22 +00:00
|
|
|
VK_UP:
|
2008-02-03 12:05:55 +00:00
|
|
|
if TaskIndex > 0 then
|
|
|
|
TaskIndex := TaskIndex - 1
|
|
|
|
else
|
|
|
|
TaskIndex := Pred(DataStore.Resource.Tasks.Count);
|
2016-07-14 16:13:22 +00:00
|
|
|
VK_DOWN:
|
2008-02-03 12:05:55 +00:00
|
|
|
if TaskIndex < Pred(DataStore.Resource.Tasks.Count) then
|
|
|
|
TaskIndex := TaskIndex + 1
|
|
|
|
else
|
|
|
|
TaskIndex := 0;
|
2016-07-14 16:13:22 +00:00
|
|
|
VK_NEXT:
|
|
|
|
if TaskIndex < Pred(DataStore.Resource.Tasks.Count) - tlVisibleItems then
|
2008-02-03 12:05:55 +00:00
|
|
|
TaskIndex := TaskIndex + tlVisibleItems
|
|
|
|
else
|
|
|
|
TaskIndex := Pred(DataStore.Resource.Tasks.Count);
|
2016-07-14 16:13:22 +00:00
|
|
|
VK_PRIOR :
|
2008-02-03 12:05:55 +00:00
|
|
|
if TaskIndex > tlVisibleItems then
|
|
|
|
TaskIndex := TaskIndex - tlVisibleItems
|
|
|
|
else
|
|
|
|
TaskIndex := 0;
|
2016-07-14 16:13:22 +00:00
|
|
|
VK_HOME:
|
|
|
|
TaskIndex := 0;
|
|
|
|
VK_END:
|
|
|
|
TaskIndex := Pred(DataStore.Resource.Tasks.Count);
|
|
|
|
VK_DELETE:
|
|
|
|
DeleteActiveTask(true);
|
|
|
|
VK_RETURN:
|
|
|
|
tlSpawnTaskEditDialog (False);
|
|
|
|
VK_INSERT:
|
|
|
|
tlSpawnTaskEditDialog (True);
|
|
|
|
VK_F2:
|
|
|
|
if Assigned(DataStore) then begin
|
|
|
|
if Assigned(DataStore.Resource) then
|
|
|
|
tlEditInPlace(Self);
|
|
|
|
end;
|
|
|
|
VK_SPACE:
|
|
|
|
if Assigned(FActiveTask) then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
FActiveTask.Complete := not FActiveTask.Complete;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
{$IFNDEF LCL}
|
2016-07-14 16:13:22 +00:00
|
|
|
VK_TAB:
|
2008-02-03 12:05:55 +00:00
|
|
|
if ssShift in Shift then
|
2016-07-14 16:13:22 +00:00
|
|
|
Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, False))
|
2008-02-03 12:05:55 +00:00
|
|
|
else
|
2016-07-14 16:13:22 +00:00
|
|
|
Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, True));
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
2016-07-14 16:13:22 +00:00
|
|
|
VK_F10:
|
|
|
|
if (ssShift in Shift) and not (Assigned(PopupMenu)) then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
PopupPoint := GetClientOrigin;
|
2016-07-14 16:13:22 +00:00
|
|
|
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2016-07-14 16:13:22 +00:00
|
|
|
VK_APPS:
|
|
|
|
if not Assigned(PopupMenu) then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
PopupPoint := GetClientOrigin;
|
2016-07-14 16:13:22 +00:00
|
|
|
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if TaskIndex < tlItemsBefore then
|
|
|
|
tlItemsBefore := TaskIndex;
|
|
|
|
if TaskIndex >= tlItemsBefore + tlVisibleItems then
|
|
|
|
tlItemsBefore := TaskIndex - tlVisibleItems + 1;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
{$IFNDEF LCL}
|
|
|
|
procedure TVpTaskList.WMVScroll(var Msg: TWMVScroll);
|
|
|
|
{$ELSE}
|
|
|
|
procedure TVpTaskList.WMVScroll(var Msg: TLMVScroll);
|
|
|
|
{$ENDIF}
|
|
|
|
begin
|
|
|
|
{ for simplicity, bail out of editing while scrolling. }
|
|
|
|
EndEdit(Self);
|
2016-06-10 19:59:00 +00:00
|
|
|
if (tlInPlaceEditor <> nil) and tlInplaceEditor.Visible then Exit;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
case Msg.ScrollCode of
|
2016-07-14 16:13:22 +00:00
|
|
|
SB_LINEUP:
|
2008-02-03 12:05:55 +00:00
|
|
|
if tlItemsBefore > 0 then
|
|
|
|
tlItemsBefore := tlItemsBefore - 1;
|
2016-07-14 16:13:22 +00:00
|
|
|
SB_LINEDOWN:
|
2008-02-03 12:05:55 +00:00
|
|
|
if tlItemsAfter > 0 then
|
|
|
|
tlItemsBefore := tlItemsBefore + 1;
|
2016-07-14 16:13:22 +00:00
|
|
|
SB_PAGEUP:
|
2008-02-03 12:05:55 +00:00
|
|
|
if tlItemsBefore >= tlVisibleItems then
|
|
|
|
tlItemsBefore := tlItemsBefore - tlVisibleItems
|
|
|
|
else
|
|
|
|
tlItemsBefore := 0;
|
2016-07-14 16:13:22 +00:00
|
|
|
SB_PAGEDOWN:
|
2008-02-03 12:05:55 +00:00
|
|
|
if tlItemsAfter >= tlVisibleItems then
|
|
|
|
tlItemsBefore := tlItemsBefore + tlVisibleItems
|
|
|
|
else
|
|
|
|
tlItemsBefore := tlAllTaskList.Count - tlVisibleItems;
|
2016-07-14 16:13:22 +00:00
|
|
|
SB_THUMBPOSITION, SB_THUMBTRACK:
|
|
|
|
tlItemsBefore := Msg.Pos;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.tlSetVScrollPos;
|
|
|
|
var
|
2016-07-14 16:13:22 +00:00
|
|
|
SI: TScrollInfo;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-07-14 16:13:22 +00:00
|
|
|
if (not HandleAllocated) or (DataStore = nil) or (DataStore.Resource = nil)
|
|
|
|
or (csDesigning in ComponentState) then Exit;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
with SI do begin
|
|
|
|
cbSize := SizeOf(SI);
|
|
|
|
fMask := SIF_RANGE or SIF_PAGE or SIF_POS;
|
|
|
|
nMin := 1;
|
|
|
|
nMax := tlAllTaskList.Count;
|
|
|
|
nPage := tlVisibleItems;
|
|
|
|
if tlItemsAfter = 0 then
|
|
|
|
nPos := tlAllTaskList.Count
|
|
|
|
else
|
|
|
|
nPos := tlItemsBefore;
|
|
|
|
nTrackPos := nPos;
|
|
|
|
end;
|
|
|
|
SetScrollInfo(Handle, SB_VERT, SI, True);
|
|
|
|
end;
|
|
|
|
{=====}
|
2016-07-14 16:13:22 +00:00
|
|
|
procedure TVpTaskList.SetShowIcon(const v: Boolean);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if v <> FShowIcon then begin
|
|
|
|
FShowIcon := v;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.SetShowResourceName(Value: Boolean);
|
|
|
|
begin
|
|
|
|
if Value <> FShowResourceName then begin
|
|
|
|
FShowResourceName := Value;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TVpTaskList.tlSetActiveTaskByCoord(Pnt: TPoint);
|
|
|
|
var
|
|
|
|
I: integer;
|
|
|
|
begin
|
|
|
|
if (DataStore = nil) or (DataStore.Resource = nil) then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
if not ReadOnly and tlClickTimer.Enabled then
|
|
|
|
tlClickTimer.Enabled := false;
|
|
|
|
|
|
|
|
TaskIndex := -1;
|
|
|
|
|
|
|
|
for I := 0 to pred(Length(tlVisibleTaskArray)) do begin
|
|
|
|
{ we've hit the end of active tasks, so bail }
|
|
|
|
if tlVisibleTaskArray[I].Task = nil then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
{ if the point is in an active task's check box... }
|
|
|
|
|
|
|
|
if PointInRect(Pnt, tlVisibleTaskArray[I].CheckRect) then begin
|
|
|
|
{ set the active task index }
|
|
|
|
TaskIndex := tlVisibleTaskToTaskIndex (I);
|
|
|
|
if not ReadOnly then begin
|
|
|
|
{ toggle the complete flag. }
|
|
|
|
FActiveTask.Complete := not FActiveTask.Complete;
|
|
|
|
FActiveTask.Changed := true;
|
|
|
|
DataStore.Resource.TasksDirty := true;
|
|
|
|
DataStore.PostTasks;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ if the point is in an active task..}
|
|
|
|
if PointInRect(Pnt, tlVisibleTaskArray[I].LineRect) then begin
|
|
|
|
{ Set ActiveTask to the selected one }
|
|
|
|
TaskIndex := tlVisibleTaskToTaskIndex (I);
|
|
|
|
if not ReadOnly then
|
|
|
|
tlClickTimer.Enabled := true;
|
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
function TVpTaskList.tlVisibleTaskToTaskIndex(const VisTaskIndex: Integer): Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-07-14 16:13:22 +00:00
|
|
|
RealTask: TVpTask;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
Result := -1;
|
2016-07-14 16:13:22 +00:00
|
|
|
if (VisTaskIndex < 0) or (VisTaskIndex >= Length(tlVisibleTaskArray)) then
|
2008-02-03 12:05:55 +00:00
|
|
|
Exit;
|
2016-07-14 16:13:22 +00:00
|
|
|
RealTask := TVpTask(tlVisibleTaskArray[VisTaskIndex].Task);
|
2008-02-03 12:05:55 +00:00
|
|
|
Result := RealTask.ItemIndex;
|
|
|
|
end;
|
|
|
|
|
2016-07-14 16:13:22 +00:00
|
|
|
function TVpTaskList.tlTaskIndexToVisibleTask(const ATaskIndex: Integer): Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-07-14 16:13:22 +00:00
|
|
|
i: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
Result := -1;
|
2016-07-14 16:13:22 +00:00
|
|
|
for i := 0 to Length(tlVisibleTaskArray) - 1 do
|
|
|
|
if ATaskIndex = TVpTask(tlVisibleTaskArray[i].Task).ItemIndex then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
Result := i;
|
|
|
|
Break;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-01-12 11:07:34 +00:00
|
|
|
{$IF VP_LCL_SCALING = 2}
|
|
|
|
procedure TVpTaskList.ScaleFontsPPI(const AToPPI: Integer;
|
|
|
|
const AProportion: Double);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
DoScaleFontPPI(TaskHeadAttributes.Font, AToPPI, AProportion);
|
|
|
|
end;
|
|
|
|
{$ELSEIF VP_LCL_SCALING = 1}
|
2017-05-22 08:11:27 +00:00
|
|
|
procedure TVpTaskList.ScaleFontsPPI(const AProportion: Double);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
DoScaleFontPPI(TaskHeadAttributes.Font, AProportion);
|
|
|
|
end;
|
|
|
|
{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
end.
|
|
|
|
|