1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from draw import draw_pixbuf, propagate_expose, draw_vlinear, cairo_state
24 from skin_config import skin_config
25 from utils import get_window_shadow_size
26 import gobject
27 import gtk
28
30 '''
31 Event box, not like Gtk.EventBox, it don't show visible window default.
32 '''
33
35 '''
36 Initialize the EventBox class.
37 '''
38 gtk.EventBox.__init__(self)
39 self.set_visible_window(False)
40
42 '''
43 ImageBox.
44
45 @undocumented: expose_image_box
46 '''
47
49 '''
50 Initialize the ImageBox class.
51
52 @param image_dpixbuf: Image dynamic pixbuf.
53 '''
54
55 gtk.EventBox.__init__(self)
56 self.set_visible_window(False)
57 self.image_dpixbuf = image_dpixbuf
58
59
60 pixbuf = self.image_dpixbuf.get_pixbuf()
61 self.set_size_request(pixbuf.get_width(), pixbuf.get_height())
62
63
64 self.connect("expose-event", self.expose_image_box)
65
67 '''
68 Callback for `expose-event` signal.
69
70 @param widget: Gtk.Widget instance.
71 @param event: Expose event.
72 '''
73
74 cr = widget.window.cairo_create()
75 rect = widget.allocation
76 pixbuf = self.image_dpixbuf.get_pixbuf()
77
78
79 draw_pixbuf(cr, pixbuf, rect.x, rect.y)
80
81
82 propagate_expose(widget, event)
83
84 return True
85
86 gobject.type_register(ImageBox)
87
89 '''
90 BackgroundBox is container for clip background.
91
92 @undocumented: expose_background_box
93 '''
94
96 '''
97 Initialize the BackgroundBox class.
98 '''
99
100 gtk.VBox.__init__(self)
101 self.set_can_focus(True)
102
103 self.connect("expose-event", self.expose_background_box)
104
106 '''
107 Mask render function.
108
109 @param cr: Cairo context.
110 @param x: X coordinate of draw area.
111 @param y: Y coordinate of draw area.
112 @param w: Width of draw area.
113 @param h: Height of draw area.
114 '''
115 draw_vlinear(cr, x, y, w, h,
116 [(0, ("#FF0000", 1)),
117 (1, ("#FF0000", 1))]
118 )
119
121 '''
122 Callback for `expose-event` signal.
123
124 @param widget: BackgroundBox self.
125 @param event: Expose event.
126 @return: Always return False.
127 '''
128 cr = widget.window.cairo_create()
129 rect = widget.allocation
130 toplevel = widget.get_toplevel()
131 coordinate = widget.translate_coordinates(toplevel, rect.x, rect.y)
132 (offset_x, offset_y) = coordinate
133
134 with cairo_state(cr):
135 cr.rectangle(rect.x, rect.y, rect.width, rect.height)
136 cr.clip()
137
138 (shadow_x, shadow_y) = get_window_shadow_size(toplevel)
139 skin_config.render_background(cr, widget, shadow_x, shadow_y)
140
141 self.draw_mask(cr, rect.x, rect.y, rect.width, rect.height)
142
143 return False
144
145 gobject.type_register(BackgroundBox)
146