------------------------------------------------------------------------------
--                                                                          --
--                An Ada2005 binding to the Qt C++ framework                --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2008, 2009 Vadim Godunko <vgodunko@gmail.com>                --
--                                                                          --
-- QtAda is free software;  you can  redistribute it and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
-- sion. QtAda is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
-- for  more details.  You should have  received  a copy of the GNU General --
-- Public License distributed with QtAda;  see file COPYING.  If not, write --
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
-- Boston, MA 02110-1301, USA.                                              --
--                                                                          --
------------------------------------------------------------------------------
--  $Revision: 3196 $ $Date: 2009-03-21 19:19:23 +0300 (Sat, 21 Mar 2009) $
------------------------------------------------------------------------------
with Qt4.Graphics_Items.Directors;

with Edges.Impl;

package body Edges.Constructors is

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

   function Create (Source_Node : not null access Nodes.Node'Class;
                    Dest_Node   : not null access Nodes.Node'Class)
     return not null access Edge'Class
   is
      use type Qt4.Mouse_Buttons;

   begin
      return Result : constant not null access Edge'Class
        := new Edges.Impl.Edge_Impl
      do
         declare
            R : Edges.Impl.Edge_Impl'Class
              renames Edges.Impl.Edge_Impl'Class (Result.all);

         begin
            Qt4.Graphics_Items.Directors.Constructors.Initialize (R'Access);

            R.Arrow_Size := 10.0;
            Qt4.Graphics_Items.Set_Accepted_Mouse_Buttons
             (Result, +Qt4.No_Button);
            R.Source := Source_Node;
            R.Dest := Dest_Node;
            R.Source.all.Add_Edge (Result);
            R.Dest.all.Add_Edge (Result);
            Result.Adjust_1;
         end;
      end return;
   end Create;

end Edges.Constructors;
