Ejemplo n.º 1
0
 def change_lable(self, day):
     year = self.cal.get_year()
     month=self.cal.get_month()
     y,m,d = utility.jalali_to_milady(year,month,day)
     text = "%s/%s (%s) /%s" % (y, milady_monname[m-1], m, d)
     self.date_labelm.set_label(text)
     text = "%s/%s/%s" % (year, month, day)
     self.date_label.set_label(text)
Ejemplo n.º 2
0
    def draw_day_month(self):
        x, y, w, h = self.allocation
        cr = self.window.cairo_create()
        dx = 2  #self.left_margin
        dy = self.top_margin
        sx, sy = self.current_day
        ibase = (self.basecol_width / 3)
        hrow = (h - self.top_margin) / 6
        ph = hrow / 2
        cc = 0
        i = 0
        j = 6
        cred = False

        while (i < 6):
            while (j >= 0):
                tmp = self.convert_to_str(self.day[i][j])
                _daynum = self.create_pango_layout(tmp)
                _daynum.set_font_description(
                    pango.FontDescription(self.cfont[self.size]))
                day_x, day_y = _daynum.get_pixel_size()
                gray = False
                checkholiday = False
                if (i < 2) and (self.day[i][j] > 15):
                    cr.set_source_color(self.DEACTIVE_COLOR)
                    gray = True
                if (i >= 4) and (self.day[i][j] < 20):
                    cr.set_source_color(self.DEACTIVE_COLOR)
                    gray = True

                plus = ((w - self.left_margin) /
                        7) - (_daynum.get_pixel_size()[0] + 5)
                if ((gray == False) and (holiday.holiday.has_key(self.jyear))):
                    for holi in holiday.holiday.get(self.jyear):
                        if (self.jmonth == holi[0]) and (self.day[i][j]
                                                         == holi[1]):
                            checkholiday = True
                            break

                customday = False
                if (gray == False):
                    cd = 0
                    for ctmp in self.extraday:
                        if ((self.jmonth == int(ctmp[0]))
                                and (self.day[i][j] == int(ctmp[1]))):
                            cd += 1
                            customday = True
                            cpix = ctmp[2]
                            if ctmp[2] > 2:
                                cpix = 3
                            if cd > 1:
                                cpix = 3
                if ((i == sx) and (j == sy)) and (gray == False):
                    if (checkholiday == False):
                        cr.set_source_color(self.MARKED_COLOR)
                    else:
                        cr.set_source_color(self.RED_COLOR)

                    temp = cc * self.basecol_width
                    #cr.rectangle(temp,dy-3,self.basecol_width,day_y+6)
                    cr.rectangle(temp, (hrow * i) + self.top_margin,
                                 self.basecol_width, hrow)
                    cr.fill()
                    cr.set_source_color(self.SELECTED_DAY_COLOR)
                    gray = True
                    cred = True
                if customday == True:
                    image = cairo.ImageSurface.create_from_png(
                        self.DATA_DIR + "/" + self.imagelist[cpix])
                    cr.set_source_surface(image, dx, dy)
                    cr.paint()

                if ((j == 6) or (checkholiday == True)) and (gray == False):
                    cr.set_source_color(self.RED_COLOR)
                elif ((((checkholiday == False)) and (gray == False))
                      or customday == True):
                    cr.set_source_color(self.NORMAL_DAY_COLOR)

                cr.move_to(((ibase) - (day_x / 2)) + (cc * self.basecol_width),
                           self.top_margin + ((hrow * i) + (ph - (day_y / 2))))

                cr.update_layout(_daynum)
                cr.show_layout(_daynum)
                if (gray == False) or (cred == True):
                    zy, zm, zd = utility.jalali_to_milady(
                        self.jyear, self.jmonth, self.day[i][j])
                    _daynumm = self.create_pango_layout(str(zd))
                    _daynumm.set_font_description(
                        pango.FontDescription(self.csfont[self.size]))
                    mw, mh = _daynumm.get_pixel_size()
                    cr.set_source_color(self.DEACTIVE_COLOR)
                    if ((i == sx) and (j == sy)):
                        cr.set_source_color(self.SELECTED_DAY_COLOR)
                    cr.move_to(
                        ((ibase * 2) - (mw / 2) + (cc * self.basecol_width)),
                        self.top_margin + ((hrow * i) + (ph + (mh / 4))))
                    cr.update_layout(_daynumm)
                    cr.show_layout(_daynumm)
                cred = False
                dx += day_x + 5 + (plus)
                cc += 1
                self.col_width[j] = dx
                j -= 1

            i += 1
            j = 6
            cc = 0
            hh = (((h - self.top_margin) / 6) - (day_y + 5))
            dy += day_y + 5 + hh
            self.row_height[i - 1] = dy
            dx = 0  #self.left_margin
