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