📄 flexprops.int
字号:
/////////////////////////////////////////////////////////
// //
// FlexGraphics library //
// Copyright (c) 2002-2009, FlexGraphics software. //
// //
// Properties support //
// //
/////////////////////////////////////////////////////////
unit FlexProps;
{$I FlexDefs.inc}
interface
uses
Windows, Classes, Graphics, Forms, Controls, SysUtils,
Dialogs, TypInfo, Jpeg, {$IFDEF FG_D6} Variants, {$ENDIF}
FlexUtils, FlexAlpha, FlexHistory;
const
DefaultLineCapSize = 8 * PixelScaleFactor;
// Standard pen cap styles
psNoCap = 0;
psArrow0 = -1;
psDblArrow0 = -2;
psBackArrow0 = -3;
psBackDblArrow0 = -4;
psArrow1 = -5;
psDblArrow1 = -6;
psBackArrow1 = -7;
psBackDblArrow1 = -8;
psArrow = -9;
psTriangle = -10;
psDblTriangle = -11;
psBackTriangle = -12;
psBackDblTriangle = -13;
psSquare = -14;
psCircle = -15;
psDotCircle = -16;
psRhombus = -17;
psThinRect = -18;
psLastStandard = -18;
type
TPropType = ( ptSimple, ptComplex, ptStrList, ptHexData );
TPropStyleItem = ( psReadOnly, psVisible, psDontStore, psNonVisual,
psDisplayEdit, psEditForm, psScalable, psRef );
TPropStyle = set of TPropStyleItem;
TPropList = class;
TPropRefList = class;
{$M+}
TCustomProp = class;
{$M-}
TEditFormClass = class of TCustomForm;
TCustomPropClass = class of TCustomProp;
TPropChangedEvent = procedure(Sender: TObject; Prop: TCustomProp) of object;
TPropStoredEvent = procedure(Sender: TObject; Prop: TCustomProp;
var IsStored: boolean; const PropName: string = '') of object;
TPropReadOnlyEvent = procedure(Sender: TObject; Prop: TCustomProp;
var IsReadOnly: boolean) of object;
TPropHistoryActionEvent = procedure(Sender: TObject; Prop: TCustomProp;
var ActionClass: THistoryActionClass) of object;
TPictureLinkResolve = procedure(Sender: TObject; const LinkName: string;
APicture: TPicture);
TBitmapLinkResolve = procedure(Sender: TObject; const LinkName: string;
ABitmap: TBitmap);
TCustomProp = class
private
FOwner: TPropList;
FParent: TCustomProp;
FStyle: TPropStyle;
FEditFormClass: TEditFormClass;
function GetName: string;
procedure SetStyle(const Value: TPropStyle);
function GetNotifyLink: TNotifyLink;
protected
FPropType: TPropType;
FIsEnum: boolean;
FNotifyLink: TNotifyLink;
FSkipHistoryAction: boolean;
function GetDisplayValue: string; virtual;
procedure SetDisplayValue(const Value: string); virtual;
procedure DoBeforeChanged; virtual;
procedure DoChanged; virtual;
procedure SetPropValue(const PropName: string; Value: Variant); virtual;
function GetPropValue(const PropName: string): Variant; virtual;
function GetPropType(const PropName: string): TPropType; virtual;
public
constructor Create(AOwner: TPropList; const AName: string);
destructor Destroy; override;
function Assign(Prop: TCustomProp): boolean;
procedure Setup(Canvas: TCanvas; Scale: integer = 100); virtual;
function Edit: boolean; virtual;
procedure GetEnumList(List: TStrings); virtual;
function IsComplexStored(const PropName: string): boolean; virtual;
procedure InitPublished(AOwner: TPropList; PublishedProp: TCustomProp);
function GetPublishedComplexProp(const PropName: string): TCustomProp;
procedure GetPropNames(StrList: TStrings);
function IsParentOf(Prop: TCustomProp): Boolean;
property Owner: TPropList read FOwner write FOwner;
property Name: string read GetName;
property Parent: TCustomProp read FParent;
property Style: TPropStyle read FStyle write SetStyle;
property PropType: TPropType read FPropType;
property DisplayValue: string read GetDisplayValue write SetDisplayValue;
property IsEnum: boolean read FIsEnum;
property EditFormClass: TEditFormClass read FEditFormClass
write FEditFormClass;
property NotifyLink: TNotifyLink read GetNotifyLink write FNotifyLink;
property PropData[const PropName: string]: Variant read GetPropValue
write SetPropValue;
property PublishedPropType[const PropName: string]: TPropType
read GetPropType;
end;
TIdHistoryAction = class(THistoryStreamAction)
protected
FSourceId: LongWord;
FSourcePropName: string;
procedure DoBeginAction(Source: TObject); override;
public
property SourceId: LongWord read FSourceId write FSourceId;
property SourcePropName: string read FSourcePropName write FSourcePropName;
end;
TPropHistoryAction = class(TIdHistoryAction)
protected
function ProcessSource(Stream: TStream; Source: TObject;
DoLoad: boolean): boolean; override;
end;
TPropHistoryGroup = class(THistoryGroup)
public
constructor Create(AOwner: THistory; AParent: THistoryGroup); override;
end;
TEnumProp = class(TCustomProp)
private
FEnumIndex: integer;
FEnumList: TStrings;
function GetEnumCount: integer;
protected
procedure SetPropValue(const PropName: string; Value: Variant); override;
function GetPropValue(const PropName: string): Variant; override;
function GetDisplayValue: string; override;
procedure SetEnumIndex(Value: integer); virtual;
property EnumList: TStrings read FEnumList write FEnumList;
public
constructor Create(AOwner: TPropList; const AName: string);
destructor Destroy; override;
function AddItem(const s: string): integer;
procedure SetItem(EnumIndex: integer; const s: string);
function SetEnumType(TypeInfo: PTypeInfo): boolean;
procedure GetEnumList(List: TStrings); override;
property EnumIndex: integer read FEnumIndex write SetEnumIndex;
property EnumCount: integer read GetEnumCount;
end;
TBoolProp = class(TEnumProp)
private
procedure SetValue(Value: boolean);
function GetValue: boolean;
protected
procedure SetPropValue(const PropName: string; Value: Variant); override;
function GetPropValue(const PropName: string): Variant; override;
public
constructor Create(AOwner: TPropList; const AName: string);
property Value: boolean read GetValue write SetValue;
end;
TGetIntEvent = procedure(Sender: TObject; out Value: integer) of object;
TIntProp = class(TCustomProp)
private
FValue: integer;
FSource: PInteger;
FOnGetValue: TGetIntEvent;
procedure SetValue(Value: integer);
function GetValue: integer;
protected
FBeforeValue: integer;
procedure SetPropValue(const PropName: string; Value: Variant); override;
function GetPropValue(const PropName: string): Variant; override;
function GetDisplayValue: string; override;
procedure SetDisplayValue(const Value: string); override;
public
constructor Create(AOwner: TPropList; const AName: string);
property Value: integer read GetValue write SetValue;
property BeforeValue: integer read FBeforeValue write FBeforeValue;
property SavedValue: integer read FValue;
property Source: PInteger read FSource write FSource;
property OnGetValue: TGetIntEvent read FOnGetValue write FOnGetValue;
end;
TLongWordProp = class(TCustomProp)
protected
FValue: LongWord;
procedure SetValue(Value: LongWord); virtual;
function GetDisplayValue: string; override;
procedure SetDisplayValue(const Value: string); override;
procedure SetPropValue(const PropName: string; Value: Variant); override;
function GetPropValue(const PropName: string): Variant; override;
public
constructor Create(AOwner: TPropList; const AName: string);
property Value: LongWord read FValue write SetValue;
end;
TDoubleProp = class(TCustomProp)
private
FValue: Double;
procedure SetValue(Value: Double);
protected
function GetDisplayValue: string; override;
procedure SetDisplayValue(const Value: string); override;
procedure SetPropValue(const PropName: string; Value: Variant); override;
function GetPropValue(const PropName: string): Variant; override;
public
constructor Create(AOwner: TPropList; const AName: string);
property Value: Double read FValue write SetValue;
end;
TDateTimeProp = class(TCustomProp)
private
FValue: TDateTime;
procedure SetValue(Value: TDateTime);
protected
function GetDisplayValue: string; override;
procedure SetDisplayValue(const Value: string); override;
procedure SetPropValue(const PropName: string; Value: Variant); override;
function GetPropValue(const PropName: string): Variant; override;
public
constructor Create(AOwner: TPropList; const AName: string);
property Value: TDateTime read FValue write SetValue;
end;
TGetStringEvent = procedure(Sender: TObject; out s: string) of object;
TStrProp = class(TCustomProp)
protected
FValue: string;
FOnGetString: TGetStringEvent;
function GetDisplayValue: string; override;
procedure SetValue(const Value: string); virtual;
function GetValue: string; virtual;
procedure SetPropValue(const PropName: string; Value: Variant); override;
function GetPropValue(const PropName: string): Variant; override;
public
constructor Create(AOwner: TPropList; const AName: string);
property Value: string read GetValue write SetValue;
property SavedValue: string read FValue write FValue;
property OnGetString: TGetStringEvent read FOnGetString write FOnGetString;
end;
TStrListProp = class(TCustomProp)
private
FStrList: TStringList;
procedure SetText(const Value: TCaption);
function GetLine(Index: integer): string;
function GetLinesCount: integer;
function GetText: TCaption;
procedure SetLine(Index: integer; const Value: string);
function GetName(Index: integer): string;
function GetValue(const Name: string): string;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -