X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fgtkmm2ext%2Fcairo_packer.cc;h=c701a9aca923c8397c74ac35ab1b8b8ad24adc1a;hb=68146a09698772eaaab2b3a46cb1c9866acb4200;hp=6145f7dd50368c42ce272998012b4ffdbb588d65;hpb=4235e9a1a278d5a6c0403ea5cb5c7477e2a1b8ad;p=ardour.git diff --git a/libs/gtkmm2ext/cairo_packer.cc b/libs/gtkmm2ext/cairo_packer.cc index 6145f7dd50..c701a9aca9 100644 --- a/libs/gtkmm2ext/cairo_packer.cc +++ b/libs/gtkmm2ext/cairo_packer.cc @@ -1,3 +1,22 @@ +/* + Copyright (C) 2012 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + #include "gtkmm2ext/utils.h" #include "gtkmm2ext/cairo_widget.h" #include "gtkmm2ext/cairo_packer.h" @@ -13,21 +32,30 @@ CairoPacker::draw_background (Gtk::Widget& w, GdkEventExpose*) Cairo::RefPtr context = win->create_cairo_context(); w.translate_coordinates (*window_parent, 0, 0, x, y); - context->set_source_rgba (0.149, 0.149, 0.149, 1.0); - Gtkmm2ext::rounded_rectangle (context, x, y, w.get_allocation().get_width(), w.get_allocation().get_height(), 9); + + Gdk::Color bg = get_bg (); + + context->set_source_rgba (bg.get_red_p(), bg.get_green_p(), bg.get_blue_p(), 1.0); + Gtkmm2ext::rounded_rectangle (context, x, y, w.get_allocation().get_width(), w.get_allocation().get_height(), 4); context->fill (); } } CairoHPacker::CairoHPacker () { - Gdk::Color bg; +} - bg.set_red (lrint (0.149 * 65535)); - bg.set_green (lrint (0.149 * 65535)); - bg.set_blue (lrint (0.149 * 65535)); +void +CairoHPacker::on_realize () +{ + HBox::on_realize (); + CairoWidget::provide_background_for_cairo_widget (*this, get_bg ()); +} - CairoWidget::provide_background_for_cairo_widget (*this, bg); +Gdk::Color +CairoHPacker::get_bg () const +{ + return get_style()->get_bg (Gtk::STATE_NORMAL); } bool @@ -39,13 +67,6 @@ CairoHPacker::on_expose_event (GdkEventExpose* ev) CairoVPacker::CairoVPacker () { - Gdk::Color bg; - - bg.set_red (lrint (0.149 * 65535)); - bg.set_green (lrint (0.149 * 65535)); - bg.set_blue (lrint (0.149 * 65535)); - - CairoWidget::provide_background_for_cairo_widget (*this, bg); } bool @@ -54,3 +75,16 @@ CairoVPacker::on_expose_event (GdkEventExpose* ev) draw_background (*this, ev); return VBox::on_expose_event (ev); } + +void +CairoVPacker::on_realize () +{ + VBox::on_realize (); + CairoWidget::provide_background_for_cairo_widget (*this, get_bg()); +} + +Gdk::Color +CairoVPacker::get_bg () const +{ + return get_style()->get_bg (Gtk::STATE_NORMAL); +}