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-2007 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. --  The Gtk_Curve widget allows the user to edit a curve covering a range of 
  27. --  values. It is typically used to fine-tune color balances in graphics 
  28. --  applications like the Gimp. 
  29. -- 
  30. --  The Gtk_Curve widget has 3 modes of operation: spline, linear and free. 
  31. --  In spline mode the user places points on the curve which are automatically 
  32. --  connected together into a smooth curve. In linear mode the user places 
  33. --  points on the curve which are connected by straight lines. In free mode the 
  34. --  user can draw the points of the curve freely, and they are not connected at 
  35. --  all. 
  36. --  </description> 
  37. --  <c_version>2.8.17</c_version> 
  38. --  <group>Drawing</group> 
  39.  
  40. with Gtk.Drawing_Area; 
  41. with Gtk.Enums; use Gtk.Enums; 
  42. with Glib.Generic_Properties; use Glib.Generic_Properties; 
  43. pragma Elaborate_All (Glib.Generic_Properties); 
  44. with Glib.Properties; 
  45.  
  46. package Gtk.Curve is 
  47.  
  48.    type Gtk_Curve_Record is new 
  49.      Gtk.Drawing_Area.Gtk_Drawing_Area_Record with private; 
  50.    type Gtk_Curve is access all Gtk_Curve_Record'Class; 
  51.  
  52.    procedure Gtk_New (Curve : out Gtk_Curve); 
  53.    --  Create a new Curve. 
  54.  
  55.    procedure Initialize (Curve : access Gtk_Curve_Record'Class); 
  56.    --  Internal initialization function. 
  57.    --  See the section "Creating your own widgets" in the documentation. 
  58.  
  59.    function Get_Type return Gtk.Gtk_Type; 
  60.    --  Return the internal value associated with a Gtk_Curve. 
  61.  
  62.    procedure Reset (Curve : access Gtk_Curve_Record); 
  63.    --  Reset the curve. 
  64.    --  Reset to a straight line from the minimum x & y values to the maximum 
  65.    --  x & y values (i.e. from the bottom-left to the top-right corners). 
  66.    --  The curve type is not changed. 
  67.  
  68.    procedure Set_Gamma (Curve : access Gtk_Curve_Record; Gamma : Gfloat); 
  69.    --  Recompute the entire curve using the given gamma value. 
  70.    --  A gamma value of 1.0 results in a straight line. Values greater than 1.0 
  71.    --  result in a curve above the straight line. Values less than 1.0 result 
  72.    --  in a curve below the straight line. The curve type is changed to 
  73.    --  Curve_Type_Free. 
  74.  
  75.    procedure Set_Range 
  76.      (Curve : access Gtk_Curve_Record; 
  77.       Min_X : Gfloat; 
  78.       Max_X : Gfloat; 
  79.       Min_Y : Gfloat; 
  80.       Max_Y : Gfloat); 
  81.    --  Set the minimum and maximum x & y values of the curve. 
  82.    --  The curve is also reset with a call to Reset. 
  83.  
  84.    procedure Set_Vector 
  85.      (Curve  : access Gtk_Curve_Record; Vector : Gfloat_Array); 
  86.    procedure Get_Vector 
  87.      (Curve  : access Gtk_Curve_Record; Vector : out Gfloat_Array); 
  88.    --  Set the vector of points on the curve. 
  89.    --  The curve type is set to Curve_Type_Free. 
  90.  
  91.    procedure Set_Curve_Type 
  92.      (Curve      : access Gtk_Curve_Record; 
  93.       Curve_Type : Gtk_Curve_Type); 
  94.    --  Set the type of the curve. 
  95.    --  The curve will remain unchanged except when changing from a free curve 
  96.    --  to a linear or spline curve, in which case the curve will be changed as 
  97.    --  little as possible. 
  98.  
  99.    ---------------- 
  100.    -- Properties -- 
  101.    ---------------- 
  102.  
  103.    --  <properties> 
  104.    --  The following properties are defined for this widget. See 
  105.    --  Glib.Properties for more information on properties. 
  106.    -- 
  107.    --  - Name:  Curve_Type_Property 
  108.    --    Type:  Gtk_Curve_Type 
  109.    --    Flags: read-write 
  110.    --    Descr: Is this curve linear, spline interpolated, or free-form 
  111.    --    See also: Set_Curve_Type 
  112.    -- 
  113.    --  - Name:  Min_X_Property 
  114.    --    Type:  Gfloat 
  115.    --    Flags: read-write 
  116.    --    Descr: Minimum possible value for X 
  117.    --    See also: Set_Range 
  118.    -- 
  119.    --  - Name:  Min_Y_Property 
  120.    --    Type:  Gfloat 
  121.    --    Flags: read-write 
  122.    --    Descr: Minimum possible value for Y 
  123.    --    See also: Set_Range 
  124.    -- 
  125.    --  - Name:  Max_X_Property 
  126.    --    Type:  Gfloat 
  127.    --    Flags: read-write 
  128.    --    Descr: Maximum possible value for X 
  129.    --    See also: Set_Range 
  130.    -- 
  131.    --  - Name:  Max_Y_Property 
  132.    --    Type:  Gfloat 
  133.    --    Flags: read-write 
  134.    --    Descr: Maximum possible value for Y 
  135.    --    See also: Set_Range 
  136.    -- 
  137.    --  </properties> 
  138.  
  139.    package Curve_Type_Properties is new Generic_Internal_Discrete_Property 
  140.      (Gtk_Curve_Type); 
  141.    type Property_Gtk_Curve_Type   is new Curve_Type_Properties.Property; 
  142.  
  143.    Curve_Type_Property : constant Property_Gtk_Curve_Type; 
  144.    Min_X_Property      : constant Glib.Properties.Property_Float; 
  145.    Max_X_Property      : constant Glib.Properties.Property_Float; 
  146.    Min_Y_Property      : constant Glib.Properties.Property_Float; 
  147.    Max_Y_Property      : constant Glib.Properties.Property_Float; 
  148.  
  149.    ------------- 
  150.    -- Signals -- 
  151.    ------------- 
  152.  
  153.    --  <signals> 
  154.    --  The following new signals are defined for this widget: 
  155.    --   - "curve-type-changed" 
  156.    --     procedure Handler (Curve : access Gtk_Curve_Record'Class); 
  157.    -- 
  158.    --  Emitted when the curve type has been changed. The curve type can be 
  159.    --  changed explicitly with a call to Set_Curve_Type. It is also changed as 
  160.    --  a side-effect of calling Reset or Set_Gamma. 
  161.    --  </signals> 
  162.  
  163.    Signal_Curve_Type_Changed : constant Glib.Signal_Name := 
  164.                                  "curve_type_changed"; 
  165.  
  166. private 
  167.    type Gtk_Curve_Record is new Gtk.Drawing_Area.Gtk_Drawing_Area_Record 
  168.      with null record; 
  169.  
  170.    Curve_Type_Property : constant Property_Gtk_Curve_Type := 
  171.      Build ("curve_type"); 
  172.    Min_X_Property      : constant Glib.Properties.Property_Float := 
  173.      Glib.Properties.Build ("min_x"); 
  174.    Max_X_Property      : constant Glib.Properties.Property_Float := 
  175.      Glib.Properties.Build ("max_x"); 
  176.    Min_Y_Property      : constant Glib.Properties.Property_Float := 
  177.      Glib.Properties.Build ("min_y"); 
  178.    Max_Y_Property      : constant Glib.Properties.Property_Float := 
  179.      Glib.Properties.Build ("max_y"); 
  180.  
  181.    pragma Import (C, Get_Type, "gtk_curve_get_type"); 
  182. end Gtk.Curve;