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