{Original idea:
 Vladimir V.,  16.10.00 : W-develop@mtu-net.ru; http//www.GameDev.narod.ru
 Modified by Spose 17.09.2002 www.daddy.h1.ru
added:
-DxImageCheckBox
-DxImageListBox
-DxScrollBar
-DxImageButtonList
-for DxImageButton:
procudere OnClick and Mouse Move/Down/Up
fixed:
-some bugs :)
deleted:
-TdxwObjectList (SUXXXXXX)
}
unit Intf;

interface
uses
  Windows, SysUtils, Classes, Controls, Contnrs, Graphics ,Dialogs,
  DXClass, DXDraws;

Type
/////////////////////////////////////////////////////////////////////////

  TDXButton = class
  private
    FSelected    : Boolean;
    FHighLighted : Boolean;
    FCaption     : String;
    FX: Integer;
    FY: Integer;
    FWidth: Integer;
    FHeight: Integer;
    FVisible    : Boolean;
  protected
    function GetBoundsRect: TRect;
  public
    FOnClick : TNotifyEvent;
    procedure DoDraw; virtual;
    constructor Create; virtual;
    destructor Destroy; override;
    property BoundsRect: TRect read GetBoundsRect;
    property Selected: Boolean read FSelected write FSelected;
    property HighLighted : Boolean read FHighLighted write FHighLighted;

    property X: Integer read FX write FX;
    property Y: Integer read FY write FY;
    property Width: Integer read FWidth write FWidth;
    property Height: Integer read FHeight write FHeight;
    property Visible: Boolean read FVisible write FVisible;
  end;


 TDXImageButton = class (TDXButton)
  private
    FImage: TPictureCollectionItem;
  protected
   function GetDrawImageIndex: Integer;
  public
   constructor Create; override;
   procedure DoDraw; override;
   procedure OnMouseUp;
   procedure OnMouseMove(x,y:integer);
   procedure OnMouseDown(x,y:integer);
   property OnClick: TnotifyEvent read Fonclick write fonclick;
   property Image: TPictureCollectionItem read FImage write FImage;
   property Caption    : String read FCaption write FCaption ;
  end;

  TDXScrollBar = class (TDXButton)
  private
    FImage: TPictureCollectionItem;
  public
   scrollwidth,scrollheight:integer;
   max,curpos:integer;
   constructor Create; override;
   procedure DoDraw; override;
   procedure mousemove(nx,ny:integer);
   procedure mousedown(nx,ny:integer);
   procedure mouseup;
   property Image: TPictureCollectionItem read FImage write FImage;
  end;

  TDXImageListBox = class (TDXButton)
  private
    FImage: TPictureCollectionItem;
  public
   viewlines:byte;
   lines:Tstringlist;
   scr:TdxScrollBar;
   constructor Create; override;
   procedure DoDraw; override;
   procedure start;
   property Image: TPictureCollectionItem read FImage write FImage;
  end;

  TDXImageButtonList = class (TDXButton)
  private
    FImage: TPictureCollectionItem;
  public
   viewlines:byte;
   scr:TdxScrollBar;
   List:Tlist;
   constructor Create;
   procedure OnMouseUp;
   procedure OnMouseMove(x,y:integer);
   procedure OnMouseDown(x,y:integer);
   procedure DoDraw; override;
   procedure Add(names:string; onclick1:TnotifyEvent);
   property Image: TPictureCollectionItem read FImage write FImage;
  end;

 TDXImageCheckBox = class (TDXButton)
  private
    FImage: TPictureCollectionItem;
  protected
   function GetDrawImageIndex: Integer;
  public
   WidthWithText:integer;
   procedure OnMouseUp;
   procedure OnMouseMove(x,y:integer);
   procedure OnMouseDown(x,y:integer);
   constructor Create; override;
   procedure DoDraw; override;
   property Image: TPictureCollectionItem read FImage write FImage;
   property Caption    : String read FCaption write FCaption ;
  end;

