1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  The Gtk.Adjustment.Gtk_Adjustment object represents a value which has an 
  26. --  associated lower and upper bound, together with step and page increments, 
  27. --  and a page size. It is used within several GTK+ widgets, including 
  28. --  Gtk.Spin_Button.Gtk_Spin_Button, Gtk.Viewport.Gtk_Viewport, and 
  29. --  Gtk.GRange.Gtk_Range (which is a base class for 
  30. --  Gtk.Scrollbar.Gtk_Hscrollbar, Gtk.Scrollbar.Gtk_Vscrollbar, 
  31. --  Gtk.Scale.Gtk_Hscale, and Gtk.Scale.Gtk_Vscale). 
  32. -- 
  33. --  The Gtk.Adjustment.Gtk_Adjustment object does not update the value itself. 
  34. --  Instead it is left up to the owner of the Gtk.Adjustment.Gtk_Adjustment to 
  35. --  control the value. 
  36. -- 
  37. --  The owner of the Gtk.Adjustment.Gtk_Adjustment typically calls the 
  38. --  Gtk.Adjustment.Value_Changed and Gtk.Adjustment.Changed functions after 
  39. --  changing the value and its bounds. This results in the emission of the 
  40. --  Gtk.Adjustment.Gtk_Adjustment::value_changed or 
  41. --  Gtk.Adjustment.Gtk_Adjustment::changed signal respectively. 
  42. -- 
  43. --  </description> 
  44. --  <description> 
  45. --  The meaning of the most important fields can be explained on the following 
  46. --  figure (imagine this is a scrollbar): 
  47. -- 
  48. --  [-------|=================|-------------------] 
  49. -- 
  50. --  lower value value + page_size upper 
  51. -- 
  52. --  </description> 
  53. --  <group>Scrolling</group> 
  54. pragma Ada_2005; 
  55.  
  56. pragma Warnings (Off, "*is already use-visible*"); 
  57. with Glib;            use Glib; 
  58. with Glib.Object;     use Glib.Object; 
  59. with Glib.Properties; use Glib.Properties; 
  60.  
  61. package Gtk.Adjustment is 
  62.  
  63.    type Gtk_Adjustment_Record is new GObject_Record with null record; 
  64.    type Gtk_Adjustment is access all Gtk_Adjustment_Record'Class; 
  65.  
  66.    ------------------ 
  67.    -- Constructors -- 
  68.    ------------------ 
  69.  
  70.    procedure Gtk_New 
  71.       (Adjustment     : out Gtk_Adjustment; 
  72.        Value          : Gdouble; 
  73.        Lower          : Gdouble; 
  74.        Upper          : Gdouble; 
  75.        Step_Increment : Gdouble; 
  76.        Page_Increment : Gdouble; 
  77.        Page_Size      : Gdouble := 0.0); 
  78.    procedure Initialize 
  79.       (Adjustment     : not null access Gtk_Adjustment_Record'Class; 
  80.        Value          : Gdouble; 
  81.        Lower          : Gdouble; 
  82.        Upper          : Gdouble; 
  83.        Step_Increment : Gdouble; 
  84.        Page_Increment : Gdouble; 
  85.        Page_Size      : Gdouble := 0.0); 
  86.    --  Create a new adjustment. Value is the initial value of the adjustment. 
  87.    --  It must be in the range (Lower .. Upper) and the adjustment's value will 
  88.    --  never be outside this range. Step_Increment is the value used to make 
  89.    --  minor adjustments, such as when the user clicks on the arrows of a 
  90.    --  scrollbar. Page_Increment is used to make major adjustments, such as 
  91.    --  when the user clicks in the through on a scrollbar. Page_Size is 
  92.    --  deprecated, use the default value. 
  93.    --  "value": the initial value. 
  94.    --  "lower": the minimum value. 
  95.    --  "upper": the maximum value. 
  96.    --  "step_increment": the step increment. 
  97.    --  "page_increment": the page increment. 
  98.    --  "page_size": the page size. 
  99.  
  100.    function Gtk_Adjustment_New 
  101.       (Value          : Gdouble; 
  102.        Lower          : Gdouble; 
  103.        Upper          : Gdouble; 
  104.        Step_Increment : Gdouble; 
  105.        Page_Increment : Gdouble; 
  106.        Page_Size      : Gdouble := 0.0) return Gtk_Adjustment; 
  107.    --  Create a new adjustment. Value is the initial value of the adjustment. 
  108.    --  It must be in the range (Lower .. Upper) and the adjustment's value will 
  109.    --  never be outside this range. Step_Increment is the value used to make 
  110.    --  minor adjustments, such as when the user clicks on the arrows of a 
  111.    --  scrollbar. Page_Increment is used to make major adjustments, such as 
  112.    --  when the user clicks in the through on a scrollbar. Page_Size is 
  113.    --  deprecated, use the default value. 
  114.    --  "value": the initial value. 
  115.    --  "lower": the minimum value. 
  116.    --  "upper": the maximum value. 
  117.    --  "step_increment": the step increment. 
  118.    --  "page_increment": the page increment. 
  119.    --  "page_size": the page size. 
  120.  
  121.    function Get_Type return Glib.GType; 
  122.    pragma Import (C, Get_Type, "gtk_adjustment_get_type"); 
  123.  
  124.    ------------- 
  125.    -- Methods -- 
  126.    ------------- 
  127.  
  128.    procedure Changed (Adjustment : not null access Gtk_Adjustment_Record); 
  129.    --  Emits a Gtk.Adjustment.Gtk_Adjustment::changed signal from the 
  130.    --  Gtk.Adjustment.Gtk_Adjustment. This is typically called by the owner of 
  131.    --  the Gtk.Adjustment.Gtk_Adjustment after it has changed any of the 
  132.    --  Gtk.Adjustment.Gtk_Adjustment properties other than the value. 
  133.  
  134.    procedure Clamp_Page 
  135.       (Adjustment : not null access Gtk_Adjustment_Record; 
  136.        Lower      : Gdouble; 
  137.        Upper      : Gdouble); 
  138.    --  Update the Adjustment value to ensure that the range between Lower and 
  139.    --  Upper is in the current page (i.e. between value and value + page_size). 
  140.    --  If the range is larger than the page size, then only the start of it 
  141.    --  will be in the current page. A "value_changed" signal will be emitted if 
  142.    --  the value is changed. 
  143.    --  "lower": the lower value. 
  144.    --  "upper": the upper value. 
  145.  
  146.    procedure Configure 
  147.       (Adjustment     : not null access Gtk_Adjustment_Record; 
  148.        Value          : Gdouble; 
  149.        Lower          : Gdouble; 
  150.        Upper          : Gdouble; 
  151.        Step_Increment : Gdouble; 
  152.        Page_Increment : Gdouble; 
  153.        Page_Size      : Gdouble); 
  154.    --  Sets all properties of the adjustment at once. 
  155.    --  Use this function to avoid multiple emissions of the 
  156.    --  Gtk.Adjustment.Gtk_Adjustment::changed signal. See 
  157.    --  Gtk.Adjustment.Set_Lower for an alternative way of compressing multiple 
  158.    --  emissions of Gtk.Adjustment.Gtk_Adjustment::changed into one. 
  159.    --  Since: gtk+ 2.14 
  160.    --  "value": the new value 
  161.    --  "lower": the new minimum value 
  162.    --  "upper": the new maximum value 
  163.    --  "step_increment": the new step increment 
  164.    --  "page_increment": the new page increment 
  165.    --  "page_size": the new page size 
  166.  
  167.    function Get_Lower 
  168.       (Adjustment : not null access Gtk_Adjustment_Record) return Gdouble; 
  169.    --  Retrieves the minimum value of the adjustment. 
  170.    --  Since: gtk+ 2.14 
  171.  
  172.    procedure Set_Lower 
  173.       (Adjustment : not null access Gtk_Adjustment_Record; 
  174.        Lower      : Gdouble); 
  175.    --  Sets the minimum value of the adjustment. 
  176.    --  When setting multiple adjustment properties via their individual 
  177.    --  setters, multiple Gtk.Adjustment.Gtk_Adjustment::changed signals will be 
  178.    --  emitted. However, since the emission of the 
  179.    --  Gtk.Adjustment.Gtk_Adjustment::changed signal is tied to the emission of 
  180.    --  the Glib.Object.GObject::notify signals of the changed properties, it's 
  181.    --  possible to compress the Gtk.Adjustment.Gtk_Adjustment::changed signals 
  182.    --  into one by calling g_object_freeze_notify and g_object_thaw_notify 
  183.    --  around the calls to the individual setters. 
  184.    --  Alternatively, using a single g_object_set for all the properties to 
  185.    --  change, or using Gtk.Adjustment.Configure has the same effect of 
  186.    --  compressing Gtk.Adjustment.Gtk_Adjustment::changed emissions. 
  187.    --  Since: gtk+ 2.14 
  188.    --  "lower": the new minimum value 
  189.  
  190.    function Get_Minimum_Increment 
  191.       (Adjustment : not null access Gtk_Adjustment_Record) return Gdouble; 
  192.    --  Gets the smaller of step increment and page increment. 
  193.    --  Since: gtk+ 3.2 
  194.  
  195.    function Get_Page_Increment 
  196.       (Adjustment : not null access Gtk_Adjustment_Record) return Gdouble; 
  197.    --  Retrieves the page increment of the adjustment. 
  198.    --  Since: gtk+ 2.14 
  199.  
  200.    procedure Set_Page_Increment 
  201.       (Adjustment     : not null access Gtk_Adjustment_Record; 
  202.        Page_Increment : Gdouble); 
  203.    --  Sets the page increment of the adjustment. 
  204.    --  See Gtk.Adjustment.Set_Lower about how to compress multiple emissions 
  205.    --  of the Gtk.Adjustment.Gtk_Adjustment::changed signal when setting 
  206.    --  multiple adjustment properties. 
  207.    --  Since: gtk+ 2.14 
  208.    --  "page_increment": the new page increment 
  209.  
  210.    function Get_Page_Size 
  211.       (Adjustment : not null access Gtk_Adjustment_Record) return Gdouble; 
  212.    --  Retrieves the page size of the adjustment. 
  213.    --  Since: gtk+ 2.14 
  214.  
  215.    procedure Set_Page_Size 
  216.       (Adjustment : not null access Gtk_Adjustment_Record; 
  217.        Page_Size  : Gdouble); 
  218.    --  Sets the page size of the adjustment. 
  219.    --  See Gtk.Adjustment.Set_Lower about how to compress multiple emissions 
  220.    --  of the GtkAdjustment::changed signal when setting multiple adjustment 
  221.    --  properties. 
  222.    --  Since: gtk+ 2.14 
  223.    --  "page_size": the new page size 
  224.  
  225.    function Get_Step_Increment 
  226.       (Adjustment : not null access Gtk_Adjustment_Record) return Gdouble; 
  227.    --  Retrieves the step increment of the adjustment. 
  228.    --  Since: gtk+ 2.14 
  229.  
  230.    procedure Set_Step_Increment 
  231.       (Adjustment     : not null access Gtk_Adjustment_Record; 
  232.        Step_Increment : Gdouble); 
  233.    --  Sets the step increment of the adjustment. 
  234.    --  See Gtk.Adjustment.Set_Lower about how to compress multiple emissions 
  235.    --  of the Gtk.Adjustment.Gtk_Adjustment::changed signal when setting 
  236.    --  multiple adjustment properties. 
  237.    --  Since: gtk+ 2.14 
  238.    --  "step_increment": the new step increment 
  239.  
  240.    function Get_Upper 
  241.       (Adjustment : not null access Gtk_Adjustment_Record) return Gdouble; 
  242.    --  Retrieves the maximum value of the adjustment. 
  243.    --  Since: gtk+ 2.14 
  244.  
  245.    procedure Set_Upper 
  246.       (Adjustment : not null access Gtk_Adjustment_Record; 
  247.        Upper      : Gdouble); 
  248.    --  Sets the maximum value of the adjustment. 
  249.    --  Note that values will be restricted by 'upper - page-size' if the 
  250.    --  page-size property is nonzero. 
  251.    --  See Gtk.Adjustment.Set_Lower about how to compress multiple emissions 
  252.    --  of the Gtk.Adjustment.Gtk_Adjustment::changed signal when setting 
  253.    --  multiple adjustment properties. 
  254.    --  Since: gtk+ 2.14 
  255.    --  "upper": the new maximum value 
  256.  
  257.    function Get_Value 
  258.       (Adjustment : not null access Gtk_Adjustment_Record) return Gdouble; 
  259.    --  Gets the current value of the adjustment. See gtk_adjustment_set_value 
  260.    --  (). 
  261.  
  262.    procedure Set_Value 
  263.       (Adjustment : not null access Gtk_Adjustment_Record; 
  264.        Value      : Gdouble); 
  265.    --  Sets the Gtk.Adjustment.Gtk_Adjustment value. The value is clamped to 
  266.    --  lie between Gtk.Adjustment.Gtk_Adjustment:lower and 
  267.    --  Gtk.Adjustment.Gtk_Adjustment:upper. 
  268.    --  Note that for adjustments which are used in a 
  269.    --  Gtk.Scrollbar.Gtk_Scrollbar, the effective range of allowed values goes 
  270.    --  from Gtk.Adjustment.Gtk_Adjustment:lower to 
  271.    --  Gtk.Adjustment.Gtk_Adjustment:upper - 
  272.    --  Gtk.Adjustment.Gtk_Adjustment:page_size. 
  273.    --  "value": the new value. 
  274.  
  275.    procedure Value_Changed 
  276.       (Adjustment : not null access Gtk_Adjustment_Record); 
  277.    --  Emits a Gtk.Adjustment.Gtk_Adjustment::value_changed signal from the 
  278.    --  Gtk.Adjustment.Gtk_Adjustment. This is typically called by the owner of 
  279.    --  the Gtk.Adjustment.Gtk_Adjustment after it has changed the 
  280.    --  Gtk.Adjustment.Gtk_Adjustment:value property. 
  281.  
  282.    ---------------- 
  283.    -- Properties -- 
  284.    ---------------- 
  285.    --  The following properties are defined for this widget. See 
  286.    --  Glib.Properties for more information on properties) 
  287.  
  288.    Lower_Property : constant Glib.Properties.Property_Double; 
  289.    --  Type: Gdouble 
  290.    --  The minimum value of the adjustment. 
  291.  
  292.    Page_Increment_Property : constant Glib.Properties.Property_Double; 
  293.    --  Type: Gdouble 
  294.    --  The page increment of the adjustment. 
  295.  
  296.    Page_Size_Property : constant Glib.Properties.Property_Double; 
  297.    --  Type: Gdouble 
  298.    --  The page size of the adjustment. Note that the page-size is irrelevant 
  299.    --  and should be set to zero if the adjustment is used for a simple scalar 
  300.    --  value, e.g. in a Gtk.Spin_Button.Gtk_Spin_Button. 
  301.  
  302.    Step_Increment_Property : constant Glib.Properties.Property_Double; 
  303.    --  Type: Gdouble 
  304.    --  The step increment of the adjustment. 
  305.  
  306.    Upper_Property : constant Glib.Properties.Property_Double; 
  307.    --  Type: Gdouble 
  308.    --  The maximum value of the adjustment. Note that values will be 
  309.    --  restricted by 'upper - page-size' if the page-size property is nonzero. 
  310.  
  311.    Value_Property : constant Glib.Properties.Property_Double; 
  312.    --  Type: Gdouble 
  313.    --  The value of the adjustment. 
  314.  
  315.    ------------- 
  316.    -- Signals -- 
  317.    ------------- 
  318.  
  319.    type Cb_Gtk_Adjustment_Void is not null access procedure (Self : access Gtk_Adjustment_Record'Class); 
  320.  
  321.    type Cb_GObject_Void is not null access procedure 
  322.      (Self : access Glib.Object.GObject_Record'Class); 
  323.  
  324.    Signal_Changed : constant Glib.Signal_Name := "changed"; 
  325.    procedure On_Changed 
  326.       (Self  : not null access Gtk_Adjustment_Record; 
  327.        Call  : Cb_Gtk_Adjustment_Void; 
  328.        After : Boolean := False); 
  329.    procedure On_Changed 
  330.       (Self  : not null access Gtk_Adjustment_Record; 
  331.        Call  : Cb_GObject_Void; 
  332.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  333.        After : Boolean := False); 
  334.    --  Emitted when one or more of the Gtk.Adjustment.Gtk_Adjustment 
  335.    --  properties have been changed, other than the 
  336.    --  Gtk.Adjustment.Gtk_Adjustment:value property. 
  337.  
  338.    Signal_Value_Changed : constant Glib.Signal_Name := "value-changed"; 
  339.    procedure On_Value_Changed 
  340.       (Self  : not null access Gtk_Adjustment_Record; 
  341.        Call  : Cb_Gtk_Adjustment_Void; 
  342.        After : Boolean := False); 
  343.    procedure On_Value_Changed 
  344.       (Self  : not null access Gtk_Adjustment_Record; 
  345.        Call  : Cb_GObject_Void; 
  346.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  347.        After : Boolean := False); 
  348.    --  Emitted when the Gtk.Adjustment.Gtk_Adjustment:value property has been 
  349.    --  changed. 
  350.  
  351. private 
  352.    Value_Property : constant Glib.Properties.Property_Double := 
  353.      Glib.Properties.Build ("value"); 
  354.    Upper_Property : constant Glib.Properties.Property_Double := 
  355.      Glib.Properties.Build ("upper"); 
  356.    Step_Increment_Property : constant Glib.Properties.Property_Double := 
  357.      Glib.Properties.Build ("step-increment"); 
  358.    Page_Size_Property : constant Glib.Properties.Property_Double := 
  359.      Glib.Properties.Build ("page-size"); 
  360.    Page_Increment_Property : constant Glib.Properties.Property_Double := 
  361.      Glib.Properties.Build ("page-increment"); 
  362.    Lower_Property : constant Glib.Properties.Property_Double := 
  363.      Glib.Properties.Build ("lower"); 
  364. end Gtk.Adjustment;