2 Copyright (C) 2011-2014 Paul Davis
3 Original Author: Carl Hetherington <cth@carlh.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __CANVAS_BOX_H__
21 #define __CANVAS_BOX_H__
23 #include "canvas/item.h"
25 namespace ArdourCanvas
30 /** a Container is an item which has no content of its own
31 * but renders its children in some geometrical arrangement.
33 * Imagined examples of containers:
35 * Container: renders each child at the child's self-determined position
36 * Box: renders each child along an axis (vertical or horizontal)
37 * Table/Grid: renders each child within a two-dimensional grid
41 class LIBCANVAS_API Box : public Item
49 Box (Canvas *, Orientation);
50 Box (Item *, Orientation);
51 Box (Item *, Duple const & position, Orientation);
53 void set_spacing (double s);
54 void set_padding (double top, double right = -1.0, double bottom = -1.0, double left = -1.0);
55 void set_margin (double top, double right = -1.0, double bottom = -1.0, double left = -1.0);
57 /* aliases so that CSS box model terms work */
58 void set_border_width (double w) { set_outline_width (w); }
59 void set_border_color (Gtkmm2ext::Color c) { set_outline_color (c); }
62 void pack_start (Item*, double extra_padding = 0);
63 void pack_end (Item*, double extra_padding = 0);
65 void set_collapse_on_hide (bool);
66 void set_homogenous (bool);
68 void compute_bounding_box () const;
69 void render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
72 Orientation orientation;
74 double top_padding, right_padding, bottom_padding, left_padding;
75 double top_margin, right_margin, bottom_margin, left_margin;
77 void child_changed ();
80 bool collapse_on_hide;
84 void reposition_children ();
87 class LIBCANVAS_API VBox : public Box
92 VBox (Item *, Duple const & position);
95 class LIBCANVAS_API HBox : public Box
100 HBox (Item *, Duple const & position);