2008-02-03 12:05:55 +00:00
{*********************************************************}
{* VPDAYVIEW.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 ***** *}
{
This unit contains everything needed for the TVpDayView component ( including
the inline editor) .
The rendering of Visual PlanIt components is a bit involved. The component' s
Paint method calls RenderToCanvas. The RenderToCanvas method of each of
the visual VisualPlanIt controls is repsonsible both for drawing to the
screen ( both design and run time) as well as printing. In the case of
printing, the component needs to render itself to an arbitrary rectangle
and possibly rotated ( for the screen the rectangle is the ClientRect
and the rotation angle is always zero) . To achieve that goal, the
functions in VpCanvasUtils are used to go between the rendering of the
control and the TCanvas that it needs to render to .
The rendering of the DayView is complex. Look at the other components
( MonthView and TaskList are probably the best places to start) before making
changes to the DayView rendering.
The in place editor is currently based off the TCustomEdit class . This can
probably be changed to use a TCustomMemo as its base class . This will
provide multi- line editing capabilities.
}
2016-06-22 07:59:17 +00:00
{$I vp.inc}
2008-02-03 12:05:55 +00:00
{.$DEFINE DEBUGDV} { Causes the DayView to operate in debug mode }
unit VpDayView;
interface
uses
{$IFDEF LCL}
2016-06-19 22:41:36 +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}
2018-05-18 09:47:36 +00:00
Classes, Graphics, Controls, ExtCtrls, StdCtrls, Buttons, Forms, Menus, ImgList,
2017-05-22 08:11:27 +00:00
VpConst, VpBase, VpBaseDS, VpMisc, VpData, VpSR, VpCanvasUtils;
2008-02-03 12:05:55 +00:00
type
TVpLineRec = packed record
2016-06-19 23:40:28 +00:00
Hour: TVpHours;
Minute: Integer ;
Time: TDateTime;
Rec: TRect;
2008-02-03 12:05:55 +00:00
end ;
TVpColRec = packed record
2016-06-19 23:40:28 +00:00
Rec: TRect;
Date: TDateTime;
2008-02-03 12:05:55 +00:00
end ;
type
TVpLineArray = array of TVpLineRec;
type
TVpLineMatrix = array of TVpLineArray;
TVpColRectArray = array of TVpColRec;
TVpDVIconData = record
2016-06-19 23:40:28 +00:00
Show: Boolean ;
Bitmap: TBitmap;
end ;
TVpDVIconTypes = ( itAlarm, itRecurring, itCategory, itCustom) ;
TVpDVIcons = array [ itAlarm.. itCustom] of TVpDVIconData;
TVpOnDVBeforeDrawEvent = procedure ( Sender: TObject; Event: TVpEvent;
2018-05-17 07:58:22 +00:00
AActive: Boolean ; ACanvas: TCanvas; AGutterRect, AEventRect, AIconRect: TRect) of object ;
2016-06-19 23:40:28 +00:00
TVpOnDVAfterDrawEvent = procedure ( Sender: TObject; Event: TVpEvent;
2018-05-17 07:58:22 +00:00
AActive: Boolean ; ACanvas: TCanvas; AGutterRect, AEventRect, AIconRect: TRect) of object ;
2016-06-19 23:40:28 +00:00
TVpOnDVDrawIcons = procedure ( Sender: TObject; Event: TVpEvent;
var Icons: TVpDVIcons) of object ;
TVpDVWrapStyle = ( wsNone, wsIconFlow, wsNoFlow) ;
2008-02-03 12:05:55 +00:00
{ Forward Declarations }
TVpDayView = class ;
2018-06-09 11:42:09 +00:00
TVpDvInplaceEdit = class( TCustomEdit)
2008-02-03 12:05:55 +00:00
protected {private}
procedure CreateParams( var Params: TCreateParams) ; override ;
procedure KeyDown( var Key: Word ; Shift: TShiftState) ; override ;
{$IFNDEF LCL}
2016-07-12 09:26:14 +00:00
procedure WMKillFocus( var Msg: TWMKillFocus) ; message WM_KILLFOCUS;
2008-02-03 12:05:55 +00:00
{$ELSE}
2016-07-12 09:26:14 +00:00
procedure WMKillFocus( var Msg: TLMKillFocus) ; message LM_KILLFOCUS;
2008-02-03 12:05:55 +00:00
{$ENDIF}
public
constructor Create( AOwner: TComponent) ; override ;
end ;
TVpRHAttributes = class( TPersistent)
protected { private }
FOwner: TVpDayView;
FColor: TColor;
FHourFont: TVpFont;
FMinuteFont: TVpFont;
procedure SetColor( const Value: TColor) ;
procedure SetHourFont( Value: TVpFont) ;
procedure SetMinuteFont( Value: TVpFont) ;
public
constructor Create( AOwner: TVpDayView) ;
destructor Destroy; override ;
2016-06-19 23:40:28 +00:00
property Owner: TVpDayView read FOwner;
2008-02-03 12:05:55 +00:00
published
property HourFont: TVpFont read FHourFont write SetHourFont;
property MinuteFont: TVpFont read FMinuteFont write SetMinuteFont;
property Color: TColor read FColor write SetColor;
end ;
TVpAllDayEventAttributes = class( TPersistent)
protected {Private}
2016-06-19 23:40:28 +00:00
FOwner: TWinControl;
FBackgroundColor: TColor;
FEventBackgroundColor: TColor;
FEventBorderColor: TColor;
FFont: TVpFont;
2008-02-03 12:05:55 +00:00
public
2016-06-19 23:40:28 +00:00
constructor Create( AOwner: TWinControl) ;
2008-02-03 12:05:55 +00:00
destructor Destroy; override ;
procedure SetBackGroundColor( Value: TColor) ;
procedure SetEventBackgroundColor( Value: TColor) ;
procedure SetFont( Value: TVpFont) ;
procedure SetEventBorderColor( Value: TColor) ;
published
property BackgroundColor: TColor
read FBackgroundColor write SetBackGroundColor;
property EventBorderColor: TColor
read FEventBorderColor write SetEventBorderColor;
property EventBackgroundColor: TColor
read FEventBackgroundColor write SetEventBackgroundColor;
property Font: TVpFont
read FFont write SetFont;
end ;
TVpCHAttributes = class( TPersistent)
protected { private }
FOwner: TVpDayView;
FColor: TColor;
FFont: TVpFont;
procedure SetColor( const Value: TColor) ;
procedure SetFont( Value: TVpFont) ;
public
constructor Create( AOwner: TVpDayView) ;
destructor Destroy; override ;
property Owner: TVpDayView read FOwner;
published
property Font: TVpFont read FFont write SetFont;
property Color: TColor read FColor write SetColor;
end ;
2016-06-24 21:41:24 +00:00
TVpDayViewIconAttributes = class( TPersistent)
2016-06-19 23:40:28 +00:00
private
FShowAlarmBitmap: Boolean ;
FShowCategoryBitmap: Boolean ;
FShowRecurringBitmap: Boolean ;
FAlarmBitmap: TBitmap;
FRecurringBitmap: TBitmap;
2018-05-18 09:47:36 +00:00
FAlarmImageIndex: TImageIndex;
FRecurringImageIndex: TImageIndex;
2016-07-16 12:34:46 +00:00
FShowInPrint: Boolean ;
2016-06-19 23:40:28 +00:00
FOwner: TVpLinkableControl;
protected
procedure SetAlarmBitmap( v: TBitmap) ;
2018-05-18 09:47:36 +00:00
procedure SetAlarmImageIndex( v: TImageIndex) ;
2016-06-19 23:40:28 +00:00
procedure SetRecurringBitmap( v: TBitmap) ;
2018-05-18 09:47:36 +00:00
procedure SetRecurringImageIndex( v: TImageIndex) ;
2016-06-19 23:40:28 +00:00
procedure SetShowAlarmBitmap( const v: Boolean ) ;
procedure SetShowCategoryBitmap( const v: Boolean ) ;
procedure SetShowRecurringBitmap( const v: Boolean ) ;
public
constructor Create( AOwner: TVpLinkableControl) ;
destructor Destroy; override ;
published
property AlarmBitmap: TBitmap
read FAlarmBitmap write SetAlarmBitmap;
2018-05-18 09:47:36 +00:00
property AlarmImageIndex: TImageIndex
read FAlarmImageIndex write SetAlarmImageIndex default - 1 ;
2016-06-19 23:40:28 +00:00
property RecurringBitmap: TBitmap
read FRecurringBitmap write SetRecurringBitmap;
2018-05-18 09:47:36 +00:00
property RecurringImageIndex: TImageIndex
read FRecurringImageIndex write SetRecurringImageIndex default - 1 ;
2016-06-19 23:40:28 +00:00
property ShowAlarmBitmap: Boolean
read FShowAlarmBitmap write SetShowAlarmBitmap default True ;
property ShowCategoryBitmap : Boolean
read FShowCategoryBitmap write SetShowCategoryBitmap default True ;
property ShowRecurringBitmap : Boolean
read FShowRecurringBitmap write SetShowRecurringBitmap default True ;
2016-07-16 12:34:46 +00:00
property ShowInPrint: Boolean
read FShowInPrint write FShowInPrint default True ;
2016-06-19 23:40:28 +00:00
end ;
2008-02-03 12:05:55 +00:00
2008-02-07 23:08:26 +00:00
{ TVpDayView }
2008-02-03 12:05:55 +00:00
TVpDayView = class( TVpLinkableControl)
2016-09-12 22:25:34 +00:00
private
2017-05-25 21:24:23 +00:00
FComponentHint: TTranslateString;
2016-09-12 22:25:34 +00:00
FHintMode: TVpHintMode;
FMouseEvent: TVpEvent;
2016-09-22 23:12:16 +00:00
FOnHoliday: TVpHolidayEvent;
2016-09-12 22:25:34 +00:00
2008-02-03 12:05:55 +00:00
protected { private }
2016-06-19 23:40:28 +00:00
FGranularity: TVpGranularity;
FColumnWidth: Integer ;
FColor: TColor;
FLineColor: TColor;
FDefTopHour: TVpHours;
FTopHour: TVpHours;
FDateLabelFormat: string ;
FShowResourceName: Boolean ;
FTopLine: Integer ;
FActiveRow: Integer ;
FActiveCol: Integer ;
FActiveEvent: TVpEvent;
FGutterWidth: Integer ;
FDefaultPopup: TPopupMenu;
FLineCount: Integer ;
FVisibleLines: Integer ;
FTimeFormat: TVpTimeFormat;
FDrawingStyle: TVpDrawingStyle;
FTimeSlotColors: TVpTimeSlotColor;
FRowHeadAttr: TVpRHAttributes;
FHeadAttr: TVpCHAttributes;
FAllDayEventAttr: TVpAllDayEventAttributes;
FDisplayDate: TDateTime;
FScrollBars: TScrollStyle;
FIconAttributes: TVpDayViewIconAttributes;
FWrapStyle: TVpDVWrapStyle;
FDotDotDotColor: TColor;
FShowEventTimes: Boolean ;
2016-06-23 23:16:34 +00:00
FAllowInplaceEdit: Boolean ;
2016-08-26 13:33:45 +00:00
FDragDropTransparent: Boolean ;
FAllowDragAndDrop: Boolean ;
2016-09-22 23:12:16 +00:00
FNumDays: Integer ;
FIncludeWeekends: Boolean ;
2018-05-15 09:08:53 +00:00
FRowLinesStep: Integer ;
FShowNavButtons: Boolean ;
FFixedDate: Boolean ;
FCustomRowHeight: Integer ;
FSimpleRowTime: Boolean ;
2008-02-03 12:05:55 +00:00
{ event variables }
2016-06-19 23:40:28 +00:00
FOwnerDrawRowHead: TVpOwnerDrawRowEvent;
FOwnerDrawCells: TVpOwnerDrawRowEvent;
FOwnerDrawColHead: TVpOwnerDrawEvent;
FBeforeEdit: TVpBeforeEditEvent;
FAfterEdit: TVpAfterEditEvent;
FOwnerEditEvent: TVpEditEvent;
FOnDrawIcons: TVpOnDVDrawIcons;
FOnBeforeDrawEvent: TVpOnDVBeforeDrawEvent;
FOnAfterDrawEvent: TVpOnDVAfterDrawEvent;
FOnAddEvent: TVpOnAddNewEvent;
2008-02-03 12:05:55 +00:00
{ internal variables }
2016-06-19 23:40:28 +00:00
dvClickTimer: TTimer;
dvLoaded: Boolean ;
dvInLinkHandler: Boolean ;
dvRowHeight: Integer ;
dvColHeadHeight: Integer ;
dvRowHeadWidth: Integer ;
dvClientVArea: Integer ;
dvMouseDownPoint: TPoint;
dvMouseDown: Boolean ;
dvEndingEditing: Boolean ;
dvDragging: Boolean ;
dvDragStartTime: TDateTime;
2008-02-03 12:05:55 +00:00
{ Nav Buttons }
2016-06-19 23:40:28 +00:00
dvDayUpBtn: TSpeedButton;
dvDayDownBtn: TSpeedButton;
dvTodayBtn: TSpeedButton;
dvWeekUpBtn: TSpeedButton;
dvWeekDownBtn: TSpeedButton;
dvLineMatrix: TVpLineMatrix;
dvColRectArray: TVpColRectArray;
dvEventArray: TVpEventArray;
dvActiveEventRec: TRect;
dvActiveIconRec: TRect;
dvInPlaceEditor: TVpDvInPlaceEdit;
dvCreatingEditor: Boolean ;
2008-02-03 12:05:55 +00:00
{ the granularity based time increment for each row }
2016-06-19 23:40:28 +00:00
dvTimeIncSize: double ;
dvPainting: Boolean ;
dvVScrollDelta: Integer ;
dvHotPoint: TPoint;
2008-02-03 12:05:55 +00:00
{ property methods }
2016-06-19 23:40:28 +00:00
function GetLastVisibleDate: TDateTime;
function GetRealNumDays( WorkDate: TDateTime) : Integer ;
2008-02-03 12:05:55 +00:00
procedure SetDrawingStyle( Value: TVpDrawingStyle) ;
procedure SetColor( Value: TColor) ;
procedure SetLineColor( Value: TColor) ;
procedure SetTopHour( Value: TVpHours) ;
procedure SetTopLine( Value: Integer ) ;
procedure SetDateLabelFormat( Value: string ) ;
procedure SetGutterWidth( Value: Integer ) ;
procedure SetDefTopHour( Value: TVpHours) ;
procedure SetGranularity( Value: TVpGranularity) ;
procedure SetTimeFormat( Value: TVpTimeFormat) ;
2016-06-19 23:40:28 +00:00
procedure SetNumDays( Value: Integer ) ;
procedure SetIncludeWeekends( Value: Boolean ) ;
2008-02-03 12:05:55 +00:00
procedure SetDisplayDate( Value: TDateTime) ;
procedure SetVScrollPos;
2018-05-15 09:08:53 +00:00
procedure SetCustomRowHeight( Value: Integer ) ;
procedure SetRowLinesStep( Value: Integer ) ;
procedure SetShowNavButtons( Value: Boolean ) ;
2008-02-03 12:05:55 +00:00
procedure SetShowResourceName( Value: Boolean ) ;
2018-05-15 09:08:53 +00:00
procedure SetSimpleRowTime( Value: Boolean ) ;
2008-02-03 12:05:55 +00:00
procedure SetActiveRow( Value: Integer ) ;
procedure SetActiveCol( Value: Integer ) ;
2016-06-19 23:40:28 +00:00
procedure SetWrapStyle( const v: TVpDVWrapStyle) ;
procedure SetDotDotDotColor( const v: TColor) ;
2016-06-18 12:09:16 +00:00
procedure SetShowEventTimes( Value: Boolean ) ;
2016-09-12 22:25:34 +00:00
2008-02-03 12:05:55 +00:00
{ drag-drop methods }
procedure DoStartDrag( var DragObject: TDragObject) ; override ;
procedure DoEndDrag( Target: TObject; X, Y: Integer ) ; override ;
procedure DragOver( Source: TObject; X, Y: Integer ; State: TDragState;
var Accept: Boolean ) ; override ;
2016-09-12 22:25:34 +00:00
{ Hints }
procedure ShowHintWindow( APoint: TPoint; AEvent: TVpEvent) ;
procedure HideHintWindow;
2017-05-25 21:24:23 +00:00
procedure SetHint( const AValue: TTranslateString) ; override ;
procedure SetHintMode( const AValue: TVpHintMode) ;
2016-09-12 22:25:34 +00:00
2018-06-20 20:56:27 +00:00
{ Popup }
2016-06-19 23:40:28 +00:00
procedure PopupAddEvent( Sender: TObject) ;
2018-06-15 23:40:18 +00:00
procedure PopupAddFromICalFile( Sender: TObject) ;
2016-06-19 23:40:28 +00:00
procedure PopupDeleteEvent( Sender: TObject) ;
procedure PopupEditEvent( Sender: TObject) ;
procedure PopupToday( Sender: TObject) ;
procedure PopupTomorrow( Sender: TObject) ;
procedure PopupYesterday( Sender: TObject) ;
procedure PopupNextDay( Sender: TObject) ;
procedure PopupPrevDay( Sender: TObject) ;
procedure PopupNextWeek( Sender: TObject) ;
procedure PopupPrevWeek( Sender: TObject) ;
procedure PopupNextMonth( Sender: TObject) ;
procedure PopupPrevMonth( Sender: TObject) ;
procedure PopupNextYear( Sender: TObject) ;
procedure PopupPrevYear( Sender: TObject) ;
2016-09-10 17:26:42 +00:00
procedure PopupPickResourceGroupEvent( Sender: TObject) ;
procedure PopupDropdownEvent( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
procedure InitializeDefaultPopup;
2018-06-20 20:56:27 +00:00
{ internal methods }
procedure CreateParams( var Params: TCreateParams) ; override ;
procedure CreateWnd; override ;
function dvCalcRowHeight( Scale: Extended ; UseGran: TVpGranularity) : Integer ;
function dvCalcVisibleLines( RenderHeight, ColHeadHeight, ARowHeight: Integer ;
Scale: Extended ; StartLine, StopLine: Integer ) : Integer ;
function dvCalcColHeadHeight( Scale: Extended ) : Integer ;
procedure dvEditInPlace( Sender: TObject) ;
procedure dvHookUp;
procedure dvNavButtonsClick( Sender: TObject) ;
procedure dvPopulate;
procedure dvScrollVertical( Lines: Integer ) ;
2018-05-17 16:35:44 +00:00
procedure dvSpawnEventEditDialog( IsNewEvent: Boolean ) ;
2016-06-12 15:29:23 +00:00
procedure dvSetActiveRowByCoord( Pnt: TPoint; Sloppy: Boolean ) ;
2008-02-03 12:05:55 +00:00
procedure dvSetActiveColByCoord( Pnt: TPoint) ;
2018-06-20 20:56:27 +00:00
procedure EditEvent;
2016-09-12 22:25:34 +00:00
function EditEventAtCoord( APoint: TPoint) : Boolean ;
2018-06-20 20:56:27 +00:00
procedure EndEdit( Sender: TObject) ;
2016-09-12 22:25:34 +00:00
function GetEventAtCoord( APoint: TPoint) : TVpEvent;
function GetEventRect( AEvent: TVpEvent) : TRect;
2018-06-20 20:56:27 +00:00
procedure SetActiveEventByCoord( APoint: TPoint) ;
2016-06-12 15:29:23 +00:00
procedure SetTimeIntervals( UseGran: TVpGranularity) ;
2016-09-12 22:25:34 +00:00
2018-06-20 20:56:27 +00:00
{ inherited methods }
procedure KeyDown( var Key: Word ; Shift: TShiftState) ; override ;
procedure Loaded; override ;
procedure MouseDown( Button: TMouseButton; Shift: TShiftState; X, Y: Integer ) ; override ;
procedure MouseEnter; override ;
procedure MouseLeave; override ;
procedure MouseMove( Shift: TShiftState; X, Y: Integer ) ; override ;
procedure MouseUp( Button: TMouseButton; Shift: TShiftState; X, Y: Integer ) ; override ;
procedure Paint; override ;
2008-02-03 12:05:55 +00:00
{ message handlers }
2016-06-22 07:59:17 +00:00
procedure VpDayViewInit( var Msg: {$IFDEF DELPHI} TMessage{$ELSE} TLMessage{$ENDIF} ) ; message Vp_DayViewInit;
2008-02-03 12:05:55 +00:00
{$IFNDEF LCL}
2016-06-12 15:29:23 +00:00
procedure WMLButtonDblClk( var Msg : TWMLButtonDblClk) ; message WM_LBUTTONDBLCLK;
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 WMSetFocus( var Msg : TWMSetFocus) ; message WM_SETFOCUS;
2016-06-28 11:08:29 +00:00
procedure WMEraseBackground ( var Msg : TWMERASEBKGND) ; // ??? wp: missing "message WM_ERASEBKGND"?
2016-06-12 15:29:23 +00:00
procedure CMWantSpecialKey( var Msg: TCMWantSpecialKey) ; message CM_WANTSPECIALKEY;
2008-02-03 12:05:55 +00:00
{$ELSE}
2016-06-12 15:29:23 +00:00
function DoMouseWheel( Shift: TShiftState; WheelDelta: Integer ; MousePos: TPoint) : Boolean ; override ;
function DoMouseWheelDown( Shift: TShiftState; MousePos: TPoint) : Boolean ; override ;
function DoMouseWheelUp( Shift: TShiftState; MousePos: TPoint) : Boolean ; override ;
2008-02-03 12:05:55 +00:00
procedure WMSize( var Msg: TLMSize) ; message LM_SIZE;
procedure WMVScroll( var Msg: TLMVScroll) ; message LM_VSCROLL;
2016-06-12 15:29:23 +00:00
procedure WMSetFocus( var Msg: TLMSetFocus) ; message LM_SETFOCUS;
2016-06-28 11:08:29 +00:00
procedure WMEraseBackground( var Msg: TLMERASEBKGND) ; message LM_ERASEBKGND;
2016-06-12 15:29:23 +00:00
procedure WMLButtonDblClk( var Msg: TLMLButtonDblClk) ; message LM_LBUTTONDBLCLK;
2008-02-03 12:05:55 +00:00
{$ENDIF}
2016-06-21 20:45:28 +00:00
2008-02-03 12:05:55 +00:00
public
constructor Create( AOwner: TComponent) ; override ;
destructor Destroy; override ;
2016-09-12 22:25:34 +00:00
function BuildEventString( AEvent: TVpEvent; UseAsHint: Boolean ) : String ;
2008-02-03 12:05:55 +00:00
procedure DeleteActiveEvent( Verify: Boolean ) ;
procedure DragDrop( Source: TObject; X, Y: Integer ) ; override ;
procedure Invalidate; override ;
2016-09-22 23:12:16 +00:00
function IsHoliday( ADate: TDate; out AHolidayName: String ) : Boolean ;
procedure LoadLanguage;
2016-06-18 12:09:16 +00:00
procedure LinkHandler( Sender: TComponent; NotificationType: TVpNotificationType;
2008-02-03 12:05:55 +00:00
const Value: Variant ) ; override ;
2018-06-12 16:40:51 +00:00
procedure EditSelectedEvent( IsNewEvent: Boolean = false ) ;
2008-02-03 12:05:55 +00:00
2016-06-19 23:40:28 +00:00
function GetControlType: TVpItemType; override ;
procedure AutoScaledPaintToCanvas( PaintCanvas: TCanvas; PaintTo: TRect;
Angle: TVpRotationAngle; RenderDate: TDateTime; StartLine, StopLine: Integer ;
UseGran: TVpGranularity) ;
procedure PaintToCanvas ( ACanvas: TCanvas; ARect: TRect; Angle: TVpRotationAngle;
ADate: TDateTime; StartHour, EndHour: TVpHours; UseGran: TVpGranularity) ;
2016-07-06 08:17:28 +00:00
procedure RenderToCanvas( RenderCanvas: TCanvas; RenderIn: TRect;
2016-06-19 23:40:28 +00:00
Angle: TVpRotationAngle; Scale: Extended ; RenderDate: TDateTime;
StartLine, StopLine: Integer ; UseGran: TVpGranularity; DisplayOnly: Boolean ) ; override ;
2016-06-26 13:52:59 +00:00
2018-01-12 12:42:12 +00:00
{$IF VP_LCL_SCALING = 2}
procedure ScaleFontsPPI( const AToPPI: Integer ; const AProportion: Double ) ; override ;
{$ELSE}
{$IF VP_LCL_SCALING = 1}
procedure ScaleFontsPPI( const AProportion: Double ) ; override ;
{$ENDIF}
{$ENDIF}
2008-02-29 21:39:52 +00:00
property ActiveEvent: TVpEvent read FActiveEvent write FActiveEvent;
2008-02-03 12:05:55 +00:00
property TopHour: TVpHours read FTopHour write SetTopHour;
property TopLine: Integer read FTopLine write SetTopLine;
property LineCount: Integer read FLineCount;
property ActiveRow: Integer read FActiveRow write SetActiveRow;
property ActiveCol: Integer read FActiveCol write SetActiveCol;
property Date: TDateTime read FDisplayDate write SetDisplayDate;
2016-06-19 23:40:28 +00:00
property LastVisibleDate: TDateTime read GetLastVisibleDate;
2008-02-03 12:05:55 +00:00
property VisibleLines: Integer read FVisibleLines;
2016-06-21 20:45:28 +00:00
2008-02-03 12:05:55 +00:00
published
property Align;
property Anchors;
2018-05-18 07:43:44 +00:00
{$IFDEF LCL}
property BorderSpacing;
{$ENDIF}
2008-02-03 12:05:55 +00:00
property Constraints;
property ReadOnly ;
property TabStop;
property TabOrder;
property Font;
2016-06-19 23:40:28 +00:00
property AllDayEventAttributes: TVpAllDayEventAttributes read FAllDayEventAttr write FAllDayEventAttr;
2016-08-26 13:33:45 +00:00
property AllowDragAndDrop: Boolean read FAllowDragAndDrop write FAllowDragAndDrop default false ;
2016-06-23 23:16:34 +00:00
property AllowInplaceEditing: Boolean read FAllowInplaceEdit write FAllowInplaceEdit default true ;
2016-06-19 23:40:28 +00:00
property DotDotDotColor: TColor read FDotDotDotColor write SetDotDotDotColor default clBlack;
property ShowEventTimes: Boolean read FShowEventTimes write SetShowEventTimes default true ;
2016-08-26 13:33:45 +00:00
property DragDropTransparent: Boolean read FDragDropTransparent write FDragDropTransparent default false ;
2016-06-19 23:40:28 +00:00
property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle stored True ;
property TimeSlotColors: TVpTimeSlotColor read FTimeSlotColors write FTimeSlotColors;
property HeadAttributes: TVpCHAttributes read FHeadAttr write FHeadAttr;
property RowHeadAttributes: TVpRHAttributes read FRowHeadAttr write FRowHeadAttr;
property IconAttributes: TVpDayViewIconAttributes read FIconAttributes write FIconAttributes;
2008-02-03 12:05:55 +00:00
property Color: TColor read FColor write SetColor;
2016-06-19 23:40:28 +00:00
property OwnerDrawRowHeader: TVpOwnerDrawRowEvent read FOwnerDrawRowHead write FOwnerDrawRowHead;
property OwnerDrawColHeader: TVpOwnerDrawEvent read FOwnerDrawColHead write FOwnerDrawColHead;
property OwnerDrawCells: TVpOwnerDrawRowEvent read FOwnerDrawCells write FOwnerDrawCells;
property ShowResourceName: Boolean read FShowResourceName write SetShowResourceName;
2008-02-03 12:05:55 +00:00
property LineColor: TColor read FLineColor write SetLineColor;
property GutterWidth: Integer read FGutterWidth write SetGutterWidth;
2016-06-19 23:40:28 +00:00
property DateLabelFormat: string read FDateLabelFormat write SetDateLabelFormat;
2008-02-03 12:05:55 +00:00
Property Granularity: TVpGranularity read FGranularity write SetGranularity;
property DefaultTopHour: TVpHours read FDefTopHour write SetDefTopHour;
property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat;
2016-06-19 23:40:28 +00:00
property IncludeWeekends: Boolean read FIncludeWeekends write SetIncludeWeekends default True ;
property NumDays: Integer read FNumDays write SetNumDays default 1 ;
property WrapStyle: TVpDVWrapStyle read FWrapStyle Write SetWrapStyle default wsIconFlow;
2017-05-25 21:24:23 +00:00
property HintMode: TVpHintMode read FHintMode write SetHintMode default hmPlannerHint;
2018-05-15 09:08:53 +00:00
property ShowNavButtons: Boolean read FShowNavButtons write SetShowNavButtons default true ;
property FixedDate: Boolean read FFixedDate write FFixedDate default false ;
2018-05-17 08:09:21 +00:00
property RowHeight: Integer read FCustomRowHeight write SetCustomRowHeight default 0 ;
2018-05-15 09:08:53 +00:00
property RowLinesStep: Integer read FRowLinesStep write SetRowLinesStep default 1 ;
property SimpleRowTime: Boolean read FSimpleRowTime write SetSimpleRowTime default false ;
2008-02-03 12:05:55 +00:00
{events}
2016-06-19 23:40:28 +00:00
property AfterEdit: TVpAfterEditEvent read FAfterEdit write FAfterEdit;
2008-02-03 12:05:55 +00:00
property BeforeEdit: TVpBeforeEditEvent read FBeforeEdit write FBeforeEdit;
2016-06-19 23:40:28 +00:00
property OnAddEvent: TVpOnAddNewEvent read FOnAddEvent write FOnAddEvent;
property OnAfterDrawEvent: TVpOnDVAfterDrawEvent read FOnAfterDrawEvent write FOnAfterDrawEvent;
property OnBeforeDrawEvent: TVpOnDVBeforeDrawEvent read FOnBeforeDrawEvent write FOnBeforeDrawEvent;
property OnDrawIcons: TVpOnDVDrawIcons read FOnDrawIcons Write FOnDrawIcons;
2016-09-22 23:12:16 +00:00
property OnHoliday: TVpHolidayEvent read FOnHoliday write FOnHoliday;
2016-06-19 23:40:28 +00:00
property OnOwnerEditEvent: TVpEditEvent read FOwnerEditEvent write FOwnerEditEvent;
2008-02-03 12:05:55 +00:00
property OnClick;
end ;
implementation
uses
2016-09-17 15:48:39 +00:00
{$IFDEF LCL}
DateUtils,
{$ENDIF}
2016-09-12 22:25:34 +00:00
SysUtils, StrUtils, Math, Dialogs,
2018-06-15 23:40:18 +00:00
VpEvntEditDlg, VpDayViewPainter, VpICal;
2008-02-03 12:05:55 +00:00
(*****************************************************************************)
{ TVpTGInPlaceEdit }
constructor TVpDvInPlaceEdit. Create( AOwner: TComponent) ;
begin
inherited Create( AOwner) ;
TabStop : = False ;
BorderStyle : = bsNone;
2018-06-04 10:36:57 +00:00
// DoubleBuffered := False;
2008-02-03 12:05:55 +00:00
end ;
{=====}
procedure TVpDvInPlaceEdit. CreateParams( var Params: TCreateParams) ;
begin
inherited CreateParams( Params) ;
Params. Style : = Params. Style{$IFNDEF LCL} or ES_MULTILINE{$ENDIF} ;
end ;
{=====}
procedure TVpDvInPlaceEdit. KeyDown( var Key: Word ; Shift: TShiftState) ;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!! WARNING
// !!!!
// !!!! Experimental change below. Verify this change before releasing
// !!!! VP 1.03
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
begin
case Key of
2016-06-19 23:40:28 +00:00
VK_RETURN:
begin
Key : = 0 ;
TVpDayView( Owner) . EndEdit( Self) ;
end ;
2008-02-03 12:05:55 +00:00
2016-06-19 23:40:28 +00:00
VK_UP:
begin
Key : = 0 ;
TVpDayView( Owner) . ActiveRow : = TVpDayView( Owner) . ActiveRow - 1 ;
2008-02-03 12:05:55 +00:00
// !!!! TVpDayView(Owner).EndEdit(Self); !!!! !!!!!!!!!!!!!!!!!!!!!!!!!
2016-06-19 23:40:28 +00:00
end ;
2008-02-03 12:05:55 +00:00
2016-06-19 23:40:28 +00:00
VK_DOWN:
begin
Key : = 0 ;
TVpDayView( Owner) . ActiveRow : = TVpDayView( Owner) . ActiveRow + 1 ;
2008-02-03 12:05:55 +00:00
// !!!! TVpDayView(Owner).EndEdit(Self); !!!! !!!!!!!!!!!!!!!!!!!!!!!!!
2016-06-19 23:40:28 +00:00
end ;
2008-02-03 12:05:55 +00:00
2016-06-19 23:40:28 +00:00
VK_ESCAPE:
begin
Key : = 0 ;
2018-06-09 11:42:09 +00:00
Hide;
2016-06-19 23:40:28 +00:00
TVpDayView( Owner) . SetFocus;
end ;
2008-02-03 12:05:55 +00:00
2016-06-20 14:21:33 +00:00
else
inherited ;
2008-02-03 12:05:55 +00:00
end ;
end ;
{=====}
{$IFNDEF LCL}
2016-06-19 23:40:28 +00:00
procedure TVpDvInPlaceEdit. WMKillFocus( var Msg: TWMKillFocus) ;
2008-02-03 12:05:55 +00:00
{$ELSE}
2016-06-19 23:40:28 +00:00
procedure TVpDvInPlaceEdit. WMKillFocus( var Msg: TLMKillFocus) ;
2008-02-03 12:05:55 +00:00
{$ENDIF}
begin
2016-07-12 09:26:14 +00:00
Unused( Msg) ;
2008-02-03 12:05:55 +00:00
TVpDayView( Owner) . EndEdit( self) ;
end ;
{=====}
{ TVpAllDayEventAttributes }
2016-06-19 23:40:28 +00:00
constructor TVpAllDayEventAttributes. Create( AOwner: TWinControl) ;
2008-02-03 12:05:55 +00:00
begin
FOwner: = AOwner;
FFont : = TVpFont. Create( AOwner) ;
FBackgroundColor : = clBtnShadow;
FEventBackgroundColor : = clBtnFace;
FEventBorderColor : = cl3dDkShadow;
end ;
{=====}
destructor TVpAllDayEventAttributes. Destroy;
begin
inherited ;
FFont. Free;
end ;
{=====}
procedure TVpAllDayEventAttributes. SetBackGroundColor( Value: TColor) ;
begin
FBackgroundColor : = Value;
FOwner. Invalidate;
end ;
{=====}
procedure TVpAllDayEventAttributes. SetEventBackgroundColor( Value: TColor) ;
begin
FEventBackgroundColor : = Value;
FOwner. Invalidate;
end ;
{=====}
procedure TVpAllDayEventAttributes. SetEventBorderColor( Value: TColor) ;
begin
FEventBorderColor : = Value;
FOwner. Invalidate;
end ;
procedure TVpAllDayEventAttributes. SetFont( Value: TVpFont) ;
begin
FFont. Assign( Value) ;
FFont. Owner : = FOwner;
end ;
{=====}
(*****************************************************************************)
2016-06-19 23:40:28 +00:00
{ TVpDayViewIconAttributes }
constructor TVpDayViewIconAttributes. Create( AOwner: TVpLinkableControl) ;
begin
inherited Create;
FOwner : = AOwner;
FAlarmBitmap : = TBitmap. Create;
FRecurringBitmap : = TBitmap. Create;
2018-05-18 09:47:36 +00:00
FAlarmImageIndex : = - 1 ;
FRecurringImageIndex : = - 1 ;
2016-06-19 23:40:28 +00:00
FShowAlarmBitmap : = True ;
FShowCategoryBitmap : = True ;
FShowRecurringBitmap : = True ;
2016-07-16 12:34:46 +00:00
FShowInPrint : = True ;
2016-06-19 23:40:28 +00:00
end ;
destructor TVpDayViewIconAttributes. Destroy;
begin
FAlarmBitmap. Free;
FRecurringBitmap. Free;
inherited Destroy;
end ;
procedure TVpDayViewIconAttributes. SetAlarmBitmap( v: TBitmap) ;
begin
FAlarmBitmap. Assign( v) ;
if Assigned( FOwner) then
FOwner. Invalidate;
end ;
2018-05-18 09:47:36 +00:00
procedure TVpDayViewIconAttributes. SetAlarmImageIndex( v: TImageIndex) ;
begin
if FAlarmImageIndex < > v then
begin
FAlarmImageIndex : = v;
if Assigned( FOwner) then
FOwner. Invalidate;
end ;
end ;
2016-06-19 23:40:28 +00:00
procedure TVpDayViewIconAttributes. SetRecurringBitmap( v: TBitmap) ;
begin
FRecurringBitmap. Assign( v) ;
if Assigned( FOwner) then
2018-05-18 09:47:36 +00:00
FOwner. Invalidate;
end ;
procedure TVpDayViewIconAttributes. SetRecurringImageIndex( v: TImageIndex) ;
begin
if FRecurringImageIndex < > v then
begin
FRecurringImageIndex : = v;
if Assigned( FOwner) then
FOwner. Invalidate;
end ;
2016-06-19 23:40:28 +00:00
end ;
procedure TVpDayViewIconAttributes. SetShowAlarmBitmap( const v: Boolean ) ;
begin
if FShowAlarmBitmap < > v then begin
FShowAlarmBitmap : = v;
if Assigned( FOwner) then
FOwner. Invalidate
end ;
end ;
procedure TVpDayViewIconAttributes. SetShowCategoryBitmap( const v: Boolean ) ;
begin
if FShowCategoryBitmap < > v then begin
FShowCategoryBitmap : = v;
if Assigned( FOwner) then
FOwner. Invalidate;
end ;
end ;
procedure TVpDayViewIconAttributes. SetShowRecurringBitmap( const v: Boolean ) ;
begin
if FShowRecurringBitmap < > v then begin
FShowRecurringBitmap : = v;
if Assigned( FOwner) then
FOwner. Invalidate
end ;
end ;
2008-02-03 12:05:55 +00:00
(*****************************************************************************)
{ TVpDayView }
constructor TVpDayView. Create( AOwner: TComponent) ;
begin
inherited ;
ControlStyle : = [ csCaptureMouse, csOpaque, csDoubleClicks] ;
2017-05-25 21:24:23 +00:00
HintWindowClass : = TVpHintWindow;
2008-02-03 12:05:55 +00:00
{ Create internal classes and stuff }
2016-06-24 21:41:24 +00:00
FTimeSlotColors : = TVpTimeSlotColor. Create( self) ;
FHeadAttr : = TVpCHAttributes. Create( self) ;
FRowHeadAttr : = TVpRHAttributes. Create( self) ;
2016-06-19 23:40:28 +00:00
FAllDayEventAttr : = TVpAllDayEventAttributes. Create( self) ;
2016-06-26 11:37:20 +00:00
dvClickTimer : = TTimer. Create( self) ;
2016-06-24 21:41:24 +00:00
FIconAttributes : = TVpDayViewIconAttributes. Create( Self) ;
2008-02-03 12:05:55 +00:00
{ create Nav buttons }
2016-06-19 23:40:28 +00:00
dvDayUpBtn : = TSpeedButton. Create( self) ;
dvDayUpBtn. Parent : = self;
dvDayDownBtn : = TSpeedButton. Create( self) ;
dvDayDownBtn. Parent : = self;
dvTodayBtn : = TSpeedButton. Create( self) ;
2016-06-24 21:41:24 +00:00
dvTodayBtn. Parent : = self;
2016-06-19 23:40:28 +00:00
dvWeekDownBtn : = TSpeedButton. Create( self) ;
dvWeekDownBtn. Parent : = self;
dvWeekUpBtn : = TSpeedButton. Create( self) ;
dvWeekUpBtn. Parent : = self;
2008-02-03 12:05:55 +00:00
{ flat }
2016-06-19 23:40:28 +00:00
dvTodayBtn. Flat : = true ;
dvWeekDownBtn. Flat : = true ;
dvDayDownBtn. Flat : = true ;
dvDayUpBtn. Flat : = true ;
dvWeekUpBtn. Flat : = true ;
2008-02-03 12:05:55 +00:00
{ transparent }
2016-06-19 23:40:28 +00:00
dvTodayBtn. Transparent : = true ;
dvWeekDownBtn. Transparent : = true ;
dvDayDownBtn. Transparent : = true ;
dvDayUpBtn. Transparent : = true ;
dvWeekUpBtn. Transparent : = true ;
2008-02-03 12:05:55 +00:00
{ load their images }
2017-05-23 17:39:54 +00:00
{$IFDEF NEW_ICONS}
LoadGlyphFromRCDATA( dvDayUpBtn. Glyph, 'VpRArrow' , 1 6 , 2 4 , 3 2 ) ;
LoadGlyphFromRCDATA( dvDayDownBtn. Glyph, 'VpLArrow' , 1 6 , 2 4 , 3 2 ) ;
LoadGlyphFromRCDATA( dvTodayBtn. Glyph, 'VpToday' , 1 6 , 2 4 , 3 2 ) ;
LoadGlyphFromRCDATA( dvWeekUpBtn. Glyph, 'VpRArrows' , 1 6 , 2 4 , 3 2 ) ;
LoadGlyphFromRCDATA( dvWeekDownBtn. Glyph, 'VpLArrows' , 1 6 , 2 4 , 3 2 ) ;
{$ELSE}
2016-06-24 21:41:24 +00:00
dvDayUpBtn. Glyph. LoadFromResourceName( HINSTANCE, 'VPRIGHTARROW' ) ;
dvDayDownBtn. Glyph. LoadFromResourceName( HINSTANCE, 'VPLEFTARROW' ) ;
dvTodayBtn. Glyph. LoadFromResourceName( HINSTANCE, 'VPTODAY' ) ;
dvWeekUpBtn. Glyph. LoadFromResourceName( HINSTANCE, 'VPRIGHTARROWS' ) ;
dvWeekDownBtn. Glyph. LoadFromResourceName( HINSTANCE, 'VPLEFTARROWS' ) ;
2017-05-23 17:39:54 +00:00
{$ENDIF}
2008-02-03 12:05:55 +00:00
{ set their OnClick handler }
2016-06-19 23:40:28 +00:00
dvDayUpBtn. OnClick : = dvNavButtonsClick;
dvDayDownBtn. OnClick : = dvNavButtonsClick;
dvTodayBtn. OnClick : = dvNavButtonsClick;
dvWeekUpBtn. OnClick : = dvNavButtonsClick;
dvWeekDownBtn. OnClick : = dvNavButtonsClick;
{ Set up the hints }
dvDayUpBtn. ShowHint : = True ;
dvDayDownBtn. ShowHint : = True ;
dvTodayBtn. ShowHint : = True ;
dvWeekUpBtn. ShowHint : = True ;
dvWeekDownBtn. ShowHint : = True ;
2008-02-03 12:05:55 +00:00
{ 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-06-19 23:40:28 +00:00
NumDays : = 1 ;
dvInLinkHandler : = false ;
dvClickTimer. Enabled : = false ;
dvClickTimer. Interval : = ClickDelay;
dvClickTimer. OnTimer : = dvEditInPlace;
dvCreatingEditor : = false ;
FDrawingStyle : = ds3d;
dvPainting : = false ;
2018-05-15 09:08:53 +00:00
FShowNavButtons : = true ;
2016-06-19 23:40:28 +00:00
FShowResourceName : = true ;
FColor : = clWindow;
FLineColor : = clGray;
Granularity : = gr30min;
FDefTopHour : = h_07;
FDisplayDate : = Now;
2018-05-15 09:08:53 +00:00
FFixedDate : = false ;
FCustomRowHeight : = 0 ;
FRowLinesStep : = 1 ;
FSimpleRowTime : = false ;
2016-06-19 23:40:28 +00:00
TopHour : = FDefTopHour;
FTimeFormat : = tf12Hour;
2016-09-22 23:12:16 +00:00
FDateLabelFormat : = 'dddddd' ; //'dddd, mmmm dd, yyyy';
2016-06-19 23:40:28 +00:00
FColumnWidth : = 2 0 0 ;
FScrollBars : = ssVertical;
FActiveRow : = - 1 ;
FGutterWidth : = 7 ;
dvEndingEditing : = False ;
FWrapStyle : = wsIconFlow;
FDotDotDotColor : = clBlack;
FIncludeWeekends : = True ;
2016-06-23 23:16:34 +00:00
FAllowInplaceEdit : = true ;
2016-09-12 22:25:34 +00:00
FShowEventTimes : = true ;
2008-02-03 12:05:55 +00:00
{ set up fonts and colors }
2016-06-19 23:40:28 +00:00
FHeadAttr. Font. Size : = 1 0 ;
FHeadAttr. Font. Style : = [ ] ;
FHeadAttr. Color : = clBtnFace;
2008-02-03 12:05:55 +00:00
2016-06-19 23:40:28 +00:00
FRowHeadAttr. FHourFont. Size : = 1 8 ;
FRowHeadAttr. FHourFont. Style : = [ ] ;
FRowHeadAttr. FMinuteFont. Size : = 9 ;
2008-02-03 12:05:55 +00:00
FRowHeadAttr. FMinuteFont. Style : = [ ] ;
2016-06-19 23:40:28 +00:00
FRowHeadAttr. Color : = clBtnFace;
2016-06-14 14:24:19 +00:00
{$IFNDEF LCL}
2016-06-19 23:40:28 +00:00
FHeadAttr. Font. Name : = 'Tahoma' ;
FRowHeadAttr. FHourFont. Name : = 'Tahoma' ;
FRowHeadAttr. FMinuteFont. Name : = 'Tahoma' ;
2016-06-14 14:24:19 +00:00
{$ENDIF}
2008-02-03 12:05:55 +00:00
SetLength( dvEventArray, MaxVisibleEvents) ;
2016-06-18 12:09:16 +00:00
DragMode : = dmManual;
dvDragging : = false ;
2016-08-26 13:33:45 +00:00
2008-02-03 12:05:55 +00:00
dvMouseDownPoint : = Point( 0 , 0 ) ;
2016-06-18 12:09:16 +00:00
dvMouseDown : = false ;
2008-02-03 12:05:55 +00:00
2016-09-10 17:26:42 +00:00
// Size
2016-06-19 23:40:28 +00:00
Height : = 2 2 5 ;
Width : = 2 6 5 ;
2008-02-03 12:05:55 +00:00
2016-09-10 17:26:42 +00:00
// popup menu
2016-06-19 23:40:28 +00:00
FDefaultPopup : = TPopupMenu. Create( Self) ;
2012-09-24 19:30:17 +00:00
Self. PopupMenu : = FDefaultPopup;
2016-09-10 17:26:42 +00:00
FDefaultPopup. OnPopup : = PopupDropDownEvent;
2008-11-10 13:54:49 +00:00
LoadLanguage;
2008-02-03 12:05:55 +00:00
dvHookUp;
end ;
{=====}
destructor TVpDayView. Destroy;
begin
2016-06-18 11:17:39 +00:00
FreeAndNil( dvInplaceEditor) ;
2008-02-03 12:05:55 +00:00
FTimeSlotColors. Free;
FHeadAttr. Free;
FRowHeadAttr. Free;
FAllDayEventAttr. Free;
dvClickTimer. Free;
FDefaultPopup. Free;
2016-06-19 23:40:28 +00:00
FIconAttributes. Free;
2008-02-03 12:05:55 +00:00
dvDayUpBtn. Free;
dvDayDownBtn. Free;
dvTodayBtn. Free;
dvWeekUpBtn. Free;
dvWeekDownBtn. Free;
inherited ;
end ;
2008-11-10 13:54:49 +00:00
2016-09-12 22:25:34 +00:00
function TVpDayView. BuildEventString( AEvent: TVpEvent;
UseAsHint: Boolean ) : String ;
var
timeFmt: String ;
timeStr: String ;
s: String ;
res: TVpResource;
grp: TVpResourceGroup;
isOverlayed: Boolean ;
showDetails: Boolean ;
begin
Result : = '' ;
if ( AEvent = nil ) or ( Datastore = nil ) or ( Datastore. Resource = nil ) then
exit;
grp : = Datastore. Resource. Group;
showDetails : = ( grp < > nil ) and ( odEventDescription in grp. ShowDetails) ;
isOverlayed : = AEvent. IsOverlayed;
timefmt : = GetTimeFormatStr( TimeFormat) ;
if UseAsHint then begin
{ Usage as hint }
if isOverlayed then begin
grp : = Datastore. Resource. Group;
if ( odResource in grp. ShowDetails) then begin
res : = Datastore. Resources. GetResource( AEvent. ResourceID) ;
Result : = RSOverlayed + ': ' + res. Description;
end else
Result : = RSOverlayed;
end else
showDetails : = true ;
timeStr : = IfThen( AEvent. AllDayEvent,
RSAllDay,
FormatDateTime( timeFmt, AEvent. StartTime) + ' - ' + FormatDateTime( timeFmt, AEvent. EndTime)
) ;
Result : = IfThen( Result = '' ,
timeStr,
Result + LineEnding + timeStr
) ;
if showDetails then begin
// Event description
Result : = Result + LineEnding + LineEnding +
RSEvent + ':' + LineEnding + AEvent. Description;
// Event notes
if ( AEvent. Notes < > '' ) then begin
s : = WrapText( AEvent. Notes, MAX_HINT_WIDTH) ;
s : = StripLastLineEnding( s) ;
Result : = Result + LineEnding + LineEnding +
RSNotes + ':' + LineEnding + s;
end ;
// Event location
if ( AEvent. Location < > '' ) then
Result : = Result + LineEnding + LineEnding +
RSLocation + ':' + LineEnding + AEvent. Location;
end ;
end
else
begin
{ Usage as cell text }
if isOverlayed then begin
Result : = '[' + RSOverlayedEvent + '] ' ;
if showDetails then begin
res : = Datastore. Resources. GetResource( AEvent. ResourceID) ;
if res < > nil then
Result : = '[' + res. Description + '] '
end ;
end else
showDetails : = true ;
timeStr : = IfThen( ShowEventTimes, Format( '%s - %s: ' , [
FormatDateTime( timeFmt, AEvent. StartTime) ,
FormatDateTime( timeFmt, AEvent. EndTime)
] ) ) ;
if showDetails then
Result : = IfThen( Result = '' ,
timeStr + AEvent. Description,
Result + timeStr + AEvent. Description)
else
Result : = IfThen( Result = '' ,
timeStr,
Result + timeStr) ;
end ;
end ;
2008-11-10 13:54:49 +00:00
procedure TVpDayView. LoadLanguage;
begin
2016-09-10 20:08:06 +00:00
dvDayUpBtn. Hint : = RSNextDay;
dvDayDownBtn. Hint : = RSPrevDay;
dvTodayBtn. Hint : = RSToday;
dvWeekUpBtn. Hint : = RSNextWeek;
dvWeekDownBtn. Hint : = RSPrevWeek;
2008-11-10 13:54:49 +00:00
FDefaultPopup. Items. Clear;
InitializeDefaultPopup;
end ;
2008-02-03 12:05:55 +00:00
{=====}
procedure TVpDayView. DeleteActiveEvent( Verify: Boolean ) ;
var
DoIt: Boolean ;
begin
2016-06-19 23:40:28 +00:00
if ReadOnly then
2008-02-03 12:05:55 +00:00
Exit;
2016-09-10 19:06:41 +00:00
if ( FActiveEvent < > nil ) and ( not FActiveEvent. CanEdit) then
exit;
2016-07-04 22:09:42 +00:00
2008-02-03 12:05:55 +00:00
dvClickTimer. Enabled : = false ;
EndEdit( self) ;
DoIt : = not Verify;
if FActiveEvent < > nil then begin
if Verify then
2016-06-24 21:55:47 +00:00
DoIt : = ( MessageDlg( RSConfirmDeleteEvent + #13 #10 #10 + RSPermanent,
2016-06-19 23:40:28 +00:00
mtConfirmation, [ mbYes, mbNo] , 0 ) = mrYes) ;
2008-02-03 12:05:55 +00:00
if DoIt then begin
FActiveEvent. Deleted : = true ;
DataStore. PostEvents;
Invalidate;
end ;
end ;
end ;
{=====}
procedure TVpDayView. Invalidate;
begin
inherited ;
end ;
2016-09-22 23:12:16 +00:00
function TVpDayView. IsHoliday( ADate: TDate; out AHolidayName: String ) : Boolean ;
begin
AHolidayName : = '' ;
if Assigned( FOnHoliday) then
FOnHoliday( Self, ADate, AHolidayName) ;
Result : = AHolidayName < > '' ;
end ;
2008-02-03 12:05:55 +00:00
procedure TVpDayView. LinkHandler( Sender: TComponent;
NotificationType: TVpNotificationType; const Value: Variant ) ;
begin
dvInLinkHandler : = true ;
try
case NotificationType of
2016-06-19 23:40:28 +00:00
neDateChange : Date : = Value;
neDataStoreChange : Invalidate;
neInvalidate : Invalidate;
2008-02-03 12:05:55 +00:00
end ;
finally
dvInLinkHandler : = false ;
end ;
end ;
{=====}
procedure TVpDayView. dvHookUp;
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 ;
2016-09-12 22:25:34 +00:00
{ Hint support }
procedure TVpDayView. ShowHintWindow( APoint: TPoint; AEvent: TVpEvent) ;
var
txt: String ;
begin
2017-05-25 21:24:23 +00:00
HideHintWindow;
case FHintMode of
hmPlannerHint:
begin
if ( AEvent = nil ) or ( Datastore = nil ) or ( Datastore. Resource = nil ) then
exit;
txt : = BuildEventString( AEvent, true ) ;
end ;
hmComponentHint:
txt : = FComponentHint;
end ;
if ( txt < > '' ) and not ( csDesigning in ComponentState) and
not ( ( dvInplaceEditor < > nil ) and dvInplaceEditor. Visible) then
2016-09-12 22:25:34 +00:00
begin
2017-05-25 21:24:23 +00:00
Hint : = txt;
2016-09-12 22:25:34 +00:00
Application. Hint : = Hint;
Application. ActivateHint( ClientToScreen( APoint) , true ) ;
end ;
end ;
procedure TVpDayView. HideHintWindow;
begin
2017-05-25 21:24:23 +00:00
Application. CancelHint;
2016-09-12 22:25:34 +00:00
end ;
{ Popup menu }
2008-02-03 12:05:55 +00:00
procedure TVpDayView. InitializeDefaultPopup;
var
2016-06-19 23:40:28 +00:00
NewItem: TMenuItem;
NewSubItem: TMenuItem;
2016-09-10 19:06:41 +00:00
canEdit: Boolean ;
2008-02-03 12:05:55 +00:00
begin
2016-09-10 19:06:41 +00:00
canEdit : = ( FActiveEvent < > nil ) and FActiveEvent. CanEdit;
2016-09-10 17:26:42 +00:00
FDefaultPopup. Items. Clear;
2018-06-15 23:40:18 +00:00
if RSPopupAddEvent < > '' then begin // Add
2016-06-19 23:40:28 +00:00
NewItem : = TMenuItem. Create( Self) ;
2016-09-12 22:25:34 +00:00
NewItem. Caption : = RSPopupAddEvent;
2008-02-03 12:05:55 +00:00
NewItem. OnClick : = PopupAddEvent;
NewItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
FDefaultPopup. Items. Add( NewItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
if RSPopupAddEventFromICal < > '' then begin
NewItem : = TMenuItem. Create( Self) ;
NewItem. Caption : = RSPopupAddEventFromICal; // Import from iCal
NewItem. OnClick : = PopupAddFromICalFile;
NewItem. Tag : = 0 ;
FDefaultPopup. Items. Add( NewItem) ;
end ;
if RSPopupEditEvent < > '' then begin // Edit
2016-06-19 23:40:28 +00:00
NewItem : = TMenuItem. Create( Self) ;
2016-09-12 22:25:34 +00:00
NewItem. Caption : = RSPopupEditEvent;
2016-09-10 19:06:41 +00:00
NewItem. Enabled : = canEdit;
2008-02-03 12:05:55 +00:00
NewItem. OnClick : = PopupEditEvent;
NewItem. Tag : = 1 ;
2016-06-19 23:40:28 +00:00
FDefaultPopup. Items. Add( NewItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
if RSPopupDeleteEvent < > '' then begin // Delete
2016-06-19 23:40:28 +00:00
NewItem : = TMenuItem. Create( Self) ;
2016-09-12 22:25:34 +00:00
NewItem. Caption : = RSPopupDeleteEvent;
2016-09-10 19:06:41 +00:00
NewItem. Enabled : = canEdit;
2008-02-03 12:05:55 +00:00
NewItem. OnClick : = PopupDeleteEvent;
NewItem. Tag : = 1 ;
2016-06-19 23:40:28 +00:00
FDefaultPopup. Items. Add( NewItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
NewItem : = TMenuItem. Create( Self) ; // ----
2016-09-10 19:06:41 +00:00
NewItem. Caption : = '-' ;
FDefaultPopup. Items. Add( NewItem) ;
2018-06-15 23:40:18 +00:00
if RSPopupChangeDate < > '' then begin // Change date >
2016-06-19 23:40:28 +00:00
NewItem : = TMenuItem. Create( Self) ;
2016-09-12 22:25:34 +00:00
NewItem. Caption : = RSPopupChangeDate;
2008-02-03 12:05:55 +00:00
NewItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
FDefaultPopup. Items. Add( NewItem) ;
2008-02-03 12:05:55 +00:00
2018-06-15 23:40:18 +00:00
if RSToday < > '' then begin // Today
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = RSToday;
2008-02-03 12:05:55 +00:00
NewSubItem. OnClick : = PopupToday;
NewSubItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
NewItem. Add( NewSubItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
NewSubItem : = TMenuItem. Create( Self) ; // ---
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = '-' ;
NewItem. Add( NewSubItem) ;
2018-06-15 23:40:18 +00:00
if RSYesterday < > '' then begin // Yesterday
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = RSYesterday;
2008-02-03 12:05:55 +00:00
NewSubItem. OnClick : = PopupYesterday;
NewSubItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
NewItem. Add( NewSubItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
if RSTomorrow < > '' then begin // Tomorrow
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = RSTomorrow;
2008-02-03 12:05:55 +00:00
NewSubItem. OnClick : = PopupTomorrow;
NewSubItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
NewItem. Add( NewSubItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
NewSubItem : = TMenuItem. Create( Self) ; // --
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = '-' ;
NewItem. Add( NewSubItem) ;
2018-06-15 23:40:18 +00:00
if RSNextDay < > '' then begin // Next day
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = RSNextDay;
2008-02-03 12:05:55 +00:00
NewSubItem. OnClick : = PopupNextDay;
NewSubItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
NewItem. Add( NewSubItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
if RSPrevDay < > '' then begin // Prev day
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = RSPrevDay;
2008-02-03 12:05:55 +00:00
NewSubItem. OnClick : = PopupPrevDay;
NewSubItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
NewItem. Add( NewSubItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
NewSubItem : = TMenuItem. Create( Self) ; // ---
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = '-' ;
NewItem. Add( NewSubItem) ;
2018-06-15 23:40:18 +00:00
if RSNextWeek < > '' then begin // Next week
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = RSNextWeek;
2008-02-03 12:05:55 +00:00
NewSubItem. OnClick : = PopupNextWeek;
NewSubItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
NewItem. Add( NewSubItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
if RSPrevWeek < > '' then begin // Prev week
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = RSPrevWeek;
2008-02-03 12:05:55 +00:00
NewSubItem. OnClick : = PopupPrevWeek;
NewSubItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
NewItem. Add( NewSubItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
NewSubItem : = TMenuItem. Create( Self) ; // ---
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = '-' ;
NewItem. Add( NewSubItem) ;
2018-06-15 23:40:18 +00:00
if RSNextMonth < > '' then begin // Next month
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = RSNextMonth;
2008-02-03 12:05:55 +00:00
NewSubItem. OnClick : = PopupNextMonth;
NewSubItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
NewItem. Add( NewSubItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
if RSPrevMonth < > '' then begin // Prev Month
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = RSPrevMonth;
2008-02-03 12:05:55 +00:00
NewSubItem. OnClick : = PopupPrevMonth;
NewSubItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
NewItem. Add( NewSubItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
NewSubItem : = TMenuItem. Create( Self) ; // ---
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = '-' ;
NewItem. Add( NewSubItem) ;
2018-06-15 23:40:18 +00:00
if RSNextYear < > '' then begin // Next year
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = RSNextYear;
2008-02-03 12:05:55 +00:00
NewSubItem. OnClick : = PopupNextYear;
NewSubItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
NewItem. Add( NewSubItem) ;
2008-02-03 12:05:55 +00:00
end ;
2018-06-15 23:40:18 +00:00
if RSPrevYear < > '' then begin // Prev year
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2016-09-10 20:08:06 +00:00
NewSubItem. Caption : = RSPrevYear;
2008-02-03 12:05:55 +00:00
NewSubItem. OnClick : = PopupPrevYear;
NewSubItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
NewItem. Add( NewSubItem) ;
2008-02-03 12:05:55 +00:00
end ;
end ;
2016-09-10 17:26:42 +00:00
if ( Datastore < > nil ) and ( Datastore. Resource < > nil ) then
AddResourceGroupMenu( FDefaultPopup. Items, Datastore. Resource, PopupPickResourceGroupEvent) ;
2008-02-03 12:05:55 +00:00
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupAddEvent( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
var
2016-06-19 23:40:28 +00:00
StartTime: TDateTime;
EndTime: TDateTime;
2008-02-03 12:05:55 +00:00
begin
2018-06-15 23:40:18 +00:00
if ReadOnly or ( not CheckCreateResource) or
( not Assigned( DataStore) ) or ( not Assigned( DataStore. Resource) )
then
2008-02-03 12:05:55 +00:00
Exit;
2016-06-19 23:40:28 +00:00
StartTime : = trunc( FDisplayDate + ActiveCol) + dvLineMatrix[ ActiveCol, ActiveRow] . Time;
2018-05-15 09:08:53 +00:00
EndTime : = StartTime + dvTimeIncSize * FRowLinesStep;
2016-06-19 23:40:28 +00:00
FActiveEvent : = DataStore. Resource. Schedule. AddEvent(
DataStore. GetNextID( EventsTableName) ,
StartTime,
EndTime
) ;
Repaint;
2018-06-15 23:40:18 +00:00
2008-02-03 12:05:55 +00:00
{ edit this new event }
dvSpawnEventEditDialog( True ) ;
end ;
2018-06-15 23:40:18 +00:00
procedure TVpDayView. PopupAddFromICalFile( Sender: TObject) ;
var
dlg: TOpenDialog;
ical: TVpICalendar;
fn: String ;
i: Integer ;
id: Integer ;
startTime, endTime: TDateTime;
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-15 23:40:18 +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 TVpICalEvent) then
Continue;
startTime : = TVpICalEvent( ical[ i] ) . StartTime[ false ] ; // use local times
endTime : = TVpICalEvent( ical[ i] ) . EndTime[ false ] ;
if ( startTime = 0 ) and ( endTime = 0 ) then
continue;
id : = DataStore. GetNextID( EventsTableName) ;
FActiveEvent : = Datastore. Resource. Schedule. AddEvent( id, starttime, endtime) ;
2018-06-18 21:54:25 +00:00
FActiveEvent. Changed : = true ;
2018-06-15 23:40:18 +00:00
FActiveEvent. LoadFromICalendar( TVpICalEvent( ical[ i] ) ) ;
Datastore. PostEvents;
Datastore. NotifyDependents;
end ;
end ;
Invalidate;
finally
ical. Free;
Screen. Cursor : = crDefault;
end ;
end ;
finally
dlg. Free;
end ;
end ;
2008-02-03 12:05:55 +00:00
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupDeleteEvent( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
begin
2016-06-19 23:40:28 +00:00
if ReadOnly then
Exit;
Repaint;
2008-02-03 12:05:55 +00:00
if FActiveEvent < > nil then
DeleteActiveEvent ( True ) ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupEditEvent( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
begin
2016-06-19 23:40:28 +00:00
if ReadOnly then
Exit;
Repaint;
2008-02-03 12:05:55 +00:00
if FActiveEvent < > nil then
{ edit this Event }
dvSpawnEventEditDialog( False ) ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupToday( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
begin
Date : = Now;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupTomorrow( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
begin
Date : = Now + 1 ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupYesterday( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
begin
Date : = Now - 1 ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupNextDay( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
begin
Date : = Date + 1 ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupPrevDay( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
begin
Date : = Date - 1 ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupNextWeek( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
begin
Date : = Date + 7 ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupPrevWeek( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
begin
Date : = Date - 7 ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupNextMonth( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
var
2016-06-19 23:40:28 +00:00
M, D, Y: Word ;
2008-02-03 12:05:55 +00:00
begin
DecodeDate( Date, Y, M, D) ;
if M = 1 2 then begin
M : = 1 ;
Y : = Y + 1 ;
end else
M : = M + 1 ;
2016-09-17 15:48:39 +00:00
if ( D > DaysInAMonth( Y, M) ) then
D : = DaysInAMonth( Y, M) ;
2008-02-03 12:05:55 +00:00
Date : = EncodeDate( Y, M, D) ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupPrevMonth( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
var
2016-06-19 23:40:28 +00:00
M, D, Y: Word ;
2008-02-03 12:05:55 +00:00
begin
DecodeDate( Date, Y, M, D) ;
if M = 1 then begin
M : = 1 2 ;
Y : = Y - 1 ;
end else
M : = M - 1 ;
2016-09-17 15:48:39 +00:00
if ( D > DaysInAMonth( Y, M) ) then
D : = DaysInAMonth( Y, M) ;
2008-02-03 12:05:55 +00:00
Date : = EncodeDate( Y, M, D) ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupNextYear( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
var
M, D, Y : Word ;
begin
2016-06-19 23:40:28 +00:00
DecodeDate( Date, Y, M, D) ;
Date : = EncodeDate( Y + 1 , M, 1 ) ;
2008-02-03 12:05:55 +00:00
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. PopupPrevYear( Sender: TObject) ;
2008-02-03 12:05:55 +00:00
var
2016-06-19 23:40:28 +00:00
M, D, Y: Word ;
2008-02-03 12:05:55 +00:00
begin
2016-06-19 23:40:28 +00:00
DecodeDate( Date, Y, M, D) ;
Date : = EncodeDate( Y - 1 , M, 1 ) ;
2008-02-03 12:05:55 +00:00
end ;
{=====}
2016-09-10 17:26:42 +00:00
procedure TVpDayView. PopupPickResourceGroupEvent( Sender: TObject) ;
begin
2016-09-10 18:27:50 +00:00
Datastore. Resource. Group : = TVpResourceGroup( TMenuItem( Sender) . Tag) ;
2016-09-10 17:26:42 +00:00
Datastore. UpdateGroupEvents;
end ;
procedure TVpDayView. PopupDropDownEvent( Sender: TObject) ;
begin
InitializeDefaultPopup;
end ;
2008-02-03 12:05:55 +00:00
procedure TVpDayView. Loaded;
begin
inherited ;
TopHour : = DefaultTopHour;
dvLoaded : = true ;
dvPopulate;
end ;
{=====}
procedure TVpDayView. Paint;
begin
2016-06-19 23:40:28 +00:00
RenderToCanvas( Canvas, Rect( 0 , 0 , Width, Height) , ra0, 1 , FDisplayDate,
TopLine, - 1 , FGranularity, False ) ;
2008-02-03 12:05:55 +00:00
SetVScrollPos;
end ;
{=====}
procedure TVpDayView. dvPopulate;
begin
if DataStore < > nil then
DataStore. Date : = FDisplayDate;
end ;
{=====}
procedure TVpDayView. dvNavButtonsClick( Sender: TObject) ;
begin
{ set the value of Date based on which button was pressed. }
if Sender = dvDayUpBtn then
Date : = Date + 1
else if Sender = dvDayDownBtn then
Date : = Date - 1
else if Sender = dvTodayBtn then
Date : = trunc( Now)
else if Sender = dvWeekUpBtn then
Date : = Date + 7
else if Sender = dvWeekDownBtn then
Date : = Date - 7 ;
end ;
{=====}
2018-05-17 08:09:21 +00:00
function TVpDayView. dvCalcVisibleLines( RenderHeight, ColHeadHeight, ARowHeight: Integer ;
2016-06-19 23:40:28 +00:00
Scale: Extended ; StartLine, StopLine: Integer ) : Integer ;
2008-02-03 12:05:55 +00:00
var
vertical: integer ;
2016-07-12 18:00:32 +00:00
d: Integer = 0 ; // d = result of "div"
m: Integer = 0 ; // m = result of "mod"
2008-02-03 12:05:55 +00:00
begin
if StartLine < 0 then
StartLine : = TopLine;
{ take into account the number lines that are allowed! }
2016-07-05 22:21:02 +00:00
// vertical := Round(RenderHeight - ColHeadHeight * Scale - 2);
vertical : = Round( RenderHeight - ColHeadHeight * Scale) ;
2018-05-17 08:09:21 +00:00
DivMod( Vertical, ARowHeight, d, m) ;
2016-07-05 22:21:02 +00:00
Result : = d + ord( m < > 0 ) ;
{
2018-05-17 08:09:21 +00:00
if Vertical mod ARowHeight = 0 then
2016-07-05 22:21:02 +00:00
Result : =
2018-05-17 08:09:21 +00:00
Result : = Vertical div ARowHeight + 1 ; // - 4; //+2;
2016-07-05 22:21:02 +00:00
}
2008-02-03 12:05:55 +00:00
if Result > FLineCount then
2016-07-02 15:44:34 +00:00
Result : = FLineCount;
2008-02-03 12:05:55 +00:00
2016-07-05 22:21:02 +00:00
if ( StopLine > 0 ) and ( StopLine > StartLine) and ( Result > Stopline- StartLine) then
Result : = StopLine - StartLine + 1 ;
{
2008-02-03 12:05:55 +00:00
if ( StopLine > 0 ) and ( StopLine > StartLine) then
if Result > StopLine - StartLine then
Result : = StopLine - StartLine + 2 ;
2016-07-05 22:21:02 +00:00
}
2008-02-03 12:05:55 +00:00
FVisibleLines : = Result ;
end ;
{=====}
procedure TVpDayView. SetColor( Value: TColor) ;
begin
if FColor < > Value then begin
FColor : = Value;
Invalidate;
end ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
function TVpDayView. dvCalcColHeadHeight( Scale: Extended ) : Integer ;
2008-02-03 12:05:55 +00:00
var
2016-06-19 23:40:28 +00:00
TextHeight: Integer ;
2018-05-15 19:47:29 +00:00
glyphHeights: Integer ;
2008-02-03 12:05:55 +00:00
begin
2016-06-19 23:40:28 +00:00
Canvas. Font. Assign( FHeadAttr. Font) ;
2016-08-08 18:29:24 +00:00
Canvas. Font. Size : = ScaleY( Canvas. Font. Size, DesignTimeDPI) ;
2008-02-03 12:05:55 +00:00
2016-06-20 14:21:33 +00:00
if FShowResourceName and ( DataStore < > nil ) and ( DataStore. Resource < > nil ) then
2016-07-04 20:30:36 +00:00
TextHeight : = Canvas. TextHeight( TallShortChars) * 2 + TextMargin * 3
2008-02-03 12:05:55 +00:00
else
2016-07-04 20:30:36 +00:00
TextHeight : = Canvas. TextHeight( TallShortChars) + TextMargin * 2 ;
2016-06-19 23:40:28 +00:00
Result : = Round( TextHeight * Scale) ;
2018-05-15 19:47:29 +00:00
if Assigned( dvTodayBtn. Glyph) then begin
glyphHeights : = dvDayUpBtn. Glyph. Height + dvTodayBtn. Glyph. Height + 6 ;
if Result < glyphHeights then Result : = glyphHeights;
end ;
2008-02-03 12:05:55 +00:00
dvColHeadHeight : = Result ;
end ;
{=====}
procedure TVpDayView. DoStartDrag( var DragObject: TDragObject) ;
2016-08-26 13:33:45 +00:00
{$IFDEF LCL}
var
P, HotSpot: TPoint;
EventName: string ;
{$ENDIF}
begin
2008-02-03 12:05:55 +00:00
DvDragStartTime : = 0.0 ;
2016-08-26 13:33:45 +00:00
if ReadOnly or not FAllowDragAndDrop then
2008-02-03 12:05:55 +00:00
Exit;
if FActiveEvent < > nil then begin
2008-02-11 01:09:19 +00:00
// Set the time from which this event was dragged
2016-08-26 13:33:45 +00:00
2016-06-19 23:40:28 +00:00
DvDragStartTime : = trunc( Date + ActiveCol) + dvLineMatrix[ ActiveCol, ActiveRow] . Time;
2008-02-03 12:05:55 +00:00
2016-08-26 13:33:45 +00:00
{$IFDEF LCL}
EventName : = FActiveEvent. Description;
2016-11-21 17:12:05 +00:00
GetCursorPos( P{%H-} ) ;
2016-08-26 13:33:45 +00:00
P : = TVpDayView( Self) . ScreenToClient( P) ;
HotSpot : = Point( P. X - Self. dvActiveEventRec. Left, P. Y - Self. dvActiveEventRec. Top) ;
DragObject : = TVpEventDragObject. CreateWithDragImages( Self as TControl,
HotSpot, Self. dvActiveEventRec, EventName, FDragDropTransparent) ;
{$ELSE}
DragObject : = DragObject : = TVpEventDragObject. Create( Self) ;
{$ENDIF}
2008-02-03 12:05:55 +00:00
TVpEventDragObject( DragObject) . Event : = FActiveEvent;
end
else
2016-08-26 13:33:45 +00:00
{$IFDEF LCL}
CancelDrag;
{$ELSE}
2008-02-07 23:08:26 +00:00
DragObject. Free; //EndDrag(false);
2016-08-26 13:33:45 +00:00
{$ENDIF}
2008-02-03 12:05:55 +00:00
end ;
{=====}
procedure TVpDayView. DoEndDrag( Target: TObject; X, Y: Integer ) ;
2016-08-26 13:33:45 +00:00
begin
2016-11-21 17:12:05 +00:00
Unused( Target, X, Y) ;
2016-08-26 13:33:45 +00:00
if ReadOnly or ( not FAllowDragAndDrop) then
2008-02-03 12:05:55 +00:00
Exit;
2016-08-26 13:33:45 +00:00
{$IFNDEF LCL}
2008-02-03 12:05:55 +00:00
TVpEventDragObject( Target) . Free;
2016-08-26 13:33:45 +00:00
{$ENDIF}
// not needed for LCL: we use DragObjectEx !!
2008-02-03 12:05:55 +00:00
end ;
{=====}
procedure TVpDayView. DragOver( Source: TObject; X, Y: Integer ; State: TDragState;
var Accept: Boolean ) ;
2016-08-26 13:33:45 +00:00
begin
2016-11-21 17:12:05 +00:00
Unused( Source, State) ;
2016-08-26 13:33:45 +00:00
if ReadOnly or ( not FAllowDragAndDrop) then begin
2008-02-03 12:05:55 +00:00
Accept : = False ;
Exit;
end ;
if ( X > dvRowHeadWidth + GutterWidth) and ( Y > dvColHeadHeight) then begin
{ The mouse is dragging over the client area }
dvSetActiveColByCoord( Point( X, Y) ) ;
dvSetActiveRowByCoord( Point( X, Y) , False ) ;
Accept : = true ;
end else
Accept : = false ;
end ;
{=====}
procedure TVpDayView. DragDrop( Source: TObject; X, Y: Integer ) ;
var
2016-06-19 23:40:28 +00:00
Event: TVpEvent;
Duration: TDateTime;
DragToTime: TDateTime;
i: Integer ;
2016-08-26 13:33:45 +00:00
begin
2016-11-21 17:12:05 +00:00
Unused( X, Y) ;
2016-08-26 13:33:45 +00:00
if ReadOnly or ( not FAllowDragAndDrop) then
2008-02-03 12:05:55 +00:00
Exit;
2016-08-26 13:33:45 +00:00
Event : = TVpEventDragObject( Source) . Event;
2008-02-03 12:05:55 +00:00
if Event < > nil then begin
Duration : = Event. EndTime - Event. StartTime;
2016-09-03 17:41:24 +00:00
DragToTime : = trunc( Date + ActiveCol) + dvLineMatrix[ ActiveCol, ActiveRow] . Time;
2008-02-03 12:05:55 +00:00
if Ord( Event. RepeatCode) = 0 then
2016-08-26 13:33:45 +00:00
{ if this is not a recurring event then just drop it here }
2008-02-03 12:05:55 +00:00
Event. StartTime : = DragToTime
else
2016-08-26 13:33:45 +00:00
{ if this is a recurring event, then modify the event' s start time
according to how far the event was dragged }
2008-02-03 12:05:55 +00:00
Event. StartTime : = Event. StartTime + ( DragToTime - DvDragStartTime) ;
Event. EndTime : = Event. StartTime + Duration;
DataStore. PostEvents;
2016-08-26 13:33:45 +00:00
{ Force a repaint. This will update the rectangles for the event }
2016-06-19 23:40:28 +00:00
Repaint;
2008-02-03 12:05:55 +00:00
{ Reset the active event rectangle }
2016-06-19 23:40:28 +00:00
for I : = 0 to pred( Length( dvEventArray) ) do begin
if dvEventArray[ I] . Event = nil then
Break;
if dvEventArray[ i] . Event = Event then begin
dvActiveEventRec : = dvEventArray[ I] . Rec;
dvActiveIconRec : = dvEventArray[ I] . IconRect;
Break;
end ;
end ;
2008-02-03 12:05:55 +00:00
2016-08-26 13:33:45 +00:00
{ Invalidate; }
2008-02-03 12:05:55 +00:00
end ;
2008-02-07 23:08:26 +00:00
// TVpEventDragObject(Source).EndDrag(False);
2008-02-03 12:05:55 +00:00
end ;
{=====}
2016-06-19 23:40:28 +00:00
function TVpDayView. dvCalcRowHeight( Scale: Extended ;
UseGran: TVpGranularity) : Integer ;
2008-02-03 12:05:55 +00:00
var
2016-06-19 23:40:28 +00:00
SaveFont: TFont;
Temp: Integer ;
2008-02-03 12:05:55 +00:00
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;
Canvas. Font. Assign( FRowHeadAttr. FMinuteFont) ;
2016-08-08 18:29:24 +00:00
Canvas. Font. Size : = ScaleY( Canvas. Font. Size, DesignTimeDPI) ;
2016-07-02 22:46:05 +00:00
Canvas. Font. Height : = GetRealFontHeight( Canvas. Font) ;
2016-07-04 20:30:36 +00:00
Result : = 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 > Result then
Result : = Temp;
2018-05-15 09:08:53 +00:00
if FCustomRowHeight = 0 then
Result : = Result + TextMargin * 2
else
Result : = FCustomRowHeight;
2008-02-03 12:05:55 +00:00
2016-06-19 23:40:28 +00:00
Result : = Round( Result * Scale) ;
2016-06-20 11:00:59 +00:00
dvClientVArea : = Result * MinutesInDay div GranularityMinutes[ UseGran] ;
2008-02-03 12:05:55 +00:00
dvRowHeight : = Result ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
2016-06-20 14:21:33 +00:00
function TVpDayView. GetLastVisibleDate: TDateTime;
2016-06-19 23:40:28 +00:00
begin
Result : = Date + GetRealNumDays( Date) ;
end ;
2008-02-03 12:05:55 +00:00
{=====}
2016-06-19 23:40:28 +00:00
function TVpDayView. GetRealNumDays( WorkDate: TDateTime) : Integer ;
var
i: Integer ;
begin
if not FIncludeWeekends then begin
Result : = 0 ;
i : = 0 ;
while i < FNumDays do begin
2016-07-04 20:30:36 +00:00
if ( DayOfWeek( WorkDate) < > 1 ) and ( DayOfWeek( WorkDate) < > 7 ) then
2016-06-19 23:40:28 +00:00
Inc( i) ;
WorkDate : = WorkDate + 1 ;
2016-09-22 23:12:16 +00:00
Inc( Result ) ;
2016-06-19 23:40:28 +00:00
end ;
end else
Result : = FNumDays;
end ;
2008-02-03 12:05:55 +00:00
{=====}
procedure TVpDayView. SetDrawingStyle( Value: TVpDrawingStyle) ;
begin
if FDrawingStyle < > Value then begin
FDrawingStyle : = Value;
Repaint;
end ;
end ;
{=====}
procedure TVpDayView. SetLineColor( Value: TColor) ;
begin
if FLineColor < > Value then begin
FLineColor : = Value;
Repaint;
end ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. SetTopHour( Value: TVpHours) ;
2008-02-03 12:05:55 +00:00
begin
if FTopHour < > Value then begin
FTopHour : = Value;
2016-06-19 23:40:28 +00:00
TopLine : = HourToLine( FTopHour, FGranularity) ;
2008-02-03 12:05:55 +00:00
end ;
end ;
{=====}
procedure TVpDayView. SetTopLine( Value: Integer ) ;
begin
if Value < > FTopLine then begin
if Value + VisibleLines > = pred( LineCount) then begin
2016-07-01 13:21:43 +00:00
// FTopLine := pred(LineCount) - VisibleLines + 2; // why +2?
FTopLine : = pred( LineCount) - VisibleLines;
if FTopLine < 0 then FTopLine : = 0 ;
2008-02-03 12:05:55 +00:00
{ prevent the control from hanging at the bottom }
if ( Value < FTopLine) and ( Value > 0 ) then
FTopLine : = Value;
end
else if Value < 0 then
FTopLine : = 0
else
FTopLine : = Value;
Invalidate;
SetVScrollPos;
end ;
end ;
{=====}
procedure TVpDayView. SetDateLabelFormat( Value: string ) ;
begin
if Value < > FDateLabelFormat then begin
FDateLabelFormat : = Value;
Invalidate;
end ;
end ;
{=====}
procedure TVpDayView. SetGutterWidth( Value: Integer ) ;
begin
2016-06-19 23:40:28 +00:00
if ( Value < > FGutterWidth) and ( Value > - 1 ) and ( Value < Width div 1 0 ) then
begin
2008-02-03 12:05:55 +00:00
FGutterWidth : = Value;
Invalidate;
end ;
end ;
{=====}
procedure TVpDayView. SetDefTopHour( Value: TVpHours) ;
begin
if Value < > FDefTopHour then begin
FDefTopHour : = Value;
if csDesigning in ComponentState then
TopHour : = Value;
end ;
end ;
{=====}
2016-06-19 23:40:28 +00:00
procedure TVpDayView. SetTimeIntervals( UseGran: TVpGranularity) ;
2008-02-03 12:05:55 +00:00
var
2016-06-19 23:40:28 +00:00
I, J: Integer ;
2016-06-20 10:21:06 +00:00
grPerHour: Integer ;
2008-02-03 12:05:55 +00:00
begin
2016-06-20 10:21:06 +00:00
FLineCount : = MinutesInDay div GranularityMinutes[ UseGran] ;
dvTimeIncSize : = GranularityMinutes[ UseGran] / MinutesInDay;
grPerHour : = 6 0 div GranularityMinutes[ UseGran] ;
2008-02-03 12:05:55 +00:00
SetLength( dvLineMatrix, NumDays) ;
for I : = 0 to pred( NumDays) do begin
2016-07-02 15:44:34 +00:00
SetLength( dvLineMatrix[ I] , LineCount + 1 ) ; // was +1. Why? Without it, the IDE crashes! - there is an upper loop index of LineCount in DrawCells. After correcting that, the crash is gone.
// wp: the additional line is needed to fully display the last line of the day.
2008-02-03 12:05:55 +00:00
for J : = 0 to pred( LineCount) do begin
2016-06-20 10:21:06 +00:00
dvLineMatrix[ I, J] . Hour : = TVpHours( J div grPerHour) ;
dvLineMatrix[ I, J] . Minute : = ( J mod grPerHour) * GranularityMinutes[ UseGran] ;
dvLineMatrix[ I, J] . Time : = ord( dvLineMatrix[ I, J] . Hour) / 2 4 + dvTimeIncSize * ( J mod grPerHour) ;
end ;
end ;
2008-02-03 12:05:55 +00:00
if FLineCount < = FVisibleLines then
2016-06-19 23:40:28 +00:00
FTopLine : = HourToLine( h_00, FGranularity) ;
2008-02-03 12:05:55 +00:00
SetVScrollPos;
end ;
procedure TVpDayView. SetGranularity( Value: TVpGranularity) ;
begin
FGranularity : = Value;
2016-07-01 13:21:43 +00:00
SetTimeIntervals( FGranularity) ;
2016-06-20 11:00:59 +00:00
FTopLine : = HourToLine( FTopHour, FGranularity) ;
2016-07-01 13:21:43 +00:00
if dvRowHeight < > 0 then
dvCalcVisibleLines( Height, dvColHeadHeight, dvRowHeight, 1 , FTopLine, - 1 ) ;
if ( FGranularity = gr60Min) and ( FVisibleLines = LineCount) then
FTopLine : = 0 ;
2008-02-03 12:05:55 +00:00
Invalidate;
end ;
{=====}
procedure TVpDayView. SetTimeFormat( Value: TVpTimeFormat) ;
begin
if Value < > FTimeFormat then begin
FTimeFormat : = Value;
Invalidate;
end ;
end ;
{=====}
procedure TVpDayView. SetDisplayDate( Value: TDateTime) ;
begin
2018-05-15 09:08:53 +00:00
if ( not FFixedDate) and ( FDisplayDate < > Value) then begin
2008-02-03 12:05:55 +00:00
EndEdit( self) ;
FDisplayDate : = Value;
if dvLoaded then
dvPopulate;
Invalidate;
if ( not dvInLinkHandler) and ( ControlLink < > nil ) then
ControlLink. Notify( self, neDateChange, Date) ;
end ;
end ;
{=====}
{$IFNDEF LCL}
procedure TVpDayView. WMSize( var Msg: TWMSize) ;
{$ELSE}
procedure TVpDayView. WMSize( var Msg: TLMSize) ;
{$ENDIF}
var
MaxLinesToDraw: Integer ;
EmptyLines: Integer ;
begin
inherited ;
2016-06-20 14:21:33 +00:00
2008-02-03 12:05:55 +00:00
{ How many lines are there between TopLine and the last line of the day. }
MaxLinesToDraw : = Length( dvLineMatrix[ 0 ] ) - TopLine;
EmptyLines : = FVisibleLines - MaxLinesToDraw;
if EmptyLines > 0 then
TopLine : = TopLine - EmptyLines
else
Invalidate;
end ;
{=====}
procedure TVpDayView. CreateParams( var Params: TCreateParams) ;
begin
inherited CreateParams( Params) ;
with Params do
begin
Style : = Style or WS_TABSTOP;
if FScrollBars in [ ssVertical, ssBoth] then Style : = Style or WS_VSCROLL;
if FScrollBars in [ ssHorizontal, ssBoth] then Style : = Style or WS_HSCROLL;
{$IFNDEF LCL}
WindowClass. style : = CS_DBLCLKS;
{$ENDIF}
end ;
end ;
{=====}
procedure TVpDayView. CreateWnd;
begin
inherited ;
2008-02-07 16:22:04 +00:00
PostMessage ( Handle, Vp_DayViewInit, 0 , 0 ) ;
2008-02-03 12:05:55 +00:00
end ;
2016-09-12 22:25:34 +00:00
procedure TVpDayView. MouseEnter;
begin
FMouseEvent : = nil ;
end ;
procedure TVpDayView. MouseLeave;
begin
HideHintWindow;
end ;
2016-06-20 14:21:33 +00:00
procedure TVpDayView. MouseUp( Button: TMouseButton; Shift: TShiftState;
X, Y: Integer ) ;
2008-02-07 23:08:26 +00:00
begin
inherited MouseUp( Button, Shift, X, Y) ;
if Button = mbLeft then
begin
2016-06-18 12:09:16 +00:00
dvMouseDownPoint : = Point( 0 , 0 ) ;
dvMouseDown : = false ;
dvDragging : = false ;
2008-02-07 23:08:26 +00:00
end
else
begin
end ;
end ;
2008-02-03 12:05:55 +00:00
2008-02-07 23:08:26 +00:00
procedure TVpDayView. MouseMove( Shift: TShiftState; X, Y: Integer ) ;
2016-09-12 22:25:34 +00:00
var
event: TVpEvent;
2008-02-07 23:08:26 +00:00
begin
inherited MouseMove( Shift, X, Y) ;
if ( FActiveEvent < > nil ) and ( not ReadOnly ) then begin
2016-08-26 13:33:45 +00:00
if ( not dvDragging) and dvMouseDown and
2016-09-10 19:06:41 +00:00
( ( dvMouseDownPoint. x < > x) or ( dvMouseDownPoint. y < > y) ) and
FActiveEvent. CanEdit
2008-02-07 23:08:26 +00:00
then begin
dvDragging : = true ;
dvClickTimer. Enabled : = false ;
BeginDrag( true ) ;
end ;
end ;
2016-09-12 22:25:34 +00:00
if ShowHint then
begin
event : = GetEventAtCoord( Point( X, Y) ) ;
2017-05-25 21:24:23 +00:00
if event = nil then
HideHintWindow
else
2016-09-12 22:25:34 +00:00
if FMouseEvent < > event then begin
2017-05-25 21:24:23 +00:00
// HideHintWindow;
2016-09-12 22:25:34 +00:00
ShowHintWindow( Point( X, Y) , event) ;
FMouseEvent : = event;
end ;
end ;
2008-02-03 12:05:55 +00:00
end ;
2016-06-20 14:21:33 +00:00
procedure TVpDayView. MouseDown( Button: TMouseButton; Shift: TShiftState;
X, Y: Integer ) ;
2008-02-03 12:05:55 +00:00
var
2016-06-20 14:21:33 +00:00
i: Integer ;
2008-02-03 12:05:55 +00:00
begin
2008-02-07 23:08:26 +00:00
inherited MouseDown( Button, Shift, X, Y) ;
if Button = mbLeft then
2016-06-26 11:37:20 +00:00
begin
dvMouseDownPoint : = Point( x, y) ;
dvMouseDown : = true ;
2008-02-07 23:08:26 +00:00
2016-06-26 11:37:20 +00:00
{ if the mouse was pressed down in the client area, then select the cell. }
if not focused then SetFocus;
2008-02-07 23:08:26 +00:00
2016-06-26 11:37:20 +00:00
if ( x > dvRowHeadWidth - 9 ) and ( y > dvColHeadHeight) then
2008-02-07 23:08:26 +00:00
begin
2016-06-26 11:37:20 +00:00
{ The mouse click landed inside the client area }
dvSetActiveColByCoord( Point( x, y) ) ;
dvSetActiveRowByCoord( Point( x, y) , True ) ;
if not ReadOnly then
EditEventAtCoord( Point( x, y) ) ;
end else
if y > dvColHeadHeight then
dvSetActiveRowByCoord( Point ( x, y) , True ) ;
2008-02-03 12:05:55 +00:00
2016-06-26 11:37:20 +00:00
if Assigned( OnClick) then
OnClick( self) ;
end
else begin
2016-06-28 16:50:32 +00:00
if not Focused then
2016-06-26 11:37:20 +00:00
SetFocus;
2008-02-03 12:05:55 +00:00
2016-06-26 11:37:20 +00:00
if ( x > dvRowHeadWidth - 9 ) and ( y > dvColHeadHeight) then
begin
{ The mouse click landed inside the client area }
dvSetActiveColByCoord( Point( x, y) ) ;
dvSetActiveRowByCoord( Point( x, y) , True ) ;
end ;
2008-02-03 12:05:55 +00:00
2016-06-26 11:37:20 +00:00
EditEventAtCoord( Point ( x, y) ) ;
dvClickTimer. Enabled : = false ;
2008-02-03 12:05:55 +00:00
2016-06-28 16:50:32 +00:00
if not Assigned( FActiveEvent) then
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-06-26 11:37:20 +00:00
end ;
2008-02-03 12:05:55 +00:00
end ;
{=====}
{$IFNDEF LCL}
2016-06-20 14:21:33 +00:00
procedure TVpDayView. WMLButtonDblClk( var Msg: TWMLButtonDblClk) ;
2008-02-03 12:05:55 +00:00
{$ELSE}
2016-06-20 14:21:33 +00:00
procedure TVpDayView. WMLButtonDblClk( var Msg: TLMLButtonDblClk) ;
2008-02-03 12:05:55 +00:00
{$ENDIF}
var
StartTime, EndTime: TDateTime;
begin
inherited ;
dvClickTimer. Enabled : = false ;
2016-08-26 15:45:53 +00:00
dvMouseDownPoint : = Point( 0 , 0 ) ;
dvMouseDown : = false ;
dvDragging : = false ;
2008-02-03 12:05:55 +00:00
{ if the mouse was pressed down in the client area, then select the cell. }
if not focused then SetFocus;
if ( Msg. XPos > dvRowHeadWidth - 9 ) and ( Msg. YPos > dvColHeadHeight) then
begin
{ The mouse click landed inside the client area }
2016-06-20 14:21:33 +00:00
dvSetActiveRowByCoord( Point( Msg. XPos, Msg. YPos) , True ) ;
2008-02-03 12:05:55 +00:00
{ See if we hit an active event }
if ( FActiveEvent < > nil ) and ( not ReadOnly ) then begin
{ edit this event }
dvSpawnEventEditDialog( False ) ;
end else if not ReadOnly then begin
2016-06-20 14:21:33 +00:00
if not CheckCreateResource then
Exit;
2008-02-03 12:05:55 +00:00
if ( DataStore = nil ) or ( DataStore. Resource = nil ) then
Exit;
{ otherwise, we must want to create a new event }
StartTime : = trunc( FDisplayDate + ActiveCol)
+ dvLineMatrix[ ActiveCol, ActiveRow] . Time;
2018-05-15 09:08:53 +00:00
EndTime : = StartTime + dvTimeIncSize * FRowLinesStep;
2008-02-03 12:05:55 +00:00
FActiveEvent : = DataStore. Resource. Schedule. AddEvent(
DataStore. GetNextID( EventsTableName) , StartTime, EndTime) ;
{ edit this new event }
dvSpawnEventEditDialog( True ) ;
end ;
end ;
end ;
{=====}
2016-06-12 15:29:23 +00:00
{$IFDEF LCL}
function TVpDayView. DoMouseWheel( Shift: TShiftState; WheelDelta: Integer ;
MousePos: TPoint) : Boolean ;
begin
Result : = inherited DoMouseWheel( Shift, WheelDelta, MousePos) ;
end ;
function TVpDayView. DoMouseWheelDown( Shift: TShiftState;
MousePos: TPoint) : Boolean ;
var
delta: Integer ;
begin
Result : = inherited DoMouseWheelDown( Shift, MousePos) ;
if not Result then begin
if [ ssCtrl, ssShift] * Shift < > [ ] then begin
delta : = HourToLine( h_01, FGranularity) ;
if delta = 1 then delta : = 3 ;
end else
delta : = 1 ;
dvScrollVertical( delta) ;
Result : = True ;
end ;
end ;
function TVpDayView. DoMouseWheelUp( Shift: TShiftState;
MousePos: TPoint) : Boolean ;
var
delta: Integer ;
begin
Result : = inherited DoMouseWheelUp( Shift, MousePos) ;
if not Result then begin
if [ ssCtrl, ssShift] * Shift < > [ ] then begin
delta : = HourToLine( h_01, FGranularity) ;
if delta = 1 then delta : = 3 ;
end else
delta : = 1 ;
dvScrollVertical( - delta) ;
Result : = True ;
end ;
end ;
{$ENDIF}
2018-06-12 16:40:51 +00:00
procedure TVpDayView. EditSelectedEvent( IsNewEvent: Boolean = false ) ;
2008-02-03 12:05:55 +00:00
begin
if ReadOnly then
Exit;
if FActiveEvent < > nil then
2018-06-12 16:40:51 +00:00
dvSpawnEventEditDialog( IsNewEvent) ;
2008-02-03 12:05:55 +00:00
end ;
{=====}
2018-05-17 16:35:44 +00:00
procedure TVpDayView. dvSpawnEventEditDialog( IsNewEvent: Boolean ) ;
2008-02-03 12:05:55 +00:00
var
AllowIt: Boolean ;
EventDlg : TVpEventEditDialog;
begin
if ( DataStore = nil ) or ( DataStore. Resource = nil ) or ReadOnly then
Exit;
2018-05-17 16:35:44 +00:00
if ( not IsNewEvent) and ( not FActiveEvent. CanEdit) then begin
2016-09-10 19:06:41 +00:00
MessageDlg( RSCannotEditOverlayedEvent, mtInformation, [ mbOK] , 0 ) ;
exit;
end ;
2008-02-03 12:05:55 +00:00
AllowIt : = false ;
if Assigned( FOwnerEditEvent) then
2018-05-17 16:35:44 +00:00
FOwnerEditEvent( self, FActiveEvent, IsNewEvent, DataStore. Resource, AllowIt)
2008-02-03 12:05:55 +00:00
else begin
EventDlg : = TVpEventEditDialog. Create( nil ) ;
try
EventDlg. DataStore : = DataStore;
2016-07-16 10:44:10 +00:00
AllowIt : = EventDlg. Execute( FActiveEvent) ;
2008-02-03 12:05:55 +00:00
finally
EventDlg. Free;
end ;
end ;
if AllowIt then begin
FActiveEvent. Changed : = true ;
DataStore. PostEvents;
2018-05-17 16:35:44 +00:00
if IsNewEvent and Assigned( FOnAddEvent) then
2016-06-20 14:21:33 +00:00
FOnAddEvent( self, FActiveEvent) ;
2008-02-03 12:05:55 +00:00
end else begin
2018-05-17 16:35:44 +00:00
if IsNewEvent then begin
2008-02-03 12:05:55 +00:00
FActiveEvent. Deleted : = true ;
DataStore. PostEvents;
FActiveEvent : = nil ;
dvActiveEventRec : = Rect( 0 , 0 , 0 , 0 ) ;
2016-06-20 14:21:33 +00:00
dvActiveIconRec : = Rect( 0 , 0 , 0 , 0 ) ;
2018-05-17 16:04:57 +00:00
end ;
2008-02-03 12:05:55 +00:00
end ;
2018-05-17 16:35:44 +00:00
Invalidate;
2008-02-03 12:05:55 +00:00
end ;
{=====}
{$IFNDEF LCL}
2016-06-20 14:21:33 +00:00
procedure TVpDayView. WMSetFocus( var Msg: TWMSetFocus) ;
2008-02-03 12:05:55 +00:00
{$ELSE}
2016-06-20 14:21:33 +00:00
procedure TVpDayView. WMSetFocus( var Msg: TLMSetFocus) ;
2008-02-03 12:05:55 +00:00
{$ENDIF}
begin
2016-07-12 09:26:14 +00:00
Unused( Msg) ;
2008-02-03 12:05:55 +00:00
if ActiveRow = - 1 then ActiveRow : = TopLine;
end ;
{=====}
{$IFNDEF LCL}
2016-06-20 14:21:33 +00:00
procedure TVpDayView. WMEraseBackground( var Msg: TWMERASEBKGND) ;
2008-02-03 12:05:55 +00:00
{$ELSE}
2016-06-20 14:21:33 +00:00
procedure TVpDayView. WMEraseBackground( var Msg: TLMERASEBKGND) ;
2008-02-03 12:05:55 +00:00
{$ENDIF}
begin
Msg. Result : = 1 ;
end ;
{=====}
{$IFNDEF LCL}
procedure TVpDayView. CMWantSpecialKey( var Msg: TCMWantSpecialKey) ;
begin
inherited ;
Msg. Result : = 1 ;
end ;
{$ENDIF}
{=====}
2016-06-20 14:21:33 +00:00
procedure TVpDayView. SetActiveEventByCoord( APoint: TPoint) ;
var
I : Integer ;
begin
for I : = 0 to pred( Length( dvEventArray) ) do begin
if dvEventArray[ I] . Event = nil then
Exit;
2016-06-29 21:46:53 +00:00
if PointInRect( APoint, dvEventArray[ I] . Rec) then
begin
2016-06-20 14:21:33 +00:00
FActiveEvent : = TVpEvent( dvEventArray[ I] . Event) ;
dvActiveEventRec : = dvEventArray[ I] . Rec;
2016-06-24 21:41:24 +00:00
dvActiveIconRec : = dvEventArray[ I] . IconRect;
2016-06-20 14:21:33 +00:00
Exit;
end ;
end ;
end ;
2008-02-03 12:05:55 +00:00
2016-09-12 22:25:34 +00:00
function TVpDayView. EditEventAtCoord( APoint: TPoint) : Boolean ;
2008-02-03 12:05:55 +00:00
var
I: Integer ;
begin
result : = false ;
if ReadOnly then
Exit;
for I : = 0 to pred( Length( dvEventArray) ) do begin
2016-06-26 11:37:20 +00:00
FActiveEvent : = nil ; // wp: shouldn't these be set also if ReadOnly is true?
dvActiveEventRec : = Rect( 0 , 0 , 0 , 0 ) ;
dvActiveIconRec : = Rect( 0 , 0 , 0 , 0 ) ;
if dvEventArray[ I] . Event = nil then
2008-02-03 12:05:55 +00:00
{ we've hit the end of visible events without finding a match }
Exit;
2016-09-12 22:25:34 +00:00
if PointInRect( APoint, dvEventArray[ I] . Rec) then
2016-06-29 21:46:53 +00:00
begin
2008-02-03 12:05:55 +00:00
FActiveEvent : = TVpEvent( dvEventArray[ I] . Event) ;
dvActiveEventRec : = dvEventArray[ I] . Rec;
2016-06-20 14:21:33 +00:00
dvActiveIconRec : = dvEventArray[ I] . IconRect;
2008-02-03 12:05:55 +00:00
dvClickTimer. Enabled : = true ;
result : = true ;
Break;
end ;
end ;
end ;
{=====}
2016-09-12 22:25:34 +00:00
function TVpDayView. GetEventAtCoord( APoint: TPoint) : TVpEvent;
2008-02-03 12:05:55 +00:00
var
I: Integer ;
begin
result : = nil ;
for I : = 0 to pred( Length( dvEventArray) ) do begin
if dvEventArray[ I] . Event = nil then
Exit;
2016-09-12 22:25:34 +00:00
if PointInRect( APoint, dvEventArray[ I] . Rec) then
2016-06-29 21:46:53 +00:00
begin
2008-02-03 12:05:55 +00:00
result : = TVpEvent( dvEventArray[ I] . Event) ;
Exit;
end ;
end ;
end ;
2016-09-12 22:25:34 +00:00
function TVpDayView. GetEventRect( AEvent: TVpEvent) : TRect;
var
i: Integer ;
begin
for i: = 0 to High( dvEventArray) do
if dvEventArray[ i] . Event = AEvent then begin
Result : = dvEventArray[ i] . Rec;
exit;
end ;
end ;
2008-02-03 12:05:55 +00:00
procedure TVpDayView. dvEditInPlace( Sender: TObject) ;
begin
{ this is the timer event which spawns an in-place editor }
{ if the event is doublecliked before this timer fires, then the }
{ event is edited in a dialog based editor. }
dvClickTimer. Enabled : = false ;
EditEvent;
end ;
{=====}
procedure TVpDayView. EditEvent;
var
AllowIt: Boolean ;
begin
if ReadOnly then
Exit;
2016-06-23 23:16:34 +00:00
if not FAllowInplaceEdit then
Exit;
2016-09-10 19:06:41 +00:00
if ( FActiveEvent < > nil ) and ( not FActiveEvent. CanEdit) then
Exit;
2016-06-23 23:16:34 +00:00
2008-02-03 12:05:55 +00:00
{ call the user defined BeforeEdit event }
2016-06-23 23:16:34 +00:00
AllowIt : = true ;
2008-02-03 12:05:55 +00:00
if Assigned( FBeforeEdit) then
FBeforeEdit( Self, FActiveEvent, AllowIt) ;
2016-06-23 23:16:34 +00:00
if not AllowIt then
exit;
{ create and spawn the in-place editor }
if dvInPlaceEditor = nil then begin
dvInPlaceEditor : = TVpDvInPlaceEdit. Create( Self) ;
dvInPlaceEditor. Parent : = self;
dvInPlaceEditor. OnExit : = EndEdit;
2008-02-03 12:05:55 +00:00
end ;
2016-07-04 21:48:27 +00:00
if FActiveEvent. AllDayEvent then
dvInplaceEditor. SetBounds(
dvActiveEventRec. Left + 2 * ( TextMargin div 2 ) , // this way it is calculated in DrawAllDayEvents
dvActiveEventRec. Top + 2 * ( TextMargin div 2 ) ,
WidthOf( dvActiveEventRec) - TextMargin div 2 ,
HeightOf( dvActiveEventRec)
)
else
dvInPlaceEditor. SetBounds(
dvActiveIconRec. Right + TextMargin,
dvActiveEventRec. Top + TextMargin,
dvActiveEventRec. Right - dvActiveIconRec. Right - TextMargin,
dvActiveEventRec. Bottom - dvActiveEventRec. Top - TextMargin
) ;
2016-06-23 23:16:34 +00:00
dvInPlaceEditor. Show;
dvInPlaceEditor. Text : = FActiveEvent. Description;
Invalidate;
dvInPlaceEditor. SetFocus;
2008-02-03 12:05:55 +00:00
end ;
{=====}
procedure TVpDayView. EndEdit( Sender: TObject) ;
begin
2016-06-20 14:21:33 +00:00
if dvEndingEditing then
Exit;
dvEndingEditing : = True ;
try
2016-06-18 11:17:39 +00:00
if ( dvInPlaceEditor < > nil ) and dvInplaceEditor. Visible then begin
2008-02-03 12:05:55 +00:00
if dvInPlaceEditor. Text < > FActiveEvent. Description then begin
FActiveEvent. Description : = dvInPlaceEditor. Text ;
FActiveEvent. Changed : = true ;
DataStore. PostEvents;
if Assigned( FAfterEdit) then
FAfterEdit( self, FActiveEvent) ;
end ;
2016-06-18 11:17:39 +00:00
dvInplaceEditor. Hide;
2008-02-03 12:05:55 +00:00
Invalidate;
end ;
2016-06-20 14:21:33 +00:00
finally
dvEndingEditing : = False ;
end ;
2008-02-03 12:05:55 +00:00
end ;
{=====}
procedure TVpDayView. KeyDown( var Key: Word ; Shift: TShiftState) ;
var
PopupPoint : TPoint;
begin
case Key of
2016-06-20 14:21:33 +00:00
VK_UP:
ActiveRow : = ActiveRow - 1 ;
VK_DOWN:
ActiveRow : = ActiveRow + 1 ;
VK_NEXT:
ActiveRow : = ActiveRow + FVisibleLines;
VK_PRIOR:
ActiveRow : = ActiveRow - FVisibleLines;
VK_LEFT:
Date : = Date - 1 ;
VK_RIGHT:
Date : = Date + 1 ;
VK_HOME:
ActiveRow : = 0 ;
VK_END:
ActiveRow : = LineCount;
VK_DELETE:
if not ReadOnly then
DeleteActiveEvent( true ) ;
2008-02-03 12:05:55 +00:00
{$IFNDEF LCL}
2016-06-20 14:21:33 +00:00
VK_TAB:
2008-02-03 12:05:55 +00:00
if ssShift in Shift then
Windows. SetFocus ( GetNextDlgTabItem( GetParent( Handle) , Handle, False ) )
else
Windows. SetFocus ( GetNextDlgTabItem( GetParent( Handle) , Handle, True ) ) ;
{$ENDIF}
2016-06-20 14:21:33 +00:00
VK_F10:
2008-02-03 12:05:55 +00:00
if ( ssShift in Shift) and not ( Assigned ( PopupMenu) ) then begin
PopupPoint : = GetClientOrigin;
2016-06-20 14:21:33 +00:00
FDefaultPopup. Popup( PopupPoint. x + 1 0 , PopupPoint. y + 1 0 ) ;
2008-02-03 12:05:55 +00:00
end ;
2016-06-20 14:21:33 +00:00
VK_APPS :
if not Assigned( PopupMenu) then begin
2008-02-03 12:05:55 +00:00
PopupPoint : = GetClientOrigin;
2016-06-20 14:21:33 +00:00
FDefaultPopup. Popup( PopupPoint. x + 1 0 , PopupPoint. y + 1 0 ) ;
end ;
VK_RETURN:
PopupEditEvent( Self) ;
VK_INSERT:
PopupAddEvent( Self) ;
VK_F2:
if Assigned( FActiveEvent) then
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
dvEditInPlace( Self) ;
2008-02-03 12:05:55 +00:00
end ;
end ;
end ;
{=====}
{$IFNDEF LCL}
procedure TVpDayView. WMVScroll( var Msg: TWMVScroll) ;
{$ELSE}
procedure TVpDayView. WMVScroll( var Msg: TLMVScroll) ;
{$ENDIF}
begin
{ for simplicity, bail out of editing while scrolling. }
EndEdit( Self) ;
2016-06-26 08:14:09 +00:00
// wp: Next line should never happen after EndEdit...
2016-06-18 11:17:39 +00:00
if ( dvInPlaceEditor < > nil ) and dvInplaceEditor. Visible then Exit;
2008-02-03 12:05:55 +00:00
case Msg. ScrollCode of
SB_LINEUP : dvScrollVertical( - 1 ) ;
SB_LINEDOWN : dvScrollVertical( 1 ) ;
SB_PAGEUP : dvScrollVertical( - FVisibleLines) ;
SB_PAGEDOWN : dvScrollVertical( FVisibleLines) ;
SB_THUMBPOSITION, SB_THUMBTRACK : TopLine : = Msg. Pos;
end ;
end ;
{=====}
procedure TVpDayView. dvScrollVertical( Lines: Integer ) ;
begin
TopLine : = TopLine + Lines;
end ;
{=====}
procedure TVpDayView. SetVScrollPos;
var
SI : TScrollInfo;
begin
if not HandleAllocated then
Exit;
with SI do begin
cbSize : = SizeOf( SI) ;
fMask : = SIF_RANGE or SIF_PAGE or SIF_POS;
nMin : = 0 ;
2016-07-02 15:44:34 +00:00
nMax : = FLineCount;
2008-02-03 12:05:55 +00:00
if FVisibleLines > = FLineCount then
nPage : = nMax
else
nPage : = FVisibleLines;
if FTopLine = pred( LineCount) - VisibleLines then
nPos : = LineCount
else
nPos : = FTopLine;
nTrackPos : = nPos;
end ;
2016-07-01 13:21:43 +00:00
SetScrollInfo( Handle, SB_VERT, SI, True ) ;
2008-02-03 12:05:55 +00:00
end ;
{=====}
2016-06-20 14:21:33 +00:00
2018-05-15 09:08:53 +00:00
procedure TVpDayView. SetCustomRowHeight( Value: Integer ) ;
begin
if Value < > FCustomRowHeight then begin
2018-05-19 22:57:26 +00:00
if ( Value < > 0 ) and ( Value < 1 )
then FCustomRowHeight : = 1
2018-05-15 09:08:53 +00:00
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 ;
2008-02-03 12:05:55 +00:00
procedure TVpDayView. SetShowResourceName( Value: Boolean ) ;
begin
if Value < > FShowResourceName then begin
FShowResourceName : = Value;
Invalidate;
end ;
end ;
2018-05-15 09:08:53 +00:00
procedure TVpDayView. SetSimpleRowTime( Value: Boolean ) ;
begin
if Value < > FSimpleRowTime then begin
FSimpleRowTime : = Value;
Invalidate;
end ;
end ;
2016-06-20 14:21:33 +00:00
procedure TVpDayView. SetNumDays( Value: Integer ) ;
2008-02-03 12:05:55 +00:00
begin
2016-06-21 18:45:18 +00:00
if ( Value < > FNumDays) and ( Value > 0 ) and ( Value < 3 1 ) then begin
2008-02-03 12:05:55 +00:00
FNumDays : = Value;
SetLength( dvColRectArray, FNumDays) ;
SetTimeIntervals( Granularity) ;
ActiveCol : = 0 ;
Invalidate;
end ;
end ;
procedure TVpDayView. SetIncludeWeekends( Value : Boolean ) ;
begin
if Value < > FIncludeWeekends then begin
FIncludeWeekends : = Value;
Invalidate;
end ;
end ;
{=====}
procedure TVpDayView. SetActiveRow( Value: Integer ) ;
var
OldActiveRow: Integer ;
begin
if dvClickTimer. Enabled then
dvClickTimer. Enabled : = false ;
if not Focused then SetFocus;
OldActiveRow : = FActiveRow;
{ set active row }
if ( Value < 0 ) then
FActiveRow : = 0
else if ( Value > = pred( LineCount) ) then
FActiveRow : = pred( LineCount)
else
FActiveRow : = Value;
{ clamp in view }
if ( FActiveRow < FTopLine) then
TopLine : = FActiveRow
else if ( FActiveRow > = FTopLine + FVisibleLines) then
TopLine : = FActiveRow - FVisibleLines + 1 ;
if ( OldActiveRow < > FActiveRow) then begin
Invalidate;
end ;
end ;
{=====}
procedure TVpDayView. SetActiveCol( Value: Integer ) ;
begin
if FActiveCol < > Value then begin
if Value < 0 then
FActiveCol : = 0
else if Value > pred( NumDays) then
FActiveCol : = pred( NumDays)
else
FActiveCol : = Value;
Invalidate;
end ;
end ;
{=====}
2016-06-20 14:21:33 +00:00
procedure TVpDayView. SetDotDotDotColor( const v: TColor) ;
begin
if v < > FDotDotDotColor then begin
FDotDotDotColor : = v;
Invalidate;
end ;
end ;
2008-02-03 12:05:55 +00:00
{=====}
2016-06-20 14:21:33 +00:00
procedure TVpDayView. SetShowEventTimes( Value: Boolean ) ;
begin
if Value < > FShowEventTimes then begin
FShowEventTimes : = Value;
Invalidate;
end
end ;
2008-02-03 12:05:55 +00:00
{=====}
2016-06-20 14:21:33 +00:00
procedure TVpDayView. SetWrapStyle( const v: TVpDVWrapStyle) ;
begin
if v < > FWrapStyle then begin
FWrapStyle : = v;
Invalidate;
end ;
end ;
2017-05-25 21:24:23 +00:00
procedure TVpDayView. SetHint( const AValue: TTranslateString) ;
begin
inherited ;
if FHintMode = hmComponentHint then
FComponentHint : = AValue;
end ;
procedure TVpDayView. SetHintMode( const AValue: TVpHintMode) ;
begin
if AValue = FHintMode then
exit;
FHintMode : = AValue;
if FHintMode = hmPlannerHint then
FComponentHint : = Hint;
end ;
2016-06-20 14:21:33 +00:00
{=====}
procedure TVpDayView. dvSetActiveRowByCoord( Pnt: TPoint; Sloppy: Boolean ) ;
2008-02-03 12:05:55 +00:00
var
I : Integer ;
begin
if dvClickTimer. Enabled then
dvClickTimer. Enabled : = false ;
for I : = 0 to pred( LineCount) do begin
2016-06-20 14:21:33 +00:00
if Sloppy and
( Pnt. y < = dvLineMatrix[ ActiveCol, I] . Rec. Bottom) and
( Pnt. y > dvLineMatrix[ ActiveCol, I] . Rec. Top)
then begin
ActiveRow : = I;
Exit;
end else
2016-06-29 21:46:53 +00:00
if PointInRect( Pnt, dvLineMatrix[ ActiveCol, I] . Rec) then
begin
2016-06-20 14:21:33 +00:00
ActiveRow : = I;
2008-02-03 12:05:55 +00:00
Exit;
end ;
end ;
end ;
{=====}
procedure TVpDayView. dvSetActiveColByCoord( Pnt: TPoint) ;
var
I : Integer ;
begin
for I : = 0 to pred( length( dvColRectArray) ) do begin
2016-06-29 21:46:53 +00:00
if PointInRect( Pnt, dvColRectArray[ I] . Rec) then
begin
2008-02-03 12:05:55 +00:00
ActiveCol : = I;
Exit;
end ;
end ;
end ;
{=====}
function TVpDayView. GetControlType : TVpItemType;
begin
Result : = itDayView;
end ;
2016-06-20 14:21:33 +00:00
procedure TVpDayView. AutoScaledPaintToCanvas( PaintCanvas: TCanvas; PaintTo: TRect;
Angle: TVpRotationAngle; RenderDate: TDateTime; StartLine, StopLine: Integer ;
UseGran: TVpGranularity) ;
2008-02-03 12:05:55 +00:00
var
2016-06-20 14:21:33 +00:00
SrcResY: Integer ;
DestResY: Integer ;
Scale: Extended ;
2008-02-03 12:05:55 +00:00
begin
2016-06-20 14:21:33 +00:00
SrcResY : = GetDeviceCaps( Canvas. Handle, LOGPIXELSY) ;
DestResY : = GetDeviceCaps( PaintCanvas. Handle, LOGPIXELSY) ;
Scale : = DestResY / SrcResY;
RenderToCanvas( PaintCanvas, PaintTo, Angle, Scale, RenderDate, StartLine, StopLine, UseGran, True ) ;
2008-02-03 12:05:55 +00:00
end ;
2016-06-20 14:21:33 +00:00
procedure TVpDayView. PaintToCanvas( ACanvas: TCanvas; ARect: TRect;
Angle: TVpRotationAngle; ADate: TDateTime; StartHour, EndHour: TVpHours;
UseGran: TVpGranularity) ;
2008-02-03 12:05:55 +00:00
begin
2016-06-20 14:21:33 +00:00
RenderToCanvas(
ACanvas,
ARect,
Angle,
1 ,
ADate,
HourToLine( StartHour, UseGran) ,
HourToLine( EndHour, UseGran) ,
UseGran,
True ) ;
2008-02-03 12:05:55 +00:00
end ;
2016-06-20 14:21:33 +00:00
procedure TVpDayView. RenderToCanvas( RenderCanvas: TCanvas; RenderIn: TRect;
Angle: TVpRotationAngle; Scale: Extended ; RenderDate: TDateTime;
StartLine, StopLine: Integer ; UseGran: TVpGranularity; DisplayOnly: Boolean ) ;
2016-06-22 14:43:43 +00:00
var
painter: TVpDayViewPainter;
begin
dvPainting : = true ;
painter : = TVpDayviewPainter. Create( Self, RenderCanvas) ;
try
painter. RenderToCanvas( RenderIn, Angle, Scale, RenderDate, StartLine,
StopLine, UseGran, DisplayOnly) ;
finally
painter. Free;
dvPainting : = false ;
end ;
end ;
2008-02-03 12:05:55 +00:00
2016-06-22 07:59:17 +00:00
procedure TVpDayView. VpDayViewInit( var Msg: {$IFDEF DELPHI} TMessage{$ELSE} TLMessage{$ENDIF} ) ;
2016-06-20 14:21:33 +00:00
begin
2016-07-12 09:26:14 +00:00
Unused( Msg) ;
2016-06-20 14:21:33 +00:00
if csLoading in ComponentState then begin
PostMessage( Handle, Vp_DayViewInit, 0 , 0 ) ;
Exit;
end ;
dvCalcColHeadHeight( 1 ) ;
dvCalcRowHeight( 1 , FGranularity) ;
dvCalcVisibleLines( Height, dvColHeadHeight, dvRowHeight, 1 , TopLine, - 1 ) ;
2008-02-03 12:05:55 +00:00
SetVScrollPos;
end ;
2017-05-22 08:11:27 +00:00
2018-01-12 11:07:34 +00:00
{$IF VP_LCL_SCALING = 2}
procedure TVpDayView. ScaleFontsPPI( const AToPPI: Integer ;
const AProportion: Double ) ;
begin
inherited ;
DoScaleFontPPI( AllDayEventAttributes. Font, AToPPI, AProportion) ;
DoScaleFontPPI( HeadAttributes. Font, AToPPI, AProportion) ;
DoScaleFontPPI( RowHeadAttributes. HourFont, AToPPI, AProportion) ;
DoScaleFontPPI( RowHeadAttributes. MinuteFont, AToPPI, AProportion) ;
end ;
{$ELSEIF VP_LCL_SCALING = 1}
2017-05-22 08:11:27 +00:00
procedure TVpDayView. ScaleFontsPPI( const AProportion: Double ) ;
begin
inherited ;
DoScaleFontPPI( AllDayEventAttributes. Font, AProportion) ;
DoScaleFontPPI( HeadAttributes. Font, AProportion) ;
DoScaleFontPPI( RowHeadAttributes. HourFont, AProportion) ;
DoScaleFontPPI( RowHeadAttributes. MinuteFont, AProportion) ;
end ;
{$ENDIF}
2008-02-03 12:05:55 +00:00
(*****************************************************************************)
{ TVpCHAttributes }
constructor TVpCHAttributes. Create( AOwner: TVpDayView) ;
begin
inherited Create;
FOwner : = AOwner;
FFont : = TVpFont. Create( AOwner) ;
end ;
{=====}
destructor TVpCHAttributes. Destroy;
begin
FFont. Free;
inherited ;
end ;
{=====}
procedure TVpCHAttributes. SetColor( const Value: TColor) ;
begin
if FColor < > Value then begin
FColor : = Value;
FOwner. Invalidate;
end ;
end ;
{=====}
procedure TVpCHAttributes. SetFont( Value: TVpFont) ;
begin
FFont. Assign( Value) ;
end ;
{=====}
(*****************************************************************************)
{ TVpRHAttributes }
constructor TVpRHAttributes. Create( AOwner: TVpDayView) ;
begin
inherited Create;
FOwner : = AOwner;
FHourFont : = TVpFont. Create( AOwner) ;
FMinuteFont : = TVpFont. Create( AOwner) ;
2016-06-14 14:24:19 +00:00
{$IFNDEF LCL}
FHourFont. Name : = 'Tahoma' ;
2008-02-03 12:05:55 +00:00
FMinuteFont. Name : = 'Tahoma' ;
2016-06-14 14:24:19 +00:00
{$ENDIF}
2008-02-03 12:05:55 +00:00
end ;
{=====}
destructor TVpRHAttributes. Destroy;
begin
FHourFont. Free;
FMinuteFont. Free;
inherited ;
end ;
{=====}
procedure TVpRHAttributes. SetColor( const Value: TColor) ;
begin
if FColor < > Value then begin
FColor : = Value;
FOwner. Invalidate;
end ;
end ;
{=====}
procedure TVpRHAttributes. SetHourFont( Value: TVpFont) ;
begin
if Value < > FHourFont then begin
FHourFont. Assign( Value) ;
FOwner. Invalidate;
end ;
end ;
{=====}
procedure TVpRHAttributes. SetMinuteFont( Value: TVpFont) ;
begin
if Value < > FMinuteFont then begin
FMinuteFont. Assign( Value) ;
FOwner. Invalidate;
end ;
end ;
end .