/////////////////////////////////////////////////////////////////////////

  TDXWObject = class
  private
    FMouseInControl: Boolean;
    FText          : String;
    FFocused       : Boolean;
    FAllowAllUp    : Boolean;
    FGroupIndex    : Integer;
    FDown          : Boolean;
    FCanHighLighted: Boolean;

    FLeft          : Integer;
    FTop           : Integer;
    FWidth         : Integer;
    FHeight        : Integer;
    FVisible       : Boolean;
    FEnabled       : Boolean;
    FMouseCaptured : boolean;
    FdClickedPoint  : TPoint;

    FOnMouseUp     : TMouseEvent;
    FOnMouseDown   : TMouseEvent;
    FOnMouseMove   : TMouseMoveEvent;

    FOnKeyDown     : TKeyEvent;
    FOnKeyUp       : TKeyEvent;
    FOnKeyPress    : TKeyPressEvent;

    FName          : String;
    FFont          : TFont;
    FTag           : Integer;
    FOwner         : TObject;
    FBoundsRect    : TRect;

    procedure SetHeight(const Value: Integer);
    procedure SetLeft(const Value: Integer);
    procedure SetTop(const Value: Integer);
    procedure SetWidth(const Value: Integer);
    procedure SetBoundsRect(const Value: TRect);
  protected
    function  GetBoundsRect: TRect;
    procedure DoDraw;virtual;abstract;
    procedure SetMouseInControl(const Value: Boolean);virtual;

    Procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); virtual;
    Procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); virtual;
    Procedure MouseMove(Shift: TShiftState; X, Y: Integer); virtual;

    Procedure KeyDown(var Key: Word; Shift: TShiftState); virtual;
    Procedure KeyUp(var Key: Word; Shift: TShiftState);virtual;
    Procedure KeyPress(var Key : char); virtual;
    Procedure FontChenged(Sender: TObject); virtual;abstract;
    Procedure SetBounds; virtual;

  public
    constructor Create(AOwner:TObject); virtual;
    destructor Destroy; override;

    property Owner       : TObject read FOwner write FOwner;
    property MouseInControl : Boolean read FMouseInControl write SetMouseInControl;
    property Focused     : Boolean read FFocused write FFocused;
    property AllowAllUp  : Boolean read FAllowAllUp write FAllowAllUp default False;
    property Down        : Boolean read FDown write FDown default False;
    property Visible     : Boolean read FVisible write FVisible;
    property Enabled     : Boolean read FEnabled write FEnabled;
    property CanHighLighted : Boolean read FCanHighLighted write FCanHighLighted;
    property MouseCaptured  : Boolean read FMouseCaptured write FMouseCaptured default False;
    property dClickedPoint  : TPoint read FdClickedPoint;

    property Tag        : Integer read FTag write FTag default 0;
    property GroupIndex : Integer read FGroupIndex write FGroupIndex default 0;
    property Name       : String read FName write FName;
    property Font       : TFont read FFont write FFont;
    property BoundsRect : TRect  read FBoundsRect write SetBoundsRect;

    property Left    : Integer read FLeft write SetLeft;
    property Top     : Integer read FTop write SetTop;
    property Width   : Integer read FWidth write SetWidth;
    property Height  : Integer read FHeight write SetHeight;

    property OnMouseUp   : TMouseEvent read FOnMouseUp   write FOnMouseUp;
    property OnMouseDown : TMouseEvent read FOnMouseDown write FOnMouseDown;
    property OnMouseMove : TMouseMoveEvent read FOnMouseMove write FOnMouseMove;

    property OnKeyDown   : TKeyEvent read FOnKeyDown write FOnKeyDown;
    property OnKeyUp     : TKeyEvent read FOnKeyUp write FOnKeyUp;
    property OnKeyPress  : TKeyPressEvent read FOnKeyPress write FOnKeyPress;

  end;

 TDXWImageObject = class (TDXWObject)
  private
   FImage  : TPictureCollectionItem;
   procedure SetSurface(Value: TDirectDrawSurface);
  protected
   procedure SetImage(const Value: TPictureCollectionItem);virtual;
   function GetDrawImageIndex: Integer;virtual;
  public
   procedure DoDraw; override;
   property Image : TPictureCollectionItem read FImage write SetImage;
  end;

 TDXWLabel = class (TDXWObject)
  private
   FAutoSize : Boolean;
   procedure SetSurface(Value: TDirectDrawSurface);
  public
   constructor Create(AOwner:TObject); override;
   procedure DoDraw; override;
   property Caption  : String read FText write FText ;
   property AutoSize : Boolean read FAutoSize write FAutoSize;
  end;


 TDXWEdit = class (TDXWImageObject)
  private
   FCaretPos : integer;
   FOnChange : TNotifyEvent;
   procedure SetText(const Value: String);
   procedure Change;
  public
   constructor Create(AOwner:TObject); override;
   procedure DoDraw; override;

   function GetDrawImageIndex: Integer;override;

   Procedure KeyDown(var Key: Word; Shift: TShiftState);override;
   Procedure KeyUp(var Key: Word; Shift: TShiftState);override;
   Procedure KeyPress(var Key : char);override;

   property Text    : String read FText write SetText ;
   property OnChange : TNotifyEvent read FOnChange write FOnChange;
  end;

 TDXWPanel = class (TDXWImageObject)
  public
   function GetDrawImageIndex: Integer;override;
  end;

