unit MeineKompo;
interface
uses
Windows, SysUtils, Classes, Controls, Graphics, Messages, Math, StdActns,
ExtCtrls, Dialogs;
type
TShelfType = (stNone, st3, st4, st6, st8, st9, st10, st14, st28);
TMRAnlage =
class(TCustomControl)
private
myAnlagenShelfs : TMRAnlagenShelfs;
myhasdata :
array of Boolean;
function myFillShelf(
const ShelfType: TShelfType): TShelfType;
procedure mySetAnlagenShelfs(
const Value: TMRAnlagenShelfs);
published
property Shelfs: TMRAnlagenShelfs
read myAnlagenShelfs
write mySetAnlagenShelfs;
end;
TMRAnlagenShelfs =
class(TCollection)
private
myOwner : TMRAnlage;
function myGetShelf(
const Index: Integer): TMRAnlagenShelf;
procedure mySetShelf(
const Index: Integer;
const Value: TMRAnlagenShelf);
protected
function GetOwner: TPersistent;
override;
public
constructor Create(
const AOwner: TMRAnlage);
function Add: TMRAnlagenShelf;
function Owner: TMRAnlage;
property Items[
const Index: Integer]: TMRAnlagenShelf
read myGetShelf
write mySetShelf;
default;
end;
TMRAnlagenShelf =
class(TCollectionItem)
private
myShelfType : TShelfType;
myHEinheit : Integer;
procedure mySetShelfType(
const Value: TShelfType);
procedure mySetHEinheit(
const Value: Integer);
public
constructor Create(Collection: TCollection);
override;
published
property Hoeheneinheiten: Integer
read myHEinheit
write mySetHEinheit
default 1;
property ShelfType: TShelfType
read myShelfType
write mySetShelfType
default stNone;
end;
implementation
{ TMRAnlage }
procedure TMRAnlage.mySetAnlagenShelfs(
const Value: TMRAnlagenShelfs);
begin
myAnlagenShelfs.Assign(Value);
end;
constructor TMRAnlage.Create(AOwner: TComponent);
begin
inherited;
Width := 300;
Height := 200;
myAnlagenShelfs := TMRAnlagenShelfs.Create(Self);
myAnlagenShelfs.Clear;
SetLength(myhasdata, 0);
end;
function TMRAnlage.myFillShelf(
const ShelfType: TShelfType): TShelfType;
begin
// CODE TO DO
// Hier wird auf das Array myhasdata zugegriffen
Result := ERGEBNIS;
end;
{ TMRAnlagenShelfs }
constructor TMRAnlagenShelfs.Create(
const AOwner: TMRAnlage);
begin
inherited Create(TMRAnlagenShelf);
myOwner := AOwner;
end;
function TMRAnlagenShelfs.Add: TMRAnlagenShelf;
begin
Result := TMRAnlagenShelf(
inherited Add);
myOwner.Invalidate;
SetLength(myOwner.myhasdata, Length(myOwner.myhasdata)+1);
myOwner.myhasdata[High(myOwner.myhasdata)] := false;
end;
{ TMRAnlagenShelf }
constructor TMRAnlagenShelf.Create(Collection: TCollection);
begin
inherited;
myHEinheit := 1;
end;
procedure TMRAnlagenShelf.mySetHEinheit(
const Value: Integer);
begin
myHEinheit := Value;
TMRAnlage(Collection.Owner).Invalidate;
end;
procedure TMRAnlagenShelf.mySetShelfType(
const Value: TShelfType);
begin
if myShelfType<>Value
then
begin
myShelfType := TMRAnlage(Collection.Owner).myFillShelf(Value);
end;
end;
end.