home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
sibylft1.zip
/
DOC.DAT
/
DOC
/
SPCC
/
CLASSES.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-04-07
|
36KB
|
964 lines
{╔══════════════════════════════════════════════════════════════════════════╗
║ ║
║ Sibyl Portable Component Classes ║
║ ║
║ Copyright (c) 1995,97 SpeedSoft Germany, All rights reserved. ║
║ ║
╚══════════════════════════════════════════════════════════════════════════╝}
UNIT Classes;
INTERFACE
USES Dos,SysUtils;
{$IFDEF OS2}
USES PmWin,BseDos;
{$ENDIF}
{$IFDEF Win95}
USES WinUser,WinBase;
{$ENDIF}
//TStream seek origins
CONST
soFromBeginning = 0;
soFromCurrent = 1;
soFromEnd = 2;
TYPE
EStreamError=CLASS(Exception);
EFCreateError=CLASS(EStreamError);
EFOpenError=CLASS(EStreamError);
TStream=CLASS(TObject)
PRIVATE
FUNCTION GetSize:LONGINT;VIRTUAL;
FUNCTION GetPosition:LONGINT;
PROCEDURE SetPosition(NewPos:Longint);
PROCEDURE Error(ResourceId:WORD);VIRTUAL;
PUBLIC
PROCEDURE ReadBuffer(VAR Buffer;Count:LONGINT);
PROCEDURE WriteBuffer(CONST Buffer;Count:LONGINT);
FUNCTION CopyFrom(Source: TStream; Count: Longint): Longint;
FUNCTION Read(VAR Buffer;Count:LONGINT):LONGINT;VIRTUAL;ABSTRACT;
FUNCTION Write(CONST Buffer;Count:LONGINT):LONGINT;VIRTUAL;ABSTRACT;
FUNCTION Seek(Offset:LONGINT;Origin:WORD):LONGINT;VIRTUAL;ABSTRACT;
FUNCTION EndOfData: BOOLEAN; VIRTUAL;
FUNCTION ReadLn: STRING; VIRTUAL;
PROCEDURE WriteLn(CONST S: STRING); VIRTUAL;
PUBLIC
PROPERTY Position:LONGINT read GetPosition write SetPosition;
PROPERTY Size:LONGINT read GetSize;
END;
CONST
{FileStream Open modes}
fmCreate = $FFFF; (* Delphi *)
Stream_Create = fmCreate; (* compatibility only *)
Stream_Open = fmInOut; (* compatibility only *)
TYPE
THandleStream= class(TStream)
PRIVATE
FHandle: LongInt;
PUBLIC
CONSTRUCTOR Create(AHandle: LongInt);
FUNCTION Read(VAR Buffer; Count: Longint): Longint; override;
FUNCTION Write(CONST Buffer; Count: Longint): Longint; override;
FUNCTION Seek(Offset: Longint; Origin: Word): Longint; override;
PUBLIC
PROPERTY Handle: LongInt read FHandle;
END;
TYPE
TFileStream=CLASS(TStream)
PRIVATE
PStreamFile:FILE;
PUBLIC
{Rene}
CONSTRUCTOR Create(CONST FileName:STRING;Mode:LONGWORD);
DESTRUCTOR Destroy;OVERRIDE;
FUNCTION Read(VAR Buffer;Count:LONGINT):LONGINT;OVERRIDE;
FUNCTION Write(CONST Buffer;Count:LONGINT):LONGINT;OVERRIDE;
FUNCTION Seek(Offset:LONGINT;Origin:WORD):LONGINT;OVERRIDE;
END;
TMemoryStream=CLASS(TStream)
PRIVATE
FBuffer: PByteArray;
FSize, FCapacity, FPosition: LongInt;
PROCEDURE SetCapacity(NewCapacity: LongInt);
PROTECTED
PROPERTY Capacity:LongInt read FCapacity write SetCapacity;
PUBLIC
DESTRUCTOR Destroy;OVERRIDE;
FUNCTION Read(VAR Buffer;Count:Longint):Longint;OVERRIDE;
FUNCTION Write(CONST Buffer; Count: Longint):Longint;OVERRIDE;
FUNCTION Seek(Offset: Longint; Origin: Word):Longint;OVERRIDE;
PROCEDURE LoadFromStream(Stream: TStream);
PROCEDURE LoadFromFile(CONST FileName:STRING);
PROCEDURE SaveToStream(Stream: TStream);
PROCEDURE SaveToFile(CONST FileName:STRING);
PROCEDURE SetSize(NewSize: Longint);
PROCEDURE Clear;
PUBLIC
PROPERTY Memory: PByteArray read FBuffer;
END;
CONST
MaxListSize = MaxLongInt DIV SizeOf(Pointer);
{ A notify event is a method variable, i.e. a PROCEDURE
variable for objects. Some classes allow the specification
of objects to be notified of changes. }
TYPE
TComponent=CLASS;
{$M+}
TNotifyEvent = PROCEDURE(Sender:TObject) OF OBJECT;
{$M-}
EListError = CLASS(Exception);
{TList CLASS}
TList = CLASS;
PPointerList = ^TPointerList;
TPointerList = ARRAY[0..MaxListSize-1] OF POINTER;
TListSortCompare = FUNCTION(Item1,Item2: POINTER):LONGINT;
TFreeListItem = PROCEDURE(Sender:TObject;Item:POINTER) OF OBJECT;
TList = CLASS
PRIVATE
FList:PPointerList;
FCount:LONGINT;
FCapacity:LONGINT;
FGrowth:LONGINT;
FOnFreeItem:TFreeListItem;
FUNCTION Get(Index:LONGINT):POINTER;
PROCEDURE Put(Index:LONGINT;Item:POINTER);
PROCEDURE SetCount(NewCount:LONGINT);
PROTECTED
PROCEDURE Error; VIRTUAL;
PROCEDURE Grow; VIRTUAL;
PROCEDURE SetCapacity(NewCapacity:LONGINT); VIRTUAL;
PROCEDURE FreeItem(Item:POINTER); VIRTUAL;
PUBLIC
DESTRUCTOR Destroy; OVERRIDE;
PROCEDURE Clear; VIRTUAL;
FUNCTION Add(Item:POINTER):LONGINT;
PROCEDURE Delete(Index:LONGINT);
FUNCTION Remove(Item:POINTER):LONGINT;
PROCEDURE Cut(Index1,Index2:LONGINT);
PROCEDURE Insert(Index:LONGINT;Item:POINTER);
PROCEDURE Exchange(Index1,Index2:LONGINT);
PROCEDURE Move(CurIndex,NewIndex:LONGINT);
FUNCTION IndexOf(Item:POINTER):LONGINT;
FUNCTION First:POINTER;
FUNCTION Last:POINTER;
FUNCTION Expand:TList;
PROCEDURE Pack;
PROCEDURE Sort(Compare: TListSortCompare);
PUBLIC
PROPERTY Capacity:LONGINT read FCapacity write SetCapacity;
PROPERTY Count:LONGINT read FCount write SetCount;
PROPERTY Growth:LONGINT read FGrowth write FGrowth;
PROPERTY Items[Index:LONGINT]:POINTER read Get write Put; default;
PROPERTY List:PPointerList read FList;
PROPERTY OnFreeItem:TFreeListItem read FOnFreeItem write FOnFreeItem;
END;
{TChainList CLASS}
PChainListItem = ^TChainListItem;
TChainListItem = RECORD
prev:PChainListItem;
Item:Pointer;
next:PChainListItem;
END;
TChainList = CLASS(TObject)
PRIVATE
FList:PChainListItem;
FListEnd:PChainListItem;
FCount:LongInt;
FOnFreeItem:TFreeListItem;
PRIVATE
FUNCTION Index2PLE(Index:LongInt):PChainListItem;
FUNCTION Item2PLE(Item:Pointer):PChainListItem;
FUNCTION PLE2Index(ple:PChainListItem):LongInt;
FUNCTION Item2Index(Item:Pointer):LongInt;
PROCEDURE Connect(ple1,ple2:PChainListItem);
FUNCTION Get(Index:LongInt):Pointer;
PROCEDURE Put(Index:LongInt;Item:Pointer);
PROTECTED
PROCEDURE Error; VIRTUAL;
PROCEDURE FreeItem(Item:POINTER); VIRTUAL;
PUBLIC
DESTRUCTOR Destroy; OVERRIDE;
PROCEDURE Clear; VIRTUAL;
FUNCTION Add(Item:Pointer):LongInt;
FUNCTION Remove(Item:Pointer):LongInt;
PROCEDURE Delete(Index:LongInt);
FUNCTION First:Pointer;
FUNCTION Last:Pointer;
FUNCTION IndexOf(Item:Pointer):LongInt;
PROCEDURE Insert(Index:LongInt;Item:Pointer);
PROCEDURE Move(CurIndex,NewIndex:LongInt);
PROCEDURE Exchange(Index1,Index2:LongInt);
PROCEDURE Pack;
PUBLIC
PROPERTY Count:LongInt read FCount;
PROPERTY Items[Index:LongInt]:Pointer read Get write Put; default;
PROPERTY OnFreeItem:TFreeListItem read FOnFreeItem write FOnFreeItem;
END;
{ TStrings is an abstract base class for storing a
number of Strings. Every String can be associated
with a value as well as with an object. So, IF you
want to store simple Strings, or collections of
keys and values, or collection of named objects,
TStrings is the abstract ancestor you should
derive your class from. }
TYPE
EStringListError = CLASS(Exception);
TStrings = CLASS(TObject)
PRIVATE
FUpdateSemaphore: LongInt;
FPreventFree: Boolean;
FUNCTION GetValue(CONST Name: STRING): STRING;
PROCEDURE SetValue(CONST Name, Value: STRING);
FUNCTION FindValue(CONST Name: STRING; VAR Value: STRING): LongInt;
FUNCTION GetName(Index: LongInt): STRING;
PROTECTED
FUNCTION Get(Index: LongInt): STRING; VIRTUAL; abstract;
FUNCTION GetCount: LongInt; VIRTUAL; abstract;
FUNCTION GetObject(Index: LongInt): TObject; VIRTUAL;
PROCEDURE Put(Index: LongInt; CONST S: STRING); VIRTUAL;
PROCEDURE PutObject(Index: LongInt; AObject: TObject); VIRTUAL;
PROCEDURE SetUpdateState(Updating: Boolean); VIRTUAL;
FUNCTION GetTextStr: AnsiString; VIRTUAL;
PROCEDURE SetTextStr(CONST Value: AnsiString); VIRTUAL;
PUBLIC
FUNCTION Add(CONST S: STRING): LongInt; VIRTUAL;
FUNCTION AddObject(CONST S: STRING; AObject: TObject): LongInt; VIRTUAL;
PROCEDURE AddStrings(AStrings: TStrings); VIRTUAL;
PROCEDURE Append(CONST S: STRING);
PROCEDURE Assign(AStrings: TStrings); VIRTUAL;
PROCEDURE BeginUpdate;
PROCEDURE Clear; VIRTUAL; abstract;
PROCEDURE Delete(Index: LongInt); VIRTUAL; abstract;
PROCEDURE EndUpdate;
FUNCTION Equals(AStrings: TStrings): Boolean;
PROCEDURE Exchange(Index1, Index2: LongInt); VIRTUAL;
FUNCTION GetText: PChar;VIRTUAL;
FUNCTION IndexOf(CONST S: STRING): LongInt; VIRTUAL;
FUNCTION IndexOfName(CONST Name: STRING): LongInt;
FUNCTION IndexOfObject(AObject: TObject): LongInt;
PROCEDURE Insert(Index: LongInt; CONST S: STRING); VIRTUAL; abstract;
PROCEDURE InsertObject(Index: LongInt; CONST S: STRING; AObject: TObject); VIRTUAL;
PROCEDURE LoadFromFile(CONST FileName: STRING);
PROCEDURE SetText(Text: PChar);VIRTUAL;
PROCEDURE LoadFromStream(Stream: TStream); VIRTUAL;
PROCEDURE Move(CurIndex, NewIndex: LongInt); VIRTUAL;
PROCEDURE SaveToFile(CONST FileName: STRING);
PROCEDURE SaveToStream(Stream: TStream); VIRTUAL;
PUBLIC
PROPERTY Names[Index: LongInt]: STRING read GetName;
PROPERTY Count: LongInt read GetCount;
PROPERTY Objects[Index: LongInt]: TObject read GetObject write PutObject;
PROPERTY Values[CONST Name: STRING]: STRING read GetValue write SetValue;
PROPERTY Strings[Index: LongInt]: STRING read Get write Put; default;
PROPERTY Text:AnsiString read GetTextStr write SetTextStr;
END;
{ TStringList is a concrete class derived
from TStrings. TStringList stores its items
in a PRIVATE field of type TList. It's very
fast, since it performs binary search for
retrieving objects by name. You can specify
whether you want TStringList to be sorted or
unsorted as well as case-sensitive or not.
You can also specify the way a TStringList
object handles duplicate entries.
TStringList is able to notify the user when
the list's data changes or has been changed.
Use the properties OnChange and OnChanged. }
TYPE
TDuplicates = (dupIgnore, dupAccept, dupError);
TFreeStringListItem = PROCEDURE(Sender:TObject;AObject:TObject) OF OBJECT;
TYPE
TStringList = CLASS(TStrings)
PRIVATE
FList: TList;
FSorted: Boolean;
FDuplicates: TDuplicates;
FCaseSensitive: Boolean;
FOnChange: TNotifyEvent;
FOnChanging: TNotifyEvent;
FOnFreeItem: TFreeStringListItem;
FLockChange:BOOLEAN;
PROCEDURE BottomUpHeapSort;
PROCEDURE SetSorted(Value: Boolean);
PROCEDURE SetCaseSensitive(Value: Boolean);
PROTECTED
PROCEDURE Changed; VIRTUAL;
PROCEDURE Changing; VIRTUAL;
FUNCTION Get(Index: LongInt): STRING; OVERRIDE;
FUNCTION GetCount: LongInt; OVERRIDE;
FUNCTION GetObject(Index: LongInt): TObject; OVERRIDE;
PROCEDURE Put(Index: LongInt; CONST S: STRING); OVERRIDE;
PROCEDURE PutObject(Index: LongInt; AObject: TObject); OVERRIDE;
PROCEDURE SetUpdateState(Updating: Boolean); OVERRIDE;
PROCEDURE FreeItem(AObject: TObject);VIRTUAL;
PUBLIC
CONSTRUCTOR Create;
DESTRUCTOR Destroy; OVERRIDE;
FUNCTION Add(CONST S: STRING): LongInt; OVERRIDE;
PROCEDURE Clear; OVERRIDE;
PROCEDURE Delete(Index: LongInt); OVERRIDE;
PROCEDURE Exchange(Index1, Index2: LongInt); OVERRIDE;
FUNCTION Find(CONST S: STRING; VAR Index: LongInt): Boolean; VIRTUAL;
FUNCTION IndexOf(CONST S: STRING): LongInt; OVERRIDE;
PROCEDURE Insert(Index: LongInt; CONST S: STRING); OVERRIDE;
PROCEDURE Sort; VIRTUAL;
PROPERTY Duplicates: TDuplicates read FDuplicates write FDuplicates;
PROPERTY CaseSensitive: Boolean read FCaseSensitive write SetCaseSensitive;
PROPERTY Sorted: Boolean read FSorted write SetSorted;
PROPERTY OnChange: TNotifyEvent read FOnChange write FOnChange;
PROPERTY OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
PROPERTY OnFreeItem: TFreeStringListItem read FOnFreeItem write FOnFreeItem;
END;
{ StrItem is a space-efficient way to store an object
associated with a STRING. It is used inside TStringList. }
TYPE
PStrItem = ^TStrItem;
TStrItem = RECORD
FObject: TObject;
FString: STRING;
END;
FUNCTION NewStrItem(CONST AString: STRING; AObject: TObject): PStrItem;
PROCEDURE DisposeStrItem(P: PStrItem);
TYPE
{ TBits implements a Boolean array. Entries are
numbered 0 .. Size - 1, as usual. Bits allows
read / write access to entries. OpenBit returns
index of first True bit, or -1 if none is True. }
PBitsArray = ^TBitsArray;
TBitsArray = ARRAY[0..MaxLongInt DIV 4] OF LongWord;
EBitsError = class(Exception);
TBits = class
PRIVATE
FBits: PBitsArray;
FSize: LongInt;
PROCEDURE Error;
FUNCTION GetBit(Index: LongInt): Boolean;
PROCEDURE SetBit(Index: LongInt; Bit: Boolean);
PROCEDURE SetSize(NewSize: LongInt);
PUBLIC
DESTRUCTOR Destroy; override;
FUNCTION OpenBit: LongInt;
property Bits[Index: LongInt]: Boolean read GetBit write SetBit; default;
property Size: LongInt read FSize write SetSize;
END;
TYPE
//General types
HWindow=LONGWORD;
PMessage=^TMessage;
{$M+}
TMessage=RECORD
{$M-}
Msg:LONGWORD;
ReceiverClass: TObject;
Receiver: HWindow;
Handled: LONGBOOL; {True if the message was handled}
CASE Integer OF
0: ( Param1: LONGWORD;
Param2: LONGWORD;
Result: LONGWORD);
1: ( WParam: LONGWORD;
LParam: LONGWORD;
MsgResult: LONGWORD);
2: ( Param1Lo: WORD;
Param1Hi: WORD;
Param2Lo: WORD;
Param2Hi: WORD;
ResultLo: WORD;
ResultHi: WORD);
3: ( Param1LoByteLo:BYTE;
Param1LoByteHi:BYTE;
Param1HiByteLo:BYTE;
Param1HiByteHi:BYTE;
Param2LoByteLo:BYTE;
Param2LoByteHi:BYTE;
Param2HiByteLo:BYTE;
Param2HiByteHi:BYTE;
ResultLoByteLo:BYTE;
ResultLoByteHi:BYTE;
ResultHiByteLo:BYTE;
ResultHiByteHi:BYTE);
END;
HDC=LONGWORD;
HPalette=LONGWORD;
{$M+}
TColor=LONGINT;
{$M-}
PPoint=^TPoint;
{$M+}
TPoint=RECORD
X,Y:LONGINT;
END;
{$M-}
PRect=^TRect;
{$M+}
TRect=RECORD
CASE LongInt OF
0: (Left,Bottom,Right,Top:LONGINT);
1: (LeftBottom,RightTop:TPoint);
END;
{$M-}
PSize=^TSize;
{$M+}
TSize=RECORD
CX,CY:LONGINT;
END;
TRGB=RECORD
Blue:BYTE;
Green:BYTE;
Red:BYTE;
Fill:BYTE;
END;
{$M-}
CONST
{$M+}
{Default RGB color values}
clBlack = TColor($00000000);
clMaroon = TColor($00800000);
clGreen = TColor($00008000);
clOlive = TColor($00808000);
clNavy = TColor($00000080);
clPurple = TColor($00800080);
clTeal = TColor($00008080);
clGray = TColor($00808080);
clSilver = TColor($00C6C6C6);
clRed = TColor($00FF0000);
clLime = TColor($0000FF00);
clYellow = TColor($00FFFF00);
clBlue = TColor($000000FF);
clFuchsia = TColor($00FF00FF);
clAqua = TColor($0000FFFF);
clLtGray = TColor($00CCCCCC);
clDkGray = TColor($00808080);
clWhite = TColor($00FFFFFF);
{System Colors}
clScrollbar = TColor(0 OR $80000000);
clBackGround = TColor(1 OR $80000000);
clActiveCaption = TColor(2 OR $80000000);
clInactiveCaption = TColor(3 OR $80000000);
clMenu = TColor(4 OR $80000000);
clWindow = TColor(5 OR $80000000);
clWindowFrame = TColor(6 OR $80000000);
clMenuText = TColor(7 OR $80000000);
clWindowText = TColor(8 OR $80000000);
clCaptionText = TColor(9 OR $80000000);
clActiveBorder = TColor(10 OR $80000000);
clInactiveBorder = TColor(11 OR $80000000);
clAppWorkSpace = TColor(12 OR $80000000);
clHighlight = TColor(13 OR $80000000);
clHighlightText = TColor(14 OR $80000000);
clBtnFace = TColor(15 OR $80000000);
clBtnShadow = TColor(16 OR $80000000);
clGrayText = TColor(17 OR $80000000);
clBtnText = TColor(18 OR $80000000);
clInactiveCaptionText = TColor(19 OR $80000000);
clBtnHighlight = TColor(20 OR $80000000);
cl3DDkShadow = TColor(21 OR $80000000);
cl3DLight = TColor(22 OR $80000000);
clInfoText = TColor(23 OR $80000000);
clInfo = TColor(24 OR $80000000);
clBtnDefault = TColor(25 OR $80000000);
clDlgWindow = TColor(26 OR $80000000);
clEntryField = TColor(27 OR $80000000);
clStaticText = TColor(28 OR $80000000);
{$M-}
TYPE
TColorName = RECORD
Name: STRING[20];
Value: LONGINT;
END;
CONST
MaxDefaultColors = 18;
DefaultColors: ARRAY[1..MaxDefaultColors] OF TColorName = (
(Name:'clBlack'; Value:clBlack),
(Name:'clMaroon'; Value:clMaroon),
(Name:'clGreen'; Value:clGreen),
(Name:'clOlive'; Value:clOlive),
(Name:'clNavy'; Value:clNavy),
(Name:'clPurple'; Value:clPurple),
(Name:'clTeal'; Value:clTeal),
(Name:'clGray'; Value:clGray),
(Name:'clSilver'; Value:clSilver),
(Name:'clRed'; Value:clRed),
(Name:'clLime'; Value:clLime),
(Name:'clYellow'; Value:clYellow),
(Name:'clBlue'; Value:clBlue),
(Name:'clFuchsia'; Value:clFuchsia),
(Name:'clAqua'; Value:clAqua),
(Name:'clLtGray'; Value:clLtGray),
(Name:'clDkGray'; Value:clDkGray),
(Name:'clWhite'; Value:clWhite));
MaxSystemColors = 29;
SystemColors: ARRAY[1..MaxSystemColors] OF TColorName = (
(Name:'clScrollbar'; Value:clScrollBar),
(Name:'clBackGround'; Value:clBackGround),
(Name:'clActiveCaption'; Value:clActiveCaption),
(Name:'clInactiveCaption'; Value:clInactiveCaption),
(Name:'clMenu'; Value:clMenu),
(Name:'clWindow'; Value:clWindow),
(Name:'clWindowFrame'; Value:clWindowFrame),
(Name:'clMenuText'; Value:clMenuText),
(Name:'clWindowText'; Value:clWindowText),
(Name:'clCaptionText'; Value:clCaptionText),
(Name:'clActiveBorder'; Value:clActiveBorder),
(Name:'clInactiveBorder'; Value:clInactiveBorder),
(Name:'clAppWorkSpace'; Value:clAppWorkSpace),
(Name:'clHighLight'; Value:clHighLight),
(Name:'clHighLightText'; Value:clHighLightText),
(Name:'clBtnFace'; Value:clBtnFace),
(Name:'clBtnShadow'; Value:clBtnShadow),
(Name:'clGrayText'; Value:clGrayText),
(Name:'clBtnText'; Value:clBtnText),
(Name:'clInactiveCaptionText'; Value:clInactiveCaptionText),
(Name:'clBtnHighlight'; Value:clBtnHighlight),
(Name:'cl3DDkShadow'; Value:cl3DDkShadow),
(Name:'cl3DLight'; Value:cl3DLight),
(Name:'clInfoText'; Value:clInfoText),
(Name:'clInfo'; Value:clInfo),
(Name:'clBtnDefault'; Value:clBtnDefault),
(Name:'clDlgWindow'; Value:clDlgWindow),
(Name:'clEntryField'; Value:clEntryField),
(Name:'clStaticText'; Value:clStatictext));
FUNCTION ColorName(ColorValue:TColor):STRING;
FUNCTION ColorValue(ColorName:STRING):TColor;
TYPE
TResourceName=STRING[32];
TResourceStream=CLASS(TMemoryStream)
PRIVATE
FHeaderPos:LONGINT;
FResourceList:TList;
SCUStream:TStream;
PUBLIC
FUNCTION NewResourceEntry(CONST ResName:TResourceName;
VAR Data;DataLen:LONGINT):BOOLEAN;
FUNCTION WriteResourcesToStream(Stream:TMemoryStream):BOOLEAN;
DESTRUCTOR Destroy;OVERRIDE;
END;
{Standard Resource names for NewResourceEntry}
CONST
rnGlyph = 'rnGlyph';
rnBitmap = 'rnBitmap';
rnPicture = 'rnPicture';
rnPictureLeaf = 'rnPictureLeaf';
rnPictureOpen = 'rnPictureOpen';
rnPictureClosed = 'rnPictureClosed';
rnFont = 'rnFont';
rnTabFont = 'rnTabFont';
rnLines = 'rnLines';
rnItems = 'rnItems';
rnTabs = 'rnTabs';
rnDBServer = 'rnDBServer';
rnDBDataBase = 'rnDBDataBase';
rnDBTable = 'rnDBTable';
rnDBQuery = 'rnDBQuery';
rnDBDataField = 'rnDBDataField';
rnGridSizes = 'rnGridSize';
rnFileName = 'rnFileName';
rnIcon = 'rnIcon';
rnDBGridCols = 'rnDBGridCols';
rnStatusPanels = 'rnStatusPanels';
rnHeaders = 'rnHeaders';
TYPE
TComponentState=SET OF (csDesigning,csReading,csWriting,csDestroying,
csLoaded,csForm,csDetail,csReferenceControl,
csReference,csAcceptsControls,csHandleLinks,
{Rene}csHasMainMenu);
TDesignerState=SET OF (dsFormVisible,dsNoRealSizing{-},
dsNoSourceCode,dsStored,dsAutoCreate);
TOperation=(opInsert,opRemove);
TGetChildProc=PROCEDURE(Child:TComponent) OF OBJECT;
ESCUError=CLASS(Exception);
TComponent=CLASS(TObject)
PRIVATE
FLanguages:POINTER;
FName:PSTRING;
FUnitName:PSTRING;
FTypeName:PSTRING;
FOwner:TComponent;
FComponentState:TComponentState;
FDesignerState:TDesignerState;
FCreateFromSCU:BOOLEAN;
FComponents:TList;
FFreeNotifyList:TList;
FMethods:POINTER;
FTag:LONGINT;
FWriteComponentCount:LONGINT;
SCUStream:TMemoryStream;
SCUResStream:TResourceStream;
SCUWriteError:BOOLEAN;
FOnCreate:TNotifyEvent;
FOnDestroy:TNotifyEvent;
FReference:TComponent;
FUNCTION GetComponentCount:LONGINT;
FUNCTION GetComponent(AIndex:LONGINT):TComponent;
FUNCTION GetComponentIndex:LONGINT;
PROCEDURE SetComponentIndex(Index:LONGINT);
FUNCTION GetName:STRING;
PROCEDURE SetName(CONST NewName:STRING);
FUNCTION GetUnitName:STRING;
FUNCTION GetTypeName:STRING;
PROCEDURE SetTypeName(NewName:STRING);
FUNCTION GetDesigned:BOOLEAN;
PROCEDURE SetupSCU;
FUNCTION ReadPropertiesSCU(Namep,Resourcep:POINTER;VAR ClassPointer:POINTER):BOOLEAN;
FUNCTION ReadComponentsSCU(NameTable,ResourceTable:POINTER;VAR ClassP:POINTER):BOOLEAN;
PROCEDURE ReadResourceSCU(ResourceTable:POINTER;VAR ClassP:POINTER);
PROCEDURE WriteComponent(Child:TComponent);
PROCEDURE ReadSCU(Data:POINTER);
PROTECTED
PROCEDURE SetupComponent;VIRTUAL;
PROCEDURE Loaded;VIRTUAL;
PROCEDURE LoadedFromSCU(SCUParent:TComponent);VIRTUAL;
PROCEDURE LoadingFromSCU(SCUParent:TComponent);VIRTUAL;
PROCEDURE GetChildren(Proc:TGetChildProc);VIRTUAL;
FUNCTION HasParent:BOOLEAN;VIRTUAL;
PROCEDURE UpdateLinkList(CONST PropertyName:STRING;LinkList:TList);VIRTUAL; //for component links
PUBLIC
CONSTRUCTOR Create(AOwner:TComponent);VIRTUAL;
DESTRUCTOR Destroy;OVERRIDE;
PROCEDURE InsertComponent(AComponent:TComponent);VIRTUAL;
PROCEDURE RemoveComponent(AComponent:TComponent);VIRTUAL;
FUNCTION IndexOfComponent(AComponent:TComponent):LONGINT;
PROCEDURE DestroyComponents;
FUNCTION FindComponent(CONST AName:STRING):TComponent;
PROCEDURE ReadSCUResource(CONST ResName:TResourceName;VAR Data;DataLen:LONGINT);VIRTUAL;
FUNCTION WriteSCUResource(Stream:TResourceStream):BOOLEAN;VIRTUAL;
PROCEDURE ReadFromStream(SCUStream:TStream);
PROCEDURE WriteToStream(SCUStream:TStream);
PROCEDURE Notification(AComponent:TComponent;Operation:TOperation);VIRTUAL;
PROCEDURE FreeNotification(AComponent:TComponent);VIRTUAL;
PROCEDURE SetDesigning(Value:BOOLEAN);VIRTUAL;
PROCEDURE GetDesignerPopupEvents(AString:TStringList);VIRTUAL;
PROCEDURE DesignerPopupEvent(Value:LONGINT);VIRTUAL;
PROPERTY Owner:TComponent read FOwner;
PROPERTY Components[Index:LONGINT]:TComponent read GetComponent;
PROPERTY ComponentCount:LONGINT read GetComponentCount;
PROPERTY ComponentIndex:LONGINT read GetComponentIndex write SetComponentIndex;
PROPERTY ComponentState:TComponentState read FComponentState write FComponentState;
PROPERTY DesignerState:TDesignerState read FDesignerState write FDesignerState; stored;
PROPERTY UnitName:STRING read GetUnitName;
PROPERTY TypeName:STRING read GetTypeName write SetTypeName;
PROPERTY Designed:BOOLEAN read GetDesigned;
PROPERTY FreeNotifyList:TList read FFreeNotifyList;
PROPERTY Methods:POINTER read FMethods write FMethods; {undocumented}
PUBLISHED
PROPERTY Name:STRING read GetName write SetName;
PROPERTY Tag:LONGINT read FTag write FTag;
PROPERTY OnCreate:TNotifyEvent read FOnCreate write FOnCreate;
PROPERTY OnDestroy:TNotifyEvent read FOnDestroy write FOnDestroy;
END;
TComponentClass=CLASS OF TComponent;
TCollection = CLASS;
TCollectionItem = CLASS
PRIVATE
FCollection:TCollection;
PRIVATE
FUNCTION GetIndex:LONGINT;
PROCEDURE SetCollection(NewValue:TCollection);
PROTECTED
PROCEDURE SetIndex(NewIndex:LONGINT);VIRTUAL;
PROCEDURE Changed(AllItems:BOOLEAN);
PUBLIC
PROCEDURE Assign(Source:TCollectionItem);VIRTUAL;ABSTRACT;
CONSTRUCTOR Create(ACollection: TCollection);VIRTUAL;
DESTRUCTOR Destroy;OVERRIDE;
PUBLIC
PROPERTY Collection:TCollection read FCollection write SetCollection;
PROPERTY Index:LONGINT read GetIndex write SetIndex;
END;
TCollectionItemClass=CLASS OF TCollectionItem;
TCollection=CLASS(TComponent)
PRIVATE
FItemClass:TCollectionItemClass;
FItems:TList;
FUpdateCount:LONGINT;
PRIVATE
FUNCTION GetCount:LONGINT;
PROCEDURE InsertItem(Item:TCollectionItem);
PROCEDURE RemoveItem(Item:TCollectionItem);
PROTECTED
PROCEDURE Changed;
FUNCTION GetItem(Index:LONGINT):TCollectionItem;
PROCEDURE SetItem(Index:LONGINT;Value:TCollectionItem);
PUBLIC
PROCEDURE Update(Item:TCollectionItem);VIRTUAL;
PROCEDURE SetupComponent;OVERRIDE;
DESTRUCTOR Destroy;OVERRIDE;
FUNCTION Add:TCollectionItem;
PROCEDURE Assign(Source:TCollection);VIRTUAL;
PROCEDURE BeginUpdate;
PROCEDURE Clear;
PROCEDURE EndUpdate;
PUBLIC
PROPERTY Count:LONGINT read GetCount;
PROPERTY Items[Index:LONGINT]:TCollectionItem read GetItem write SetItem;
PROPERTY ItemClass:TCollectionItemClass read FItemClass write FItemClass;
END;
TStringSelectList=CLASS(TComponent)
PRIVATE
FList:TStringList;
FSelected:STRING;
PROTECTED
PROCEDURE SetStringItem(NewValue:STRING);VIRTUAL;
PROCEDURE SetupComponent;OVERRIDE;
PUBLIC
DESTRUCTOR Destroy;OVERRIDE;
FUNCTION GetItems:TStringList;VIRTUAL;
PROPERTY SelectedItem:STRING read FSelected write SetStringItem;
PROPERTY Items:TStringList read GetItems;
END;
{$M+}
TThreadPriority=(tpIdle,tpLowest,tpLower,tpNormal,tpHigher,tpHighest,tpTimeCritical);
{$M-}
TThreadMethod=PROCEDURE OF OBJECT;
TThread=CLASS
PRIVATE
FOnTerminate:TNotifyEvent;
FHandle:LONGWORD;
FPriority:TThreadPriority;
FFreeOnTerminate:BOOLEAN;
FTerminated:BOOLEAN;
FReturnValue:LONGINT;
FSuspended:BOOLEAN;
FFinished:BOOLEAN;
FThreadId:LONGWORD;
FParameter:POINTER;
FMethod:TThreadMethod;
PROCEDURE SetSuspended(NewValue:BOOLEAN);
PROCEDURE SetPriority(NewValue:TThreadPriority);
PROCEDURE SyncTerminate;
PROCEDURE MsgIdle;
PROTECTED
PROCEDURE DoTerminate;VIRTUAL;
PROCEDURE Execute;VIRTUAL;ABSTRACT;
PUBLIC
CONSTRUCTOR Create(CreateSuspended:Boolean);
CONSTRUCTOR ExtCreate(CreateSuspended:Boolean;StackSize:LONGWORD;
Priority:TThreadPriority;Param:POINTER);
DESTRUCTOR Destroy;OVERRIDE;
FUNCTION WaitFor:LONGINT;
PROCEDURE Terminate;
PROCEDURE Suspend;
PROCEDURE Resume;
PROCEDURE Kill;
PROCEDURE Synchronize(Method:TThreadMethod);
PROCEDURE ProcessMsgs;
PROPERTY Terminated:BOOLEAN read FTerminated;
PROPERTY ReturnValue:LONGINT read FReturnValue write FReturnValue;
PROPERTY ThreadId:LONGWORD read FThreadId;
PROPERTY Handle:LONGWORD read FHandle;
PROPERTY Priority:TThreadPriority read FPriority write SetPriority;
PROPERTY Parameter:POINTER read FParameter write FParameter;
PROPERTY Suspended:BOOLEAN read FSuspended write SetSuspended;
PROPERTY FreeOnTerminate:BOOLEAN read FFreeOnTerminate write FFreeOnTerminate;
PROPERTY OnTerminate:TNotifyEvent read FOnTerminate write FOnTerminate;
END;
PROCEDURE RegisterClasses(CONST ComponentClasses: ARRAY OF TComponentClass);
FUNCTION SearchClassByName(CONST Name:STRING):TComponentClass;
FUNCTION CallReadProp(Objekt:TObject;FuncAddr:POINTER;Typ:BYTE;
TypLen:LONGINT;Value:POINTER):BOOLEAN;
FUNCTION CallWriteProp(Objekt:TObject;ProcAddr:POINTER;Typ:BYTE;
TypLen:LONGINT;Value:POINTER):BOOLEAN;
TYPE
PSCUFileFormat=^TSCUFileFormat;
TSCUFileFormat=RECORD
Version:STRING[5];
ObjectOffset,ObjectLen:LONGINT;
NameTableOffset,NameTableLen:LONGINT;
ResourceOffset,ResourceLen:LONGINT;
ObjectCount:LONGINT;
UseEntry:LONGINT;
NextEntry:POINTER;
END;
PFormListItem=^TFormListItem;
TFormListItem=RECORD
Form:TComponent;
FormName:STRING[64];
UnitName:STRING;
AutoCreate:BOOLEAN;
SCUPointer:POINTER;
SCUSize:LONGINT;
END;
FUNCTION WritePropertiesToStream(FormList:TList):TMemoryStream;
FUNCTION WritePropertiesToFile(FileName:STRING;FormList:TList):BOOLEAN;
TYPE
TMsgDlgBtn=(mbYes,mbNo,mbOk,mbCancel,mbAbort,mbRetry,mbIgnore,mbAll,mbHelp);
TMsgDlgButtons=SET OF TMsgDlgBtn;
TMsgDlgType=(mtWarning,mtError,mtInformation,mtConfirmation,mtCustom,mtCritical);
TMsgDlgReturn=(mrOk,mrCancel,mrYes,mrNo,mrIgnore,mrRetry,mrAbort,mrNone,mrAll);
CONST
mbYesNo=[mbYes,mbNo];
mbYesNoCancel=[mbYes,mbNo,mbCancel];
mbOkCancel=[mbOk,mbCancel];
mbAbortRetryIgnore=[mbAbort,mbRetry,mbIgnore];
FUNCTION MessageBox2(CONST Msg:STRING;Typ:TMsgDlgType;Buttons:TMsgDlgButtons):TMsgDlgReturn;
FUNCTION ErrorBox2(CONST Msg:STRING):TMsgDlgReturn;
FUNCTION GetExperts:TList;
VAR RegisteredClasses:TList;
PropertyEditDialogs:TList;
LibExperts:TList;
LibExpertInstances:TList;
TYPE
TPropertyEditorReturn=(edOk,edCancel,edList,edNoEditor);
TPropertyEditor=CLASS(TComponent)
PRIVATE
FPropertyOwner:TComponent;
FPropertyName:STRING;
FList:TStringList;
PUBLIC
FUNCTION Execute(VAR Value;ValueLen:LONGINT):TPropertyEditorReturn;VIRTUAL;ABSTRACT;
PUBLIC
PROPERTY PropertyOwner:TComponent read FPropertyOwner;
PROPERTY PropertyName:STRING read FPropertyName;
PROPERTY List:TStringList read FList;
END;
TPropertyEditorClass=CLASS OF TPropertyEditor;
TStringPropertyEditor=CLASS(TPropertyEditor)
PUBLIC
FUNCTION Execute(VAR Value:STRING;ValueLen:LONGINT):TPropertyEditorReturn;VIRTUAL;ABSTRACT;
END;
TShortIntPropertyEditor=CLASS(TPropertyEditor)
PUBLIC
FUNCTION Execute(VAR Value:ShortInt):TPropertyEditorReturn;VIRTUAL;ABSTRACT;
END;
TIntegerPropertyEditor=CLASS(TPropertyEditor)
PUBLIC
FUNCTION Execute(VAR Value:Integer):TPropertyEditorReturn;VIRTUAL;ABSTRACT;
END;
TLongIntPropertyEditor=CLASS(TPropertyEditor)
PUBLIC
FUNCTION Execute(VAR Value:LongInt):TPropertyEditorReturn;VIRTUAL;ABSTRACT;
END;
TClassPropertyEditorReturn=(peOk,peCancel,peClear,peNoEditor);
TClassPropertyEditor=CLASS(TPropertyEditor)
PRIVATE
PROPERTY PropertyOwner;
PROPERTY PropertyName;
PROPERTY List;
PUBLIC
FUNCTION Execute(VAR ClassToEdit:TObject):TClassPropertyEditorReturn;VIRTUAL;
END;
TClassPropertyEditorClass=CLASS OF TClassPropertyEditor;
PROCEDURE AddPropertyEditor(OwnerClass:TClass;PropertyName:STRING;PropertyEditor:TPropertyEditorClass);
FUNCTION CallPropertyEditor(Owner:TComponent;PropertyName:STRING;VAR Value;ValueLen:LONGINT;
VAR List:TStringList):TPropertyEditorReturn;
FUNCTION PropertyEditorAvailable(OwnerClass:TClass;PropertyName:STRING):BOOLEAN;
PROCEDURE AddClassPropertyEditor(ClassToEdit:TClass;PropertyEditor:TClassPropertyEditorClass);
FUNCTION CallClassPropertyEditor(VAR ClassToEdit:TObject):TClassPropertyEditorReturn;
FUNCTION ClassPropertyEditorAvailable(ClassName:STRING):BOOLEAN;
FUNCTION GetTempFileName:STRING;
FUNCTION InDesigner:BOOLEAN;
IMPLEMENTATION