1-----------------------------------------------------------------------
2--               GtkAda - Ada95 binding for Gtk+/Gnome               --
3--                                                                   --
4--      Copyright (C) 2000 E. Briot, J. Brobecker and A. Charlet     --
5--                Copyright (C) 2000-2006 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--  A Gtk_Color_Combo is a widget that ease the selection of colors
32--  by the user. It is a special form of a Gtk_Combo_Box, that displays
33--  a special popup window, with a list of colors.
34--
35--  Note that nothing appears in the button, this your responsibility to
36--  update it when the user selects a new color (see the "changed" signal).
37--
38--  The recommended solution is to put a Gtk_Pixmap as the
39--  child of the button of the combo box ("Add (Get_Button (Combo), Pixmap)"),
40--  and updated it in the handler for this signal.
41--  </description>
42--  <c_version>gtkextra 2.1.1</c_version>
43--  <group>Selectors</group>
44
45with Gdk.Color;
46with Gtk.Extra.Combo_Button;
47
48package Gtk.Extra.Color_Combo is
49
50   type Gtk_Color_Combo_Record is
51     new Gtk.Extra.Combo_Button.Gtk_Combo_Button_Record with private;
52   type Gtk_Color_Combo is access all Gtk_Color_Combo_Record'Class;
53
54   procedure Gtk_New (Widget : out Gtk_Color_Combo);
55   --  Create a new default combo box.
56   --  It shows a list of 40 default colors.
57
58   procedure Initialize (Widget : access Gtk_Color_Combo_Record'Class);
59   --  Internal initialization function.
60   --  See the section "Creating your own widgets" in the documentation.
61
62   procedure Gtk_New
63     (Widget : out Gtk_Color_Combo;
64      Nrows  : Gint;
65      Ncols  : Gint;
66      Values : Gdk.Color.Gdk_Color_Array);
67   --  Create a new combo box with a specific list of colors.
68   --  Note that Color_Names must contain at least Nrows * Ncols elements.
69
70   procedure Initialize
71     (Widget : access Gtk_Color_Combo_Record;
72      Nrows  : Gint;
73      Ncols  : Gint;
74      Values : Gdk.Color.Gdk_Color_Array);
75   --  Internal initialization function.
76   --  See the section "Creating your own widgets" in the documentation.
77
78   function Get_Type return Gtk.Gtk_Type;
79   --  Return the internal value associated with a Gtk_Color_Combo.
80
81   function Get_Color_At
82     (Widget : access Gtk_Color_Combo_Record;
83      Row    : Gint;
84      Col    : Gint) return Gdk.Color.Gdk_Color;
85   --  Return the name of the color at specific coordinates.
86
87   procedure Find_Color
88     (Color_Combo : access Gtk_Color_Combo_Record;
89      Color       : Gdk.Color.Gdk_Color;
90      Row         : out Gint;
91      Col         : out Gint);
92   --  Return the coordinates in which a color appear in the popup window.
93   --  (-1, -1) is returned if the color was not found in the combo box.
94
95   function Get_Selection (Color_Combo : access Gtk_Color_Combo_Record)
96      return Gdk.Color.Gdk_Color;
97   --  Return the current selection in the combo.
98
99   function Set_Color
100     (Color_Combo : access Gtk_Color_Combo_Record;
101      Name        : String)
102     return Boolean;
103   --  Set the new current color. If the color is not found in the list of
104   --  colors provided in the popup window, False is returned.
105
106   function Set_Color
107     (Color_Combo : access Gtk_Color_Combo_Record;
108      Color       : Gdk.Color.Gdk_Color)
109     return Boolean;
110   --  Set the new current color. Color must have been allocated first.  If the
111   --  color is not found in the list of colors provided in the popup window,
112   --  False is returned.
113
114   function Get_Ncols (Color_Combo : access Gtk_Color_Combo_Record)
115      return Gint;
116   --  Return the number of columns in the popup window
117
118   function Get_Nrows (Color_Combo : access Gtk_Color_Combo_Record)
119      return Gint;
120   --  Return the number of rows in the popup window
121
122   procedure Changed
123     (Color_Combo : access Gtk_Color_Combo_Record;
124      Row : Gint;
125      Col : Gint);
126   --  Emit the changed signal for the widget, as if the color at coordinates
127   --  (Row, Col) had been selected.
128   --  Note that this doesn't change the internal state of the widget (use
129   --  Set_Color for that).
130
131   -------------
132   -- Signals --
133   -------------
134
135   --  <signals>
136   --  The following new signals are defined for this widget:
137   --
138   --  - "changed"
139   --  procedure Handler (Color_Combo : access Gtk_Color_Combo_Record'Class;
140   --                     Selection   : Gint;
141   --                     Color       : access Gdk.Color.Gdk_Color);
142   --
143   --  Emitted when the color has selected a new color.
144   --  Selection is the number of the selection (this is the total
145   --  row * Ncols + col). Color_Name is the name of the selected color.
146   --  </signals>
147
148private
149   type Gtk_Color_Combo_Record is
150     new Gtk.Extra.Combo_Button.Gtk_Combo_Button_Record with null record;
151   pragma Import (C, Get_Type, "gtk_color_combo_get_type");
152end Gtk.Extra.Color_Combo;
153