~lubuntu-software-center-team/lubuntu-software-center/vala-port

« back to all changes in this revision

Viewing changes to src/Widgets/RoundBox.vala

  • Committer: Stephen Smally
  • Date: 2012-03-18 10:38:53 UTC
  • Revision ID: eco.stefi@fastwebnet.it-20120318103853-v7wg1qfuifjkc3gc
Implemented dynamic category view

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
using Cairo;
4
4
 
5
5
namespace Lsc.Widgets {
6
 
    public class RoundBox : Box {
 
6
    public class RoundBox : EventBox {
7
7
        private Cairo.Context cr;
 
8
        private Box container;
8
9
        
9
10
        private enum Colors {
10
11
            BACKGROUND,
12
13
        }
13
14
        
14
15
        public RoundBox (Orientation or, int spacing) {
15
 
            orientation = or;
16
 
            this.spacing = spacing;
17
16
            set_has_window(false);
 
17
            
 
18
            container = new Box(or, spacing);
 
19
            
 
20
            add(container);
 
21
        }
 
22
        
 
23
        public void pack_start (Widget widget, bool expand, bool fill, int space) {
 
24
            container.pack_start(widget, expand, fill, space);
18
25
        }
19
26
        
20
27
        private void draw_rounded_rectangle (Colors rgb, uint x, uint y, int width, int height, double radius) {
 
28
            Gdk.RGBA color;
 
29
            bool res;
21
30
            if (rgb == Colors.BACKGROUND)
22
 
                cr.set_source_rgb (1, 1, 1);
 
31
                res = get_style_context().lookup_color("base_color", out color);
23
32
            else
24
 
                cr.set_source_rgb (0.8, 0.8, 0.8);
 
33
                color = { 0.8, 0.8, 0.8, 1 };
 
34
                res = true;
 
35
            
 
36
            if (res == false) {
 
37
                color = { 0, 0, 0, 0 };
 
38
            }
 
39
            
 
40
            Gdk.cairo_set_source_rgba (cr, color);
25
41
            
26
42
            cr.new_path();
27
43
            cr.move_to (x + radius, y);