Gnome User Interface Library Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
#include <gnome.h> struct GnomeColorPicker; |
|
This widget provides color selection facilities to your application. The widget appears as a button which contains a "color swatch" of the currently selected color. When the button is pressed, the widget presents the user with a color selection dialog where the color can be selected.
You can select the color to be displayed in a number of ways: floating point values for the red, green and blue channels, integers in the range 0 to 65,535, or integers in the range 0 to 255, depending on your needs.
void color_picked_callback(GtkWidget *w, guint r, guint g, guint b, guint a, gpointer data) { g_print("User selected color (rgba): d d d d\n", r, g, b, a); /* save colors to configuration file, or use them some other way */ } ... GtkWidget *cp; /* create a color picker, set a default color */ cp = gnome_color_picker_new(); gnome_color_picker_set_i8(GNOME_COLOR_PICKER(cp), 255, 0, 0, 0); /* connect a function to our widget */ gtk_signal_connect(GTK_OBJECT(cp), "color_set", GTK_SIGNAL_FUNC(color_picked_callback), NULL); ... /* retrieve color from our widget, someplace else in code */ gdouble r, g, b, a; gnome_color_picker_get_d(GNOME_COLOR_PICKER(cp), &r, &g, &b, &a); g_print("Color (rgba): %g %g %g %g\n", r, g, b, a); |
|
Creates a new GNOME color picker widget. This returns a widget in the form of a small button containing a swatch representing the current selected color. When the button is clicked, a color-selection dialog will open, allowing the user to select a color. The swatch will be updated to reflect the new color when the user finishes.
void gnome_color_picker_set_d (GnomeColorPicker *cp, |
Set color shown in the color picker widget using floating point values.
void gnome_color_picker_get_d (GnomeColorPicker *cp, |
Retrieve color currently selected in the color picker widget in the form of floating point values.
cp : | Pointer to GNOME color picker widget. |
r : | Output location of red color component, values are in [0.0, 1.0] |
g : | Output location of green color component, values are in [0.0, 1.0] |
b : | Output location of blue color component, values are in [0.0, 1.0] |
a : | Output location of alpha color component, values are in [0.0, 1.0] |
void gnome_color_picker_set_i8 (GnomeColorPicker *cp, |
Set color shown in the color picker widget using 8-bit integer values.
void gnome_color_picker_get_i8 (GnomeColorPicker *cp, |
Retrieve color currently selected in the color picker widget in the form of 8-bit integer values.
cp : | Pointer to GNOME color picker widget. |
r : | Output location of red color component, values are in [0, 255] |
g : | Output location of green color component, values are in [0, 255] |
b : | Output location of blue color component, values are in [0, 255] |
a : | Output location of alpha color component, values are in [0, 255] |
void gnome_color_picker_set_i16 (GnomeColorPicker *cp, |
Set color shown in the color picker widget using 16-bit integer values.
void gnome_color_picker_get_i16 (GnomeColorPicker *cp, |
Retrieve color currently selected in the color picker widget in the form of 16-bit integer values.
cp : | Pointer to GNOME color picker widget. |
r : | Output location of red color component, values are in [0, 65535] |
g : | Output location of green color component, values are in [0, 65535] |
b : | Output location of blue color component, values are in [0, 65535] |
a : | Output location of alpha color component, values are in [0, 65535] |
void gnome_color_picker_set_dither (GnomeColorPicker *cp, |
Sets whether the picker should dither the color sample or just paint a solid rectangle.
void gnome_color_picker_set_use_alpha (GnomeColorPicker *cp, |
Sets whether or not the picker should use the alpha channel.
void gnome_color_picker_set_title (GnomeColorPicker *cp, const |
Sets the title for the color selection dialog.