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