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 }
2016-06-18 12:09:16 +00:00
{ Include drag-and-drop, not working with Lazarus }
{$IFDEF DELPHI}
{$DEFINE DRAGDROP}
{$ELSE}
{$UNDEF DRAGDROP}
{$ENDIF}
2008-02-03 12:05:55 +00:00
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}
2016-06-22 07:59:17 +00:00
Classes, Graphics, Controls, ComCtrls, ExtCtrls, StdCtrls,
2008-02-03 12:05:55 +00:00
Buttons, VpBase, VpBaseDS, VpMisc, VpData, VpSR, VpConst,
VpCanvasUtils, Menus;
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;
Active: Boolean ; ACanvas: TCanvas; EventRect: TRect; IconRect: TRect) of object ;
TVpOnDVAfterDrawEvent = procedure ( Sender: TObject; Event: TVpEvent;
Active: Boolean ; ACanvas: TCanvas; EventRect: TRect; IconRect: TRect) of object ;
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 ;
TVpDvInPlaceEdit = class( TCustomEdit)
protected {private}
procedure CreateParams( var Params: TCreateParams) ; override ;
procedure KeyDown( var Key: Word ; Shift: TShiftState) ; override ;
{$IFNDEF LCL}
procedure WMKillFocus( var Msg : TWMKillFocus) ; message WM_KILLFOCUS;
{$ELSE}
procedure WMKillFocus( var Msg : TLMKillFocus) ; message LM_KILLFOCUS;
{$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;
FOwner: TVpLinkableControl;
protected
procedure SetAlarmBitmap( v: TBitmap) ;
procedure SetRecurringBitmap( v: TBitmap) ;
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;
property RecurringBitmap: TBitmap
read FRecurringBitmap write SetRecurringBitmap;
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 ;
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)
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 ;
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;
FNumDays: Integer ;
FIncludeWeekends: Boolean ;
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 ;
2016-06-18 12:09:16 +00:00
{$IFDEF DRAGDROP}
2016-06-19 23:40:28 +00:00
dvDragging: Boolean ;
dvDragStartTime: TDateTime;
2016-06-18 12:09:16 +00:00
{$ENDIF}
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;
procedure SetShowResourceName( Value: Boolean ) ;
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 ) ;
2008-02-03 12:05:55 +00:00
{ drag-drop methods }
2016-06-18 12:09:16 +00:00
{$IFDEF DRAGDROP}
2008-02-03 12:05:55 +00:00
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-06-18 12:09:16 +00:00
{$ENDIF}
2008-02-03 12:05:55 +00:00
{ internal methods }
2016-06-19 23:40:28 +00:00
function dvCalcRowHeight( Scale: Extended ; UseGran: TVpGranularity) : Integer ;
function dvCalcVisibleLines( RenderHeight, ColHeadHeight, RowHeight: Integer ;
Scale: Extended ; StartLine, StopLine: Integer ) : Integer ;
function dvCalcColHeadHeight( Scale: Extended ) : Integer ;
2008-02-03 12:05:55 +00:00
procedure dvEditInPlace( Sender: TObject) ;
procedure dvHookUp;
2016-06-19 23:40:28 +00:00
procedure PopupAddEvent( Sender: TObject) ;
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) ;
2008-02-03 12:05:55 +00:00
procedure InitializeDefaultPopup;
procedure Paint; override ;
procedure Loaded; override ;
procedure dvSpawnEventEditDialog( NewEvent: 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) ;
procedure dvPopulate;
procedure dvNavButtonsClick( Sender: TObject) ;
procedure dvScrollVertical( Lines: Integer ) ;
procedure CreateParams( var Params: TCreateParams) ; override ;
procedure CreateWnd; override ;
2016-06-19 23:40:28 +00:00
procedure MouseUp( Button: TMouseButton; Shift: TShiftState; X, Y: Integer ) ; override ;
2008-02-07 23:08:26 +00:00
procedure MouseMove( Shift: TShiftState; X, Y: Integer ) ; override ;
2016-06-19 23:40:28 +00:00
procedure MouseDown( Button: TMouseButton; Shift: TShiftState; X, Y: Integer ) ; override ;
procedure SetActiveEventByCoord( APoint: TPoint) ;
2008-02-03 12:05:55 +00:00
function EditEventAtCoord( Point: TPoint) : Boolean ;
function GetEventAtCoord( Point: TPoint) : TVpEvent;
procedure EditEvent;
procedure EndEdit( Sender: TObject) ;
procedure KeyDown( var Key: Word ; Shift: TShiftState) ; override ;
2016-06-12 15:29:23 +00:00
procedure SetTimeIntervals( UseGran: TVpGranularity) ;
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 ;
2008-11-10 13:54:49 +00:00
procedure LoadLanguage;
2008-02-03 12:05:55 +00:00
procedure DeleteActiveEvent( Verify: Boolean ) ;
2016-06-18 12:09:16 +00:00
{$IFDEF DRAGDROP}
2008-02-03 12:05:55 +00:00
procedure DragDrop( Source: TObject; X, Y: Integer ) ; override ;
2016-06-18 12:09:16 +00:00
{$ENDIF}
2016-06-20 11:00:59 +00:00
// function HourToLine(const Value: TVpHours; const UseGran: TVpGranularity): Integer;
2008-02-03 12:05:55 +00:00
procedure Invalidate; override ;
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 ;
procedure EditSelectedEvent;
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) ;
procedure RenderToCanvas ( RenderCanvas: TCanvas; RenderIn: TRect;
Angle: TVpRotationAngle; Scale: Extended ; RenderDate: TDateTime;
StartLine, StopLine: Integer ; UseGran: TVpGranularity; DisplayOnly: Boolean ) ; override ;
2016-06-26 13:52:59 +00:00
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;
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-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 ;
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;
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;
property OnOwnerEditEvent: TVpEditEvent read FOwnerEditEvent write FOwnerEditEvent;
2008-02-03 12:05:55 +00:00
property OnClick;
end ;
implementation
uses
2016-06-22 14:43:43 +00:00
SysUtils, Math, Forms, Dialogs, VpEvntEditDlg, VpDayViewPainter;
2008-02-03 12:05:55 +00:00
(*****************************************************************************)
{ TVpTGInPlaceEdit }
constructor TVpDvInPlaceEdit. Create( AOwner: TComponent) ;
begin
inherited Create( AOwner) ;
TabStop : = False ;
BorderStyle : = bsNone;
DoubleBuffered : = False ;
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 ;
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
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;
FShowAlarmBitmap : = True ;
FShowCategoryBitmap : = True ;
FShowRecurringBitmap : = True ;
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 ;
procedure TVpDayViewIconAttributes. SetRecurringBitmap( v: TBitmap) ;
begin
FRecurringBitmap. Assign( v) ;
if Assigned( FOwner) then
FOwner. Invalidate
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] ;
{ 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 }
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' ) ;
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}
2016-06-19 23:40:28 +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 ;
FShowResourceName : = true ;
FColor : = clWindow;
FLineColor : = clGray;
Granularity : = gr30min;
FDefTopHour : = h_07;
FDisplayDate : = Now;
TopHour : = FDefTopHour;
FTimeFormat : = tf12Hour;
FDateLabelFormat : = 'dddd, mmmm dd, yyyy' ;
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 ;
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
{$IFDEF DRAGDROP}
DragMode : = dmManual;
dvDragging : = false ;
{$ENDIF}
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
{ 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-06-19 23:40:28 +00:00
FDefaultPopup : = TPopupMenu. Create( Self) ;
2012-09-24 19:30:17 +00:00
Self. PopupMenu : = FDefaultPopup;
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
procedure TVpDayView. LoadLanguage;
begin
2016-06-19 23:40:28 +00:00
dvDayUpBtn. Hint : = RSHintNextDay; //rsHintTomorrow;
dvDayDownBtn. Hint : = RSHintPrevDay; //rsHintYesterday;
dvTodayBtn. Hint : = RSHintToday;
dvWeekUpBtn. Hint : = RSHintNextWeek;
dvWeekDownBtn. Hint : = RSHintPrevWeek;
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
Str: string ;
DoIt: Boolean ;
begin
2016-06-19 23:40:28 +00:00
if ReadOnly then
2008-02-03 12:05:55 +00:00
Exit;
dvClickTimer. Enabled : = false ;
EndEdit( self) ;
DoIt : = not Verify;
if FActiveEvent < > nil then begin
Str : = '"' + FActiveEvent. Description + '"' ;
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 ;
{=====}
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 ;
{=====}
procedure TVpDayView. InitializeDefaultPopup;
var
2016-06-19 23:40:28 +00:00
NewItem: TMenuItem;
NewSubItem: TMenuItem;
2008-02-03 12:05:55 +00:00
begin
if RSDayPopupAdd < > '' then begin
2016-06-19 23:40:28 +00:00
NewItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewItem. Caption : = RSDayPopupAdd;
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 ;
if RSDayPopupEdit < > '' then begin
2016-06-19 23:40:28 +00:00
NewItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewItem. Caption : = RSDayPopupEdit;
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 ;
if RSDayPopupDelete < > '' then begin
2016-06-19 23:40:28 +00:00
NewItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewItem. Caption : = RSDayPopupDelete;
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 ;
if RSDayPopupNav < > '' then begin
2016-06-19 23:40:28 +00:00
NewItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewItem. Caption : = RSDayPopupNav;
NewItem. Tag : = 0 ;
2016-06-19 23:40:28 +00:00
FDefaultPopup. Items. Add( NewItem) ;
2008-02-03 12:05:55 +00:00
if RSDayPopupNavToday < > '' then begin
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewSubItem. Caption : = RSDayPopupNavToday;
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 ;
if RSDayPopupNavYesterday < > '' then begin
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewSubItem. Caption : = RSDayPopupNavYesterday;
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 ;
if RSDayPopupNavTomorrow < > '' then begin
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewSubItem. Caption : = RSDayPopupNavTomorrow;
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 ;
if RSDayPopupNavNextDay < > '' then begin
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewSubItem. Caption : = RSDayPopupNavNextDay;
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 ;
if RSDayPopupNavPrevDay < > '' then begin
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewSubItem. Caption : = RSDayPopupNavPrevDay;
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 ;
if RSDayPopupNavNextWeek < > '' then begin
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewSubItem. Caption : = RSDayPopupNavNextWeek;
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 ;
if RSDayPopupNavPrevWeek < > '' then begin
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewSubItem. Caption : = RSDayPopupNavPrevWeek;
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 ;
if RSDayPopupNavNextMonth < > '' then begin
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewSubItem. Caption : = RSDayPopupNavNextMonth;
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 ;
if RSDayPopupNavPrevMonth < > '' then begin
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewSubItem. Caption : = RSDayPopupNavPrevMonth;
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 ;
if RSDayPopupNavNextYear < > '' then begin
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewSubItem. Caption : = RSDayPopupNavNextYear;
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 ;
if RSDayPopupNavPrevYear < > '' then begin
2016-06-19 23:40:28 +00:00
NewSubItem : = TMenuItem. Create( Self) ;
2008-02-03 12:05:55 +00:00
NewSubItem. Caption : = RSDayPopupNavPrevYear;
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 ;
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
2016-06-19 23:40:28 +00:00
if ReadOnly then
Exit;
if not CheckCreateResource then
Exit;
2008-02-03 12:05:55 +00:00
if not Assigned ( DataStore) then
Exit;
if not Assigned ( DataStore. Resource) then
Exit;
2016-06-19 23:40:28 +00:00
StartTime : = trunc( FDisplayDate + ActiveCol) + dvLineMatrix[ ActiveCol, ActiveRow] . Time;
2008-02-03 12:05:55 +00:00
EndTime : = StartTime + dvTimeIncSize;
2016-06-19 23:40:28 +00:00
FActiveEvent : = DataStore. Resource. Schedule. AddEvent(
DataStore. GetNextID( EventsTableName) ,
StartTime,
EndTime
) ;
2008-02-03 12:05:55 +00:00
2016-06-19 23:40:28 +00:00
Repaint;
2008-02-03 12:05:55 +00:00
{ edit this new event }
dvSpawnEventEditDialog( True ) ;
end ;
{=====}
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 ;
if ( D > DaysInMonth( Y, M) ) then
D : = DaysInMonth( Y, M) ;
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 ;
if ( D > DaysInMonth( Y, M) ) then
D : = DaysInMonth( Y, M) ;
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 ;
{=====}
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 ;
{=====}
2016-06-19 23:40:28 +00:00
function TVpDayView. dvCalcVisibleLines( RenderHeight, ColHeadHeight, RowHeight: Integer ;
Scale: Extended ; StartLine, StopLine: Integer ) : Integer ;
2008-02-03 12:05:55 +00:00
var
vertical: integer ;
begin
if StartLine < 0 then
StartLine : = TopLine;
{ take into account the number lines that are allowed! }
2016-06-19 23:40:28 +00:00
vertical : = Round( RenderHeight - ColHeadHeight * Scale - 2 ) ;
2008-02-03 12:05:55 +00:00
Result : = trunc ( Vertical div RowHeight) + 2 ;
if Result > FLineCount then
Result : = FLineCOunt;
if ( StopLine > 0 ) and ( StopLine > StartLine) then
if Result > StopLine - StartLine then
Result : = StopLine - StartLine + 2 ;
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 ;
2008-02-03 12:05:55 +00:00
begin
2016-06-19 23:40:28 +00:00
Canvas. Font. Assign( FHeadAttr. Font) ;
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-06-19 23:40:28 +00:00
TextHeight : = Canvas. TextHeight( RSTallShortChars) * 2 + TextMargin * 3
2008-02-03 12:05:55 +00:00
else
2016-06-19 23:40:28 +00:00
TextHeight : = Canvas. TextHeight( RSTallShortChars) + TextMargin * 2 ;
Result : = Round( TextHeight * Scale) ;
2008-02-03 12:05:55 +00:00
dvColHeadHeight : = Result ;
end ;
{=====}
2016-06-18 12:09:16 +00:00
{$IFDEF DRAGDROP}
2008-02-03 12:05:55 +00:00
procedure TVpDayView. DoStartDrag( var DragObject: TDragObject) ;
2016-06-18 12:09:16 +00:00
begin //exit;
2008-02-03 12:05:55 +00:00
DvDragStartTime : = 0.0 ;
if ReadOnly then
Exit;
if FActiveEvent < > nil then begin
2008-02-11 01:09:19 +00:00
// Set the time from which this event was dragged
2016-06-19 23:40:28 +00:00
DvDragStartTime : = trunc( Date + ActiveCol) + dvLineMatrix[ ActiveCol, ActiveRow] . Time;
2008-02-03 12:05:55 +00:00
DragObject : = TVpEventDragObject. Create( Self) ;
TVpEventDragObject( DragObject) . Event : = FActiveEvent;
end
else
2008-02-07 23:08:26 +00:00
DragObject. Free; //EndDrag(false);
2008-02-03 12:05:55 +00:00
end ;
{=====}
procedure TVpDayView. DoEndDrag( Target: TObject; X, Y: Integer ) ;
2016-06-18 12:09:16 +00:00
begin //exit;
2008-02-03 12:05:55 +00:00
if ReadOnly then
Exit;
TVpEventDragObject( Target) . Free;
end ;
{=====}
procedure TVpDayView. DragOver( Source: TObject; X, Y: Integer ; State: TDragState;
var Accept: Boolean ) ;
2016-06-18 12:09:16 +00:00
begin //exit;
2008-02-03 12:05:55 +00:00
if ReadOnly then begin
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-06-18 12:09:16 +00:00
begin //exit;
2008-02-03 12:05:55 +00:00
if ReadOnly then
Exit;
Event : = TVpEventDragObject( Source) . Event;
if Event < > nil then begin
Duration : = Event. EndTime - Event. StartTime;
DragToTime : = trunc( Date + ActiveCol)
+ dvLineMatrix[ ActiveCol, ActiveRow] . Time;
if Ord( Event. RepeatCode) = 0 then
{ if this is not a recurring event then just drop it here }
Event. StartTime : = DragToTime
else
{ if this is a recurring event, then modify the event's start time }
{ according to how far the event was dragged }
Event. StartTime : = Event. StartTime + ( DragToTime - DvDragStartTime) ;
Event. EndTime : = Event. StartTime + Duration;
DataStore. PostEvents;
{ 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
{ Invalidate; }
end ;
2008-02-07 23:08:26 +00:00
// TVpEventDragObject(Source).EndDrag(False);
2008-02-03 12:05:55 +00:00
end ;
{=====}
2016-06-18 12:09:16 +00:00
{$ENDIF}
2008-02-03 12:05:55 +00:00
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) ;
Result : = Canvas. TextHeight( RSTallShortChars) ;
Canvas. Font. Assign( SaveFont) ;
Temp : = Canvas. TextHeight( RSTallShortChars) ;
if Temp > Result then
Result : = Temp;
Result : = Result + TextMargin * 2 ;
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
if ( DayOfWeek ( WorkDate) < > 1 ) and ( DayOfWeek ( WorkDate) < > 7 ) then
Inc( i) ;
WorkDate : = WorkDate + 1 ;
Inc ( Result ) ;
end ;
end else
Result : = FNumDays;
end ;
2008-02-03 12:05:55 +00:00
{=====}
2016-06-20 11:00:59 +00:00
( *
2016-06-19 23:40:28 +00:00
function TVpDayView. HourToLine( const Value: TVpHours;
2016-06-12 15:29:23 +00:00
const UseGran: TVpGranularity) : Integer ;
2008-02-03 12:05:55 +00:00
begin
2016-06-20 11:00:59 +00:00
Result : = Ord( Value) * 6 0 div GranularityMinutes[ UseGran] ;
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-06-22 12:16:45 +00:00
SetLength( dvLineMatrix[ I] , LineCount) ; // 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.
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
if FDisplayDate < > Value then begin
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-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 ;
{$IFDEF DRAGDROP}
dvDragging : = false ;
{$ENDIF}
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 ) ;
begin
inherited MouseMove( Shift, X, Y) ;
if ( FActiveEvent < > nil ) and ( not ReadOnly ) then begin
2016-06-18 12:09:16 +00:00
{$IFDEF DRAGDROP}
2008-02-07 23:08:26 +00:00
if ( not dvDragging) and dvMouseDown
and ( ( dvMouseDownPoint. x < > x) or ( dvMouseDownPoint. y < > y) )
then begin
dvDragging : = true ;
dvClickTimer. Enabled : = false ;
BeginDrag( true ) ;
end ;
2016-06-18 12:09:16 +00:00
{$ENDIF}
2008-02-07 23:08:26 +00:00
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 ;
{ 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;
EndTime : = StartTime + dvTimeIncSize;
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}
2008-02-03 12:05:55 +00:00
procedure TVpDayView. EditSelectedEvent;
begin
if ReadOnly then
Exit;
if FActiveEvent < > nil then
dvSpawnEventEditDialog( false ) ;
end ;
{=====}
procedure TVpDayView. dvSpawnEventEditDialog( NewEvent: Boolean ) ;
var
AllowIt: Boolean ;
EventDlg : TVpEventEditDialog;
begin
if ( DataStore = nil ) or ( DataStore. Resource = nil ) or ReadOnly then
Exit;
AllowIt : = false ;
if Assigned( FOwnerEditEvent) then
FOwnerEditEvent( self, FActiveEvent, DataStore. Resource, AllowIt)
else begin
EventDlg : = TVpEventEditDialog. Create( nil ) ;
try
EventDlg. DataStore : = DataStore;
AllowIt : = EventDlg. Execute( FActiveEvent, FTimeFormat) ;
finally
EventDlg. Free;
end ;
end ;
if AllowIt then begin
FActiveEvent. Changed : = true ;
DataStore. PostEvents;
2016-06-20 14:21:33 +00:00
if Assigned( FOnAddEvent) then
FOnAddEvent( self, FActiveEvent) ;
2008-02-03 12:05:55 +00:00
Invalidate;
end else begin
if NewEvent then begin
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 ) ;
2008-02-03 12:05:55 +00:00
end else
DataStore. PostEvents;
Invalidate;
end ;
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
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
function TVpDayView. EditEventAtCoord( Point: TPoint) : Boolean ;
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-06-29 21:46:53 +00:00
if PointInRect( Point, dvEventArray[ I] . Rec) then
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 ;
{=====}
function TVpDayView. GetEventAtCoord( Point: TPoint) : TVpEvent;
var
I: Integer ;
begin
result : = nil ;
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( Point, dvEventArray[ I] . Rec) then
begin
2008-02-03 12:05:55 +00:00
result : = TVpEvent( dvEventArray[ I] . Event) ;
Exit;
end ;
end ;
end ;
{=====}
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;
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-06-23 23:16:34 +00:00
dvInPlaceEditor. SetBounds(
2016-06-24 21:41:24 +00:00
dvActiveIconRec. Right + TextMargin,
2016-06-23 23:16:34 +00:00
dvActiveEventRec. Top + TextMargin,
2016-06-24 21:41:24 +00:00
dvActiveEventRec. Right - dvActiveIconRec. Right - TextMargin,
2016-06-24 19:10:59 +00:00
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-01 22:21:07 +00:00
nMax : = FLineCount + 1 ;
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
2008-02-03 12:05:55 +00:00
procedure TVpDayView. SetShowResourceName( Value: Boolean ) ;
begin
if Value < > FShowResourceName then begin
FShowResourceName : = 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 ;
{=====}
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
2008-02-07 16:22:04 +00:00
{.$IFNDEF LCL}
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
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 ;
2008-02-07 16:22:04 +00:00
{.$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 .