/////////////////////////////////////////////////////////////////////////
var
fsurface:TDirectDrawSurface;


implementation
uses unit1;
/////////////////////////////////////////////////////////////////////////

function Shorten(S: string; Cut: Integer): string;
begin
  SetLength(S, Length(S) - Cut);
  Result:=S;
end;

constructor TDXButton.Create;
begin
  inherited Create;
  FVisible:=true;
end;

destructor TDXButton.Destroy;
begin
  inherited Destroy;
end;

procedure TDXButton.DoDraw;
begin
end;

function TDXButton.GetBoundsRect: TRect;
begin
  Result := Bounds(FX,FY,FWidth,FHeight);
end;

constructor TDXWObject.Create(AOwner:TObject);
begin
  inherited Create;
  FFont:=TFont.Create;
  FFont.Color:=clBlack;
  FVisible:=true;
  FEnabled:=true;
  FText:='';
  FOwner:=AOwner;
end;


destructor TDXWObject.Destroy;
begin
  FFont.Free;
  inherited Destroy;
end;

function TDXWObject.GetBoundsRect: TRect;
begin
  Result := Bounds(FLeft,FTop,FWidth,FHeight);
end;

procedure TDXWObject.SetMouseInControl(const Value: Boolean);
begin
 if FMouseInControl=Value then Exit;

 if FMouseInControl and (not Value)then
  begin
   FDown:=false;
  end;

 FMouseInControl:=Value;
end;

procedure TDXWObject.KeyDown(var Key: Word; Shift: TShiftState);
begin
if Assigned(FOnKeyDown) then FOnKeyDown(self,Key,Shift);
end;

procedure TDXWObject.KeyPress(var Key: char);
begin
if Assigned(FOnKeyPress) then FOnKeyPress(self,Key);
end;

procedure TDXWObject.KeyUp(var Key: Word; Shift: TShiftState);
begin
if Assigned(FOnKeyUp) then FOnKeyUp(self,Key,Shift);
end;

procedure TDXWObject.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
  Y: Integer);
begin
FDown:=true;
FFocused:=true;
FdClickedPoint:=Point(X-Left,Y-Top);

if Assigned(FOnMouseDown) then FOnMouseDown(Self,Button,Shift,X,Y);
end;

procedure TDXWObject.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
MouseInControl:=true;
if Assigned(FOnMouseMove) then FOnMouseMove(Self,Shift,X,Y);
end;

procedure TDXWObject.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
  Y: Integer);
begin
FDown:=false;
if ( PtInRect(BoundsRect,Point(X,Y)) ) and
   ( Assigned(FOnMouseUp) )
   then FOnMouseUp(Self,Button,Shift,X,Y);
end;

////////////////////////////////////////////////////////////////////////

constructor TDXImageButton.Create;
begin
  inherited Create;
  FCaption:='';
end;

constructor TDXImageListBox.Create;
begin
  inherited Create;
  scr:=tdxscrollbar.Create;
  lines:=Tstringlist.create;
end;

constructor TDXImageButtonList.Create;
begin
  inherited Create;
  scr:=tdxscrollbar.Create;
  List:=Tlist.Create;
end;

constructor TDXImageCheckBox.Create;
begin
  inherited Create;
  FCaption:='';
end;

constructor TDXScrollbar.Create;
begin
  inherited Create;
end;


function TDXImageButton.GetDrawImageIndex: Integer;
begin
  if Selected then Result :=1 else Result :=0;
end;

function TDXImageCheckBox.GetDrawImageIndex: Integer;
begin
  if Selected then Result :=1 else Result :=0;
end;

