5
namespace Lsc.Widgets {
6
public class RoundBox : Box {
7
private Cairo.Context cr;
14
public RoundBox (Orientation or, int spacing) {
16
this.spacing = spacing;
17
set_has_window(false);
20
private void draw_rounded_rectangle (Colors rgb, uint x, uint y, int width, int height, double radius) {
21
if (rgb == Colors.BACKGROUND)
22
cr.set_source_rgb (1, 1, 1);
24
cr.set_source_rgb (0.8, 0.8, 0.8);
27
cr.move_to (x + radius, y);
28
cr.arc (width - x - radius, y + radius, radius, Math.PI * 1.5, Math.PI * 2);
29
cr.arc (width - x - radius, height - y - radius, radius, 0, Math.PI * 0.5);
30
cr.arc (x + radius, height - y - radius, radius, Math.PI * 0.5, Math.PI);
31
cr.arc (x + radius, y + radius, radius, Math.PI, Math.PI * 1.5);
37
public override bool draw (Cairo.Context cr) {
40
int width = get_allocated_width ();
41
int height = get_allocated_height ();
42
double arc_radius = 10.0;
44
draw_rounded_rectangle(Colors.BORDER, 0, 0, width, height, arc_radius);
45
draw_rounded_rectangle(Colors.BACKGROUND, 1, 1, width, height, arc_radius-1);
50
public override void size_allocate (Allocation allocation) {
51
base.size_allocate (allocation);