5
namespace Lsc.Widgets {
6
public class RoundBox : EventBox {
7
private Cairo.Context cr;
15
public RoundBox (Orientation or, int spacing) {
16
set_has_window(false);
18
container = new Box(or, spacing);
23
public void pack_start (Widget widget, bool expand, bool fill, int space) {
24
container.pack_start(widget, expand, fill, space);
27
private void draw_rounded_rectangle (Colors rgb, uint x, uint y, int width, int height, double radius) {
30
if (rgb == Colors.BACKGROUND)
31
res = get_style_context().lookup_color("base_color", out color);
33
color = { 0.8, 0.8, 0.8, 1 };
37
color = { 0, 0, 0, 0 };
40
Gdk.cairo_set_source_rgba (cr, color);
43
cr.move_to (x + radius, y);
44
cr.arc (width - x - radius, y + radius, radius, Math.PI * 1.5, Math.PI * 2);
45
cr.arc (width - x - radius, height - y - radius, radius, 0, Math.PI * 0.5);
46
cr.arc (x + radius, height - y - radius, radius, Math.PI * 0.5, Math.PI);
47
cr.arc (x + radius, y + radius, radius, Math.PI, Math.PI * 1.5);
53
public override bool draw (Cairo.Context cr) {
56
int width = get_allocated_width ();
57
int height = get_allocated_height ();
58
double arc_radius = 10.0;
60
draw_rounded_rectangle(Colors.BORDER, 0, 0, width, height, arc_radius);
61
draw_rounded_rectangle(Colors.BACKGROUND, 1, 1, width, height, arc_radius-1);
66
public override void size_allocate (Allocation allocation) {
67
base.size_allocate (allocation);