------------------------------------------------------------------------------
--                                                                          --
--                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: 3244 $ $Date: 2009-04-15 12:30:41 +0400 (Wed, 15 Apr 2009) $
------------------------------------------------------------------------------
with Ada.Containers.Vectors;

with Qt4.Point_Fs;
with Qt4.Rect_Fs;
with Qt4.Graphics_Items.Directors;
with Qt4.Graphics_Scene_Mouse_Events;
with Qt4.Painters;
with Qt4.Painter_Paths;
with Qt4.Style_Option_Graphics_Items;
with Qt4.Variants;
with Qt4.Widgets;

with Edges;
with Graph_Widgets;

package Nodes.Impl is

   type Edge_Access is access all Edges.Edge'Class;

   package Edge_List_Package is
     new Ada.Containers.Vectors (Positive, Edge_Access);

   type Node_Impl is new Qt4.Graphics_Items.Directors.Q_Graphics_Item_Director
     and Node with
   record
      Edge_List : Edge_List_Package.Vector;
      New_Pos   : Qt4.Point_Fs.Q_Point_F;
      Graph     : access Graph_Widgets.Graph_Widget'Class;
   end record;

   overriding
   procedure Add_Edge (Self : not null access Node_Impl;
                       Edge : not null access Edges.Edge'Class);

   overriding
   procedure Calculate_Forces (Self : not null access Node_Impl);

   overriding
   function Advance (Self : not null access Node_Impl) return Boolean;

   overriding
   function Bounding_Rect (Self : not null access constant Node_Impl)
     return Qt4.Rect_Fs.Q_Rect_F;

   overriding
   function Shape (Self : not null access constant Node_Impl)
     return Qt4.Painter_Paths.Q_Painter_Path;

   overriding
   procedure Paint
    (Self    : not null access Node_Impl;
     Painter : in out Qt4.Painters.Q_Painter'Class;
     Option  :
       Qt4.Style_Option_Graphics_Items.Q_Style_Option_Graphics_Item'Class;
     Widget  : access Qt4.Widgets.Q_Widget'Class := null);

   overriding
   function Item_Type (Self : not null access Node_Impl)
     return Qt4.Graphics_Items.Graphics_Item_Type;

   overriding
   procedure Mouse_Press_Event
    (Self : not null access Node_Impl;
     Event : not null access
       Qt4.Graphics_Scene_Mouse_Events.Q_Graphics_Scene_Mouse_Event'Class);

   overriding
   procedure Mouse_Release_Event
    (Self : not null access Node_Impl;
     Event : not null access
       Qt4.Graphics_Scene_Mouse_Events.Q_Graphics_Scene_Mouse_Event'Class);

   overriding
   function Item_Change
    (Self   : not null access Node_Impl;
     Change : Qt4.Graphics_Items.Graphics_Item_Graphics_Item_Change;
     Value  : Qt4.Variants.Q_Variant)
       return Qt4.Variants.Q_Variant;

end Nodes.Impl;
