📄 jvtfdays.pas
字号:
{-----------------------------------------------------------------------------
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/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvTFDays.PAS, released on 2003-08-01.
The Initial Developer of the Original Code is Unlimited Intelligence Limited.
Portions created by Unlimited Intelligence Limited are Copyright (C) 1999-2002 Unlimited Intelligence Limited.
All Rights Reserved.
Contributor(s):
Mike Kolter (original code)
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
This version of the source contains modifications which enable the use
of time blocks. These modifications can be found by doing a search for
"DEF Jv_TIMEBLOCKS". Previously, two versions were released; one which did
NOT support timeblocks and one which did support timeblocks. (Hence the
use of the compiler defines.)
These two versions are in the process of being integrated. The compiler
defines remain as an indicator of exactly what has been changed. All
lines that are NOT compiled ($IFNDEF Jv_TIMEBLOCKS and $ELSE) remain
as a reference during the transition, but have been commented out to
reduce confusion. Many of these lines are marked by a "// remove" comment.
The conditional defines and disabled code will be removed and this file
will be cleaned up after the time block code has been fully integrated
and tested.
Changes to JvTFDays by deanh:
============================
These changes peform the following functions.
1) The addition of a new time entry is aborted if the user presses escape.
2) New property for FancyHeader to only show the '00' minutes. This emulates outlook's behaviour.
3) Few changes to clean up the dithering of the background.
4) Hide the blank area that sometimes appears at the bottom of the Calendar when scrolling right down to the bottom.
5) Remove the focus rectangle when ShowFocus is false (the focus rect is not shown in Outlook).
-----------------------------------------------------------------------------}
// $Id: JvTFDays.pas,v 1.45 2005/02/17 10:20:54 marquardt Exp $
unit JvTFDays;
{$I jvcl.inc}
interface
uses
{$IFDEF USEJVCL}
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
{$ENDIF USEJVCL}
SysUtils, Classes,
{$IFDEF VCL}
Windows, Messages, Graphics, Controls, Forms, Dialogs,
StdCtrls, ImgList,
{$ENDIF VCL}
{$IFDEF VisualCLX}
QGraphics, QControls, QForms, QDialogs,
QStdCtrls, QImgList, QWindows, Types,
{$ENDIF VisualCLX}
JvTFManager, JvTFSparseMatrix, JvTFUtils;
// (ahuser) do not convert to JvExVCL. This package is USEJVCL'ed
const
AbsMinColWidth = 5;
SizingThreshold = 5;
gcUndef = -3;
gcGroupHdr = -2;
gcHdr = -1;
type
EJvTFDaysError = class(Exception);
{$IFDEF Jv_TIMEBLOCKS}
// remove TTFDayOfWeek and TTFDaysOfWeek, they are found in JvTFUtils
//TTFDayOfWeek = (dowSunday, dowMonday, dowTuesday, dowWednesday,
// dowThursday, dowFriday, dowSaturday);
//TTFDaysOfWeek = set of TTFDayOfWeek;
EJvTFBlockGranError = class(EJvTFDaysError);
{$ENDIF Jv_TIMEBLOCKS}
// Forward declarations
TJvTFDays = class;
TJvTFDaysCols = class;
TJvTFDaysCol = class;
TJvTFDaysPrinter = class;
TJvTFDaysTemplate = class;
TJvTFDaysHdrAttr = class;
{$IFDEF Jv_TIMEBLOCKS}
// okay to leave
TJvTFDaysTimeBlocks = class;
TJvTFDaysTimeBlock = class;
{$ENDIF Jv_TIMEBLOCKS}
TJvTFDaysCoord = record
Col: Integer;
Row: Integer;
CellX: Integer;
CellY: Integer;
AbsX: Integer;
AbsY: Integer;
Schedule: TJvTFSched;
Appt: TJvTFAppt;
DragAccept: Boolean;
end;
TJvTFDrawPicInfo = class(TObject)
public
ImageList: TCustomImageList;
ImageIndex: Integer;
PicLeft: Integer;
PicTop: Integer;
end;
TJvTFDaysTemplates = (agtNone, agtLinear, agtComparative);
TJvTFListMoveEvent = procedure(Sender: TObject; CurIndex, NewIndex: Integer) of object;
TJvTFCompNamesList = class(TStringList)
private
FOnMove: TJvTFListMoveEvent;
public
procedure Move(CurIndex, NewIndex: Integer); override;
property OnMove: TJvTFListMoveEvent read FOnMove write FOnMove;
end;
TJvTFDaysTemplate = class(TPersistent)
private
FActiveTemplate: TJvTFDaysTemplates;
FCompDate: TDate;
FCompNames: TJvTFCompNamesList;
FLinearDayCount: Integer;
FLinearEndDate: TDate;
FLinearName: string;
FLinearStartDate: TDate;
FShortTitles: Boolean;
FUpdatingGrid: Boolean;
// Property Access Methods
function GetCompNames: TStrings;
procedure SetActiveTemplate(Value: TJvTFDaysTemplates);
procedure SetCompDate(Value: TDate);
procedure SetCompNames(Value: TStrings);
procedure SetLinearDayCount(Value: Integer);
procedure SetLinearEndDate(Value: TDate);
procedure SetLinearName(const Value: string);
procedure SetLinearStartDate(Value: TDate);
procedure SetShortTitles(Value: Boolean);
protected
FCompNamesChanged: Boolean;
FGrid: TJvTFDays;
FUpdatingCompNames: Boolean;
FIgnoreNav: Boolean;
procedure DoDateChangedEvent;
procedure DoDateChangingEvent(var NewDate: TDate);
procedure CompNamesChanged(Sender: TObject); virtual;
procedure CompNamesMoved(Sender: TObject; CurIndex, NewIndex: Integer); virtual;
procedure LinearDaysChanged; virtual;
procedure BeginGridUpdate;
procedure EndGridUpdate;
public
constructor Create(AApptGrid: TJvTFDays);
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure BeginCompNamesUpdate;
procedure EndCompNamesUpdate;
procedure UpdateGrid;
property UpdatingGrid: Boolean read FUpdatingGrid;
property ApptGrid: TJvTFDays read FGrid;
published
property ActiveTemplate: TJvTFDaysTemplates read FActiveTemplate
write SetActiveTemplate default agtNone;
property CompDate: TDate read FCompDate write SetCompDate;
property CompNames: TStrings read GetCompNames write SetCompNames;
property IgnoreNav: Boolean read FIgnoreNav write FIgnoreNav default False;
property LinearDayCount: Integer read FLinearDayCount write SetLinearDayCount;
property LinearEndDate: TDate read FLinearEndDate write SetLinearEndDate;
property LinearName: string read FLinearName write SetLinearName;
property LinearStartDate: TDate read FLinearStartDate write SetLinearStartDate;
property ShortTitles: Boolean read FShortTitles write SetShortTitles default True;
end;
TJvTFDaysPrimeTime = class(TPersistent)
private
FStartTime: TTime;
FEndTime: TTime;
FColor: TColor;
procedure SetStartTime(Value: TTime);
procedure SetEndTime(Value: TTime);
procedure SetColor(Value: TColor);
protected
FApptGrid: TJvTFDays;
FFillPic: TBitmap;
procedure Change;
procedure UpdateFillPic;
public
constructor Create(AApptGrid: TJvTFDays);
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
published
property StartTime: TTime read FStartTime write SetStartTime;
property EndTime: TTime read FEndTime write SetEndTime;
property Color: TColor read FColor write SetColor;
end;
TJvTFCreateQuickEntryEvent = procedure(Sender: TObject; var ApptID: string;
var StartDate: TDate; var StartTime: TTime; var EndDate: TDate;
var EndTime: TTime; var Confirm: Boolean) of object;
TJvTFDropApptEvent = procedure(Appt: TJvTFAppt; SchedName: string;
NewStartDate: TDate; NewStartTime: TTime; NewEndDate: TDate;
NewEndTime: TTime; Share: Boolean; var Confirm: Boolean) of object;
TJvTFDragRowColEvent = procedure(Sender: TObject; Index: Integer;
var NewInfo: Integer; var Confirm: Boolean) of object;
TJvTFSizeApptEvent = procedure(Sender: TObject; Appt: TJvTFAppt;
var NewEndDT: TDateTime; var Confirm: Boolean) of object;
TJvTFSelecTJvTFApptEvent = procedure(Sender: TObject; OldSel, NewSel: TJvTFAppt) of object;
TJvTFDrawApptEvent = procedure(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Appt: TJvTFAppt; Selected: Boolean) of object;
TJvTFDrawGrabHandleEvent = procedure(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; Appt: TJvTFAppt; TopHandle: Boolean) of object;
TJvTFDrawDataCellEvent = procedure(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Col, Row: Integer) of object;
TJvTFDaysCorner = (agcTopLeft, agcTopRight, agcBottomLeft, agcBottomRight);
TJvTFDrawCornerEvent = procedure(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Corner: TJvTFDaysCorner) of object;
TJvTFDrawHdrEvent = procedure(Sender: TObject; ACanvas: TCanvas; ARect: TRect;
Index: Integer; Selected: Boolean) of object;
TJvTFDrawApptBarEvent = procedure(Sender: TObject; ACanvas: TCanvas;
Appt: TJvTFAppt; Col: Integer; BarRect, TimeStampRect: TRect) of object;
TJvTFFailEditorEvent = procedure(Sender: TObject; Col: Integer; Appt: TJvTFAppt;
var EditorBounds: TRect; var Fail: Boolean) of object;
TJvTFDateChangingEvent = procedure(Sender: TObject; var NewDate: TDate) of object;
TJvTFGranChangingEvent = procedure(Sender: TObject; var NewGran: Integer) of object;
TJvTFShadeCellEvent = procedure(Sender: TObject; ColIndex, RowIndex: Integer;
var CellColor: TColor) of object;
TJvTFBeginEditEvent = procedure(Sender: TObject; Appt: TJvTFAppt;
var AllowEdit: Boolean) of object;
TJvTFInPlaceApptEditor = class(TMemo)
private
FLinkedAppt: TJvTFAppt;
FQuickCreate: Boolean;
protected
FCancelEdit: Boolean;
procedure DoExit; override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
public
constructor Create(AOwner: TComponent); override;
property LinkedAppt: TJvTFAppt read FLinkedAppt write FLinkedAppt;
property QuickCreate: Boolean read FQuickCreate write FQuickCreate;
end;
TJvTFApptMap = class(TObject)
private
FData: TJvTFSparseMatrix;
function GetLocation(Row, Col: Integer): TJvTFAppt;
protected
FGridCol: TJvTFDaysCol;
procedure Add(Appt: TJvTFAppt);
procedure ProcessMapGroup(GroupStart, GroupEnd: Integer);
procedure UpdateMapGroups;
public
constructor Create(AGridCol: TJvTFDaysCol); virtual;
destructor Destroy; override;
procedure Clear;
function ColCount(Row: Integer): Integer;
procedure GetAppts(StartRow, EndRow: Integer; ApptList: TStringList);
function LocateMapCol(Appt: TJvTFAppt; MapSearchRow: Integer): Integer;
property Location[Row, Col: Integer]: TJvTFAppt read GetLocation;
procedure Refresh;
function HasAppt(Appt: TJvTFAppt): Boolean;
procedure Dump(AName: TFileName); // used for debugging only
end;
TJvTFDaysOption = (agoSizeCols, agoSizeRows, agoSizeColHdr, agoSizeRowHdr,
agoMoveCols, agoSizeAppt, agoMoveAppt, agoSnapMove,
agoSnapSize, agoEditing, agoShowPics, agoShowText,
agoShowApptHints, agoShowColHdrHints, agoShowSelHint,
agoEnforceMaxColWidth, agoQuickEntry, agoFormattedDesc);
TJvTFDaysOptions = set of TJvTFDaysOption;
TJvTFDaysState = (agsNormal, agsSizeCol, agsSizeRow, agsSizeColHdr,
agsSizeRowHdr, agsMoveCol, agsSizeAppt, agsMoveAppt);
{$IFDEF Jv_TIMEBLOCKS}
// ok
TJvTFColTitleStyle = (ctsSingleClip, ctsSingleEllipsis, ctsMultiClip,
ctsMultiEllipsis, ctsHide, ctsRotated);
{$ELSE}
// remove
//TJvTFColTitleStyle = (ctsSingleClip, ctsSingleEllipsis, ctsMultiClip,
// ctsMultiEllipsis, ctsHide);
{$ENDIF Jv_TIMEBLOCKS}
TJvTFDaysThresholds = class(TPersistent)
private
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -