eb05362005-11-05Henrik Grubbström (Grubba) /* -*- C -*- */
1a05542005-07-28Martin Nilsson class GTK2.ColorSelection; inherit GTK2.Vbox; //! The color selection widget is, not surprisingly, a widget for //! interactive selection of colors. This composite widget lets the //! user select a color by manipulating RGB (Red, Green, Blue) and HSV //! (Hue, Saturation, Value) triples. This is done either by adjusting //! single values with sliders or entries, or by picking the desired //! color from a hue-saturation wheel/value bar. Optionally, the //! opacity of the color can also be set. //! <p> //! The color selection widget currently emits only one signal, //! "color_changed", which is emitted whenever the current color in the //! widget changes, either when the user changes it or if it's set //! explicitly through set_color(). //! </p> //! IMG: GTK2.ColorSelection() //! Properties: //! int current-alpha //! GDK2.Color current-color //! int has-opacity-control //! int has-palette signal color_changed;
3d76632005-11-03Lance Dillon void create(?mapping(string:mixed) props)
1a05542005-07-28Martin Nilsson //! Create a new color selection.
3d76632005-11-03Lance Dillon {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_not_inited(); pgtk2_verify_setup();
3d76632005-11-03Lance Dillon  if (args) { INIT_WITH_PROPS(GTK_TYPE_COLOR_SELECTION);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
3d76632005-11-03Lance Dillon  } else { GtkWidget *gc; gc=gtk_color_selection_new(); THIS->obj=G_OBJECT(gc); }
ba9e802006-02-27Martin Stjernholm  pgtk2__init_this_object();
3d76632005-11-03Lance Dillon }
1a05542005-07-28Martin Nilsson  void set_has_opacity_control(int setting); //! Sets whether or not to use opacity. int get_has_opacity_control(); //! Determines whether the colorsel has an opacity control. void set_has_palette(int has_palette); //! Shows and hides the palette based upon the value of has_palette int get_has_palette(); //! Determines whether the color selector has a color palette. int get_current_alpha(); //! Returns the current alpha value. void set_current_alpha(int alpha); //! Sets the current opacity to be alpha. The first time this //! is called, it will also set the original opacity to be alpha too. mapping(string:int) get_current_color() //! When you need to query the current color, typically when you've //! received a "color_changed" signal, you use this function. The //! return value is an array of floats, See the set_color() function //! for the description of this array. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { GdkColor color; gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(THIS->obj), &color);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
5e9fc02015-08-18Per Hedbor  push_static_text("pixel"); push_int(color.pixel); push_static_text("red"); push_int(color.red); push_static_text("green"); push_int(color.green); push_static_text("blue"); push_int(color.blue);
1a05542005-07-28Martin Nilsson  f_aggregate_mapping(8); } } void set_current_color(mapping(string:int) color) //! You can set the current color explicitly by calling this function //! with an array of colors (floats). The length of the array depends //! on whether opacity is enabled or not. Position 0 contains the red //! component, 1 is green, 2 is blue and opacity is at position 3 (only //! if opacity is enabled, see set_opacity()) All values are between //! 0 and 65535 {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { struct svalue *sv; struct mapping *m; GdkColor color;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%m",&m);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("pixel"));
1a05542005-07-28Martin Nilsson  if (sv)
5c55b02005-12-30Martin Nilsson  color.pixel=(guint32)PGTK_GETINT(sv);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("red"));
1a05542005-07-28Martin Nilsson  if (sv)
5c55b02005-12-30Martin Nilsson  color.red=(guint16)PGTK_GETINT(sv);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("green"));
1a05542005-07-28Martin Nilsson  if (sv)
5c55b02005-12-30Martin Nilsson  color.green=(guint16)PGTK_GETINT(sv);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("blue"));
1a05542005-07-28Martin Nilsson  if (sv)
5c55b02005-12-30Martin Nilsson  color.blue=(guint16)PGTK_GETINT(sv);
1a05542005-07-28Martin Nilsson  gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(THIS->obj), &color); } RETURN_THIS(); } int get_previous_alpha(); //! Returns the previous alpha value. void set_previous_alpha(int alpha); //! Sets the 'previous' alpha to be alpha. This function should //! be called with some hesitation, as it might seem confusing //! to have that alpha change. mapping(string:int) get_previous_color() //! Returns the original color value. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { GdkColor color; gtk_color_selection_get_previous_color(GTK_COLOR_SELECTION(THIS->obj), &color);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("pixel")); push_int(color.pixel); ref_push_string(_STR("red")); push_int(color.red); ref_push_string(_STR("green")); push_int(color.green); ref_push_string(_STR("blue")); push_int(color.blue);
1a05542005-07-28Martin Nilsson  f_aggregate_mapping(8); } } void set_previous_color(mapping(string:int) colors) //! Sets the 'previous' color to be color. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
1a05542005-07-28Martin Nilsson  { struct mapping *m; struct svalue *sv; GdkColor color;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%m",&m);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("pixel"));
1a05542005-07-28Martin Nilsson  if (sv)
5c55b02005-12-30Martin Nilsson  color.pixel=(guint32)PGTK_GETINT(sv);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("red"));
1a05542005-07-28Martin Nilsson  if (sv)
5c55b02005-12-30Martin Nilsson  color.red=(guint16)PGTK_GETINT(sv);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("green"));
1a05542005-07-28Martin Nilsson  if (sv)
5c55b02005-12-30Martin Nilsson  color.green=(guint16)PGTK_GETINT(sv);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("blue"));
1a05542005-07-28Martin Nilsson  if (sv)
5c55b02005-12-30Martin Nilsson  color.blue=(guint16)PGTK_GETINT(sv);
1a05542005-07-28Martin Nilsson  gtk_color_selection_set_previous_color(GTK_COLOR_SELECTION(THIS->obj), &color); } RETURN_THIS(); } int is_adjusting(); //! Gets the current state of the colorsel.