Ewl_Colorpicker: The colour picking widget
Detailed Description
- Remarks:
- Inherits from Ewl_Box.
Tutorial
The Ewl_Colorpicker widget provides a way to let the user select a color either by manually entering its values, or graphically via the built-in Ewl_Spectrum widget, which also provides a preview of the color. The color can be selected in RGB or HSV format (but can be retrieved only in RGB format for now).
Ewl_Widget *cp; cp = ewl_colorpicker_new(); ewl_widget_show(cp);
Once you've setup the colour picker, you can read its current and previous value and set them. For example the following swaps the two.
unsigned int r,g,b; ewl_colorpicker_current_rgb_get(EWL_COLORPICKER(cp), &r, &g, &b); ewl_colorpicker_previous_rgb_set(EWL_COLORPICKER(cp), r, g, b);
You can also change the display mode of the spectrum programmatically
void ewl_colorpicker_color_mode_set(Ewl_Colorpicker *cp, Ewl_Color_Mode type); Ewl_Color_Mode ewl_colorpicker_color_mode_get(Ewl_Colorpicker *cp);
Data Structures | |
struct | Ewl_Colorpicker |
Inherits from Ewl_Box to produce a color picker widget. More... | |
Defines | |
#define | EWL_COLORPICKER(cp) ((Ewl_Colorpicker *) cp) |
#define | EWL_COLORPICKER_IS(w) (ewl_widget_type_is(EWL_WIDGET(w), EWL_COLORPICKER_TYPE)) |
#define | EWL_COLORPICKER_TYPE "colorpicker" |
Typedefs | |
typedef Ewl_Colorpicker | Ewl_Colorpicker |
Functions | |
unsigned int | ewl_colorpicker_alpha_get (Ewl_Colorpicker *cp) |
Retrive the alpha value from the color picker. | |
void | ewl_colorpicker_alpha_set (Ewl_Colorpicker *cp, unsigned int alpha) |
Set the alpha value into the color picker. | |
void | ewl_colorpicker_cb_alpha_change (Ewl_Widget *w, void *ev, void *data) |
void | ewl_colorpicker_cb_dnd_data (Ewl_Widget *w, void *ev, void *data) |
void | ewl_colorpicker_cb_previous_clicked (Ewl_Widget *w, void *ev, void *data) |
void | ewl_colorpicker_cb_radio_change (Ewl_Widget *w, void *ev, void *data) |
void | ewl_colorpicker_cb_spinner_change (Ewl_Widget *w, void *ev, void *data) |
void | ewl_colorpicker_cb_square_change (Ewl_Widget *w, void *ev, void *data) |
void | ewl_colorpicker_cb_vertical_change (Ewl_Widget *w, void *ev, void *data) |
Ewl_Color_Mode | ewl_colorpicker_color_mode_get (Ewl_Colorpicker *cp) |
Get the color mode of the color picker. | |
void | ewl_colorpicker_color_mode_set (Ewl_Colorpicker *cp, Ewl_Color_Mode type) |
Set the color mode of the color picker. | |
void | ewl_colorpicker_current_rgb_get (Ewl_Colorpicker *cp, unsigned int *r, unsigned int *g, unsigned int *b) |
Retrieve the current RGB values from the color picker. | |
void | ewl_colorpicker_current_rgb_set (Ewl_Colorpicker *cp, unsigned int r, unsigned int g, unsigned int b) |
Set the current RGB values into the color picker. | |
unsigned int | ewl_colorpicker_has_alpha_get (Ewl_Colorpicker *cp) |
Retrieves if the color picker displays alpha information. | |
void | ewl_colorpicker_has_alpha_set (Ewl_Colorpicker *cp, unsigned int alpha) |
Set if the color picker displays alpha information. | |
int | ewl_colorpicker_init (Ewl_Colorpicker *cp) |
Initializes the cp color picker widget. | |
Ewl_Widget * | ewl_colorpicker_new (void) |
Creates a new Ewl_Colorpicker widget. | |
void | ewl_colorpicker_previous_rgba_get (Ewl_Colorpicker *cp, unsigned int *r, unsigned int *g, unsigned int *b, unsigned int *a) |
Retrieve the previous RGBA values from the color picker. | |
void | ewl_colorpicker_previous_rgba_set (Ewl_Colorpicker *cp, unsigned int r, unsigned int g, unsigned int b, unsigned int a) |
Set the previous RBGA values into the color picker. |
Define Documentation
#define EWL_COLORPICKER | ( | cp | ) | ((Ewl_Colorpicker *) cp) |
Typecast a pointer to an Ewl_Colorpicker pointer.
#define EWL_COLORPICKER_IS | ( | w | ) | (ewl_widget_type_is(EWL_WIDGET(w), EWL_COLORPICKER_TYPE)) |
Returns TRUE if the widget is an Ewl_Colorpicker, FALSE otherwise
#define EWL_COLORPICKER_TYPE "colorpicker" |
The type name for the Ewl_Colorpicker widget
Typedef Documentation
typedef struct Ewl_Colorpicker Ewl_Colorpicker |
The Ewl_Colorpicker
Function Documentation
unsigned int ewl_colorpicker_alpha_get | ( | Ewl_Colorpicker * | cp | ) |
Retrive the alpha value from the color picker.
- Parameters:
-
cp,: The colourpicker to get the alpha value from
- Returns:
- Returns the alpha value of the colorpicker (0-255)
void ewl_colorpicker_alpha_set | ( | Ewl_Colorpicker * | cp, | |
unsigned int | alpha | |||
) |
Set the alpha value into the color picker.
- Parameters:
-
cp,: the colourpicker to set the alpha value too alpha,: The alpha value to set.
void ewl_colorpicker_cb_alpha_change | ( | Ewl_Widget * | w, | |
void * | ev, | |||
void * | data | |||
) |
void ewl_colorpicker_cb_dnd_data | ( | Ewl_Widget * | w, | |
void * | ev, | |||
void * | data | |||
) |
void ewl_colorpicker_cb_previous_clicked | ( | Ewl_Widget * | w, | |
void * | ev, | |||
void * | data | |||
) |
void ewl_colorpicker_cb_radio_change | ( | Ewl_Widget * | w, | |
void * | ev, | |||
void * | data | |||
) |
void ewl_colorpicker_cb_spinner_change | ( | Ewl_Widget * | w, | |
void * | ev, | |||
void * | data | |||
) |
void ewl_colorpicker_cb_square_change | ( | Ewl_Widget * | w, | |
void * | ev, | |||
void * | data | |||
) |
void ewl_colorpicker_cb_vertical_change | ( | Ewl_Widget * | w, | |
void * | ev, | |||
void * | data | |||
) |
Ewl_Color_Mode ewl_colorpicker_color_mode_get | ( | Ewl_Colorpicker * | cp | ) |
Get the color mode of the color picker.
- Parameters:
-
cp,: The colorpicker to get the mode from
- Returns:
- Returns the Ewl_Color_Mode of the colorpicker
void ewl_colorpicker_color_mode_set | ( | Ewl_Colorpicker * | cp, | |
Ewl_Color_Mode | mode | |||
) |
Set the color mode of the color picker.
- Parameters:
-
cp,: The colorpicker to set the mode on mode,: The mode to set on the colorpicker
- Returns:
- Returns no value.
void ewl_colorpicker_current_rgb_get | ( | Ewl_Colorpicker * | cp, | |
unsigned int * | r, | |||
unsigned int * | g, | |||
unsigned int * | b | |||
) |
Retrieve the current RGB values from the color picker.
- Parameters:
-
cp,: The colorpicker to get the current rgb values from r,: Where to store the red value g,: Where to store the green value b,: Where to store the blue value
- Returns:
- Returns no value
void ewl_colorpicker_current_rgb_set | ( | Ewl_Colorpicker * | cp, | |
unsigned int | r, | |||
unsigned int | g, | |||
unsigned int | b | |||
) |
Set the current RGB values into the color picker.
- Parameters:
-
cp,: The colourpicker to set the current rgb value into r,: The red value to set g,: The green value to set b,: The blue value to set
- Returns:
- Returns no value.
unsigned int ewl_colorpicker_has_alpha_get | ( | Ewl_Colorpicker * | cp | ) |
Retrieves if the color picker displays alpha information.
- Parameters:
-
cp,: The colour picker to get the has_alpha flag from
- Returns:
- Returns the value of the has_alpha flag (TRUE or FALSE)
void ewl_colorpicker_has_alpha_set | ( | Ewl_Colorpicker * | cp, | |
unsigned int | alpha | |||
) |
Set if the color picker displays alpha information.
- Parameters:
-
cp,: The colour picker to set the has_alpha flag on. alpha,: Value to set the has_alpha param too. (TRUE or FALSE)
- Returns:
- Returns no value.
int ewl_colorpicker_init | ( | Ewl_Colorpicker * | cp | ) |
Initializes the cp
color picker widget.
- Parameters:
-
cp,: The Ewl_Colorpicker to initialize
- Returns:
- Returns TRUE on success or FALSE on failure
Ewl_Widget* ewl_colorpicker_new | ( | void | ) |
Creates a new Ewl_Colorpicker widget.
- Returns:
- Returns a new Ewl_Colorpicker widget or NULL on failure
void ewl_colorpicker_previous_rgba_get | ( | Ewl_Colorpicker * | cp, | |
unsigned int * | r, | |||
unsigned int * | g, | |||
unsigned int * | b, | |||
unsigned int * | a | |||
) |
Retrieve the previous RGBA values from the color picker.
- Parameters:
-
cp,: The colorpicker to get the previous rgb value from. r,: Where to store the red value g,: Where to store the green value b,: Where to store the blue value a,: Where to store the alpha value
- Returns:
- Returns no value.
void ewl_colorpicker_previous_rgba_set | ( | Ewl_Colorpicker * | cp, | |
unsigned int | r, | |||
unsigned int | g, | |||
unsigned int | b, | |||
unsigned int | a | |||
) |
Set the previous RBGA values into the color picker.
- Parameters:
-
cp,: The colorpicker to set the previous rgb value into r,: The red value to set g,: The green value to set b,: The blue value to set a,: The alpha value to set
- Returns:
- Returns no value.