1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 """bars layout"""
19
20 from lib.xcairo import *
21 from lib.geom import *
22 import calendar
23 import optparse
24 import sys
25 from datetime import date, timedelta
26
27 import _base
28
29 parser = _base.get_parser(__name__)
30 parser.set_defaults(rows=2)
31
33 """bars layout class"""
35 S,G,L = self.Theme
36 make_sloppy_rect(cr, rect, G.month.sloppy_dx, G.month.sloppy_dy, G.month.sloppy_rot)
37
38 day, span = calendar.monthrange(year, month)
39 mmeasure = 'A'*max(map(len,L.month_name))
40 if self.options.month_with_year:
41 mmeasure += 'A'*(len(str(year))+1)
42
43 rows = 31 if G.month.symmetric else span
44 grid = VLayout(rect_from_origin(rect), 32)
45 dom_grid = VLayout(grid.item_span(31,1), rows)
46
47
48 if S.month.box_shadow:
49 f = S.month.box_shadow_size
50 shad = (f,-f) if G.landscape else (f,f)
51 draw_shadow(cr, rect_from_origin(rect), shad)
52
53
54 for dom in range(1,rows+1):
55 R = dom_grid.item(dom-1)
56 if dom <= span:
57 holiday_tuple = self.holiday_provider(year, month, dom, day)
58 day_style = holiday_tuple[2]
59 dcell = _base.DayCell(day = (dom, day), header = holiday_tuple[0], footer = holiday_tuple[1],
60 theme = (day_style, G.dom, L), show_day_name = True)
61 dcell.draw(cr, R, self.options.short_daycell_ratio)
62 else:
63 day_style = S.dom
64 draw_box(cr, rect = R, stroke_rgba = day_style.frame, fill_rgba = day_style.bg,
65 stroke_width = mm_to_dots(day_style.frame_thickness))
66 day = (day + 1) % 7
67
68
69 mcolor = S.month.color_map_bg[year%2][month]
70 mcolor_fg = S.month.color_map_fg[year%2][month]
71 R_mb = grid.item(0)
72 draw_box(cr, rect = R_mb, stroke_rgba = S.month.frame, fill_rgba = mcolor,
73 stroke_width = mm_to_dots(S.month.frame_thickness))
74 draw_box(cr, rect = rect_from_origin(rect), stroke_rgba = S.month.frame, fill_rgba = (),
75 stroke_width = mm_to_dots(S.month.frame_thickness))
76 R_text = rect_rel_scale(R_mb, 1, 0.5)
77 mshad = None
78 if S.month.text_shadow:
79 f = S.month.text_shadow_size
80 mshad = (f,-f) if G.landscape else (f,f)
81 title_str = L.month_name[month]
82 if self.options.month_with_year: title_str += ' ' + str(year)
83 draw_str(cr, text = title_str, rect = R_text, scaling = -1, stroke_rgba = mcolor_fg,
84 align = (2,0), font = S.month.font, measure = mmeasure, shadow = mshad)
85 cr.restore()
86