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