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. --  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. In 
  31. --  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. -- 
  37. --  </description> 
  38. --  <group>Drawing</group> 
  39.  
  40. pragma Warnings (Off, "*is already use-visible*"); 
  41. with Glib;             use Glib; 
  42. with Glib.Properties;  use Glib.Properties; 
  43. with Glib.Types;       use Glib.Types; 
  44. with Gtk.Buildable;    use Gtk.Buildable; 
  45. with Gtk.Drawing_Area; use Gtk.Drawing_Area; 
  46. with Gtk.Enums;        use Gtk.Enums; 
  47. with Gtk.Widget;       use Gtk.Widget; 
  48.  
  49. package Gtk.Curve is 
  50.  
  51.    type Gtk_Curve_Record is new Gtk_Drawing_Area_Record with null record; 
  52.    type Gtk_Curve is access all Gtk_Curve_Record'Class; 
  53.  
  54.    ------------------ 
  55.    -- Constructors -- 
  56.    ------------------ 
  57.  
  58.    procedure Gtk_New (Curve : out Gtk_Curve); 
  59.    procedure Initialize (Curve : access Gtk_Curve_Record'Class); 
  60.  
  61.    function Get_Type return Glib.GType; 
  62.    pragma Import (C, Get_Type, "gtk_curve_get_type"); 
  63.  
  64.    ------------- 
  65.    -- Methods -- 
  66.    ------------- 
  67.  
  68.    procedure Reset (Curve : access Gtk_Curve_Record); 
  69.    --  Reset the curve. Reset to a straight line from the minimum x & y values 
  70.    --  to the maximum x & y values (i.e. from the bottom-left to the top-right 
  71.    --  corners). The curve type is not changed. 
  72.  
  73.    procedure Set_Curve_Type 
  74.       (Curve    : access Gtk_Curve_Record; 
  75.        The_Type : Gtk.Enums.Gtk_Curve_Type); 
  76.    --  Set the type of the curve. The curve will remain unchanged except when 
  77.    --  changing from a free curve to a linear or spline curve, in which case 
  78.    --  the curve will be changed as little as possible. 
  79.  
  80.    procedure Set_Gamma (Curve : access Gtk_Curve_Record; Gamma : Gfloat); 
  81.    --  Recompute the entire curve using the given gamma value. A gamma value 
  82.    --  of 1.0 results in a straight line. Values greater than 1.0 result in a 
  83.    --  curve above the straight line. Values less than 1.0 result in a curve 
  84.    --  below the straight line. The curve type is changed to Curve_Type_Free. 
  85.  
  86.    procedure Set_Range 
  87.       (Curve : access Gtk_Curve_Record; 
  88.        Min_X : Gfloat; 
  89.        Max_X : Gfloat; 
  90.        Min_Y : Gfloat; 
  91.        Max_Y : Gfloat); 
  92.    --  Set the minimum and maximum x & y values of the curve. The curve is 
  93.    --  also reset with a call to Reset. 
  94.  
  95.    ---------------------- 
  96.    -- GtkAda additions -- 
  97.    ---------------------- 
  98.  
  99.    procedure Set_Vector 
  100.      (Curve  : access Gtk_Curve_Record; 
  101.       Vector : Gfloat_Array); 
  102.    procedure Get_Vector 
  103.      (Curve  : access Gtk_Curve_Record; 
  104.       Vector : out Gfloat_Array); 
  105.    --  Set the vector of points on the curve. 
  106.    --  The curve type is set to Curve_Type_Free. 
  107.  
  108.    ---------------- 
  109.    -- Interfaces -- 
  110.    ---------------- 
  111.    --  This class implements several interfaces. See Glib.Types 
  112.    -- 
  113.    --  - "Buildable" 
  114.  
  115.    package Implements_Buildable is new Glib.Types.Implements 
  116.      (Gtk.Buildable.Gtk_Buildable, Gtk_Curve_Record, Gtk_Curve); 
  117.    function "+" 
  118.      (Widget : access Gtk_Curve_Record'Class) 
  119.    return Gtk.Buildable.Gtk_Buildable 
  120.    renames Implements_Buildable.To_Interface; 
  121.    function "-" 
  122.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  123.    return Gtk_Curve 
  124.    renames Implements_Buildable.To_Object; 
  125.  
  126.    ---------------- 
  127.    -- Properties -- 
  128.    ---------------- 
  129.    --  The following properties are defined for this widget. See 
  130.    --  Glib.Properties for more information on properties) 
  131.    -- 
  132.    --  Name: Curve_Type_Property 
  133.    --  Type: Gtk.Enums.Gtk_Curve_Type 
  134.    --  Flags: read-write 
  135.    -- 
  136.    --  Name: Max_X_Property 
  137.    --  Type: Gfloat 
  138.    --  Flags: read-write 
  139.    -- 
  140.    --  Name: Max_Y_Property 
  141.    --  Type: Gfloat 
  142.    --  Flags: read-write 
  143.    -- 
  144.    --  Name: Min_X_Property 
  145.    --  Type: Gfloat 
  146.    --  Flags: read-write 
  147.    -- 
  148.    --  Name: Min_Y_Property 
  149.    --  Type: Gfloat 
  150.    --  Flags: read-write 
  151.  
  152.    Curve_Type_Property : constant Gtk.Enums.Property_Gtk_Curve_Type; 
  153.    Max_X_Property : constant Glib.Properties.Property_Float; 
  154.    Max_Y_Property : constant Glib.Properties.Property_Float; 
  155.    Min_X_Property : constant Glib.Properties.Property_Float; 
  156.    Min_Y_Property : constant Glib.Properties.Property_Float; 
  157.  
  158.    ------------- 
  159.    -- Signals -- 
  160.    ------------- 
  161.    --  The following new signals are defined for this widget: 
  162.    -- 
  163.    --  "curve-type-changed" 
  164.    --     procedure Handler (Self : access Gtk_Curve_Record'Class); 
  165.  
  166.    Signal_Curve_Type_Changed : constant Glib.Signal_Name := "curve-type-changed"; 
  167.  
  168. private 
  169.    Curve_Type_Property : constant Gtk.Enums.Property_Gtk_Curve_Type := 
  170.      Gtk.Enums.Build ("curve-type"); 
  171.    Max_X_Property : constant Glib.Properties.Property_Float := 
  172.      Glib.Properties.Build ("max-x"); 
  173.    Max_Y_Property : constant Glib.Properties.Property_Float := 
  174.      Glib.Properties.Build ("max-y"); 
  175.    Min_X_Property : constant Glib.Properties.Property_Float := 
  176.      Glib.Properties.Build ("min-x"); 
  177.    Min_Y_Property : constant Glib.Properties.Property_Float := 
  178.      Glib.Properties.Build ("min-y"); 
  179. end Gtk.Curve;