2 Copyright (C) 2012 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.
20 #include "gtkmm2ext/utils.h"
21 #include "gtkmm2ext/cairo_widget.h"
22 #include "gtkmm2ext/cairo_packer.h"
25 CairoPacker::draw_background (Gtk::Widget& w, GdkEventExpose*)
28 Gtk::Widget* window_parent;
29 Glib::RefPtr<Gdk::Window> win = Gtkmm2ext::window_to_draw_on (w, &window_parent);
33 Cairo::RefPtr<Cairo::Context> context = win->create_cairo_context();
34 w.translate_coordinates (*window_parent, 0, 0, x, y);
36 Gdk::Color bg = get_bg ();
38 context->set_source_rgba (bg.get_red_p(), bg.get_green_p(), bg.get_blue_p(), 1.0);
39 Gtkmm2ext::rounded_rectangle (context, x, y, w.get_allocation().get_width(), w.get_allocation().get_height(), 4);
44 CairoHPacker::CairoHPacker ()
49 CairoHPacker::on_realize ()
52 CairoWidget::provide_background_for_cairo_widget (*this, get_bg ());
56 CairoHPacker::get_bg () const
58 return get_style()->get_bg (Gtk::STATE_NORMAL);
62 CairoHPacker::on_expose_event (GdkEventExpose* ev)
64 draw_background (*this, ev);
65 return HBox::on_expose_event (ev);
68 CairoVPacker::CairoVPacker ()
73 CairoVPacker::on_expose_event (GdkEventExpose* ev)
75 draw_background (*this, ev);
76 return VBox::on_expose_event (ev);
80 CairoVPacker::on_realize ()
83 CairoWidget::provide_background_for_cairo_widget (*this, get_bg());
87 CairoVPacker::get_bg () const
89 return get_style()->get_bg (Gtk::STATE_NORMAL);