with Ada.Unchecked_Conversion;
package body Mcc.Gui.Widget.Button.Picture is

   ------------
   -- Create --
   ------------

   procedure Create
     (Obj    : in out Picture_Button;
      Parent : in     Mcc.Gui.Container.Container'Class;
      X      : in     Integer;
      Y      : in     Integer;
      Width  : in     Natural;
      Height : in     Natural;
      Image  : in     Mcc.Gui.Image.Image'Class)
   is
      type Parent_Access is access constant Mcc.Gui.Container.Container'Class;
      function Convert is new Ada.Unchecked_Conversion(
         Parent_Access,Mcc.Gui.Container.Container_Pointer);
   begin
      Obj.My_Peer := Peer.Create_Peer(Mcc.Gui.Container.Get_Peer(Parent));
      Peer.Eval("button " & Obj.My_Peer.Name.all &
         " -image " & Mcc.Gui.Image.Get_Peer(Image).Name.all);
      Peer.Eval("place " & Obj.My_Peer.Name.all & 
         " -anchor nw" &
         " -x " & Integer'Image(X) &
         " -y " & Integer'Image(Y) &
         " -width" & Integer'Image(Width) &
         " -height" & Integer'Image(Height));
      Obj.Parent := Convert(Parent'Unchecked_Access);
   end Create;

   ---------------
   -- Set_Image --
   ---------------

   procedure Set_Image
     (Obj   : in out Picture_Button;
      Image : in     Mcc.Gui.Image.Image'Class)
   is
   begin
      Peer.Eval(Obj.My_Peer.Name.all & " configure -image " &
         Mcc.Gui.Image.Get_Peer(Image).Name.all);
   end Set_Image;

end Mcc.Gui.Widget.Button.Picture;