sp-color-slider.cpp revision 9fb4864477462bc005fa792b095fd06549eca4ab
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen * A slider with colored background
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen * Lauris Kaplinski <lauris@kaplinski.com>
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen * bulia byak <buliabyak@users.sf.net>
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen * Copyright (C) 2001-2002 Lauris Kaplinski
6e16a663ee96cd1329e48518138efb415046d9f6mcecchetti * This code is in public domain
6e16a663ee96cd1329e48518138efb415046d9f6mcecchettistatic void sp_color_slider_class_init (SPColorSliderClass *klass);
6e16a663ee96cd1329e48518138efb415046d9f6mcecchettistatic void sp_color_slider_init (SPColorSlider *slider);
6e16a663ee96cd1329e48518138efb415046d9f6mcecchettistatic void sp_color_slider_destroy (GtkObject *object);
6e16a663ee96cd1329e48518138efb415046d9f6mcecchettistatic void sp_color_slider_realize (GtkWidget *widget);
6e16a663ee96cd1329e48518138efb415046d9f6mcecchettistatic void sp_color_slider_size_request (GtkWidget *widget, GtkRequisition *requisition);
6e16a663ee96cd1329e48518138efb415046d9f6mcecchettistatic void sp_color_slider_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
6e16a663ee96cd1329e48518138efb415046d9f6mcecchetti/* static void sp_color_slider_draw (GtkWidget *widget, GdkRectangle *area); */
6e16a663ee96cd1329e48518138efb415046d9f6mcecchetti/* static void sp_color_slider_draw_focus (GtkWidget *widget); */
8001ba81cb851b38d86650a2fef5817facffb763johanengelen/* static void sp_color_slider_draw_default (GtkWidget *widget); */
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelenstatic gint sp_color_slider_expose (GtkWidget *widget, GdkEventExpose *event);
6e16a663ee96cd1329e48518138efb415046d9f6mcecchettistatic gint sp_color_slider_button_press (GtkWidget *widget, GdkEventButton *event);
6e16a663ee96cd1329e48518138efb415046d9f6mcecchettistatic gint sp_color_slider_button_release (GtkWidget *widget, GdkEventButton *event);
6e16a663ee96cd1329e48518138efb415046d9f6mcecchettistatic gint sp_color_slider_motion_notify (GtkWidget *widget, GdkEventMotion *event);
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelenstatic void sp_color_slider_adjustment_changed (GtkAdjustment *adjustment, SPColorSlider *slider);
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelenstatic void sp_color_slider_adjustment_value_changed (GtkAdjustment *adjustment, SPColorSlider *slider);
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelenstatic void sp_color_slider_paint (SPColorSlider *slider, GdkRectangle *area);
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelenstatic const guchar *sp_color_slider_render_gradient (gint x0, gint y0, gint width, gint height,
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen gint c[], gint dc[], guint b0, guint b1, guint mask);
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelenstatic const guchar *sp_color_slider_render_map (gint x0, gint y0, gint width, gint height,
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen guchar *map, gint start, gint step, guint b0, guint b1, guint mask);
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen "SPColorSlider",
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen (GtkClassInitFunc) sp_color_slider_class_init,
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen type = gtk_type_unique (GTK_TYPE_WIDGET, &info);
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelensp_color_slider_class_init (SPColorSliderClass *klass)
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen parent_class = (GtkWidgetClass*)gtk_type_class (GTK_TYPE_WIDGET);
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen slider_signals[GRABBED] = gtk_signal_new ("grabbed",
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE),
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen GTK_SIGNAL_OFFSET (SPColorSliderClass, grabbed),
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen slider_signals[DRAGGED] = gtk_signal_new ("dragged",
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE),
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen GTK_SIGNAL_OFFSET (SPColorSliderClass, dragged),
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen slider_signals[RELEASED] = gtk_signal_new ("released",
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE),
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen GTK_SIGNAL_OFFSET (SPColorSliderClass, released),
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen slider_signals[CHANGED] = gtk_signal_new ("changed",
d37634d73670180f99a3e0ea583621373d90ec4fJohan Engelen (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE),
6e16a663ee96cd1329e48518138efb415046d9f6mcecchetti widget_class->size_request = sp_color_slider_size_request;
6e16a663ee96cd1329e48518138efb415046d9f6mcecchetti widget_class->size_allocate = sp_color_slider_size_allocate;
6e16a663ee96cd1329e48518138efb415046d9f6mcecchetti/* widget_class->draw = sp_color_slider_draw; */
6e16a663ee96cd1329e48518138efb415046d9f6mcecchetti/* widget_class->draw_focus = sp_color_slider_draw_focus; */
6e16a663ee96cd1329e48518138efb415046d9f6mcecchetti/* widget_class->draw_default = sp_color_slider_draw_default; */
6e16a663ee96cd1329e48518138efb415046d9f6mcecchetti widget_class->expose_event = sp_color_slider_expose;
6e16a663ee96cd1329e48518138efb415046d9f6mcecchetti widget_class->button_press_event = sp_color_slider_button_press;
6e16a663ee96cd1329e48518138efb415046d9f6mcecchetti widget_class->button_release_event = sp_color_slider_button_release;
6e16a663ee96cd1329e48518138efb415046d9f6mcecchetti widget_class->motion_notify_event = sp_color_slider_motion_notify;
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
gdk_window_move_resize (widget->window, allocation->x, allocation->y, allocation->width, allocation->height);
static gint
return FALSE;
static gint
return FALSE;
static gint
if (slider->value != slider->oldvalue) gtk_signal_emit (GTK_OBJECT (slider), slider_signals[CHANGED]);
return FALSE;
static gint
return FALSE;
if (!adjustment) {
const guchar *b;
warea.x = 0;
warea.y = 0;
b = NULL;
gint s, d;
b = sp_color_slider_render_map (cpaint.x - carea.x, cpaint.y - carea.y, cpaint.width, cpaint.height,
if (b != NULL) {
gint i;
c, dc,
if (b != NULL) {
b = sp_color_slider_render_gradient (MAX(cpaint.x - carea.x, carea.width/2), cpaint.y - carea.y, wi, cpaint.height,
c, dc,
if (b != NULL) {
x = aarea.x;
y1++;
y2--;
static const guchar *
gint x, y;
guint r, g, b, a;
if (!buf) {
guchar *d;
d = dp;
r += dc[0];
return buf;
static const guchar *
gint x, y;
if (!buf) {
guchar *d;
d = dp;
return buf;