procedure tdxscrollbar.mousemove(nx,ny:integer);
begin
if not Visible then exit;
if ptinrect(BoundsRect,mouse.CursorPos) then
HighLighted:=true
else
HighLighted:=false;
if (selected) and (HighLighted) then
begin
curpos:=(nY+3-Y)div(scrollheight div max);
end;
if max<=curpos then
curpos:=max;
end;

procedure tdxscrollbar.mouseup;
begin
if not Visible then exit;
selected:=false;
end;


procedure Tdxscrollbar.mousedown(nx,ny:integer);
begin
if not Visible then exit;
if highlighted then
selected:=true;
if (selected) and (HighLighted) then
begin
curpos:=(nY+3-Y)div((scrollheight-image.height) div max);
end;
if max<=curpos then
curpos:=max;
end;

procedure Tdximagebutton.OnMouseUp;
begin
if selected then
begin
selected:=false;
OnClick(self);
end;
end;

procedure TdximageCheckBox.OnMouseUp;
begin
if highlighted then
selected:=not selected;
end;

procedure Tdximagebutton.OnMouseMove(x,y:integer);
begin
if ptinrect(boundsrect,point(x,y)) then
highlighted:=true else
highlighted:=false;
end;

procedure TdximageCheckBox.OnMouseMove(x,y:integer);
begin
if ptinrect(bounds(self.x,self.y,widthwithtext,height),point(x,y)) then
highlighted:=true else
highlighted:=false;
end;

procedure Tdximagebutton.OnMouseDown(x,y:integer);
begin
if ptinrect(boundsrect,point(x,y)) then
selected:=true;
end;
procedure Tdximagebuttonlist.OnMouseUp;
var i:integer;
begin
if scr.Visible then
scr.mouseup;
for i:=scr.curpos to scr.curpos+viewlines do
if i<=list.Count-1 then
TdxImageButton(list[i]).OnMouseUp;
end;

procedure TdximageCheckBox.OnMouseDown(x,y:integer);
begin
end;


procedure Tdximagebuttonlist.OnMouseMove(x,y:integer);
var i:integer;
begin
if scr.Visible then
scr.mousemove(x,y);
for i:=scr.curpos to scr.curpos+viewlines do
if i<=list.Count-1 then
TdxImageButton(list[i]).OnMouseMove(x,y);
end;

procedure Tdximagebuttonlist.OnMouseDown(x,y:integer);
var i:integer;
begin
if scr.Visible then
scr.mousedown(x,y);
for i:=scr.curpos to scr.curpos+viewlines do
if i<=list.Count-1 then
TdxImageButton(list[i]).OnMouseDown(x,y);
end;

procedure TDXImageButton.DoDraw;
var
  ImageIndex: Integer;
begin
if Not FVisible then Exit;
  ImageIndex := GetDrawImageIndex;
  Image.Draw( FSurface, X, Y, ImageIndex);
  if FCaption<>'' then
   begin
    with FSurface.Canvas do
    begin
     Brush.Style := bsClear;
     if HighLighted then
     begin
      Font.Color := clWhite;
      Font.Style:=[fsBold];
     end
     else
     begin
      Font.Style:=[];
      Font.Color := clYellow;
     end;

     Font.Size := 12;
     Font.Name:='Times New Roman';
     TextOut(X+(Width-TextWidth(FCaption))div 2 ,
             Y+(Height-TextHeight('A'))div 2, FCaption);
     Release;
    end;
   end;
end;


procedure TDXImagebuttonList.add(names:string;Onclick1:TNotifyEvent);
begin
list.add(TdxImageButton.Create);
TdximageButton(list[list.Count-1]).image:=image;
with TdximageButton(list[list.Count-1]) do
begin
visible:=false;
width:=image.width;
height:=image.Height;
caption:=names;
OnClick:=OnClick1;
end;

end;


procedure TDXImageListBox.Start;
begin
scr.max:=lines.Count-1;
if scr.max+1>=viewlines then
scr.max:=scr.max+1-viewlines;
scr.curpos:=0;
scr.x:=x+image.Width;
scr.Y:=y;
scr.scrollheight:=image.Height*viewlines;
scr.Width:=scr.scrollwidth;
scr.Height:=scr.scrollheight;
end;

procedure TDXImageListBox.DoDraw;
var
  I: Integer;
