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. -- As a special exception, if other files instantiate generics from  -- 
  22. -- this unit, or you link this unit with other files to produce an   -- 
  23. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  24. -- executable to be covered by the GNU General Public License. This  -- 
  25. -- exception does not however invalidate any other reasons why the   -- 
  26. -- executable file  might be covered by the  GNU Public License.     -- 
  27. ----------------------------------------------------------------------- 
  28.  
  29. --  <description> 
  30. --  The Gtk_Color_Button is a button which displays the currently selected 
  31. --  color an allows to open a color selection dialog to change the color. It is 
  32. --  suitable widget for selecting a color in a preference dialog. 
  33. --  </description> 
  34. --  <c_version>2.8.17</c_version> 
  35. --  <group>Selectors</group> 
  36. --  <screenshot>color-button.png</screenshot> 
  37.  
  38. with Glib.Properties; 
  39. with Gdk.Color; 
  40. with Gtk.Button; 
  41.  
  42. package Gtk.Color_Button is 
  43.  
  44.    type Gtk_Color_Button_Record is new Gtk.Button.Gtk_Button_Record with 
  45.      null record; 
  46.    type Gtk_Color_Button is access all Gtk_Color_Button_Record'Class; 
  47.  
  48.    function Get_Type return Gtk.Gtk_Type; 
  49.    --  Return the internal value associated with a Gtk_Color_Button. 
  50.  
  51.    procedure Gtk_New (Button : out Gtk_Color_Button); 
  52.    procedure Initialize (Button : access Gtk_Color_Button_Record'Class); 
  53.    --  Creates a new color button. This returns a widget in the form of a small 
  54.    --  button containing a swatch representing the current selected color. When 
  55.    --  the button is clicked, a color-selection dialog will open, allowing the 
  56.    --  user to select a color. The swatch will be updated to reflect the new 
  57.    --  color when the user finishes. 
  58.  
  59.    procedure Gtk_New_With_Color 
  60.      (Button : out Gtk_Color_Button; 
  61.       Color  : Gdk.Color.Gdk_Color); 
  62.    procedure Initialize_With_Color 
  63.      (Button : access Gtk_Color_Button_Record'Class; 
  64.       Color  : Gdk.Color.Gdk_Color); 
  65.    --  Creates a new color button. 
  66.  
  67.    procedure Set_Color 
  68.      (Button : access Gtk_Color_Button_Record; 
  69.       Color  : Gdk.Color.Gdk_Color); 
  70.    function Get_Color 
  71.      (Button : access Gtk_Color_Button_Record) return Gdk.Color.Gdk_Color; 
  72.    --  Sets the current color to be Color. 
  73.  
  74.    procedure Set_Alpha 
  75.      (Button : access Gtk_Color_Button_Record; 
  76.       Alpha  : Guint16); 
  77.    function Get_Alpha 
  78.      (Button : access Gtk_Color_Button_Record) 
  79.       return Glib.Guint16; 
  80.    --  Sets the current opacity to be Alpha (0 to 65_535). 
  81.  
  82.    procedure Set_Use_Alpha 
  83.      (Button    : access Gtk_Color_Button_Record; 
  84.       Use_Alpha : Boolean); 
  85.    function Get_Use_Alpha 
  86.      (Button : access Gtk_Color_Button_Record) return Boolean; 
  87.    --  Sets whether or not the color button should use the alpha channel. 
  88.  
  89.    procedure Set_Title 
  90.      (Button : access Gtk_Color_Button_Record; 
  91.       Title  : String); 
  92.    function Get_Title 
  93.      (Button : access Gtk_Color_Button_Record) return String; 
  94.    --  Sets the title for the color selection dialog. 
  95.  
  96.    ---------------- 
  97.    -- Properties -- 
  98.    ---------------- 
  99.  
  100.    --  <properties> 
  101.    --  The following properties are defined for this widget. See 
  102.    --  Glib.Properties for more information on properties. 
  103.    -- 
  104.    --  Name:  Alpha_Property 
  105.    --  Type:  Uint 
  106.    --  Descr: The selected opacity value 
  107.    --         (0 fully transparent, 65535 fully opaque) 
  108.    -- 
  109.    --  Name:  Color_Property 
  110.    --  Type:  Boxed 
  111.    --  Descr: The selected color 
  112.    -- 
  113.    --  Name:  Title_Property 
  114.    --  Type:  String 
  115.    --  Descr: The title of the color selection dialog 
  116.    -- 
  117.    --  Name:  Use_Alpha_Property 
  118.    --  Type:  Boolean 
  119.    --  Descr: Whether or not to give the color an alpha value 
  120.    --  </properties> 
  121.  
  122.    Alpha_Property     : constant Glib.Properties.Property_Uint; 
  123.    Color_Property     : constant Gdk.Color.Property_Gdk_Color; 
  124.    Title_Property     : constant Glib.Properties.Property_String; 
  125.    Use_Alpha_Property : constant Glib.Properties.Property_Boolean; 
  126.  
  127.    ------------- 
  128.    -- Signals -- 
  129.    ------------- 
  130.  
  131.    --  <signals> 
  132.    --  The following new signals are defined for this widget: 
  133.    -- 
  134.    --  - "color_set" 
  135.    --    procedure Handler (Button : access Gtk_Color_Button_Record'Class); 
  136.    --    The color-set signal is emitted when the user selects a color. When 
  137.    --    handling this signal, use Get_Color and Get_Alpha to find out which 
  138.    --    color was just selected. 
  139.    --    Note that this signal is only emitted when the user changes the color. 
  140.    --    If you need to react to programmatic color changes as well, use the 
  141.    --    notify::color signal. 
  142.    --  </signals> 
  143.  
  144.    Signal_Color_Set : constant Glib.Signal_Name := "color_set"; 
  145.  
  146. private 
  147.    Alpha_Property : constant Glib.Properties.Property_Uint := 
  148.      Glib.Properties.Build ("alpha"); 
  149.    Color_Property : constant Gdk.Color.Property_Gdk_Color := 
  150.      Gdk.Color.Property_Gdk_Color (Glib.Build ("color")); 
  151.    Title_Property : constant Glib.Properties.Property_String := 
  152.      Glib.Properties.Build ("title"); 
  153.    Use_Alpha_Property : constant Glib.Properties.Property_Boolean := 
  154.      Glib.Properties.Build ("use-alpha"); 
  155.  
  156.    pragma Import (C, Get_Type, "gtk_color_button_get_type"); 
  157.  
  158. end Gtk.Color_Button;