1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2007 AdaCore                    -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- As a special exception, if other files instantiate generics from  -- 
  23. -- this unit, or you link this unit with other files to produce an   -- 
  24. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  25. -- executable to be covered by the GNU General Public License. This  -- 
  26. -- exception does not however invalidate any other reasons why the   -- 
  27. -- executable file  might be covered by the  GNU Public License.     -- 
  28. ----------------------------------------------------------------------- 
  29.  
  30. --  <description> 
  31. --  This widget provides a low level graphical representation of a range of 
  32. --  values. It is used by other widgets such as Gtk_Scale and Gtk_Scrollbar. 
  33. --  </description> 
  34. --  <c_version>2.8.17</c_version> 
  35. --  <testgtk>create_range.adb</testgtk> 
  36. --  <screenshot>gtk-range</screenshot> 
  37.  
  38. with Glib.Properties; 
  39. with Gtk.Adjustment; 
  40. with Gtk.Enums; use Gtk.Enums; 
  41. with Gtk.Widget; 
  42.  
  43. package Gtk.GRange is 
  44.  
  45.    type Gtk_Range_Record is new Gtk.Widget.Gtk_Widget_Record with private; 
  46.    type Gtk_Range is access all Gtk_Range_Record'Class; 
  47.    subtype Gtk_GRange is Gtk_Range; 
  48.  
  49.    function Get_Type return Gtk.Gtk_Type; 
  50.    --  Return the internal value associated with a Gtk_Range. 
  51.  
  52.    procedure Set_Update_Policy 
  53.      (The_Range : access Gtk_Range_Record; 
  54.       Policy    : Gtk_Update_Type); 
  55.    --  Set the update policy for the range. 
  56.    --  Update_Continuous means that anytime the range slider is moved, the 
  57.    --  range value will change and the value_changed signal will be emitted. 
  58.    --  Update_Delayed means that the value will be updated after a brief 
  59.    --  timeout where no slider motion occurs, so updates are spaced by a short 
  60.    --  time rather than continuous. 
  61.    --  Update_Discontinuous means that the value will only be updated when the 
  62.    --  user releases the button and ends the slider drag operation. 
  63.  
  64.    function Get_Update_Policy 
  65.      (The_Range : access Gtk_Range_Record) return Gtk_Update_Type; 
  66.    --  Return the current update policy. 
  67.  
  68.    procedure Set_Adjustment 
  69.      (The_Range  : access Gtk_Range_Record; 
  70.       Adjustment : Gtk.Adjustment.Gtk_Adjustment); 
  71.    --  Set the adjustment to be used as the "model" object for this range 
  72.    --  widget. The adjustment indicates the current range value, the 
  73.    --  minimum and maximum range values, the step/page increments used 
  74.    --  for keybindings and scrolling, and the page size. The page size 
  75.    --  is normally 0 for Gtk_Scale and nonzero for Gtk_Scrollbar, and 
  76.    --  indicates the size of the visible area of the widget being scrolled. 
  77.    --  The page size affects the size of the scrollbar slider. 
  78.  
  79.    function Get_Adjustment 
  80.      (The_Range : access Gtk_Range_Record) 
  81.       return Gtk.Adjustment.Gtk_Adjustment; 
  82.    --  Return the adjustment associated with the range widget. 
  83.  
  84.    procedure Set_Inverted 
  85.      (The_Range : access Gtk_Range_Record; 
  86.       Setting   : Boolean := True); 
  87.    --  Ranges normally move from lower to higher values as the slider moves 
  88.    --  from top to bottom or left to right. Inverted ranges have higher values 
  89.    --  at the top or on the right rather than on the bottom or left. 
  90.  
  91.    function Get_Inverted (The_Range : access Gtk_Range_Record) return Boolean; 
  92.    --  Return whether the range is inverted. 
  93.  
  94.    procedure Set_Increments 
  95.      (The_Range : access Gtk_Range_Record; 
  96.       Step      : Gdouble; 
  97.       Page      : Gdouble); 
  98.    --  Set the Step and the Page size for the range. The Step size is used when 
  99.    --  the user clicks on the Gtk_Scrollbar arrows or moves the Gtk_Scale via 
  100.    --  the arrow keys. The Page size is used when moving by pages via the 
  101.    --  Page-Up and Page-Down keys for instance. 
  102.  
  103.    procedure Set_Range 
  104.      (The_Range : access Gtk_Range_Record; 
  105.       Min       : Gdouble; 
  106.       Max       : Gdouble); 
  107.    --  Set the allowable values in the Gtk_Range, and clamps the range value to 
  108.    --  the between Min and Max. 
  109.  
  110.    procedure Set_Value 
  111.      (The_Range : access Gtk_Range_Record; 
  112.       Value     : Gdouble); 
  113.    --  Set the current value of the given Range. If the value is outside the 
  114.    --  minimum or the maximum value range, it will be clamped to fit inside 
  115.    --  the range. 
  116.    --  Cause the "value_changed" signal to be emitted if the value is 
  117.    --  different. 
  118.  
  119.    function Get_Value (The_Range : access Gtk_Range_Record) return Gdouble; 
  120.    --  Return the current value of the range. 
  121.  
  122.    ---------------- 
  123.    -- Properties -- 
  124.    ---------------- 
  125.    --  The following properties are defined for this widget. See 
  126.    --  Glib.Properties for more information on properties. 
  127.  
  128.    --  <properties> 
  129.    --  Name:  Update_Policy_Property 
  130.    --  Type:  Gtk_Update_Type 
  131.    --  Flags: read-write 
  132.    --  Descr: How the range should be updated on the screen 
  133.    --  See also: Set_Update_Policy 
  134.    -- 
  135.    --  Name:  Adjustment_Property 
  136.    --  Type:  Object 
  137.    --  Descr: The GtkAdjustment that contains the current value of this range 
  138.    --         object 
  139.    -- 
  140.    --  Name:  Inverted_Property 
  141.    --  Type:  Boolean 
  142.    --  Descr: Invert direction slider moves to increase range value 
  143.    --  </properties> 
  144.  
  145.    Update_Policy_Property : constant Gtk.Enums.Property_Gtk_Update_Type; 
  146.    Adjustment_Property    : constant Glib.Properties.Property_Object; 
  147.    Inverted_Property      : constant Glib.Properties.Property_Boolean; 
  148.  
  149.    ---------------------- 
  150.    -- Style Properties -- 
  151.    ---------------------- 
  152.    --  The following properties can be changed through the gtk theme and 
  153.    --  configuration files, and retrieved through Gtk.Widget.Style_Get_Property 
  154.  
  155.    --  <style_properties> 
  156.    --  Name:  Arrow_Displacement_X_Property 
  157.    --  Type:  Int 
  158.    --  Descr: How far in the x direction to move the arrow when the button is 
  159.    --         depressed 
  160.    -- 
  161.    --  Name:  Arrow_Displacement_Y_Property 
  162.    --  Type:  Int 
  163.    --  Descr: How far in the y direction to move the arrow when the button is 
  164.    --         depressed 
  165.    -- 
  166.    --  Name:  Slider_Width_Property 
  167.    --  Type:  Int 
  168.    --  Descr: Width of scrollbar or scale thumb 
  169.    -- 
  170.    --  Name:  Stepper_Size_Property 
  171.    --  Type:  Int 
  172.    --  Descr: Length of step buttons at ends 
  173.    -- 
  174.    --  Name:  Stepper_Spacing_Property 
  175.    --  Type:  Int 
  176.    --  Descr: Spacing between step buttons and thumb 
  177.    -- 
  178.    --  Name:  Trough_Border_Property 
  179.    --  Type:  Int 
  180.    --  Descr: Spacing between thumb/steppers and outer trough bevel 
  181.    --  </style_properties> 
  182.  
  183.    Arrow_Displacement_X_Property : constant Glib.Properties.Property_Int; 
  184.    Arrow_Displacement_Y_Property : constant Glib.Properties.Property_Int; 
  185.    Slider_Width_Property         : constant Glib.Properties.Property_Int; 
  186.    Stepper_Size_Property         : constant Glib.Properties.Property_Int; 
  187.    Stepper_Spacing_Property      : constant Glib.Properties.Property_Int; 
  188.    Trough_Border_Property        : constant Glib.Properties.Property_Int; 
  189.  
  190.    ------------ 
  191.    -- Signal -- 
  192.    ------------ 
  193.  
  194.    --  <signals> 
  195.    --  The following new signals are defined for this widget: 
  196.    -- 
  197.    --  - "value_changed" 
  198.    --    procedure Handler (R :  access Gtk_Range_Record'Class); 
  199.    --    Emitted when the current value of the range has changed 
  200.    -- 
  201.    --  - "adjust_bounds" 
  202.    --    procedure Handler 
  203.    --       (R     : access Gtk_Range_Record'Class; 
  204.    --        Value : Gdouble); 
  205.    -- 
  206.    --  - "change_value" 
  207.    --    function Handler 
  208.    --       (R     : access Gtk_Range_Record'Class; 
  209.    --        Typ   : Gtk_Scroll_Type; 
  210.    --        Value : Gdouble) return Gboolean; 
  211.    --    Emitted when a scroll action is performed on the range. The type of 
  212.    --    event that occurred and the new value are returned. The application 
  213.    --    should return True if it has handled the event itself. 
  214.    -- 
  215.    --  - "move_slider" 
  216.    --    procedure Handler (R : access Gtk_Range_Record'Class); 
  217.    --    Emitted when the slider has changed 
  218.    -- 
  219.    --  </signals> 
  220.  
  221.    Signal_Adjust_Bounds : constant Glib.Signal_Name := "adjust_bounds"; 
  222.    Signal_Change_Value  : constant Glib.Signal_Name := "change_value"; 
  223.    Signal_Move_Slider   : constant Glib.Signal_Name := "move_slider"; 
  224.    Signal_Value_Changed : constant Glib.Signal_Name := "value_changed"; 
  225.  
  226. private 
  227.    type Gtk_Range_Record is new Gtk.Widget.Gtk_Widget_Record with null record; 
  228.  
  229.    Update_Policy_Property : constant Gtk.Enums.Property_Gtk_Update_Type := 
  230.      Gtk.Enums.Build ("update_policy"); 
  231.  
  232.    Adjustment_Property : constant Glib.Properties.Property_Object := 
  233.      Glib.Properties.Build ("adjustment"); 
  234.    Inverted_Property : constant Glib.Properties.Property_Boolean := 
  235.      Glib.Properties.Build ("inverted"); 
  236.  
  237.    Arrow_Displacement_X_Property : constant Glib.Properties.Property_Int := 
  238.      Glib.Properties.Build ("arrow-displacement-x"); 
  239.    Arrow_Displacement_Y_Property : constant Glib.Properties.Property_Int := 
  240.      Glib.Properties.Build ("arrow-displacement-y"); 
  241.    Slider_Width_Property : constant Glib.Properties.Property_Int := 
  242.      Glib.Properties.Build ("slider-width"); 
  243.    Stepper_Size_Property : constant Glib.Properties.Property_Int := 
  244.      Glib.Properties.Build ("stepper-size"); 
  245.    Stepper_Spacing_Property : constant Glib.Properties.Property_Int := 
  246.      Glib.Properties.Build ("stepper-spacing"); 
  247.    Trough_Border_Property : constant Glib.Properties.Property_Int := 
  248.      Glib.Properties.Build ("trough-border"); 
  249.  
  250.    pragma Import (C, Get_Type, "gtk_range_get_type"); 
  251. end Gtk.GRange;