Update classkeys to match new total LuaSignal count (windows only)
[ardour.git] / libs / gtkmm2ext / cairo_packer.cc
1 /*
2     Copyright (C) 2012 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #include "gtkmm2ext/utils.h"
21 #include "gtkmm2ext/cairo_widget.h"
22 #include "gtkmm2ext/cairo_packer.h"
23
24 void
25 CairoPacker::draw_background (Gtk::Widget& w, GdkEventExpose*)
26 {
27         int x, y;
28         Gtk::Widget* window_parent;
29         Glib::RefPtr<Gdk::Window> win = Gtkmm2ext::window_to_draw_on (w, &window_parent);
30
31         if (win) {
32
33                 Cairo::RefPtr<Cairo::Context> context = win->create_cairo_context();
34                 w.translate_coordinates (*window_parent, 0, 0, x, y);
35
36                 Gdk::Color bg = get_bg ();
37
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);
40                 context->fill ();
41         }
42 }
43
44 CairoHPacker::CairoHPacker ()
45 {
46 }
47
48 void
49 CairoHPacker::on_realize ()
50 {
51         HBox::on_realize ();
52         CairoWidget::provide_background_for_cairo_widget (*this, get_bg ());
53 }
54
55 Gdk::Color
56 CairoHPacker::get_bg () const
57 {
58         return get_style()->get_bg (Gtk::STATE_NORMAL);
59 }
60
61 bool
62 CairoHPacker::on_expose_event (GdkEventExpose* ev)
63 {
64         draw_background (*this, ev);
65         return HBox::on_expose_event (ev);
66 }
67
68 void
69 CairoHPacker::on_size_allocate (Gtk::Allocation& alloc)
70 {
71         get_parent()->queue_draw();
72         HBox::on_size_allocate (alloc);
73 }
74
75 CairoVPacker::CairoVPacker ()
76 {
77 }
78
79 bool
80 CairoVPacker::on_expose_event (GdkEventExpose* ev)
81 {
82         draw_background (*this, ev);
83         return VBox::on_expose_event (ev);
84 }
85
86 void
87 CairoVPacker::on_realize ()
88 {
89         VBox::on_realize ();
90         CairoWidget::provide_background_for_cairo_widget (*this, get_bg());
91 }
92
93 void
94 CairoVPacker::on_size_allocate (Gtk::Allocation& alloc)
95 {
96         get_parent()->queue_draw();
97         VBox::on_size_allocate (alloc);
98 }
99
100 Gdk::Color
101 CairoVPacker::get_bg () const
102 {
103         return get_style()->get_bg (Gtk::STATE_NORMAL);
104 }