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