Browse Source

* some interface updates for 1.1

peter 24 years ago
parent
commit
6e72decc01
2 changed files with 129 additions and 5 deletions
  1. 44 2
      fcl/inc/classesh.inc
  2. 85 3
      fcl/inc/persist.inc

+ 44 - 2
fcl/inc/classesh.inc

@@ -95,7 +95,10 @@ type
     // Extra additions
     // Extra additions
     ssMeta, ssSuper, ssHyper, ssAltGr, ssCaps, ssNum, ssScroll);
     ssMeta, ssSuper, ssHyper, ssAltGr, ssCaps, ssNum, ssScroll);
 
 
-  { THelpContext = -MaxLongint..MaxLongint; }
+  THelpContext = -MaxLongint..MaxLongint;
+  THelpType = (htKeyword, htContext);
+
+  TShortCut = Low(Word)..High(Word);
 
 
 { Standard events }
 { Standard events }
 
 
@@ -260,6 +263,35 @@ type
 
 
   TPersistentClass = class of TPersistent;
   TPersistentClass = class of TPersistent;
 
 
+{ TInterfaced Persistent }
+
+{$ifdef HASINTF}
+  TInterfacedPersistent = class(TPersistent, IInterface)
+  private
+    FOwnerInterface: IInterface;
+  protected
+    { IInterface }
+    function _AddRef: Integer; stdcall;
+    function _Release: Integer; stdcall;
+  public
+    function QueryInterface(const IID: TGUID; out Obj): HResult; virtual; stdcall;
+    procedure AfterConstruction; override;
+  end;
+{$endif HASINTF}
+
+{ TRecall class }
+
+  TRecall = class(TObject)
+  private
+    FStorage, FReference: TPersistent;
+  public
+    constructor Create(AStorage, AReference: TPersistent);
+    destructor Destroy; override;
+    procedure Store;
+    procedure Forget;
+    property Reference: TPersistent read FReference;
+  end;
+
 { TCollection class }
 { TCollection class }
 
 
   TCollection = class;
   TCollection = class;
@@ -497,6 +529,13 @@ type
     property Size: Longint read GetSize write SetSize;
     property Size: Longint read GetSize write SetSize;
   end;
   end;
 
 
+{$ifdef HASINTF}
+  IStreamPersist = interface ['{B8CD12A3-267A-11D4-83DA-00C04F60B2DD}']
+    procedure LoadFromStream(Stream: TStream);
+    procedure SaveToStream(Stream: TStream);
+  end;
+{$endif HASINTF}
+
 { THandleStream class }
 { THandleStream class }
 
 
   THandleStream = class(TStream)
   THandleStream = class(TStream)
@@ -1245,7 +1284,10 @@ function LineStart(Buffer, BufPos: PChar): PChar;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2001-05-14 21:17:24  florian
+  Revision 1.11  2001-08-12 22:10:36  peter
+    * some interface updates for 1.1
+
+  Revision 1.10  2001/05/14 21:17:24  florian
     * TGUID and IUnknown is defined in the system unit by
     * TGUID and IUnknown is defined in the system unit by
       1.1 and above
       1.1 and above
 
 

+ 85 - 3
fcl/inc/persist.inc

@@ -11,11 +11,11 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 
  **********************************************************************}
  **********************************************************************}
+
 {****************************************************************************}
 {****************************************************************************}
 {*                             TPersistent                                  *}
 {*                             TPersistent                                  *}
 {****************************************************************************}
 {****************************************************************************}
 
 
-
 procedure TPersistent.AssignError(Source: TPersistent);
 procedure TPersistent.AssignError(Source: TPersistent);
 
 
 Var SourceName : String;
 Var SourceName : String;
@@ -79,9 +79,91 @@ begin
    If OwnerName<>'' then Result:=OwnerName+'.'+Result;
    If OwnerName<>'' then Result:=OwnerName+'.'+Result;
    end;
    end;
 end;
 end;
+
+
+{****************************************************************************}
+{*                          TInterfacedPersistent                           *}
+{****************************************************************************}
+
+{$ifdef HASINTF}
+procedure TInterfacedPersistent.AfterConstruction;
+begin
+  inherited;
+//  if GetOwner<>nil then
+//   GetOwner.GetInterface(IUnknown,FOwnerInterface);
+end;
+
+
+function TInterfacedPersistent._AddRef: Integer;stdcall;
+begin
+  if FOwnerInterface<>nil then
+    Result:=FOwnerInterface._AddRef
+  else
+    Result:=-1;
+end;
+
+
+function TInterfacedPersistent._Release: Integer;stdcall;
+begin
+  if FOwnerInterface <> nil then
+    Result:=FOwnerInterface._Release
+  else
+    Result:=-1;
+end;
+
+
+function TInterfacedPersistent.QueryInterface(const IID: TGUID; out Obj): HResult;stdcall;
+begin
+  if GetInterface(IID, Obj) then
+    Result:=0
+  else
+    Result:=HResult($80004002);
+end;
+{$endif HASINTF}
+
+
+{****************************************************************************}
+{*                                TRecall                                   *}
+{****************************************************************************}
+
+constructor TRecall.Create(AStorage,AReference: TPersistent);
+begin
+  inherited Create;
+  FStorage:=AStorage;
+  FReference:=AReference;
+  Store;
+end;
+
+
+destructor TRecall.Destroy;
+begin
+  if Assigned(FReference) then
+   FReference.Assign(FStorage);
+  Forget;
+  inherited;
+end;
+
+
+procedure TRecall.Forget;
+begin
+  FReference:=nil;
+  FreeAndNil(FStorage);
+end;
+
+
+procedure TRecall.Store;
+begin
+  if Assigned(FReference) then
+    FStorage.Assign(FReference);
+end;
+
+
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2000-07-13 11:32:59  michael
+  Revision 1.3  2001-08-12 22:10:36  peter
+    * some interface updates for 1.1
+
+  Revision 1.2  2000/07/13 11:32:59  michael
   + removed logs
   + removed logs
- 
+
 }
 }