GTK+ Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# GtkColorSelection

## Name

GtkColorSelection -- a widget used to select a color.

## Synopsis

    #include <gtk/gtk.h>

    struct      GtkColorSelection;
    GtkWidget*  gtk_color_selection_new         (void);
    void        gtk_color_selection_set_update_policy
                                                (GtkColorSelection *colorsel,
                                                 GtkUpdateType policy);
    void        gtk_color_selection_set_opacity (GtkColorSelection *colorsel,
                                                 gint use_opacity);
    void        gtk_color_selection_set_color   (GtkColorSelection *colorsel,
                                                 gdouble *color);
    void        gtk_color_selection_get_color   (GtkColorSelection *colorsel,
                                                 gdouble *color);

## Object Hierarchy

      GtkObject
       +----GtkWidget
             +----GtkContainer
                   +----GtkBox
                         +----GtkVBox
                               +----GtkColorSelection

## Signal Prototypes

    "color-changed"
                void        user_function      (GtkColorSelection *colorselection,
                                                gpointer user_data);

## Description

The GtkColorSelection is a widget that is used to select a color. It consists of a color wheel and number of sliders and entry boxes for color parameters such as hue, saturation, value, red, green, blue, and opacity. It is found on the standard color selection dialog box GtkColorSelectionDialog.

## Details

### struct GtkColorSelection

    struct GtkColorSelection;

The GtkColorSelection struct contains private data only, and should be accessed using the functions below.

### gtk_color_selection_new ()

    GtkWidget*  gtk_color_selection_new         (void);

Create a new GtkColorSelection.

Returns : | a GtkColorSelection.

### gtk_color_selection_set_update_policy ()

    void        gtk_color_selection_set_update_policy
                                                (GtkColorSelection *colorsel,
                                                 GtkUpdateType policy);

Sets the policy controlling when the color_changed signals are emitted. The available policies are:

- `GTK_UPDATE_CONTINUOUS` - signals are sent continuously as the color selection changes.

- `GTK_UPDATE_DISCONTINUOUS` - signals are sent only when the mouse button is released.

- `GTK_UPDATE_DELAYED` - signals are sent when the mouse button is released or when the mouse has been motionless for a period of time.

`colorsel` : | a GtkColorSelection.
`policy` : | a GtkUpdateType value indicating the desired policy.

### gtk_color_selection_set_opacity ()

    void        gtk_color_selection_set_opacity (GtkColorSelection *colorsel,
                                                 gint use_opacity);

Controls whether opacity can be set with the GtkColorSelection. If this functionality is enabled, the necessary additional widgets are added to the GtkColorSelection and the opacity value can be retrieved via the fourth value in the color array returned by the gtk_color_selection_get_color() function.

`colorsel` : | a GtkColorSelection.
`use_opacity` : | a boolean indicating whether the opacity selection is enabled.

### gtk_color_selection_set_color ()

    void        gtk_color_selection_set_color   (GtkColorSelection *colorsel,
                                                 gdouble *color);

Sets the color in the GtkColorSelection. The widgets are updated to reflect the new color.

`colorsel` : | a GtkColorSelection.
`color` : | a color array consisting of 4 gfloat values for red, green, blue, and opacity.

### gtk_color_selection_get_color ()

    void        gtk_color_selection_get_color   (GtkColorSelection *colorsel,
                                                 gdouble *color);

Retrieve the currently selected color value.

`colorsel` : | a GtkColorSelection
`color` : | a color array consisting of 4 gfloat values for red, green, blue, and opacity.

## Signals

### The "color-changed" signal

    void        user_function                  (GtkColorSelection *colorselection,
                                                gpointer user_data);

This signal is emitted when the color changes in the GtkColorSelection according to its update policy.

`colorselection` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.

<<< Previous Page | Home | Up | Next Page >>>
GtkCList | GtkColorSelectionDialog