begin
if Not FVisible then Exit;
  for i:=1 to viewlines do
  Image.Draw( FSurface, X, Y+(i-1)*image.Height, 0);

     if HighLighted then
     with FSurface.Canvas do
     begin
     brush.Style:=bsClear;
     pen.Width:=1;
     pen.Color:=clYellow;
     rectangle(bounds(x-1,y-1,image.width+1,image.Height*viewlines+1));
     release;
     end;
     with FSurface.Canvas do
     begin
     brush.Style:=bsClear;
     font.Color:=clYellow;
     font.Style:=[];
     font.Name:='Times New Roman';
     font.Size:=10;
     for i:=scr.curpos{*2} to scr.curpos{*2} +viewlines-1 do
     if i<=lines.Count-1 then
     textout(x+5,y+(i-scr.curpos{*2})*image.Height-2,lines[i]);
     release;
     end;
     if lines.Count>viewlines then
     begin
     scr.visible:=true;
     scr.DoDraw;
     end else
     scr.Visible:=false;
end;

procedure TDXImageButtonList.DoDraw;
var
  I: Integer;
function chinar(val:integer;x1,x2:integer):boolean;
begin
result:=((val>=min(x1,x2))and(val<=max(x1,x2)));
end;
begin
if Not FVisible then Exit;
scr.scrollheight:=image.Height*viewlines;
if list.count<viewlines then
scr.scrollheight:=image.Height*list.count;
scr.Height:=scr.scrollheight;
scr.Width:=scr.scrollwidth;
scr.max:=list.Count-1;
if scr.max+1>=viewlines then
scr.max:=scr.max+1-viewlines;
scr.X:=x+image.Width;
scr.Y:=y;
for i:=0 to list.Count-1 do
if not chinar(i,scr.curpos,scr.curpos+viewlines) then
TdxImageButton(list[i]).Visible:=false else
TdxImageButton(list[i]).Visible:=true;
for i:=scr.curpos to scr.curpos+viewlines-1 do
if i<=list.Count-1 then
begin
TdxImageButton(list[i]).X:=x;
TdxImageButton(list[i]).y:=y+(i-scr.curpos)*image.Height;
TdxImageButton(list[i]).DoDraw;
end;
if list.Count>viewlines then
begin
scr.Visible:=true;
scr.DoDraw;
end else
scr.Visible:=false;
end;

procedure TDXImageCheckBox.DoDraw;
var
  ImageIndex: Integer;
begin
if Not FVisible then Exit;
  ImageIndex := GetDrawImageIndex;
  Image.Draw( FSurface, X, Y, ImageIndex);
  if highlighted then
  with fsurface.Canvas do
  begin
  brush.Style:=bsClear;
  pen.Width:=1;
  pen.Color:=clYellow;
  Font.Size := 12;
  Font.Name:='Times New Roman';
  Font.Color := clRed;
  Font.Style:=[fsBold];
  rectangle(bounds(x-1,y-1,image.Width+textwidth(fcaption)+3,image.Height+2));
  WidthWithText:=image.Width+textwidth(fcaption)+3;
  release;
  end else
   begin
    with FSurface.Canvas do
    begin
     Font.Style:=[];
     Font.Color := clRed;//clYellow;
     Font.Size := 12;
     Font.Name:='Times New Roman';
     WidthWithText:=image.Width+textwidth(fcaption)+3;
     Release;
    end;
   end;
   with FSurface.Canvas do
    begin
     TextOut(X+Width,y-2, FCaption);
     Release;
    end;
end;

procedure TDXScrollBar.DoDraw;
begin
if Not FVisible then Exit;
if max<=curpos then
curpos:=max;
  image.StretchDraw(fsurface,bounds(x,y,ScrollWidth,ScrollHeight),0);
  Image.Draw( FSurface, X+1, Y+((ScrollHeight-image.Height)div max)*curpos, 1);
  if highlighted then
  with fsurface.Canvas do
  begin
  brush.Style:=bsClear;
  pen.Width:=1;
  pen.Color:=clYellow;
  rectangle(bounds(x-1,y-1,scrollwidth+1,scrollHeight+1));
  release;
  end;

end;


/////////////////////////////////////////////////////////////////////////

function TDXWImageObject.GetDrawImageIndex: Integer;
begin
  if FDown then Result :=1 else Result :=0;
end;

