2008-02-03 12:05:55 +00:00
|
|
|
{*********************************************************}
|
|
|
|
{* VPBASE.PAS 1.03 *}
|
|
|
|
{*********************************************************}
|
|
|
|
|
|
|
|
{* ***** BEGIN LICENSE BLOCK ***** *}
|
|
|
|
{* Version: MPL 1.1 *}
|
|
|
|
{* *}
|
|
|
|
{* The contents of this file are subject to the Mozilla Public License *}
|
|
|
|
{* Version 1.1 (the "License"); you may not use this file except in *}
|
|
|
|
{* compliance with the License. You may obtain a copy of the License at *}
|
|
|
|
{* http://www.mozilla.org/MPL/ *}
|
|
|
|
{* *}
|
|
|
|
{* Software distributed under the License is distributed on an "AS IS" basis, *}
|
|
|
|
{* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License *}
|
|
|
|
{* for the specific language governing rights and limitations under the *}
|
|
|
|
{* License. *}
|
|
|
|
{* *}
|
|
|
|
{* The Original Code is TurboPower Visual PlanIt *}
|
|
|
|
{* *}
|
|
|
|
{* The Initial Developer of the Original Code is TurboPower Software *}
|
|
|
|
{* *}
|
|
|
|
{* Portions created by TurboPower Software Inc. are Copyright (C) 2002 *}
|
|
|
|
{* TurboPower Software Inc. All Rights Reserved. *}
|
|
|
|
{* *}
|
|
|
|
{* Contributor(s): *}
|
|
|
|
{* *}
|
|
|
|
{* ***** END LICENSE BLOCK ***** *}
|
|
|
|
|
2016-06-22 07:59:17 +00:00
|
|
|
{$I vp.inc}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
unit VpBase;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF LCL}
|
2016-06-07 15:09:01 +00:00
|
|
|
LMessages, LCLProc, LCLType, LResources,
|
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}
|
2022-08-16 15:04:39 +00:00
|
|
|
Classes, Graphics,
|
|
|
|
Controls, Dialogs, Forms, ExtCtrls, SysUtils, ImgList, Menus,
|
2016-07-11 21:13:57 +00:00
|
|
|
VpConst, VpSR;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
const
|
|
|
|
{Message base}
|
2016-07-12 18:00:32 +00:00
|
|
|
Vp_First = WM_USER; // $7DF0; {Sets base for all Vp messages}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
const
|
|
|
|
{Custom message types}
|
|
|
|
Vp_PrintFormatChanged = Vp_First + 1; {Print formats have changed}
|
|
|
|
Vp_DataStoreChanged = Vp_First + 2; {Data Store has changed}
|
2016-06-20 09:06:30 +00:00
|
|
|
Vp_DayViewInit = Vp_First + 3; {Initialize the DayView}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
type
|
2018-07-06 18:56:08 +00:00
|
|
|
{$IF FPC_FullVersion < 30000}
|
|
|
|
TStringArray = array of string;
|
|
|
|
{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
TVpRotationAngle = (ra0, ra90, ra180, ra270);
|
2016-07-08 11:05:54 +00:00
|
|
|
TVpItemMeasurement = (imAbsolutePixel, imPercent, imInches, imCentimeters);
|
2008-02-03 12:05:55 +00:00
|
|
|
TVpItemType = (itDayView, itWeekView, itMonthView, itCalendar,
|
2022-09-05 18:01:40 +00:00
|
|
|
itShape, itCaption, itTasks, itContacts, itGanttView);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
TVpHours = (h_00, h_01, h_02, h_03, h_04, h_05, h_06, h_07, h_08,
|
2016-06-07 11:58:39 +00:00
|
|
|
h_09, h_10, h_11, h_12, h_13, h_14, h_15, h_16, h_17,
|
|
|
|
h_18, h_19, h_20, h_21, h_22, h_23);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-20 09:06:30 +00:00
|
|
|
TVpGranularity = (gr05Min, gr06Min, gr10Min, gr15Min, gr20Min, gr30Min, gr60Min);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
TVpEditorReturnCode = (rtCommit, rtAbandon);
|
|
|
|
|
|
|
|
TVpCheckStyle = (csX, csCheck);
|
|
|
|
|
|
|
|
TVpTimeFormat = (tf24Hour, tf12Hour);
|
|
|
|
|
2016-06-14 10:38:28 +00:00
|
|
|
TVpPlaySoundMode = (psmSync, psmAsync, psmStop);
|
2016-06-13 09:53:36 +00:00
|
|
|
|
2016-09-19 22:58:13 +00:00
|
|
|
TVpHintMode = (hmPlannerHint, hmComponentHint);
|
2016-09-12 22:25:34 +00:00
|
|
|
|
2022-08-16 15:04:39 +00:00
|
|
|
TVpMenuItemKind = (mikSeparator,
|
|
|
|
mikAddEvent, mikEditEvent, mikDeleteEvent,
|
|
|
|
mikAddTask, mikEditTask, mikDeleteTask,
|
|
|
|
mikAddContact, mikEditContact, mikDeleteContact,
|
2022-08-20 17:06:03 +00:00
|
|
|
mikImportEventFromICal, mikExportEventToICal,
|
2022-08-20 21:21:14 +00:00
|
|
|
mikImportTaskFromICal, mikExportTaskToICal,
|
2022-08-18 17:44:47 +00:00
|
|
|
mikImportContactFromVCards, mikExportContactToVCard,
|
2022-08-16 15:04:39 +00:00
|
|
|
mikResourceGroups, mikNoOverlaidEvents,
|
|
|
|
mikChangeDate, mikCustomDate, mikToday, mikYesterday, mikTomorrow,
|
|
|
|
mikPrevDay, mikNextDay, mikPrevWeek, mikNextWeek,
|
|
|
|
mikPrevMonth, mikNextMonth, mikPrevYear, mikNextYear
|
|
|
|
);
|
|
|
|
|
|
|
|
const
|
|
|
|
VpMenuCaptions: array[TVpMenuItemKind] of String = ('-',
|
|
|
|
RSPopupAddEvent, RSPopupEditEvent, RSPopupDeleteEvent,
|
|
|
|
RSTaskPopupAdd, RSTaskPopupEdit, RSTaskPopupDelete,
|
|
|
|
RSContactPopupAdd, RSContactPopupEdit, RSContactPopupDelete,
|
2022-08-20 21:21:14 +00:00
|
|
|
RSPopupImportFromICal, RSPopupExportToICal,
|
|
|
|
RSPopupImportFromICal, RSPopupExportToICal,
|
2022-08-18 17:44:47 +00:00
|
|
|
RSContactPopupImportVCards, RSContactPopupExportVCard,
|
2022-08-16 15:04:39 +00:00
|
|
|
RSPopupResourceGroups, RSNoOverlayedEvents,
|
|
|
|
RSPopupChangeDate, RSCustomDate, RSToday, RSYesterday, RSTomorrow,
|
|
|
|
RSPrevDay, RSNextDay, RSPrevWeek, RSNextWeek,
|
|
|
|
RSPrevMonth, RSNextMonth, RSPrevYear, RSNextYear
|
|
|
|
);
|
|
|
|
|
|
|
|
type
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{ XML definitions }
|
|
|
|
DOMString = WideString;
|
|
|
|
|
|
|
|
{ miscellaneous stuff }
|
2016-07-03 08:39:53 +00:00
|
|
|
TVpDrawingStyle = (dsFlat, ds3d, dsNoBorder); // wp: rename dsNone --> dsNoBorder
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
{ event method types }
|
2016-06-20 09:06:30 +00:00
|
|
|
TVpMouseWheelEvent = procedure(Sender: TObject; Shift: TShiftState;
|
|
|
|
Delta, XPos, YPos: Word) of object;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
TVpOwnerDrawEvent = procedure(Sender: TObject; const Canvas: TCanvas;
|
|
|
|
R: TRect; var Drawn: Boolean) of object;
|
|
|
|
|
|
|
|
TVpOwnerDrawRowEvent = procedure(Sender: TObject; const Canvas: TCanvas;
|
|
|
|
R: TRect; RowHeight: Integer; var Drawn: Boolean) of object;
|
|
|
|
|
|
|
|
TVpOwnerDrawDayEvent = procedure(Sender: TObject; const Canvas: TCanvas;
|
|
|
|
R: TRect; Day: Integer; var Drawn: Boolean) of object;
|
|
|
|
|
2016-06-20 09:06:30 +00:00
|
|
|
TVpItemSelectedEvent = procedure(Sender: TObject;
|
|
|
|
Index: Integer) of object;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-20 09:06:30 +00:00
|
|
|
TVpGetEditorCaption = procedure(var Caption: string) of object;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-13 09:53:36 +00:00
|
|
|
TVpPlaySoundEvent = procedure(Sender: TObject; const AWavFile: String;
|
|
|
|
AMode: TVpPlaySoundMode) of object;
|
|
|
|
|
2016-09-22 17:47:27 +00:00
|
|
|
TVpHolidayEvent = procedure(Sender: TObject; ADate: TDateTime;
|
|
|
|
var AHolidayName: String) of object;
|
|
|
|
|
2018-06-08 20:03:23 +00:00
|
|
|
{ Visual planit Exceptions }
|
|
|
|
EVpException = class(Exception);
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{ XML exceptions }
|
2018-06-08 20:03:23 +00:00
|
|
|
EXML = class(EVpException);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
EVpStreamError = class(EXML)
|
|
|
|
private
|
|
|
|
seFilePos : Longint;
|
|
|
|
public
|
2016-07-15 23:25:07 +00:00
|
|
|
constructor CreateError(const FilePos: Longint; const Reason: DOMString); overload;
|
|
|
|
{$IFDEF FPC}
|
|
|
|
constructor CreateError(const FilePos: Longint; const Reason: String); overload;
|
|
|
|
{$ENDIF}
|
2016-06-20 09:06:30 +00:00
|
|
|
property FilePos: Longint read seFilePos;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
EVpFilterError = class(EVpStreamError)
|
|
|
|
private
|
2016-06-12 13:51:29 +00:00
|
|
|
feReason: DOMString;
|
|
|
|
feLine: Longint;
|
|
|
|
feLinePos: Longint;
|
2008-02-03 12:05:55 +00:00
|
|
|
public
|
2016-07-15 23:25:07 +00:00
|
|
|
constructor CreateError(const FilePos, Line, LinePos: Longint; const Reason: DOMstring); overload;
|
|
|
|
{$IFDEF FPC}
|
|
|
|
constructor CreateError(const FilePos, Line, LinePos: Longint; const Reason: string); overload;
|
|
|
|
{$ENDIF}
|
2016-06-12 13:51:29 +00:00
|
|
|
property Reason : DOMString read feReason;
|
2016-06-20 09:06:30 +00:00
|
|
|
property Line: Longint read feLine;
|
|
|
|
property LinePos: Longint read feLinePos;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
EVpParserError = class(EVpFilterError)
|
|
|
|
public
|
2016-07-15 23:25:07 +00:00
|
|
|
constructor CreateError(Line, LinePos: Longint; const Reason: DOMString); overload;
|
|
|
|
{$IFDEF FPC}
|
|
|
|
constructor CreateError(Line, LinePos: Longint; const Reason: String); overload;
|
|
|
|
{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
{ implements the Version property with its associated design time About box }
|
|
|
|
TVpComponent = class(TComponent)
|
|
|
|
protected { private }
|
2016-06-12 13:51:29 +00:00
|
|
|
function GetVersion: string;
|
|
|
|
procedure SetVersion(const Value: string);
|
2008-02-03 12:05:55 +00:00
|
|
|
public
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
published
|
|
|
|
{ properties }
|
2016-06-12 13:51:29 +00:00
|
|
|
property Version: string read GetVersion write SetVersion stored False;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
{ Ancestor for all Visual PlanIt visual controls }
|
|
|
|
TVpCustomControl = class(TCustomControl)
|
|
|
|
protected { private }
|
2016-06-20 09:06:30 +00:00
|
|
|
FAfterEnter: TNotifyEvent;
|
|
|
|
FAfterExit: TNotifyEvent;
|
|
|
|
FOnMouseWheel: TVpMouseWheelEvent;
|
|
|
|
FAutoScroll: Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
function GetVersion : string;
|
2016-06-20 09:06:30 +00:00
|
|
|
procedure SetVersion(const Value: string);
|
2016-06-22 07:59:17 +00:00
|
|
|
procedure CMVisibleChanged(var Msg: {$IFDEF DELPHI}TMessage{$ELSE}TLMessage{$ENDIF}); message CM_VISIBLECHANGED;
|
|
|
|
{$IFDEF DELPHI}
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure WMMouseWheel(var Msg : TMessage); message WM_MOUSEWHEEL;
|
2016-06-12 13:51:29 +00:00
|
|
|
procedure DoOnMouseWheel(Shift: TShiftState; Delta, XPos, YPos: SmallInt); dynamic;
|
2016-06-12 15:29:23 +00:00
|
|
|
{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure CreateWnd; override;
|
2016-06-12 13:51:29 +00:00
|
|
|
property AfterEnter: TNotifyEvent read FAfterEnter write FAfterEnter;
|
|
|
|
property AfterExit: TNotifyEvent read FAfterExit write FAfterExit;
|
|
|
|
property OnMouseWheel: TVpMouseWheelEvent read FOnMouseWheel write FOnMouseWheel;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-09-11 13:35:19 +00:00
|
|
|
public
|
2008-02-03 12:05:55 +00:00
|
|
|
constructor Create (AOwner : TComponent); override;
|
|
|
|
|
|
|
|
published
|
2016-06-12 13:51:29 +00:00
|
|
|
property Version: string read GetVersion write SetVersion stored False;
|
2008-02-03 12:05:55 +00:00
|
|
|
{$IFNDEF LCL}
|
2016-09-11 13:35:19 +00:00
|
|
|
{$IFDEF VERSION6}
|
|
|
|
property BevelEdges;
|
|
|
|
property BevelInner;
|
|
|
|
property BevelOuter;
|
|
|
|
property BevelKind;
|
|
|
|
property BevelWidth;
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
|
|
|
{$ENDIF}
|
|
|
|
|
2016-09-11 13:35:19 +00:00
|
|
|
{ The Hint property is published in TControl, but the ShowHint }
|
|
|
|
{ property is left public. odd. }
|
|
|
|
{ surfacing here will make it published in all our descendants }
|
|
|
|
property ShowHint;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
TVpPersistent = class(TPersistent)
|
|
|
|
public
|
|
|
|
procedure Invalidate; virtual; abstract;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{TVpCategoryColorMap}
|
2018-06-04 10:36:57 +00:00
|
|
|
TVpCategoryColorMap = class;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
TVpCategoryInfo= class(TPersistent)
|
|
|
|
private
|
2018-06-04 10:36:57 +00:00
|
|
|
FOwner: TComponent; // This is the DataStore.
|
2008-02-03 12:05:55 +00:00
|
|
|
FCategoryIndex: Integer;
|
2022-08-20 19:11:37 +00:00
|
|
|
function IsStoredColor: Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
protected
|
2016-06-20 09:06:30 +00:00
|
|
|
FBackgroundColor: TColor;
|
|
|
|
FColor: TColor;
|
|
|
|
FDescription: string;
|
2018-05-18 09:47:36 +00:00
|
|
|
FImageIndex: TImageIndex;
|
2016-06-20 09:06:30 +00:00
|
|
|
FIndex: Integer;
|
|
|
|
FBitmap: TBitmap;
|
2022-08-16 19:58:12 +00:00
|
|
|
FAllDayEvents: Boolean;
|
2016-09-11 13:35:19 +00:00
|
|
|
procedure SetBackgroundColor(const v: TColor);
|
|
|
|
procedure SetBitmap(v: TBitmap);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure SetColor(Value: TColor);
|
|
|
|
procedure SetDescription(Value: string);
|
2018-05-18 09:47:36 +00:00
|
|
|
procedure SetImageIndex(Value: TImageIndex);
|
2016-06-20 09:06:30 +00:00
|
|
|
public
|
2018-06-04 10:36:57 +00:00
|
|
|
constructor Create(AOwner: TComponent);
|
2016-06-20 09:06:30 +00:00
|
|
|
destructor Destroy; override;
|
2018-06-04 10:36:57 +00:00
|
|
|
property Owner: TComponent read FOwner;
|
2008-02-03 12:05:55 +00:00
|
|
|
published
|
2016-06-20 09:06:30 +00:00
|
|
|
property BackgroundColor: TColor
|
|
|
|
read FBackgroundColor write SetBackgroundColor default clWindow;
|
2016-09-11 13:35:19 +00:00
|
|
|
property Bitmap: TBitmap read FBitmap write SetBitmap;
|
2022-08-20 19:11:37 +00:00
|
|
|
property Color: TColor read FColor write SetColor stored IsStoredColor;
|
2008-02-03 12:05:55 +00:00
|
|
|
property Description: string read FDescription write SetDescription;
|
2018-05-18 09:47:36 +00:00
|
|
|
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
|
2008-02-03 12:05:55 +00:00
|
|
|
property CategoryIndex: Integer read FCategoryIndex;
|
2022-08-16 19:58:12 +00:00
|
|
|
property UseForAllDayEvents: Boolean read FAllDayEvents write FAllDayEvents default false;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
TVpCategoryColorMap = class(TPersistent)
|
|
|
|
protected
|
2018-06-04 10:36:57 +00:00
|
|
|
FOwner: TComponent;
|
2016-06-20 09:06:30 +00:00
|
|
|
FCat: array[0..9] of TVpCategoryInfo;
|
|
|
|
procedure SetCat(AIndex: Integer; AValue: TVpCategoryInfo);
|
2008-02-03 12:05:55 +00:00
|
|
|
public
|
2018-06-04 10:36:57 +00:00
|
|
|
constructor Create(AOwner: TComponent);
|
2008-02-03 12:05:55 +00:00
|
|
|
destructor Destroy; override;
|
2022-08-20 19:11:37 +00:00
|
|
|
function GetBackgroundColor(AIndex: Integer): TColor;
|
2018-06-16 23:07:26 +00:00
|
|
|
function GetColor(AIndex: Integer): TColor;
|
|
|
|
function GetName(AIndex: Integer):string;
|
2016-06-20 14:21:33 +00:00
|
|
|
function GetCategory(AIndex: Integer): TVpCategoryInfo;
|
2022-08-10 10:20:56 +00:00
|
|
|
function GetCategoryName(AIndex: Integer): String;
|
2018-06-16 23:07:26 +00:00
|
|
|
function IndexOfCategory(AName: String): Integer;
|
|
|
|
function IndexOfFirstUnusedCategory: Integer;
|
|
|
|
procedure SetCategoryName(AIndex: Integer; AName: String);
|
2008-02-03 12:05:55 +00:00
|
|
|
published
|
2016-06-20 14:21:33 +00:00
|
|
|
property Category0: TVpCategoryInfo index 0 read GetCategory write SetCat;
|
|
|
|
property Category1: TVpCategoryInfo index 1 read GetCategory write SetCat;
|
|
|
|
property Category2: TVpCategoryInfo index 2 read GetCategory write SetCat;
|
|
|
|
property Category3: TVpCategoryInfo index 3 read GetCategory write SetCat;
|
|
|
|
property Category4: TVpCategoryInfo index 4 read GetCategory write SetCat;
|
|
|
|
property Category5: TVpCategoryInfo index 5 read GetCategory write SetCat;
|
|
|
|
property Category6: TVpCategoryInfo index 6 read GetCategory write SetCat;
|
|
|
|
property Category7: TVpCategoryInfo index 7 read GetCategory write SetCat;
|
|
|
|
property Category8: TVpCategoryInfo index 8 read GetCategory write SetCat;
|
|
|
|
property Category9: TVpCategoryInfo index 9 read GetCategory write SetCat;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
{ TVpFont }
|
|
|
|
TVpFont = class(TFont)
|
|
|
|
protected
|
|
|
|
FOwner: TObject;
|
|
|
|
procedure Changed; override;
|
|
|
|
public
|
2016-07-12 18:00:32 +00:00
|
|
|
constructor Create(AOwner: TObject); virtual; reintroduce;
|
2008-02-03 12:05:55 +00:00
|
|
|
property Owner: TObject read FOwner write FOwner;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ Collections }
|
|
|
|
TVpCollectionItem = class(TCollectionItem)
|
|
|
|
protected { private }
|
|
|
|
FName: String;
|
|
|
|
FDisplayText: String;
|
|
|
|
function GetVersion: String;
|
|
|
|
procedure SetVersion(const Value: String);
|
|
|
|
procedure SetName(Value: String); virtual;
|
|
|
|
public
|
2016-06-12 13:51:29 +00:00
|
|
|
property DisplayText: string read FDisplayText write FDisplayText;
|
2008-02-03 12:05:55 +00:00
|
|
|
property Name: String read FName write SetName;
|
|
|
|
published
|
2016-06-12 13:51:29 +00:00
|
|
|
property Version: String read GetVersion write SetVersion;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
TVpCollection = class(TCollection)
|
|
|
|
protected { private }
|
|
|
|
{ property variables }
|
2016-06-20 09:06:30 +00:00
|
|
|
FItemEditor: TForm;
|
|
|
|
FReadOnly: Boolean;
|
|
|
|
FOwner: TPersistent;
|
2008-02-03 12:05:55 +00:00
|
|
|
{ event variables }
|
2016-06-20 09:06:30 +00:00
|
|
|
FOnChanged: TNotifyEvent;
|
|
|
|
FOnItemSelected: TVpItemSelectedEvent;
|
|
|
|
FOnGetEditorCaption: TVpGetEditorCaption;
|
2008-02-03 12:05:55 +00:00
|
|
|
{ Internal variables }
|
2016-06-20 09:06:30 +00:00
|
|
|
InLoaded: Boolean;
|
|
|
|
IsLoaded: Boolean;
|
|
|
|
InChanged: Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
protected
|
2016-06-20 09:06:30 +00:00
|
|
|
function GetCount: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure Loaded;
|
|
|
|
public
|
2016-06-20 09:06:30 +00:00
|
|
|
constructor Create(AOwner: TPersistent; ItemClass: TCollectionItemClass); virtual;
|
2008-02-03 12:05:55 +00:00
|
|
|
destructor Destroy; override;
|
2016-06-12 13:51:29 +00:00
|
|
|
property ItemEditor: TForm read FItemEditor write FItemEditor;
|
|
|
|
function Add: TVpCollectionItem; dynamic;
|
2008-02-03 12:05:55 +00:00
|
|
|
{$IFNDEF VERSION4}
|
|
|
|
function Insert(Index: Integer): TVpCollectionItem; dynamic;
|
|
|
|
{$ENDIF}
|
|
|
|
function GetItem(Index: Integer): TVpCollectionItem;
|
|
|
|
function GetOwner: TPersistent; override;
|
|
|
|
procedure SetItem(Index: Integer; Value: TVpCollectionItem);
|
2016-06-12 13:51:29 +00:00
|
|
|
procedure DoOnItemSelected(Index: Integer);
|
|
|
|
function GetEditorCaption: string;
|
|
|
|
function ItemByName(const Name: string) : TVpCollectionItem;
|
|
|
|
function ParentForm: TForm;
|
2008-02-03 12:05:55 +00:00
|
|
|
property Count: Integer read GetCount;
|
2016-06-20 09:06:30 +00:00
|
|
|
property Item[Index: Integer]: TVpCollectionItem read GetItem write SetItem; default;
|
|
|
|
property OnGetEditorCaption: TVpGetEditorCaption read FOnGetEditorCaption write FOnGetEditorCaption;
|
|
|
|
property ReadOnly: Boolean read FReadOnly write FReadOnly default False;
|
|
|
|
property OnChanged: TNotifyEvent read FOnChanged write FOnChanged;
|
|
|
|
property OnItemSelected: TVpItemSelectedEvent read FOnItemSelected write FOnItemSelected;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
TVpContainerList = class(TList)
|
|
|
|
protected{ private }
|
|
|
|
FOwner: TComponent;
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TComponent); virtual;
|
|
|
|
destructor Destroy; override;
|
|
|
|
end;
|
|
|
|
{ End - Collections }
|
|
|
|
|
|
|
|
TVpTimeRange = class(TPersistent)
|
|
|
|
protected{private}
|
|
|
|
FOwner: TObject;
|
|
|
|
FStartTime: TDateTime;
|
|
|
|
FEndTime: TDateTime;
|
|
|
|
FRangeBegin: TVpHours;
|
|
|
|
FRangeEnd: TVpHours;
|
|
|
|
procedure SetRangeBegin(const Value: TVpHours);
|
|
|
|
procedure SetRangeEnd(const Value: TVpHours);
|
|
|
|
procedure SetEndTime(const Value: TDateTime);
|
|
|
|
procedure SetStartTime(const Value: TDateTime);
|
|
|
|
public
|
|
|
|
constructor Create(aOwner: TObject);
|
|
|
|
destructor Destroy; override;
|
|
|
|
property StartTime: TDateTime read FStartTime write SetStartTime;
|
|
|
|
property EndTime: TDateTime read FEndTime write SetEndTime;
|
|
|
|
published
|
|
|
|
property RangeBegin: TVpHours read FRangeBegin write SetRangeBegin;
|
|
|
|
property RangeEnd: TVpHours read FRangeEnd write SetRangeEnd;
|
|
|
|
end;
|
|
|
|
|
|
|
|
TVpTimeSlotColor = class(TPersistent)
|
|
|
|
protected { private }
|
|
|
|
FOwner: TVpCustomControl;
|
|
|
|
FActiveRange: TVpTimeRange;
|
|
|
|
FInactive: TColor;
|
|
|
|
FHoliday: TColor;
|
|
|
|
FWeekend: TColor;
|
|
|
|
FActive: TColor;
|
|
|
|
FWeekday: TColor;
|
|
|
|
procedure SetActive(const Value: TColor);
|
|
|
|
procedure SetHoliday(const Value: TColor);
|
|
|
|
procedure SetInactive(const Value: TColor);
|
|
|
|
procedure SetWeekday(const Value: TColor);
|
|
|
|
procedure SetWeekend(const Value: TColor);
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TVpCustomControl);
|
|
|
|
destructor Destroy; override;
|
|
|
|
procedure Changed;
|
|
|
|
published
|
|
|
|
property Active: TColor read FActive write SetActive;
|
2016-09-22 23:12:16 +00:00
|
|
|
property Inactive: TColor read FInactive write SetInactive default OFF_COLOR;
|
|
|
|
property Holiday: TColor read FHoliday write SetHoliday default HOLIDAY_COLOR;
|
|
|
|
property Weekday: TColor read FWeekday write SetWeekday default WEEKDAY_COLOR;
|
|
|
|
property Weekend: TColor read FWeekend write SetWeekend default WEEKEND_COLOR;
|
2016-06-12 13:51:29 +00:00
|
|
|
property ActiveRange: TVpTimeRange read FActiveRange write FActiveRange;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
2022-09-05 09:27:54 +00:00
|
|
|
TVpAllDayEventAttributes = class(TPersistent)
|
|
|
|
private
|
|
|
|
FOwner: TWinControl;
|
|
|
|
FBackgroundColor: TColor;
|
|
|
|
FEventBackgroundColor: TColor;
|
|
|
|
FEventBorderColor: TColor;
|
|
|
|
FFont: TVpFont;
|
|
|
|
protected
|
|
|
|
procedure UpdateOwner;
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TWinControl);
|
|
|
|
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 default clBtnShadow;
|
|
|
|
property EventBackgroundColor: TColor
|
|
|
|
read FEventBackgroundColor write SetEventBackgroundColor default clBtnFace;
|
|
|
|
property EventBorderColor: TColor
|
|
|
|
read FEventBorderColor write SetEventBorderColor default cl3dDkShadow;
|
|
|
|
property Font: TVpFont
|
|
|
|
read FFont write SetFont;
|
|
|
|
end;
|
|
|
|
|
2017-05-25 21:24:23 +00:00
|
|
|
TVpHintWindow = class(THintWindow)
|
|
|
|
public
|
2018-01-12 12:42:12 +00:00
|
|
|
function CalcHintRect({%H-}MaxWidth: Integer; const AHint: String;
|
2017-05-25 21:24:23 +00:00
|
|
|
AData: pointer): TRect; override;
|
|
|
|
end;
|
|
|
|
|
2022-08-16 15:04:39 +00:00
|
|
|
TVpMenuItem = class(TMenuItem)
|
|
|
|
private
|
|
|
|
FKind: TVpMenuItemKind;
|
|
|
|
procedure SetKind(AValue: TVpMenuItemKind);
|
|
|
|
public
|
|
|
|
procedure Translate;
|
|
|
|
property Kind: TVpMenuItemKind read FKind write SetKind;
|
|
|
|
end;
|
|
|
|
|
2017-05-25 21:24:23 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
implementation
|
|
|
|
|
2017-05-23 17:39:54 +00:00
|
|
|
{$IFDEF NEW_ICONS}
|
|
|
|
{$R vpbasepng.res}
|
|
|
|
{$ELSE}
|
|
|
|
{$R vpbase.res}
|
|
|
|
{$ENDIF}
|
2016-04-26 15:54:35 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
uses
|
2016-07-12 18:00:32 +00:00
|
|
|
{$IFNDEF LCL}
|
|
|
|
CommCtrl,
|
2016-07-12 09:26:14 +00:00
|
|
|
{$ENDIF}
|
2016-07-12 18:00:32 +00:00
|
|
|
VpMisc;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2018-05-17 22:21:23 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{ EAdStreamError }
|
|
|
|
|
2016-07-15 23:25:07 +00:00
|
|
|
constructor EVpStreamError.CreateError(const FilePos: Integer;
|
|
|
|
const Reason: DOMString);
|
|
|
|
begin
|
|
|
|
{$IFDEF FPC}
|
|
|
|
inherited Create(UTF8Encode(Reason));
|
|
|
|
{$ELSE}
|
|
|
|
inherited Create(Reason);
|
|
|
|
{$ENDIF}
|
|
|
|
seFilePos := FilePos;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{$IFDEF FPC}
|
2008-02-03 12:05:55 +00:00
|
|
|
constructor EVpStreamError.CreateError(const FilePos: Integer;
|
2016-07-12 18:00:32 +00:00
|
|
|
const Reason: String);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-07-12 18:00:32 +00:00
|
|
|
inherited Create(Reason);
|
2008-02-03 12:05:55 +00:00
|
|
|
seFilePos := FilePos;
|
|
|
|
end;
|
2016-07-15 23:25:07 +00:00
|
|
|
{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2018-05-17 22:21:23 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{ EAdFilterError }
|
|
|
|
|
2016-06-12 13:51:29 +00:00
|
|
|
constructor EVpFilterError.CreateError(const FilePos, Line, LinePos: Integer;
|
2016-07-15 23:25:07 +00:00
|
|
|
const Reason: DOMString);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
inherited CreateError(FilePos, Reason);
|
|
|
|
feLine := Line;
|
|
|
|
feLinePos := LinePos;
|
|
|
|
feReason := Reason;
|
|
|
|
end;
|
|
|
|
|
2016-07-15 23:25:07 +00:00
|
|
|
{$IFDEF FPC}
|
|
|
|
constructor EVpFilterError.CreateError(const FilePos, Line, LinePos: Integer;
|
|
|
|
const Reason: String);
|
|
|
|
begin
|
|
|
|
feReason := UTF8DEcode(Reason);
|
|
|
|
inherited CreateError(FilePos, feReason);
|
|
|
|
feLine := Line;
|
|
|
|
feLinePos := LinePos;
|
|
|
|
end;
|
|
|
|
{$ENDIF}
|
|
|
|
|
2018-05-17 22:21:23 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{ EAdParserError }
|
|
|
|
|
2016-07-15 23:25:07 +00:00
|
|
|
constructor EVpParserError.CreateError(Line, LinePos: Integer;
|
|
|
|
const Reason: DOMString);
|
|
|
|
begin
|
|
|
|
inherited CreateError(FilePos, Line, LinePos, Reason);
|
|
|
|
end;
|
|
|
|
|
|
|
|
{$IFDEF FPC}
|
2008-02-03 12:05:55 +00:00
|
|
|
constructor EVpParserError.CreateError(Line, LinePos: Integer;
|
2016-07-12 18:00:32 +00:00
|
|
|
const Reason: String);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
inherited CreateError(FilePos, Line, LinePos, Reason);
|
|
|
|
end;
|
2016-07-15 23:25:07 +00:00
|
|
|
{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2018-05-17 22:21:23 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
(*****************************************************************************)
|
|
|
|
{ TVpCustomControl }
|
|
|
|
|
2016-06-20 09:06:30 +00:00
|
|
|
constructor TVpCustomControl.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited Create (AOwner);
|
|
|
|
TabStop := True;
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-22 07:59:17 +00:00
|
|
|
procedure TVpCustomControl.CMVisibleChanged(var Msg: {$IFDEF DELPHI}TMessage{$ELSE}TLMessage{$ENDIF});
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
if csLoading in ComponentState then
|
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpCustomControl.CreateWnd;
|
|
|
|
begin
|
|
|
|
inherited CreateWnd;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TVpCustomControl.GetVersion: string;
|
|
|
|
begin
|
|
|
|
Result := VpVersionStr;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpCustomControl.SetVersion(const Value: string);
|
|
|
|
begin
|
2016-07-12 18:00:32 +00:00
|
|
|
// This method left intentionally blank.
|
|
|
|
Unused(Value);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
2016-06-22 07:59:17 +00:00
|
|
|
{$IFDEF DELPHI}
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TVpCustomControl.WMMouseWheel(var Msg: TMessage);
|
|
|
|
begin
|
|
|
|
with Msg do
|
2016-06-12 15:29:23 +00:00
|
|
|
DoOnMouseWheel(
|
|
|
|
KeysToShiftState(LOWORD(wParam)) {fwKeys},
|
|
|
|
HIWORD(wParam) {zDelta},
|
|
|
|
LOWORD(lParam) {xPos},
|
|
|
|
HIWORD(lParam) {yPos}
|
2016-06-12 13:51:29 +00:00
|
|
|
);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2016-06-12 15:29:23 +00:00
|
|
|
|
|
|
|
procedure TVpCustomControl.DoOnMouseWheel(Shift: TShiftState;
|
|
|
|
Delta, XPos, YPos: SmallInt);
|
|
|
|
begin
|
|
|
|
if Assigned(FOnMouseWheel) then
|
|
|
|
FOnMouseWheel(Self, Shift, Delta, XPos, YPos);
|
|
|
|
end;
|
|
|
|
{$ENDIF}
|
2018-05-17 22:21:23 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
(*****************************************************************************)
|
|
|
|
{ TVpCollection }
|
|
|
|
|
2016-06-12 13:51:29 +00:00
|
|
|
constructor TVpCollection.Create(AOwner: TPersistent; ItemClass: TCollectionItemClass);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
FOwner := AOwner;
|
|
|
|
Inherited Create(ItemClass);
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TVpCollection.Destroy;
|
|
|
|
begin
|
|
|
|
ItemEditor.Free;
|
|
|
|
Clear;
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2016-06-12 13:51:29 +00:00
|
|
|
procedure TVpCollection.DoOnItemSelected(Index: Integer);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if Assigned(FOnItemSelected) then
|
|
|
|
FOnItemSelected(Self, Index);
|
|
|
|
end;
|
|
|
|
|
2016-06-12 13:51:29 +00:00
|
|
|
function TVpCollection.GetCount: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
Result := inherited Count;
|
|
|
|
end;
|
|
|
|
|
2016-06-12 13:51:29 +00:00
|
|
|
function TVpCollection.GetEditorCaption: string;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
Result := 'Editing ' + ClassName;
|
|
|
|
if Assigned(FOnGetEditorCaption) then
|
|
|
|
FOnGetEditorCaption(Result);
|
|
|
|
end;
|
|
|
|
|
2016-06-12 13:51:29 +00:00
|
|
|
function TVpCollection.Add: TVpCollectionItem;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
Result := TVpCollectionItem(inherited Add);
|
|
|
|
if ItemEditor <> nil then
|
|
|
|
//TODO: SendMessage(ItemEditor.Handle, Vp_PROPCHANGE, 0, 0);
|
|
|
|
end;
|
|
|
|
|
|
|
|
{$IFNDEF VERSION4}
|
|
|
|
function TVpCollection.Insert(Index: Integer): TVpCollectionItem;
|
|
|
|
var
|
|
|
|
I: Integer;
|
|
|
|
begin
|
|
|
|
result := Add;
|
|
|
|
for I := Index to Count - 2 do
|
|
|
|
Items[I].Index := I + 1;
|
|
|
|
Items[Count - 1].Index := Index;
|
|
|
|
end;
|
|
|
|
{$ENDIF}
|
|
|
|
|
2016-06-12 13:51:29 +00:00
|
|
|
function TVpCollection.GetItem(Index: Integer): TVpCollectionItem;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
Result := TVpCollectionItem(inherited GetItem(Index));
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TVpCollection.GetOwner: TPersistent;
|
|
|
|
begin
|
|
|
|
result := FOwner;
|
|
|
|
end;
|
|
|
|
|
2016-06-12 13:51:29 +00:00
|
|
|
procedure TVpCollection.SetItem(Index: Integer; Value: TVpCollectionItem);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
inherited SetItem(Index, Value);
|
|
|
|
end;
|
|
|
|
|
2016-06-12 13:51:29 +00:00
|
|
|
function TVpCollection.ItemByName(const Name: string): TVpCollectionItem;
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
|
|
|
i : Integer;
|
|
|
|
begin
|
|
|
|
for i := 0 to pred(Count) do
|
|
|
|
if Item[i].Name = Name then begin
|
|
|
|
Result := Item[i];
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpCollection.Loaded;
|
|
|
|
begin
|
|
|
|
InLoaded := True;
|
|
|
|
try
|
|
|
|
Changed;
|
|
|
|
finally
|
|
|
|
InLoaded := False;
|
|
|
|
end;
|
|
|
|
IsLoaded := True;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TVpCollection.ParentForm : TForm;
|
|
|
|
var
|
|
|
|
Temp : TObject;
|
|
|
|
begin
|
|
|
|
Temp := GetOwner;
|
|
|
|
while (Temp <> nil) and not (Temp is TForm) do
|
|
|
|
Temp := TComponent(Temp).Owner;
|
|
|
|
Result := TForm(Temp);
|
|
|
|
end;
|
|
|
|
|
2016-06-20 21:07:11 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
(*****************************************************************************)
|
|
|
|
{ TVpCollectionItem }
|
|
|
|
|
|
|
|
function TVpCollectionItem.GetVersion: String;
|
|
|
|
begin
|
|
|
|
Result := VpVersionStr;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpCollectionItem.SetVersion(const Value: String);
|
|
|
|
begin
|
2016-07-12 18:00:32 +00:00
|
|
|
Unused(Value);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpCollectionItem.SetName(Value: String);
|
|
|
|
begin
|
|
|
|
FName := Value;
|
|
|
|
end;
|
2018-05-17 22:21:23 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
(*****************************************************************************)
|
|
|
|
{ TO32ContainerList }
|
|
|
|
|
|
|
|
constructor TVpContainerList.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
FOwner := TComponent(AOwner);
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TVpContainerList.Destroy;
|
|
|
|
var
|
|
|
|
I: Integer;
|
|
|
|
begin
|
|
|
|
for I := 0 to Count - 1 do
|
|
|
|
TPanel(Items[I]).Free;
|
|
|
|
inherited;
|
|
|
|
end;
|
2018-05-17 22:21:23 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
(*****************************************************************************)
|
|
|
|
{ TVpComponent }
|
|
|
|
|
|
|
|
constructor TVpComponent.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited Create(AOwner);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TVpComponent.GetVersion: string;
|
|
|
|
begin
|
|
|
|
Result := VpVersionStr;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpComponent.SetVersion(const Value: string);
|
|
|
|
begin
|
|
|
|
// This method left intentionally blank.
|
2016-07-12 18:00:32 +00:00
|
|
|
Unused(Value);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2018-05-17 22:21:23 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
(*****************************************************************************)
|
|
|
|
{ VpFont }
|
|
|
|
|
|
|
|
procedure TVpFont.Changed;
|
|
|
|
begin
|
|
|
|
inherited;
|
2016-06-12 13:51:29 +00:00
|
|
|
Assert(
|
|
|
|
(FOwner is TControl) or (FOwner is TVpPersistent),
|
|
|
|
Format('TVpFont.Changed: Unexpected parent class: %s', [FOwner.ClassName])
|
|
|
|
);
|
2008-02-03 12:05:55 +00:00
|
|
|
if FOwner is TControl then
|
|
|
|
TControl(FOwner).Invalidate
|
|
|
|
else if FOwner is TVpPersistent then
|
|
|
|
TVpPersistent(FOwner).Invalidate;
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TVpFont.Create(AOwner: TObject);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
FOwner := AOwner;
|
|
|
|
end;
|
2018-05-17 22:21:23 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
(*****************************************************************************)
|
|
|
|
{ TVpCategoryColorMap }
|
|
|
|
|
2018-06-04 10:36:57 +00:00
|
|
|
constructor TVpCategoryColorMap.Create(AOwner: TComponent);
|
2016-06-20 09:06:30 +00:00
|
|
|
var
|
|
|
|
i: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
inherited Create;
|
2018-06-04 10:36:57 +00:00
|
|
|
FOwner := AOwner;
|
2018-06-16 23:07:26 +00:00
|
|
|
for i:=Low(FCat) to High(FCat) do
|
2016-06-20 09:06:30 +00:00
|
|
|
begin
|
2018-06-04 10:36:57 +00:00
|
|
|
FCat[i] := TVpCategoryInfo.Create(FOwner);
|
2016-06-20 09:06:30 +00:00
|
|
|
FCat[i].FIndex := i;
|
2022-08-20 19:11:37 +00:00
|
|
|
FCat[i].Color := CATEGORY_COLORS[i];
|
2016-06-20 09:06:30 +00:00
|
|
|
FCat[i].Description := Format(RSCategoryDesc, [i]);
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TVpCategoryColorMap.Destroy;
|
2016-06-20 09:06:30 +00:00
|
|
|
var
|
|
|
|
i: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2018-06-16 23:07:26 +00:00
|
|
|
for i:=Low(FCat) to High(FCat) do FCat[i].Free;
|
2008-02-03 12:05:55 +00:00
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
2016-06-20 14:21:33 +00:00
|
|
|
function TVpCategoryColorMap.GetCategory(AIndex: Integer): TVpCategoryInfo;
|
2016-06-20 09:06:30 +00:00
|
|
|
begin
|
|
|
|
Result := FCat[AIndex];
|
|
|
|
end;
|
|
|
|
|
2022-08-10 10:20:56 +00:00
|
|
|
function TVpCategoryColorMap.GetCategoryName(AIndex: Integer): string;
|
|
|
|
begin
|
|
|
|
Result := FCat[AIndex].Description;
|
|
|
|
end;
|
|
|
|
|
2018-06-16 23:07:26 +00:00
|
|
|
function TVpCategoryColorMap.IndexOfCategory(AName: String): Integer;
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
for i:=Low(FCat) to High(FCat) do
|
|
|
|
if SameText(FCat[i].Description, AName) then begin
|
|
|
|
Result := i;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
Result := -1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TVpCategoryColorMap.IndexOfFirstUnusedCategory: Integer;
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
for i := Low(FCat) to High(FCat) do
|
|
|
|
if FCat[i].Description = Format(RSCategoryDesc, [i]) then begin
|
|
|
|
Result := i;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
Result := -1;
|
|
|
|
end;
|
|
|
|
|
2022-08-20 19:11:37 +00:00
|
|
|
function TVpCategoryColorMap.GetBackgroundColor(AIndex: Integer): TColor;
|
|
|
|
begin
|
|
|
|
if (AIndex >= Low(FCat)) and (AIndex <= High(FCat)) then
|
|
|
|
Result := FCat[AIndex].BackgroundColor
|
|
|
|
else
|
|
|
|
Result := clWindow;
|
|
|
|
end;
|
|
|
|
|
2018-06-16 23:07:26 +00:00
|
|
|
function TVpCategoryColorMap.GetColor(AIndex: Integer): TColor;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2018-06-16 23:07:26 +00:00
|
|
|
if (AIndex >= Low(FCat)) and (AIndex <= High(FCat)) then
|
|
|
|
Result := FCat[AIndex].Color
|
2016-06-20 09:06:30 +00:00
|
|
|
else
|
|
|
|
Result := clBlack;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
2018-06-16 23:07:26 +00:00
|
|
|
function TVpCategoryColorMap.GetName(AIndex: Integer): string;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2018-06-16 23:07:26 +00:00
|
|
|
if (AIndex >= Low(FCat)) and (AIndex <= High(FCat)) then
|
|
|
|
Result := FCat[AIndex].Description
|
2016-06-20 09:06:30 +00:00
|
|
|
else
|
|
|
|
Result := '';
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
2016-06-20 09:06:30 +00:00
|
|
|
procedure TVpCategoryColorMap.SetCat(AIndex: Integer; AValue: TVpCategoryInfo);
|
|
|
|
begin
|
|
|
|
FCat[AIndex] := AValue;
|
|
|
|
end;
|
|
|
|
|
2018-06-16 23:07:26 +00:00
|
|
|
procedure TVpCategoryColorMap.SetCategoryName(AIndex: Integer; AName: String);
|
|
|
|
begin
|
|
|
|
if (AIndex >= Low(FCat)) and (AIndex <= High(FCat)) then
|
|
|
|
FCat[AIndex].Description := AName;
|
|
|
|
end;
|
2018-05-17 22:21:23 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
(*****************************************************************************)
|
|
|
|
{ TVpCategoryInfo }
|
|
|
|
|
2018-06-04 10:36:57 +00:00
|
|
|
constructor TVpCategoryInfo.Create(AOwner: TComponent);
|
2016-06-20 09:06:30 +00:00
|
|
|
begin
|
|
|
|
inherited Create;
|
2018-06-04 10:36:57 +00:00
|
|
|
FOwner := AOwner;
|
2016-06-12 13:51:29 +00:00
|
|
|
FBitmap := TBitmap.Create;
|
2016-06-20 09:06:30 +00:00
|
|
|
FBackgroundColor := clWindow;
|
2022-08-20 19:11:37 +00:00
|
|
|
FColor := clNavy;
|
2018-05-18 09:47:36 +00:00
|
|
|
FImageIndex := -1;
|
2016-06-20 09:06:30 +00:00
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-20 09:06:30 +00:00
|
|
|
destructor TVpCategoryInfo.Destroy;
|
|
|
|
begin
|
|
|
|
FBitmap.Free;
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2022-08-20 19:11:37 +00:00
|
|
|
function TVpCategoryInfo.IsStoredColor: Boolean;
|
|
|
|
begin
|
|
|
|
Result := FColor <> CATEGORY_COLORS[FIndex];
|
|
|
|
end;
|
|
|
|
|
2016-06-12 13:51:29 +00:00
|
|
|
procedure TVpCategoryInfo.SetBackgroundColor(const v: TColor);
|
2016-06-20 09:06:30 +00:00
|
|
|
begin
|
|
|
|
if v <> FBackgroundColor then
|
|
|
|
FBackgroundColor := v;
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-12 13:51:29 +00:00
|
|
|
procedure TVpCategoryInfo.SetBitmap(v: TBitmap);
|
2016-06-20 09:06:30 +00:00
|
|
|
begin
|
|
|
|
FBitmap.Assign(v);
|
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
procedure TVpCategoryInfo.SetColor(Value: TColor);
|
|
|
|
begin
|
|
|
|
if Value <> FColor then
|
|
|
|
FColor := Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpCategoryInfo.SetDescription(Value: string);
|
|
|
|
begin
|
|
|
|
if Value <> FDescription then
|
|
|
|
FDescription := Value;
|
|
|
|
end;
|
|
|
|
|
2018-05-18 09:47:36 +00:00
|
|
|
procedure TVpCategoryInfo.SetImageIndex(Value: TImageIndex);
|
|
|
|
begin
|
|
|
|
if Value <> FImageIndex then
|
|
|
|
FImageIndex := Value;
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
{ TVpTimeRange }
|
|
|
|
(*****************************************************************************)
|
|
|
|
constructor TVpTimeRange.Create(aOwner: TObject);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
FOwner := aOwner;
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TVpTimeRange.Destroy;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpTimeRange.SetRangeBegin(const Value: TVpHours);
|
|
|
|
begin
|
|
|
|
{ if the start time is being set to greater than the end, then force the }
|
|
|
|
{ end to be one hour later than the start }
|
|
|
|
if FRangeEnd < Value then
|
|
|
|
FRangeEnd := TVpHours(Ord(Value) + 1);
|
|
|
|
|
|
|
|
FRangeBegin := Value;
|
|
|
|
SetStartTime((Ord(Value) * 60) / MinutesInDay);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpTimeRange.SetRangeEnd(const Value: TVpHours);
|
|
|
|
begin
|
|
|
|
{ if the end time is being set to less than the start, then force the }
|
|
|
|
{ start to be one hour earlier than the end }
|
|
|
|
if FRangeBegin > Value then
|
|
|
|
FRangeBegin := TVpHours(Ord(Value) - 1);
|
|
|
|
FRangeEnd := Value;
|
|
|
|
SetEndTime((Ord(Value) * 60) / MinutesInDay);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpTimeRange.SetEndTime(const Value: TDateTime);
|
|
|
|
begin
|
|
|
|
if Value < StartTime then
|
|
|
|
StartTime := Value - (30 / MinutesInDay);
|
|
|
|
FEndTime := Value;
|
|
|
|
if FOwner is TVpTimeSlotColor then
|
|
|
|
(FOwner as TVpTimeSlotColor).Changed;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpTimeRange.SetStartTime(const Value: TDateTime);
|
|
|
|
begin
|
|
|
|
if Value > EndTime then
|
|
|
|
EndTime := Value + (30 / MinutesInDay);
|
|
|
|
FStartTime := Value;
|
|
|
|
if FOwner is TVpTimeSlotColor then
|
|
|
|
(FOwner as TVpTimeSlotColor).Changed;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
(*****************************************************************************)
|
|
|
|
{ TVpTimeSlotColor }
|
|
|
|
|
|
|
|
constructor TVpTimeSlotColor.Create(AOwner: TVpCustomControl);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
FOwner := AOwner;
|
2016-06-12 13:51:29 +00:00
|
|
|
FActiveRange := TVpTimeRange.Create(Self);
|
2021-10-27 18:12:33 +00:00
|
|
|
FInactive := OFF_COLOR; // $0080FFFF;
|
|
|
|
FHoliday := HOLIDAY_COLOR; // $00FF80FF;
|
|
|
|
FWeekend := WEEKEND_COLOR; // $00FFFF80;
|
2016-06-12 13:51:29 +00:00
|
|
|
FActive := clWhite;
|
2021-10-27 18:12:33 +00:00
|
|
|
FWeekday := WEEKDAY_COLOR; // clWhite;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TVpTimeSlotColor.Destroy;
|
|
|
|
begin
|
|
|
|
FActiveRange.Free;
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpTimeSlotColor.Changed;
|
|
|
|
begin
|
|
|
|
FOwner.Invalidate;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpTimeSlotColor.SetActive(const Value: TColor);
|
|
|
|
begin
|
|
|
|
if FActive <> Value then begin
|
|
|
|
FActive := Value;
|
|
|
|
Changed;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpTimeSlotColor.SetHoliday(const Value: TColor);
|
|
|
|
begin
|
|
|
|
if FHoliday <> Value then begin
|
|
|
|
FHoliday := Value;
|
|
|
|
Changed;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpTimeSlotColor.SetInactive(const Value: TColor);
|
|
|
|
begin
|
|
|
|
if FInactive <> Value then begin
|
|
|
|
FInactive := Value;
|
|
|
|
Changed;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpTimeSlotColor.SetWeekday(const Value: TColor);
|
|
|
|
begin
|
|
|
|
if FWeekday <> Value then begin
|
|
|
|
FWeekday := Value;
|
|
|
|
Changed;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpTimeSlotColor.SetWeekend(const Value: TColor);
|
|
|
|
begin
|
|
|
|
if FWeekend <> Value then begin
|
|
|
|
FWeekend := Value;
|
|
|
|
Changed;
|
|
|
|
end;
|
|
|
|
end;
|
2017-05-25 21:24:23 +00:00
|
|
|
|
|
|
|
|
2022-09-05 09:27:54 +00:00
|
|
|
{ TVpAllDayEventAttributes }
|
|
|
|
|
|
|
|
constructor TVpAllDayEventAttributes.Create(AOwner: TWinControl);
|
|
|
|
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;
|
|
|
|
UpdateOwner;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpAllDayEventAttributes.SetEventBackgroundColor(Value: TColor);
|
|
|
|
begin
|
|
|
|
FEventBackgroundColor := Value;
|
|
|
|
UpdateOwner;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpAllDayEventAttributes.SetEventBorderColor(Value: TColor);
|
|
|
|
begin
|
|
|
|
FEventBorderColor := Value;
|
|
|
|
UpdateOwner;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpAllDayEventAttributes.SetFont(Value: TVpFont);
|
|
|
|
begin
|
|
|
|
FFont.Assign(Value);
|
|
|
|
FFont.Owner := FOwner;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpAllDayEventAttributes.UpdateOwner;
|
|
|
|
begin
|
|
|
|
if Assigned(FOwner) then
|
|
|
|
FOwner.Invalidate;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2017-05-25 21:24:23 +00:00
|
|
|
{ TVpHintWindow }
|
|
|
|
|
|
|
|
function TVpHintWindow.CalcHintRect(MaxWidth: Integer; const AHint: String;
|
|
|
|
AData: pointer): TRect;
|
|
|
|
begin
|
|
|
|
Result := inherited CalcHintRect(MAX_HINT_WIDTH, AHint, AData);
|
|
|
|
end;
|
2016-04-26 15:54:35 +00:00
|
|
|
|
2022-08-16 15:04:39 +00:00
|
|
|
|
|
|
|
{ TVpMenuItem }
|
|
|
|
|
|
|
|
procedure TVpMenuItem.SetKind(AValue: TVpMenuItemKind);
|
|
|
|
begin
|
|
|
|
FKind := AValue;
|
|
|
|
Caption := VpMenuCaptions[FKind];
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpMenuItem.Translate;
|
|
|
|
|
|
|
|
procedure _Translate(AItem: TMenuItem);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if (AItem is TVpMenuItem) then
|
|
|
|
AItem.Caption := VpMenuCaptions[TVpMenuItem(AItem).Kind];
|
|
|
|
if AItem.Count > 0then
|
|
|
|
for i := 0 to AItem.Count-1 do
|
|
|
|
_Translate(AItem.Items[i]);
|
|
|
|
end;
|
|
|
|
|
|
|
|
begin
|
|
|
|
_Translate(self);
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
end.
|
|
|
|
|