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-2009, 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. -- 
  27. --  This object represents an adjustable bounded value. 
  28. --  It is used in many other widgets that have such internal values, 
  29. --  like Gtk_Scrollbar, Gtk_Spin_Button, Gtk_Range, ... 
  30. --  Modifying the value of these widgets is done through their 
  31. --  associated adjustments. 
  32. -- 
  33. --  The modification of the value is left to the user, who should 
  34. --  call Value_Changed or Changed to emit the relevant signals. 
  35. -- 
  36. --  The meaning of the most important fields can be explained on the 
  37. --  following figure (imagine this is a scrollbar): 
  38. -- 
  39. --  <example> 
  40. --     [-------|=================|-------------------] 
  41. --    lower    value        value + page_size       upper 
  42. -- 
  43. --  </example> 
  44. --  </description> 
  45. --  <c_version>2.14</c_version> 
  46. --  <group>Scrolling</group> 
  47.  
  48. with Glib.Properties; 
  49. with Gtk.Object; 
  50.  
  51. package Gtk.Adjustment is 
  52.  
  53.    type Gtk_Adjustment_Record is new Object.Gtk_Object_Record with private; 
  54.    type Gtk_Adjustment is access all Gtk_Adjustment_Record'Class; 
  55.  
  56.    procedure Gtk_New 
  57.      (Adjustment     : out Gtk_Adjustment; 
  58.       Value          : Gdouble; 
  59.       Lower          : Gdouble; 
  60.       Upper          : Gdouble; 
  61.       Step_Increment : Gdouble; 
  62.       Page_Increment : Gdouble; 
  63.       Page_Size      : Gdouble := 0.0); 
  64.    --  Create a new adjustment. 
  65.    --  Value is the initial value of the adjustment. It must be in the 
  66.    --  range (Lower .. Upper) and the adjustment's value will never be 
  67.    --  outside this range. 
  68.    --  Step_Increment is the value used to make minor adjustments, such 
  69.    --  as when the user clicks on the arrows of a scrollbar. 
  70.    --  Page_Increment is used to make major adjustments, such as when 
  71.    --  the user clicks in the through on a scrollbar. 
  72.    --  Page_Size is deprecated, use the default value. 
  73.  
  74.    procedure Initialize 
  75.      (Adjustment     : access Gtk_Adjustment_Record'Class; 
  76.       Value          : Gdouble; 
  77.       Lower          : Gdouble; 
  78.       Upper          : Gdouble; 
  79.       Step_Increment : Gdouble; 
  80.       Page_Increment : Gdouble; 
  81.       Page_Size      : Gdouble); 
  82.    --  Internal initialization function. 
  83.    --  See the section "Creating your own widgets" in the documentation. 
  84.  
  85.    procedure Configure 
  86.      (Adjustment     : access Gtk_Adjustment_Record; 
  87.       Value          : Gdouble; 
  88.       Lower          : Gdouble; 
  89.       Upper          : Gdouble; 
  90.       Step_Increment : Gdouble; 
  91.       Page_Increment : Gdouble; 
  92.       Page_Size      : Gdouble); 
  93.    --  Sets all properties of the adjustment at once. 
  94.    --  Use this function to avoid multiple emissions of the "changed" 
  95.    --  signal. See Set_Lower for an alternative way 
  96.    --  of compressing multiple emissions of "changed" into one. 
  97.    --  Since: 2.14 
  98.  
  99.    function Get_Type return Gtk.Gtk_Type; 
  100.    --  Return the internal value associated with a Gtk_Adjustment. 
  101.  
  102.    procedure Set_Value 
  103.      (Adjustment : access Gtk_Adjustment_Record; Value : Gdouble); 
  104.    function Get_Value 
  105.      (Adjustment : access Gtk_Adjustment_Record) return Gdouble; 
  106.    --  Modify the current value of the adjustment. 
  107.    --  You do not need to call Value_Changed after modifying this value, 
  108.    --  this is done automatically. 
  109.  
  110.    procedure Set_Lower 
  111.      (Adjustment : access Gtk_Adjustment_Record; 
  112.       Lower      : Gdouble); 
  113.    function Get_Lower 
  114.      (Adjustment : access Gtk_Adjustment_Record) return Gdouble; 
  115.    --  Modify the lower bound of the adjustment. 
  116.    --  When setting multiple adjustment properties via their individual 
  117.    --  setters, multiple "changed" signals will be emitted. However, since 
  118.    --  the emission of the "changed" signal is tied to the emission of the 
  119.    --  "GObject::notify" signals of the changed properties, it's possible 
  120.    --  to compress the "changed" signals into one by calling 
  121.    --  Glib.Object.Freeze_Notify and Glib.Object.Thaw_Notify around the 
  122.    --  calls to the individual setters. 
  123.    --  Alternatively, using Configure has the same effect 
  124.    --  of compressing "changed" emissions. 
  125.  
  126.    procedure Set_Upper 
  127.      (Adjustment : access Gtk_Adjustment_Record; 
  128.       Upper      : Gdouble); 
  129.    function Get_Upper 
  130.      (Adjustment : access Gtk_Adjustment_Record) return Gdouble; 
  131.    --  Modify the upper bound of the adjustment. 
  132.    --  You should call Changed after modifying this value. 
  133.  
  134.    procedure Set_Step_Increment 
  135.      (Adjustment     : access Gtk_Adjustment_Record; 
  136.       Step_Increment : Gdouble); 
  137.    function Get_Step_Increment 
  138.      (Adjustment : access Gtk_Adjustment_Record) return Gdouble; 
  139.    --  Modify the step increment of the adjustment. 
  140.    --  You should call Changed after modifying this value. 
  141.  
  142.    procedure Set_Page_Increment 
  143.      (Adjustment     : access Gtk_Adjustment_Record; 
  144.       Page_Increment : Gdouble); 
  145.    function Get_Page_Increment 
  146.      (Adjustment : access Gtk_Adjustment_Record) return Gdouble; 
  147.    --  Modify the page increment of the adjustment. 
  148.    --  You should call Changed after modifying this value. 
  149.  
  150.    procedure Set_Page_Size 
  151.      (Adjustment : access Gtk_Adjustment_Record; 
  152.       Page_Size  : Gdouble); 
  153.    function Get_Page_Size 
  154.      (Adjustment : access Gtk_Adjustment_Record) return Gdouble; 
  155.    --  Modify the page size of the adjustment. 
  156.    --  You should call Changed after modifying this value. 
  157.  
  158.    -------------------- 
  159.    -- Misc functions -- 
  160.    -------------------- 
  161.  
  162.    procedure Clamp_Page 
  163.      (Adjustment : access Gtk_Adjustment_Record; 
  164.       Lower      : Gdouble; 
  165.       Upper      : Gdouble); 
  166.    --  Update the Adjustment value to ensure that the range between Lower and 
  167.    --  Upper is in the current page (i.e. between value and value + 
  168.    --  page_size). If the range is larger than the page size, then only the 
  169.    --  start of it will be in the current page. 
  170.    --  A "value_changed" signal will be emitted if the value is changed. 
  171.  
  172.    ---------------------- 
  173.    -- Signals emission -- 
  174.    ---------------------- 
  175.  
  176.    procedure Changed (Adjustment : access Gtk_Adjustment_Record); 
  177.    --  Emit the "changed" signal on Adjustment. 
  178.    --  This warns any listener that some field other than the value has been 
  179.    --  changed. 
  180.  
  181.    procedure Value_Changed (Adjustment : access Gtk_Adjustment_Record); 
  182.    --  Emit the "value_changed" signal on Adjustment. 
  183.    --  This warns any listener that the value has been changed. 
  184.  
  185.    ---------------- 
  186.    -- Properties -- 
  187.    ---------------- 
  188.  
  189.    --  <properties> 
  190.    --  The following properties are defined for this widget. See 
  191.    --  Glib.Properties for more information on properties. 
  192.    -- 
  193.    --  Name:  Lower_Property 
  194.    --  Type:  Double 
  195.    --  Descr: The minimum value of the adjustment 
  196.    -- 
  197.    --  Name:  Page_Increment_Property 
  198.    --  Type:  Double 
  199.    --  Descr: The page increment of the adjustment 
  200.    -- 
  201.    --  Name:  Page_Size_Property 
  202.    --  Type:  Double 
  203.    --  Descr: The page size of the adjustment 
  204.    -- 
  205.    --  Name:  Step_Increment_Property 
  206.    --  Type:  Double 
  207.    --  Descr: The step increment of the adjustment 
  208.    -- 
  209.    --  Name:  Upper_Property 
  210.    --  Type:  Double 
  211.    --  Descr: The maximum value of the adjustment 
  212.    -- 
  213.    --  Name:  Value_Property 
  214.    --  Type:  Double 
  215.    --  Descr: The value of the adjustment 
  216.    -- 
  217.    --  </properties> 
  218.  
  219.    Lower_Property          : constant Glib.Properties.Property_Double; 
  220.    Page_Increment_Property : constant Glib.Properties.Property_Double; 
  221.    Page_Size_Property      : constant Glib.Properties.Property_Double; 
  222.    Step_Increment_Property : constant Glib.Properties.Property_Double; 
  223.    Upper_Property          : constant Glib.Properties.Property_Double; 
  224.    Value_Property          : constant Glib.Properties.Property_Double; 
  225.  
  226.    ------------- 
  227.    -- Signals -- 
  228.    ------------- 
  229.  
  230.    --  <signals> 
  231.    --  The following new signals are defined for this widget: 
  232.    -- 
  233.    --  - "changed" 
  234.    --    procedure Handler (Adjustment : access Gtk_Adjustment_Record'Class); 
  235.    -- 
  236.    --    This signal is emitted every time one of the parameters is modified, 
  237.    --    except the value. 
  238.    -- 
  239.    --  - "value_changed" 
  240.    --    procedure Handler (Adjustment : access Gtk_Adjustment_Record'Class); 
  241.    -- 
  242.    --    This signal is emitted every time the value of the adjustment is 
  243.    --    modified 
  244.    --  </signals> 
  245.  
  246.    Signal_Changed       : constant Glib.Signal_Name := "changed"; 
  247.    Signal_Value_Changed : constant Glib.Signal_Name := "value_changed"; 
  248.  
  249. private 
  250.    type Gtk_Adjustment_Record is new Object.Gtk_Object_Record with null record; 
  251.  
  252.    Lower_Property : constant Glib.Properties.Property_Double := 
  253.      Glib.Properties.Build ("lower"); 
  254.    Page_Increment_Property : constant Glib.Properties.Property_Double := 
  255.      Glib.Properties.Build ("page-increment"); 
  256.    Page_Size_Property : constant Glib.Properties.Property_Double := 
  257.      Glib.Properties.Build ("page-size"); 
  258.    Step_Increment_Property : constant Glib.Properties.Property_Double := 
  259.      Glib.Properties.Build ("step-increment"); 
  260.    Upper_Property : constant Glib.Properties.Property_Double := 
  261.      Glib.Properties.Build ("upper"); 
  262.    Value_Property : constant Glib.Properties.Property_Double := 
  263.      Glib.Properties.Build ("value"); 
  264.  
  265.    pragma Import (C, Get_Type, "gtk_adjustment_get_type"); 
  266. end Gtk.Adjustment;