PageRenderTime 17ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gtk/library/gtk_color_selection.e

http://github.com/tybor/Liberty
Specman e | 252 lines | 106 code | 30 blank | 116 comment | 2 complexity | a82bc857aa7432efd5ec5b94ccae8bc3 MD5 | raw file
  1indexing
  2	description: "GtkColorSelection, a widget used to select a color."
  3	copyright: "[
  4					Copyright (C) 2006 eiffel-libraries team, GTK+ team
  5					
  6					This library is free software; you can redistribute it and/or
  7					modify it under the terms of the GNU Lesser General Public License
  8					as published by the Free Software Foundation; either version 2.1 of
  9					the License, or (at your option) any later version.
 10					
 11					This library is distributed in the hope that it will be useful, but
 12					WITHOUT ANY WARRANTY; without even the implied warranty of
 13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14					Lesser General Public License for more details.
 15
 16					You should have received a copy of the GNU Lesser General Public
 17					License along with this library; if not, write to the Free Software
 18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 19					02110-1301 USA
 20				]"
 21	date: "$Date:$"
 22	revision: "$Revision:$"
 23
 24class GTK_COLOR_SELECTION
 25	-- The GtkColorSelection is a widget that is used to select a
 26	-- color. It consists of a color wheel and number of sliders and
 27	-- entry boxes for color parameters such as hue, saturation, value,
 28	-- red, green, blue, and opacity. It is found on the standard color
 29	-- selection dialog box GtkColorSelectionDialog.
 30
 31inherit GTK_VBOX
 32	rename
 33		make as vbox_make
 34	redefine
 35		struct_size
 36	end
 37
 38	-- TODO: GtkColorSelection implements AtkImplementorIface.
 39
 40insert
 41	GTK_COLOR_SELECTION_EXTERNALS
 42
 43creation make, from_external_pointer
 44
 45feature -- size
 46
 47	struct_size: INTEGER is
 48		external "C inline use <gtk/gtk.h>"
 49		alias "sizeof(GtkColorSelection)"
 50		end
 51
 52feature
 53	make is
 54			-- Creates a new GtkColorSelection.
 55		do
 56			from_external_pointer(gtk_color_selection_new)
 57		end
 58
 59feature
 60	current_color: GDK_COLOR is
 61			-- Returns the current color in the GTK_COLOR_SELECTION widget
 62		do
 63			create Result.make
 64			gtk_color_selection_get_current_color (handle, Result.handle)
 65		end
 66
 67	set_current_color (a_color: GDK_COLOR) is
 68			-- Sets the current color to be a_color. The first time this is
 69			-- called, it will also set the original color to be a_color too.
 70		do
 71			gtk_color_selection_set_current_color (handle, a_color.handle)
 72		end
 73
 74	set_has_opacity_control (a_setting: BOOLEAN) is
 75			-- Sets Current color selection to use or not use opacity.
 76			-- colorsel : a GtkColorSelection.  has_opacity : TRUE if
 77			-- colorsel can set the opacity, FALSE otherwise.
 78		do
 79			gtk_color_selection_set_has_opacity_control
 80			(handle, a_setting.to_integer)
 81		end
 82
 83	has_opacity_control: BOOLEAN is
 84			-- Does the color selection have an opacity control.
 85		do
 86			Result := (gtk_color_selection_get_has_opacity_control
 87						  (handle).to_boolean)
 88		end
 89
 90	set_has_palette (a_setting: BOOLEAN) is
 91			-- Shows or hides the palette based upon the value of `a_setting'.
 92		do
 93			gtk_color_selection_set_has_palette(handle, a_setting.to_integer)
 94		end
 95
 96	has_palette: BOOLEAN is
 97			-- Does the selector have a palette?
 98		do
 99			Result := gtk_color_selection_get_has_palette(handle).to_boolean
100		end
101
102	current_alpha: INTEGER is
103			-- the current alpha value.  
104		do
105			Result:=gtk_color_selection_get_current_alpha(handle)
106		ensure fit_natural_16: Result.in_range(0, 65535)
107		end
108
109	set_current_alpha (an_alpha: INTEGER) is
110			-- Sets the current opacity to `an_alpha'. The first time
111			-- this is called, it will also set the original opacity to
112			-- `an_alpha'.
113		require fit_natural_16: an_alpha.in_range(0, 65535)
114		do
115			gtk_color_selection_set_current_alpha(handle, an_alpha)
116		ensure set: current_alpha = an_alpha
117		end
118
119	previous_alpha: INTEGER is
120			-- the previous alpha value.
121		do
122			Result:=gtk_color_selection_get_previous_alpha(handle)
123		ensure fit_natural_16: Result.in_range(0, 65535)
124		end
125
126	set_previous_alpha (an_alpha: INTEGER) is
127			-- Sets the 'previous' alpha to `an_alpha'. This function
128			-- should be called with some hesitations, as it might seem
129			-- confusing to have that alpha change.
130		require fit_natural_16: an_alpha.in_range(0, 65535)
131		do
132			gtk_color_selection_set_previous_alpha(handle, an_alpha)
133		ensure set: previous_alpha = an_alpha
134		end
135
136	previous_color: GDK_COLOR is
137			-- the original color value.
138		do
139			create Result.make
140			gtk_color_selection_get_previous_color (handle, Result.handle)
141		end
142
143	set_previous_color (a_color: GDK_COLOR) is
144			-- Sets the 'previous' color to `a_color'. This function
145			-- should be called with some hesitations, as it might seem
146			-- confusing to have that color change. Calling
147			-- `set_current_color' will also set this color the first
148			-- time it is called.
149		require color_not_void: a_color /= Void
150		do
151			gtk_color_selection_set_previous_color(handle, a_color.handle)
152		end
153
154	is_adjusting: BOOLEAN is
155			-- Is the user currently dragging a color around?
156		do
157			Result:=(gtk_color_selection_is_adjusting(handle).to_boolean)
158		end
159
160	-- gtk_color_selection_palette_from_string ()
161
162	-- gboolean gtk_color_selection_palette_from_string (const gchar
163	-- *str, GdkColor **colors, gint *n_colors);
164
165	-- Parses a color palette string; the string is a colon-separated
166	-- list of color names readable by gdk_color_parse().
167	
168	-- str : 	a string encoding a color palette.
169	-- colors : 	return location for allocated array of GdkColor.
170	-- n_colors : 	return location for length of array.
171	-- Returns : 	TRUE if a palette was successfully parsed.
172	-- gtk_color_selection_palette_to_string ()
173	-- 
174	-- gchar*      gtk_color_selection_palette_to_string
175	--                                             (const GdkColor *colors,
176	--                                              gint n_colors);
177	-- 
178	-- Encodes a palette as a string, useful for persistent storage.
179	-- 
180	-- colors : 	an array of colors.
181	-- n_colors : 	length of the array.
182	-- Returns : 	allocated string encoding the palette.
183	-- gtk_color_selection_set_change_palette_hook ()
184	-- 
185	-- gtk_color_selection_set_change_palette_with_screen_hook ()
186	-- 
187	-- GtkColorSelectionChangePaletteWithScreenFunc gtk_color_selection_set_change_palette_with_screen_hook
188	--                                             (GtkColorSelectionChangePaletteWithScreenFunc func);
189	-- 
190	-- Installs a global function to be called whenever the user tries to modify the palette in a color selection. This function should save the new palette contents, and update the GtkSettings property "gtk-color-palette" so all GtkColorSelection widgets will be modified.
191	-- 
192	-- func : 	a function to call when the custom palette needs saving.
193	-- Returns : 	the previous change palette hook (that was replaced).
194	-- 
195	-- Since 2.2
196	-- GtkColorSelectionChangePaletteWithScreenFunc ()
197	-- 
198	-- void        (*GtkColorSelectionChangePaletteWithScreenFunc)
199	--                                             (GdkScreen *screen,
200	--                                              const GdkColor *colors,
201	--                                              gint n_colors);
202	-- 
203	-- screen : 	
204	-- colors : 	
205	-- n_colors : 	
206	-- 
207	-- Since 2.2
208feature -- Properties
209	--   "current-alpha"        guint                 : Read / Write
210	--   "current-color"        GdkColor              : Read / Write
211	--   "has-opacity-control"  gboolean              : Read / Write
212	--   "has-palette"          gboolean              : Read / Write
213	-- Property Details
214	-- The "current-alpha" property
215	-- 
216	--   "current-alpha"        guint                 : Read / Write
217	-- 
218	-- The current opacity value (0 fully transparent, 65535 fully opaque).
219	-- 
220	-- Allowed values: <= 65535
221	-- 
222	-- Default value: 65535
223	-- The "current-color" property
224	-- 
225	--   "current-color"        GdkColor              : Read / Write
226	-- 
227	-- The current color.
228	-- The "has-opacity-control" property
229	-- 
230	--   "has-opacity-control"  gboolean              : Read / Write
231	-- 
232	-- Whether the color selector should allow setting opacity.
233	-- 
234	-- Default value: FALSE
235	-- The "has-palette" property
236	-- 
237	--   "has-palette"          gboolean              : Read / Write
238	-- 
239	-- Whether a palette should be used.
240	-- 
241	-- Default value: FALSE
242	-- 
243feature -- The "color-changed" signal
244	-- void user_function (GtkColorSelection *colorselection, gpointer
245	-- user_data) : Run first
246
247	-- This signal is emitted when the color changes in the
248	-- GtkColorSelection according to its update policy.
249	-- colorselection : the object which received the signal.
250	-- user_data : user data set when the signal handler was connected.
251
252end -- class GTK_COLOR_SELECTION