1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2006-2007 AdaCore                    -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  <description> 
  25. --  The Gtk_Color_Button is a button which displays the currently selected 
  26. --  color an allows to open a color selection dialog to change the color. It is 
  27. --  suitable widget for selecting a color in a preference dialog. 
  28. --  </description> 
  29. --  <c_version>2.8.17</c_version> 
  30. --  <group>Selectors</group> 
  31. --  <screenshot>color-button.png</screenshot> 
  32.  
  33. with Glib.Properties; 
  34. with Gdk.Color; 
  35. with Gtk.Button; 
  36.  
  37. package Gtk.Color_Button is 
  38.  
  39.    type Gtk_Color_Button_Record is new Gtk.Button.Gtk_Button_Record with 
  40.      null record; 
  41.    type Gtk_Color_Button is access all Gtk_Color_Button_Record'Class; 
  42.  
  43.    function Get_Type return Gtk.Gtk_Type; 
  44.    --  Return the internal value associated with a Gtk_Color_Button. 
  45.  
  46.    procedure Gtk_New (Button : out Gtk_Color_Button); 
  47.    procedure Initialize (Button : access Gtk_Color_Button_Record'Class); 
  48.    --  Creates a new color button. This returns a widget in the form of a small 
  49.    --  button containing a swatch representing the current selected color. When 
  50.    --  the button is clicked, a color-selection dialog will open, allowing the 
  51.    --  user to select a color. The swatch will be updated to reflect the new 
  52.    --  color when the user finishes. 
  53.  
  54.    procedure Gtk_New_With_Color 
  55.      (Button : out Gtk_Color_Button; 
  56.       Color  : Gdk.Color.Gdk_Color); 
  57.    procedure Initialize_With_Color 
  58.      (Button : access Gtk_Color_Button_Record'Class; 
  59.       Color  : Gdk.Color.Gdk_Color); 
  60.    --  Creates a new color button. 
  61.  
  62.    procedure Set_Color 
  63.      (Button : access Gtk_Color_Button_Record; 
  64.       Color  : Gdk.Color.Gdk_Color); 
  65.    function Get_Color 
  66.      (Button : access Gtk_Color_Button_Record) return Gdk.Color.Gdk_Color; 
  67.    --  Sets the current color to be Color. 
  68.  
  69.    procedure Set_Alpha 
  70.      (Button : access Gtk_Color_Button_Record; 
  71.       Alpha  : Guint16); 
  72.    function Get_Alpha 
  73.      (Button : access Gtk_Color_Button_Record) 
  74.       return Glib.Guint16; 
  75.    --  Sets the current opacity to be Alpha (0 to 65_535). 
  76.  
  77.    procedure Set_Use_Alpha 
  78.      (Button    : access Gtk_Color_Button_Record; 
  79.       Use_Alpha : Boolean); 
  80.    function Get_Use_Alpha 
  81.      (Button : access Gtk_Color_Button_Record) return Boolean; 
  82.    --  Sets whether or not the color button should use the alpha channel. 
  83.  
  84.    procedure Set_Title 
  85.      (Button : access Gtk_Color_Button_Record; 
  86.       Title  : String); 
  87.    function Get_Title 
  88.      (Button : access Gtk_Color_Button_Record) return String; 
  89.    --  Sets the title for the color selection dialog. 
  90.  
  91.    ---------------- 
  92.    -- Properties -- 
  93.    ---------------- 
  94.  
  95.    --  <properties> 
  96.    --  The following properties are defined for this widget. See 
  97.    --  Glib.Properties for more information on properties. 
  98.    -- 
  99.    --  Name:  Alpha_Property 
  100.    --  Type:  Uint 
  101.    --  Descr: The selected opacity value 
  102.    --         (0 fully transparent, 65535 fully opaque) 
  103.    -- 
  104.    --  Name:  Color_Property 
  105.    --  Type:  Boxed 
  106.    --  Descr: The selected color 
  107.    -- 
  108.    --  Name:  Title_Property 
  109.    --  Type:  String 
  110.    --  Descr: The title of the color selection dialog 
  111.    -- 
  112.    --  Name:  Use_Alpha_Property 
  113.    --  Type:  Boolean 
  114.    --  Descr: Whether or not to give the color an alpha value 
  115.    --  </properties> 
  116.  
  117.    Alpha_Property     : constant Glib.Properties.Property_Uint; 
  118.    Color_Property     : constant Gdk.Color.Property_Gdk_Color; 
  119.    Title_Property     : constant Glib.Properties.Property_String; 
  120.    Use_Alpha_Property : constant Glib.Properties.Property_Boolean; 
  121.  
  122.    ------------- 
  123.    -- Signals -- 
  124.    ------------- 
  125.  
  126.    --  <signals> 
  127.    --  The following new signals are defined for this widget: 
  128.    -- 
  129.    --  - "color_set" 
  130.    --    procedure Handler (Button : access Gtk_Color_Button_Record'Class); 
  131.    --    The color-set signal is emitted when the user selects a color. When 
  132.    --    handling this signal, use Get_Color and Get_Alpha to find out which 
  133.    --    color was just selected. 
  134.    --    Note that this signal is only emitted when the user changes the color. 
  135.    --    If you need to react to programmatic color changes as well, use the 
  136.    --    notify::color signal. 
  137.    --  </signals> 
  138.  
  139.    Signal_Color_Set : constant Glib.Signal_Name := "color_set"; 
  140.  
  141. private 
  142.    Alpha_Property : constant Glib.Properties.Property_Uint := 
  143.      Glib.Properties.Build ("alpha"); 
  144.    Color_Property : constant Gdk.Color.Property_Gdk_Color := 
  145.      Gdk.Color.Property_Gdk_Color (Glib.Build ("color")); 
  146.    Title_Property : constant Glib.Properties.Property_String := 
  147.      Glib.Properties.Build ("title"); 
  148.    Use_Alpha_Property : constant Glib.Properties.Property_Boolean := 
  149.      Glib.Properties.Build ("use-alpha"); 
  150.  
  151.    pragma Import (C, Get_Type, "gtk_color_button_get_type"); 
  152.  
  153. end Gtk.Color_Button;