2 * Copyright (C) 2011-2015 Paul Davis <paul@linuxaudiosystems.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "gtkmm2ext/cell_renderer_color_selector.h"
23 #include "gtkmm2ext/utils.h"
29 using namespace Gtkmm2ext;
32 CellRendererColorSelector::CellRendererColorSelector()
33 : Glib::ObjectBase (typeid(CellRendererColorSelector) )
35 , _property_color (*this, "color")
37 property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
38 property_sensitive() = false;
51 CellRendererColorSelector::~CellRendererColorSelector ()
55 Glib::PropertyProxy<Gdk::Color>
56 CellRendererColorSelector::property_color()
58 return _property_color.get_proxy();
62 CellRendererColorSelector::render_vfunc (const Glib::RefPtr<Gdk::Drawable>& window, Gtk::Widget& /*widget*/, const Gdk::Rectangle& /*background_area*/, const Gdk::Rectangle& cell_area, const Gdk::Rectangle& expose_area, Gtk::CellRendererState /*flags*/)
64 Gdk::Color c = _property_color.get_value();
68 cairo_t* cr = gdk_cairo_create (window->gobj());
70 Gdk::Color c = _property_color.get_value();
72 cairo_rectangle (cr, expose_area.get_x(), expose_area.get_y(), expose_area.get_width(), expose_area.get_height());
79 cairo_rectangle_t drawing_rect;
81 drawing_rect.x = cell_area.get_x() + property_xpad();
82 drawing_rect.y = cell_area.get_y() + property_ypad();
83 drawing_rect.width = cell_area.get_width() - (2 * property_xpad());
84 drawing_rect.height = cell_area.get_height() - (2 * property_ypad());
86 Gtkmm2ext::rounded_rectangle (cr, drawing_rect.x, drawing_rect.y, drawing_rect.width, drawing_rect.height, 5);
87 cairo_set_source_rgb (cr, r, g, b);