procedure TDXWImageObject.DoDraw;
var
 ImageIndex: Integer;
begin
if Not FVisible then Exit;
  ImageIndex := GetDrawImageIndex;
  Image.Draw( FSurface, FLEft, FTop, ImageIndex);
  if FText<>'' then
   begin
    with FSurface.Canvas do
    begin
     Font.Assign(Self.Font);

     Brush.Style := bsClear;
     if MouseInControl and CanHighLighted then
     begin
      Font.Style:=[fsBold];
      Font.Color := clWhite;
     end
     else
     begin
      Font:=Self.Font
     end;

     {
     TextOut(FLeft+(FWidth-TextWidth(FText))div 2 ,
             FTop+(FHeight-TextHeight('A'))div 2, FText);
     }

     TextRect(BoundsRect,FLeft+(FWidth-TextWidth(FText))div 2 ,
                         FTop+(FHeight-TextHeight('A'))div 2, FText);

     Release;
    end;
   end;
end;

procedure TDXWImageObject.SetSurface(Value: TDirectDrawSurface);
begin
  FSurface := Value;
end;




{ TDXWEdit }

procedure TDXWEdit.Change;
begin
 if Assigned(FOnChange) then FOnChange(Self);
end;

constructor TDXWEdit.Create(AOwner: TObject);
begin
 inherited Create(AOwner);
 FCaretPos:=0;
end;

procedure TDXWEdit.DoDraw;
begin
  inherited DoDraw;
end;

function TDXWEdit.GetDrawImageIndex: Integer;
begin
 if Focused then Result :=1 else Result :=0;
end;

procedure TDXWEdit.KeyDown(var Key: Word; Shift: TShiftState);
begin
if (focused)and(visible) then
Case key of
 vk_back    : Text:=Shorten(FText,1);
 vk_return  : Focused:=not Focused;
end;

 inherited KeyDown(Key,Shift);
end;

procedure TDXWEdit.KeyPress(var Key: char);
begin
 if ( Ord(key)=8 ) or //BackSpace pressed
    ( Ord(key)=13 )//Enter pressed
  then Exit;
if (focused)and(visible) then
begin
 Text:=FText+Key;
 inherited KeyPress(Key);
 end;
end;

procedure TDXWEdit.KeyUp(var Key: Word; Shift: TShiftState);
begin
  inherited;
end;

procedure TDXWEdit.SetText(const Value: String);
begin
  if FText=Value then Exit;

  FText := Value;
  Change;
end;

{ TDXWLabel }

constructor TDXWLabel.Create(AOwner:TObject);
begin
  inherited Create(AOwner);
  FAutoSize:=true;
end;

procedure TDXWLabel.DoDraw;
begin
if Not FVisible then Exit;

with FSurface.Canvas do
begin
 Brush.Style := bsClear;
 Font.Assign(Self.Font);
 if FAutoSize
  then TextOut(FLeft,FTop,FText)
   else TextRect(BoundsRect,0,0,FText);
 Release;
end;

end;

procedure TDXWLabel.SetSurface(Value: TDirectDrawSurface);
begin
 FSurface := Value;
end;


{ TDXWPanel }

function TDXWPanel.GetDrawImageIndex: Integer;
begin
 Result :=0;
end;

procedure TDXWObject.SetHeight(const Value: Integer);
begin
  FHeight := Value;
  SetBounds;
end;

procedure TDXWObject.SetLeft(const Value: Integer);
begin
  FLeft := Value;
  SetBounds;
end;

procedure TDXWObject.SetTop(const Value: Integer);
begin
  FTop := Value;
  SetBounds;
end;

procedure TDXWObject.SetWidth(const Value: Integer);
begin
  FWidth := Value;
  SetBounds;
end;

procedure TDXWObject.SetBoundsRect(const Value: TRect);
begin
 FLeft:=Value.Left;
 FTop:=Value.Top;
 FWidth:=Value.Right-Value.Left;
 FHeight:=Value.Bottom-Value.Top;
 SetBounds;
end;

procedure TDXWObject.SetBounds;
begin
 FBoundsRect:=Bounds(FLeft,FTop,FWidth,FHeight);
end;

procedure TDXWImageObject.SetImage(const Value: TPictureCollectionItem);
begin
  FImage := Value;
  Width:=Value.Width;
  Height:=Value.Height;
end;

end.
