1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  Gtk.Color_Chooser.Gtk_Color_Chooser is an interface that is implemented by 
  26. --  widgets for choosing colors. Depending on the situation, colors may be 
  27. --  allowed to have alpha (translucency). 
  28. -- 
  29. --  In GTK+, the main widgets that implement this interface are 
  30. --  Gtk.Color_Chooser_Widget.Gtk_Color_Chooser_Widget, 
  31. --  Gtk.Color_Chooser_Dialog.Gtk_Color_Chooser_Dialog and 
  32. --  Gtk.Color_Button.Gtk_Color_Button. 
  33. -- 
  34. --  </description> 
  35. pragma Ada_2005; 
  36.  
  37. pragma Warnings (Off, "*is already use-visible*"); 
  38. with Gdk.RGBA;        use Gdk.RGBA; 
  39. with Glib;            use Glib; 
  40. with Glib.Object;     use Glib.Object; 
  41. with Glib.Properties; use Glib.Properties; 
  42. with Glib.Types;      use Glib.Types; 
  43. with Gtk.Enums;       use Gtk.Enums; 
  44.  
  45. package Gtk.Color_Chooser is 
  46.  
  47.    type Gtk_Color_Chooser is new Glib.Types.GType_Interface; 
  48.    Null_Gtk_Color_Chooser : constant Gtk_Color_Chooser; 
  49.  
  50.    ------------------ 
  51.    -- Constructors -- 
  52.    ------------------ 
  53.  
  54.    function Get_Type return Glib.GType; 
  55.    pragma Import (C, Get_Type, "gtk_color_chooser_get_type"); 
  56.  
  57.    ------------- 
  58.    -- Methods -- 
  59.    ------------- 
  60.  
  61.    procedure Add_Palette 
  62.       (Self            : Gtk_Color_Chooser; 
  63.        Orientation     : Gtk.Enums.Gtk_Orientation; 
  64.        Colors_Per_Line : Gint; 
  65.        N_Colors        : Gint; 
  66.        Colors          : array_of_Gdk_RGBA); 
  67.    pragma Import (C, Add_Palette, "gtk_color_chooser_add_palette"); 
  68.    --  Adds a palette to the color chooser. If Orientation is horizontal, the 
  69.    --  colors are grouped in rows, with Colors_Per_Line colors in each row. If 
  70.    --  Horizontal is False, the colors are grouped in columns instead. 
  71.    --  The default color palette of 
  72.    --  Gtk.Color_Chooser_Widget.Gtk_Color_Chooser_Widget has 27 colors, 
  73.    --  organized in columns of 3 colors. The default gray palette has 9 grays 
  74.    --  in a single row. 
  75.    --  The layout of the color chooser widget works best when the palettes 
  76.    --  have 9-10 columns. 
  77.    --  Calling this function for the first time has the side effect of 
  78.    --  removing the default color and gray palettes from the color chooser. 
  79.    --  If Colors is null, removes all previously added palettes. 
  80.    --  Since: gtk+ 3.4 
  81.    --  "orientation": Gtk.Enums.Orientation_Horizontal if the palette should 
  82.    --  be displayed in rows, Gtk.Enums.Orientation_Vertical for columns 
  83.    --  "colors_per_line": the number of colors to show in each row/column 
  84.    --  "n_colors": the total number of elements in Colors 
  85.    --  "colors": the colors of the palette, or null 
  86.  
  87.    procedure Get_Rgba 
  88.       (Self  : Gtk_Color_Chooser; 
  89.        Color : out Gdk.RGBA.Gdk_RGBA); 
  90.    pragma Import (C, Get_Rgba, "gtk_color_chooser_get_rgba"); 
  91.    --  Gets the currently-selected color. 
  92.    --  Since: gtk+ 3.4 
  93.    --  "color": a Gdk.RGBA.Gdk_RGBA to fill in with the current color 
  94.  
  95.    procedure Set_Rgba (Self : Gtk_Color_Chooser; Color : Gdk.RGBA.Gdk_RGBA); 
  96.    pragma Import (C, Set_Rgba, "gtk_color_chooser_set_rgba"); 
  97.    --  Sets the color. 
  98.    --  Since: gtk+ 3.4 
  99.    --  "color": the new color 
  100.  
  101.    function Get_Use_Alpha (Self : Gtk_Color_Chooser) return Boolean; 
  102.    --  Returns whether the color chooser shows the alpha channel. 
  103.    --  Since: gtk+ 3.4 
  104.  
  105.    procedure Set_Use_Alpha (Self : Gtk_Color_Chooser; Use_Alpha : Boolean); 
  106.    --  Sets whether or not the color chooser should use the alpha channel. 
  107.    --  Since: gtk+ 3.4 
  108.    --  "use_alpha": True if color chooser should use alpha channel, False if 
  109.    --  not 
  110.  
  111.    ---------------- 
  112.    -- Properties -- 
  113.    ---------------- 
  114.    --  The following properties are defined for this widget. See 
  115.    --  Glib.Properties for more information on properties) 
  116.  
  117.    Rgba_Property : constant Gdk.RGBA.Property_RGBA; 
  118.    --  Type: Gdk.RGBA.Gdk_RGBA 
  119.    --  The ::rgba property contains the currently selected color, as a 
  120.    --  Gdk.RGBA.Gdk_RGBA struct. The property can be set to change the current 
  121.    --  selection programmatically. 
  122.  
  123.    Use_Alpha_Property : constant Glib.Properties.Property_Boolean; 
  124.    --  When ::use-alpha is True, colors may have alpha (translucency) 
  125.    --  information. When it is False, the Gdk.RGBA.Gdk_RGBA struct obtained via 
  126.    --  the Gtk.Color_Chooser.Gtk_Color_Chooser:rgba property will be forced to 
  127.    --  have alpha == 1. 
  128.    -- 
  129.    --  Implementations are expected to show alpha by rendering the color over 
  130.    --  a non-uniform background (like a checkerboard pattern). 
  131.  
  132.    ------------- 
  133.    -- Signals -- 
  134.    ------------- 
  135.  
  136.    type Cb_Gtk_Color_Chooser_Gdk_RGBA_Void is not null access procedure 
  137.      (Self  : Gtk_Color_Chooser; 
  138.       Color : Gdk.RGBA.Gdk_RGBA); 
  139.  
  140.    type Cb_GObject_Gdk_RGBA_Void is not null access procedure 
  141.      (Self  : access Glib.Object.GObject_Record'Class; 
  142.       Color : Gdk.RGBA.Gdk_RGBA); 
  143.  
  144.    Signal_Color_Activated : constant Glib.Signal_Name := "color-activated"; 
  145.    procedure On_Color_Activated 
  146.       (Self  : Gtk_Color_Chooser; 
  147.        Call  : Cb_Gtk_Color_Chooser_Gdk_RGBA_Void; 
  148.        After : Boolean := False); 
  149.    procedure On_Color_Activated 
  150.       (Self  : Gtk_Color_Chooser; 
  151.        Call  : Cb_GObject_Gdk_RGBA_Void; 
  152.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  153.        After : Boolean := False); 
  154.    --  Emitted when a color is activated from the color chooser. This usually 
  155.    --  happens when the user clicks a color swatch, or a color is selected and 
  156.    --  the user presses one of the keys Space, Shift+Space, Return or Enter. 
  157.  
  158.    ---------------- 
  159.    -- Interfaces -- 
  160.    ---------------- 
  161.    --  This class implements several interfaces. See Glib.Types 
  162.    -- 
  163.    --  - "Gtk_Color_Chooser" 
  164.  
  165.    function "+" (W : Gtk_Color_Chooser) return Gtk_Color_Chooser; 
  166.    pragma Inline ("+"); 
  167.  
  168. private 
  169.    Use_Alpha_Property : constant Glib.Properties.Property_Boolean := 
  170.      Glib.Properties.Build ("use-alpha"); 
  171.    Rgba_Property : constant Gdk.RGBA.Property_RGBA := 
  172.      Gdk.RGBA.Build ("rgba"); 
  173.  
  174. Null_Gtk_Color_Chooser : constant Gtk_Color_Chooser := 
  175.    Gtk_Color_Chooser (Glib.Types.Null_Interface); 
  176. end Gtk.Color_Chooser;