------------------------------------------------------------------------------
--                                                                          --
--                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: 3266 $ $Date: 2009-04-18 13:27:41 +0400 (Sat, 18 Apr 2009) $
------------------------------------------------------------------------------
with Qt4.V_Box_Layouts.Constructors;
with Qt4.LCD_Numbers.Constructors;
with Qt4.Objects;
with Qt4.Sliders.Constructors;

with LCD_Ranges.MOC;
pragma Warnings (Off, LCD_Ranges.MOC);
--  Child package MOC must be included in the application.

package body LCD_Ranges is

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

   function Create return not null LCD_Ranges.LCD_Range_Access is
      Self   : constant not null LCD_Ranges.LCD_Range_Access
        := new LCD_Ranges.LCD_Range;
      LCD    : constant not null Qt4.LCD_Numbers.Q_LCD_Number_Access
        := Qt4.LCD_Numbers.Constructors.Create (2);
      Slider : constant not null Qt4.Sliders.Q_Slider_Access
        := Qt4.Sliders.Constructors.Create (Qt4.Horizontal);
      Layout : constant not null Qt4.V_Box_Layouts.Q_V_Box_Layout_Access
        := Qt4.V_Box_Layouts.Constructors.Create;

   begin
      Qt4.Widgets.Directors.Constructors.Initialize (Self);

      LCD.Set_Segment_Style (Qt4.LCD_Numbers.Filled);

      Qt4.Objects.Connect
       (Slider,
        Qt4.Signal ("valueChanged(int)"),
        LCD,
        Qt4.Slot ("display(int)"));

      Slider.Set_Range (0, 32);
      Slider.Set_Value (16);

      Layout.Add_Widget (LCD);
      Layout.Add_Widget (Slider);
      Self.Set_Layout (Layout);

      return LCD_Range_Access (Self);
   end Create;

end LCD_Ranges;
