📄 jvqdataprovider.pas
字号:
{******************************************************************************}
{* WARNING: JEDI VCL To CLX Converter generated unit. *}
{* Manual modifications will be lost on next release. *}
{******************************************************************************}
{-----------------------------------------------------------------------------
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/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvDataProviderImpl.pas, released on --.
The Initial Developer of the Original Code is Marcel Bestebroer
Portions created by Marcel Bestebroer are Copyright (C) 2002 - 2003 Marcel Bestebroer
All Rights Reserved.
Contributor(s):
Remko Bonte
Peter Th鰎nqvist
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
-----------------------------------------------------------------------------}
// $Id: JvQDataProvider.pas,v 1.30 2005/03/10 09:13:01 marquardt Exp $
unit JvQDataProvider;
{$I jvcl.inc}
interface
{$HPPEMIT '#define IInterface System::IInterface'}
uses
QWindows,
Classes, Contnrs, QGraphics, QControls, QImgList,
JclBase,
JvQComponent, JvQDataProviderIntf;
type
// Forwards
TExtensibleInterfacedPersistent = class;
TAggregatedPersistentEx = class;
TJvBaseDataItem = class;
TJvBaseDataItems = class;
TJvBaseDataContexts = class;
TJvBaseDataContextsManager = class;
TJvBaseDataContext = class;
TJvDataConsumer = class;
TJvDataConsumerAggregatedObject = class;
TJvDataConsumerServerNotify = class;
TJvDataConsumerClientNotifyList = class;
TJvDataConsumerClientNotifyItem = class;
// Class references
TAggregatedPersistentExClass = class of TAggregatedPersistentEx;
TJvDataItemTextImplClass = class of TJvBaseDataItemTextImpl;
TJvBaseDataItemClass = class of TJvBaseDataItem;
TJvDataItemsClass = class of TJvBaseDataItems;
TJvDataContextsClass = class of TJvBaseDataContexts;
TJvDataContextsManagerClass = class of TJvBaseDataContextsManager;
TJvDataContextClass = class of TJvBaseDataContext;
TJvDataConsumerAggregatedObjectClass = class of TJvDataConsumerAggregatedObject;
// Various types
TProviderNotifyEvent = procedure(ADataProvider: IJvDataProvider;
AReason: TDataProviderChangeReason; Source: IUnknown) of object;
TJvDataProviderTree = type Integer;
TJvDataProviderItemID = type string;
TJvDataProviderContexts = type Integer;
TBeforeCreateSubSvcEvent = procedure(Sender: TJvDataConsumer;
var SubSvcClass: TJvDataConsumerAggregatedObjectClass) of object;
TAfterCreateSubSvcEvent = procedure(Sender: TJvDataConsumer;
SubSvc: TJvDataConsumerAggregatedObject) of object;
TJvDataConsumerChangeReason = (ccrProviderSelect, ccrProviderChange, ccrViewChange,
ccrContextChange, ccrOther);
TJvDataConsumerChangeEvent = procedure(Sender: TJvDataConsumer;
Reason: TJvDataConsumerChangeReason) of object;
// Generic classes (move to some other unit?)
TExtensibleInterfacedPersistent = class(TPersistent, IUnknown)
private
FAdditionalIntfImpl: TList;
protected
FRefCount: Integer;
{ IUnknown }
function _AddRef: Integer; virtual; stdcall;
function _Release: Integer; virtual; stdcall;
function QueryInterface(const IID: TGUID; out Obj): HRESULT; virtual; stdcall;
procedure AddIntfImpl(const Obj: TAggregatedPersistentEx);
procedure RemoveIntfImpl(const Obj: TAggregatedPersistentEx);
function IndexOfImplClass(const AClass: TAggregatedPersistentExClass): Integer;
procedure ClearIntfImpl;
procedure InitImplementers; virtual;
procedure SuspendRefCount;
procedure ResumeRefCount;
function IsStreamableExtension(AnExtension: TAggregatedPersistentEx): Boolean; virtual;
procedure DefineProperties(Filer: TFiler); override;
procedure ReadImplementers(Reader: TReader);
procedure WriteImplementers(Writer: TWriter);
procedure ReadImplementer(Reader: TReader);
procedure WriteImplementer(Writer: TWriter; Instance: TAggregatedPersistentEx);
public
constructor Create;
destructor Destroy; override;
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
function GetInterface(const IID: TGUID; out Obj): Boolean; virtual;
class function NewInstance: TObject; override;
property RefCount: Integer read FRefCount;
end;
TAggregatedPersistent = class(TPersistent)
private
FController: Pointer;
function GetController: IUnknown;
protected
{ IUnknown }
function QueryInterface(const IID: TGUID; out Obj): HRESULT; virtual; stdcall;
function _AddRef: Integer; virtual; stdcall;
function _Release: Integer; virtual; stdcall;
public
constructor Create(Controller: IUnknown);
function GetInterface(const IID: TGUID; out Obj): Boolean; virtual;
property Controller: IUnknown read GetController;
end;
TAggregatedPersistentEx = class(TAggregatedPersistent)
private
FOwner: TExtensibleInterfacedPersistent;
protected
property Owner: TExtensibleInterfacedPersistent read FOwner;
public
constructor Create(AOwner: TExtensibleInterfacedPersistent); virtual;
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
end;
// Generic event based provider notification
TJvProviderNotification = class(TObject, IUnknown, IJvDataProviderNotify)
private
FProvider: IJvDataProvider;
FOnChanging: TProviderNotifyEvent;
FOnChanged: TProviderNotifyEvent;
protected
procedure SetProvider(Value: IJvDataProvider);
{ IUnknown }
function _AddRef: Integer; virtual; stdcall;
function _Release: Integer; virtual; stdcall;
function QueryInterface(const IID: TGUID; out Obj): HRESULT; virtual; stdcall;
{ IJvDataProviderNotify }
procedure DataProviderChanging(const ADataProvider: IJvDataProvider;
AReason: TDataProviderChangeReason; Source: IUnknown);
procedure DataProviderChanged(const ADataProvider: IJvDataProvider;
AReason: TDataProviderChangeReason; Source: IUnknown);
function Consumer: IJvDataConsumer;
public
destructor Destroy; override;
property OnChanging: TProviderNotifyEvent read FOnChanging write FOnChanging;
property OnChanged: TProviderNotifyEvent read FOnChanged write FOnChanged;
property Provider: IJvDataProvider read FProvider write SetProvider;
end;
// Item implementation classes
TJvDataItemAggregatedObject = class(TAggregatedPersistentEx)
protected
function QueryInterface(const IID: TGUID; out Obj): HRESULT; override; stdcall;
procedure ContextDestroying(Context: IJvDataContext); dynamic;
function Item: IJvDataItem;
function ItemImpl: TJvBaseDataItem;
end;
TJvBaseDataItem = class(TExtensibleInterfacedPersistent, IJvDataItem)
private
FItems: Pointer;
FItemsIntf: IJvDataItems;
FID: string;
protected
{ Initialize ID. Each item must have an unique identification. Implementers may choose how this
ID is generated. No checks are made when items are added to a provider to ensure it's
unique. If multiple items with the same ID are added only the first item in the tree will be
selectable at design time. }
procedure InitID; virtual;
{ Set the ID string. Used by InitID to set the actual ID string. }
procedure SetID(Value: string);
{ Reference counting: add 1 if this item is part of a dynamic list (Items.IsDynamic returns
True). Otherwise reference counting is not used. }
function _AddRef: Integer; override; stdcall;
{ Reference counting: substract 1 if this item is part of a dynamic list (Items.IsDynamic returns
True). Otherwise reference counting is not used. }
function _Release: Integer; override; stdcall;
{ Streaming of an item. }
procedure DefineProperties(Filer: TFiler); override;
procedure ReadSubItems(Reader: TReader);
procedure WriteSubItems(Writer: TWriter);
{ IJvDataItem methods and properties. }
function GetItems: IJvDataItems;
function GetIndex: Integer;
function GetImplementer: TObject;
function GetID: string;
procedure ContextDestroying(Context: IJvDataContext); dynamic;
function IsParentOf(AnItem: IJvDataItem; DirectParent: Boolean = False): Boolean; virtual;
function IsDeletable: Boolean; dynamic;
property Items: IJvDataItems read GetItems;
property Implementer: TObject read GetImplementer;
{ Optional IJvDataContextSensitive interface implementation }
procedure RevertToAncestor; dynamic;
function IsEqualToAncestor: Boolean; dynamic;
public
constructor Create(AOwner: IJvDataItems);
procedure AfterConstruction; override;
published
property ID: string read GetID write SetID;
end;
TJvBaseDataItemTextImpl = class(TJvDataItemAggregatedObject, IJvDataItemText)
protected
function GetCaption: string; virtual; abstract;
procedure SetCaption(const Value: string); virtual; abstract;
function Editable: Boolean; virtual; abstract;
public
property Caption: string read GetCaption write SetCaption;
end;
TJvBaseDataItemImageImpl = class(TJvDataItemAggregatedObject, IJvDataItemImage)
protected
function GetAlignment: TAlignment; virtual; abstract;
procedure SetAlignment(Value: TAlignment); virtual; abstract;
function GetImageIndex: Integer; virtual; abstract;
procedure SetImageIndex(Index: Integer); virtual; abstract;
function GetSelectedIndex: Integer; virtual; abstract;
procedure SetSelectedIndex(Value: Integer); virtual; abstract;
end;
TJvBaseDataItemRenderer = class(TJvDataItemAggregatedObject, IJvDataItemRenderer)
protected
procedure Draw(ACanvas: TCanvas; var ARect: TRect; State: TProviderDrawStates); virtual; abstract;
function Measure(ACanvas: TCanvas): TSize; virtual; abstract;
end;
TJvBaseDataItemStates = class(TJvDataItemAggregatedObject, IJvDataItemStates)
protected
function Get_Enabled: TDataItemState; virtual; abstract;
procedure Set_Enabled(Value: TDataItemState); virtual; abstract;
function Get_Checked: TDataItemState; virtual; abstract;
procedure Set_Checked(Value: TDataItemState); virtual; abstract;
function Get_Visible: TDataItemState; virtual; abstract;
procedure Set_Visible(Value: TDataItemState); virtual; abstract;
end;
// Items implementation classes
TJvDataItemsAggregatedObject = class(TAggregatedPersistentEx)
protected
procedure ContextDestroying(Context: IJvDataContext); dynamic;
function Items: IJvDataItems;
function ItemsImpl: TJvBaseDataItems;
end;
TJvBaseDataItems = class(TExtensibleInterfacedPersistent, IJvDataItems, IJvDataIDSearch)
function IJvDataIDSearch.Find = FindByID;
private
FParent: Pointer;
FParentIntf: IJvDataItem;
FProvider: IJvDataProvider;
FSubAggregate: TAggregatedPersistentEx;
protected
{ Adds an item to the list. }
procedure InternalAdd(Item: IJvDataItem); virtual; abstract;
{ Removes an item from the list. }
procedure InternalDelete(Index: Integer); virtual; abstract;
{ Moves an item in the list to a new index. }
procedure InternalMove(OldIndex, NewIndex: Integer); virtual; abstract;
{ Called by the IJvDataItemsManagement and IJvDataItemsDesigner implementations to add a new
item. It will redirect it to InternalAdd. InternalAdd will perform the add, but may also
perform addition steps if needed (in case of context specific list it might need to copy the
list first). }
procedure ItemAdd(Item: IJvDataItem);
{ Called by the IJvDataItemsManagement implementation to remove an item. It will redirect it to
InternalDelete. InternalDelete will perform the removal, but may also perform addition steps
if needed (i.e. notify the other contexts if the delete is performed on the context-less list
or copy the list for a context specific list that inherits from an ancestor). }
procedure ItemDelete(Index: Integer);
{ Called by the IJvDataItem implementation to move an item. It will redirect it to
InternalMove. InternalMove will perform the moving if it's called from within a context.
The context-less list does not allow moving of items. }
procedure ItemMove(OldIndex, NewIndex: Integer);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -