📄 flexlibs.int
字号:
/////////////////////////////////////////////////////////
// //
// FlexGraphics library //
// Copyright (c) 2002-2009, FlexGraphics software. //
// //
// Flex-libraries support //
// //
/////////////////////////////////////////////////////////
unit FlexLibs;
{$I FlexDefs.inc}
interface
uses
Windows, Classes, Controls, SysUtils, Graphics,
FlexBase, FlexProps, FlexUtils;
type
TLibItemAnchorProp = class(TCustomProp)
private
function GetAsPoint: TPoint;
procedure SetAsPoint(const Value: TPoint);
procedure SetEnabled(const Value: boolean);
procedure SetPosX(const Value: integer);
procedure SetPosY(const Value: integer);
protected
FEnabled: boolean;
FPosX: integer;
FPosY: integer;
function GetDisplayValue: string; override;
public
constructor Create(AOwner: TPropList; const AName: string);
property AsPoint: TPoint read GetAsPoint write SetAsPoint;
published
property Enabled: boolean read FEnabled write SetEnabled default False;
property PosX: integer read FPosX write SetPosX default 0;
property PosY: integer read FPosY write SetPosY default 0;
end;
TFlexLibItem = class(TFlexControl)
protected
FAnchorProp: TLibItemAnchorProp;
procedure CreateProperties; override;
procedure ControlCreate; override;
public
function CreateDragObject: TFlexDragObject;
function MakeCopy(AFlex: TFlexPanel; ALeft, ATop: integer): boolean;
property AnchorProp: TLibItemAnchorProp read FAnchorProp;
end;
TFlexLibraryClass = class of TFlexLibrary;
TFlexLibrary = class(TFlexCustomScheme)
private
FFilename: string;
FModified: boolean;
function GetByName(const Name: string): TFlexLibItem;
function GetLibItem(Index: integer): TFlexLibItem;
protected
procedure CreateProperties; override;
procedure ControlCreate; override;
public
function New: TFlexLibItem; virtual;
function NewFromFlex(AFlex: TFlexPanel): TFlexLibItem;
function Add(AControl: TFlexControl): integer; override;
procedure Delete(Index: integer); override;
procedure SaveToFiler(Filer: TFlexFiler; const Indent: string); override;
procedure LoadFromFiler(Filer: TFlexFiler); override;
property Controls[Index: integer]: TFlexLibItem read GetLibItem; default;
property ByName[const Name: string]: TFlexLibItem read GetByName;
property LibFilename: string read FFilename write FFilename;
property Modified: boolean read FModified write FModified;
end;
TFlexLibraryWithIDs = class(TFlexLibrary)
protected
procedure CreateProperties; override;
public
function Add(AControl: TFlexControl): integer; override;
end;
TFlexLibraries = class
private
FFlex: TFlexPanel;
FDragSource: TFlexPanel;
FOnChange: TNotifyEvent;
function GetCount: integer;
function GetItem(Index: integer): TFlexLibrary;
protected
procedure DoOnChange; virtual;
property DragSource: TFlexPanel read FDragSource;
public
constructor Create;
destructor Destroy; override;
function New(const Filename: string;
LibClass: TFlexLibraryClass = Nil): TFlexLibrary; virtual;
function IndexOf(ALibrary: TFlexLibrary): integer;
procedure Remove(ALibrary: TFlexLibrary);
function SaveLibrary(ALibrary: TFlexLibrary): boolean;
function LoadLibrary(ALibrary: TFlexLibrary): boolean;
property Flex: TFlexPanel read FFlex;
property Count: integer read GetCount;
property Items[Index: integer]: TFlexLibrary read GetItem; default;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
// Libraries with IDs classes ///////////////////////////////////////////////
TFlexSingleLibraries = class;
TFlexSingleLibraryClass = class of TFlexSingleLibrary;
TFlexSingleLibrary = class
private
FOwner: TFlexSingleLibraries;
FOnChange: TNotifyEvent;
protected
FId: LongWord;
FFlex: TFlexPanel;
FLibrary: TFlexLibrary;
FDragSource: TFlexPanel;
procedure DoOnChange; virtual;
property Flex: TFlexPanel read FFlex;
property DragSource: TFlexPanel read FDragSource;
public
constructor Create(AOwner: TFlexSingleLibraries;
LibClass: TFlexLibraryClass = Nil); virtual;
destructor Destroy; override;
function SaveLibrary: boolean;
function LoadLibrary: boolean;
property Owner: TFlexSingleLibraries read FOwner;
property Id: LongWord read FId;
property FlexPanel: TFlexPanel read FFlex;
property FlexLibrary: TFlexLibrary read FLibrary;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
TFlexSingleLibraries = class
private
function GetCount: integer;
function GetLibrary(Index: Integer): TFlexSingleLibrary;
protected
FList: TList;
FMaxId: LongWord;
function InternalAdd(Item: TFlexSingleLibrary): integer;
procedure InternalDelete(Index: integer);
public
constructor Create;
destructor Destroy; override;
procedure Clear;
function New(AClass: TFlexSingleLibraryClass = Nil;
LibClass: TFlexLibraryClass = Nil): TFlexSingleLibrary; virtual;
procedure Delete(Index: integer);
function IndexOf(Item: TFlexSingleLibrary): integer;
function FindByName(const FlexPanelName: string): integer;
property Count: integer read GetCount;
property Items[Index: Integer]: TFlexSingleLibrary read GetLibrary; default;
end;
var
FlexLibraries: TFlexLibraries;
implementation
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -