2 Copyright (C) 2011 Paul Davis
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
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 $Id: cell_renderer_toggle_pixbuf.cc $
24 #include "gtkmm2ext/cell_renderer_color_selector.h"
25 #include "gtkmm2ext/utils.h"
31 using namespace Gtkmm2ext;
34 CellRendererColorSelector::CellRendererColorSelector()
35 : Glib::ObjectBase (typeid(CellRendererColorSelector) )
37 , _property_color (*this, "color")
39 property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
40 property_sensitive() = false;
53 CellRendererColorSelector::~CellRendererColorSelector ()
57 Glib::PropertyProxy<Gdk::Color>
58 CellRendererColorSelector::property_color()
60 return _property_color.get_proxy();
64 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*/)
66 Gdk::Color c = _property_color.get_value();
70 cairo_t* cr = gdk_cairo_create (window->gobj());
72 Gdk::Color c = _property_color.get_value();
74 cairo_rectangle (cr, expose_area.get_x(), expose_area.get_y(), expose_area.get_width(), expose_area.get_height());
81 cairo_rectangle_t drawing_rect;
83 drawing_rect.x = cell_area.get_x() + property_xpad();
84 drawing_rect.y = cell_area.get_y() + property_ypad();
85 drawing_rect.width = cell_area.get_width() - (2 * property_xpad());
86 drawing_rect.height = cell_area.get_height() - (2 * property_ypad());
88 Gtkmm2ext::rounded_rectangle (cr, drawing_rect.x, drawing_rect.y, drawing_rect.width, drawing_rect.height, 5);
89 cairo_set_source_rgb (cr, r, g, b);