GIMP Widgets Library Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# GimpColorButton

## Name

GimpColorButton -- Widget for selecting a color.

## Synopsis

    struct      GimpColorButton;
    GtkWidget*  gimp_color_button_new           (const gchar *title,
                                                 gint width,
                                                 gint height,
                                                 const GimpRGB *color,
                                                 GimpColorAreaType type);
    void        gimp_color_button_set_color     (GimpColorButton *gcb,
                                                 const GimpRGB *color);
    void        gimp_color_button_get_color     (GimpColorButton *gcb,
                                                 GimpRGB *color);
    gboolean    gimp_color_button_has_alpha     (GimpColorButton *gcb);
    void        gimp_color_button_set_type      (GimpColorButton *gcb,
                                                 GimpColorAreaType type);

## Object Hierarchy

      GObject
       +----GtkObject
             +----GtkWidget
                   +----GtkContainer
                         +----GtkBin
                               +----GtkButton
                                     +----GimpButton
                                           +----GimpColorButton

## Signal Prototypes

    "color-changed"
                void        user_function      (GimpColorButton *gimpcolorbutton,
                                                gpointer user_data);

## Description

This widget provides a simple button with a preview showing the color.

On click a GtkColorSelectionDialog is opened. Additionally the button supports Drag and Drop and has a right-click menu that allows to choose the color from the current FG or BG color. If the user changes the color, the "color_changed" signal is emitted.

## Details

### struct GimpColorButton

    struct GimpColorButton;

### gimp_color_button_new ()

    GtkWidget*  gimp_color_button_new           (const gchar *title,
                                                 gint width,
                                                 gint height,
                                                 const GimpRGB *color,
                                                 GimpColorAreaType type);

Creates a new GimpColorButton widget.

This returns a button with a preview showing the color. When the button is clicked a GtkColorSelectionDialog is opened. If the user changes the color the new color is written into the array that was used to pass the initial color and the "color_changed" signal is emitted.

`title` : | String that will be used as title for the color_selector.
`width` : | Width of the colorpreview in pixels.
`height` : | Height of the colorpreview in pixels.
`color` : | A pointer to a GimpRGB color.
`type` : |
Returns : | Pointer to the new GimpColorButton widget.

### gimp_color_button_set_color ()

    void        gimp_color_button_set_color     (GimpColorButton *gcb,
                                                 const GimpRGB *color);

`gcb` : | Pointer to a GimpColorButton.
`color` : | Pointer to the new GimpRGB color.

### gimp_color_button_get_color ()

    void        gimp_color_button_get_color     (GimpColorButton *gcb,
                                                 GimpRGB *color);

`gcb` : | Pointer to a GimpColorButton.
`color` : |

### gimp_color_button_has_alpha ()

    gboolean    gimp_color_button_has_alpha     (GimpColorButton *gcb);

`gcb` : | Pointer to a GimpColorButton.
Returns : |

### gimp_color_button_set_type ()

    void        gimp_color_button_set_type      (GimpColorButton *gcb,
                                                 GimpColorAreaType type);

`gcb` : |
`type` : |

## Signals

### The "color-changed" signal

    void        user_function                  (GimpColorButton *gimpcolorbutton,
                                                gpointer user_data);

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

## See Also

libgimpcolor-gimpcolorspace

<<< Previous Page | Home | Up | Next Page >>>
GimpColorArea | GimpColorScale