Ejemplo n.º 3
0
    def draw_day_month(self):
        x, y, w, h = self.allocation
        cr = self.window.cairo_create()
        dx = 2 #self.left_margin
        dy = self.top_margin
        sx,sy=self.current_day
        i=0
        j=6
        cred=False

        while(i<6):
            while (j>=0):
                tmp=self.convert_to_str(self.day[i][j])
                _daynum = self.create_pango_layout(tmp)
                _daynum.set_font_description(pango.FontDescription("Sans 10"))

                gray=False

                if (i<2)and(self.day[i][j]>15):
                    cr.set_source_color(self.DEACTIVE_COLOR)
                    gray=True
                if (i>=4)and(self.day[i][j]<20):
                    cr.set_source_color(self.DEACTIVE_COLOR)
                    gray=True               
                
                plus = ( (w-self.left_margin)/7 ) -(_daynum.get_pixel_size()[0]+5)
                            
                if ((i==sx)and(j==sy))and(gray==False):
                    cr.set_source_color(self.MARKED_COLOR)
                    
                    x2,y2=_daynum.get_pixel_size()
                    x2=16
                    cr.rectangle((dx),dy-3,(x2+16),y2+6)
                    cr.fill()
                    cr.set_source_color(self.SELECTED_DAY_COLOR)
                    gray=True
                    cred=True
                if gray == False:
                    cr.set_source_color(self.NORMAL_DAY_COLOR)
                cr.move_to( dx+2,dy)
                cr.update_layout(_daynum)
                cr.show_layout(_daynum)
                if (gray==False)or(cred==True):
                    zy,zm,zd=utility.jalali_to_milady(self.jyear,self.jmonth,self.day[i][j])
                    _daynumm = self.create_pango_layout(str(zd))
                    _daynumm.set_font_description(pango.FontDescription("Sans 6"))
                    cr.set_source_color(self.DEACTIVE_COLOR)
                    if ((i==sx)and(j==sy)):
                        cr.set_source_color(self.SELECTED_DAY_COLOR)
                    cr.move_to( (dx+18) , dy+5)
                    cr.update_layout(_daynumm)
                    cr.show_layout(_daynumm)
                cred=False
                dx += _daynum.get_pixel_size()[0]+5+(plus)
                self.col_width[j]=dx
                j-=1

            i+=1
            j=6
            fonth = _daynum.get_pixel_size()[1]
            hh = ( ( (h-self.top_margin)/6 ) -(fonth+5) )
            dy += fonth+5+hh
            self.row_height[i-1]=dy
            dx = 0 
Ejemplo n.º 4
0
 def change_lable(self, day):
     self.year = self.cal.get_year()
     self.month=self.cal.get_month()
     self.day = day
     self.gyear,self.gmonth,self.gday = utility.jalali_to_milady(self.year,self.month,self.day)
Ejemplo n.º 5
0
    def draw_day_month(self):
        x, y, w, h = self.allocation
        cr = self.window.cairo_create()
        dx = 2  #self.left_margin
        dy = self.top_margin
        sx, sy = self.current_day
        i = 0
        j = 6
        cred = False

        while (i < 6):
            while (j >= 0):
                tmp = self.convert_to_str(self.day[i][j])
                _daynum = self.create_pango_layout(tmp)
                _daynum.set_font_description(pango.FontDescription("Sans 10"))

                gray = False

                if (i < 2) and (self.day[i][j] > 15):
                    cr.set_source_color(self.DEACTIVE_COLOR)
                    gray = True
                if (i >= 4) and (self.day[i][j] < 20):
                    cr.set_source_color(self.DEACTIVE_COLOR)
                    gray = True

                plus = ((w - self.left_margin) /
                        7) - (_daynum.get_pixel_size()[0] + 5)

                if ((i == sx) and (j == sy)) and (gray == False):
                    cr.set_source_color(self.MARKED_COLOR)

                    x2, y2 = _daynum.get_pixel_size()
                    x2 = 16
                    cr.rectangle((dx), dy - 3, (x2 + 16), y2 + 6)
                    cr.fill()
                    cr.set_source_color(self.SELECTED_DAY_COLOR)
                    gray = True
                    cred = True
                if gray == False:
                    cr.set_source_color(self.NORMAL_DAY_COLOR)
                cr.move_to(dx + 2, dy)
                cr.update_layout(_daynum)
                cr.show_layout(_daynum)
                if (gray == False) or (cred == True):
                    zy, zm, zd = utility.jalali_to_milady(
                        self.jyear, self.jmonth, self.day[i][j])
                    _daynumm = self.create_pango_layout(str(zd))
                    _daynumm.set_font_description(
                        pango.FontDescription("Sans 6"))
                    cr.set_source_color(self.DEACTIVE_COLOR)
                    if ((i == sx) and (j == sy)):
                        cr.set_source_color(self.SELECTED_DAY_COLOR)
                    cr.move_to((dx + 18), dy + 5)
                    cr.update_layout(_daynumm)
                    cr.show_layout(_daynumm)
                cred = False
                dx += _daynum.get_pixel_size()[0] + 5 + (plus)
                self.col_width[j] = dx
                j -= 1

            i += 1
            j = 6
            fonth = _daynum.get_pixel_size()[1]
            hh = (((h - self.top_margin) / 6) - (fonth + 5))
            dy += fonth + 5 + hh
            self.row_height[i - 1] = dy
            dx = 0
Ejemplo n.º 6
0
 def change_lable(self, day):
     self.year = self.cal.get_year()
     self.month = self.cal.get_month()
     self.day = day
     self.gyear, self.gmonth, self.gday = utility.jalali_to_milady(
         self.year, self.month, self.day)