Example #1
0
 def drawBoxEditingHelperLines(self, cr):
     if not self.boxEditing:
         return
     editType, event, box, x0, t0 = self.boxEditing
     setColor(cr, fgColor)
     d = editingBoxHelperLineWidth
     cr.rectangle(box.x, 0, d, box.y)
     cr.fill()
     cr.rectangle(box.x + box.w - d, 0, d, box.y)
     cr.fill()
Example #2
0
	def highlight(self, widget=None, event=None):
		#self.drag_highlight()
		if self.get_window()==None:
			return
		cr = self.get_window().cairo_create()
		setColor(cr, self.highlightColor)
		#print(tuple(self.get_allocation()), tuple(self.label.get_allocation()))
		w = self.get_allocation().width
		h = self.get_allocation().height
		cr.rectangle(0, 0, w, 1)
		cr.fill()
		cr.rectangle(0, h-1, w, 1)
		cr.fill()
		cr.rectangle(0, 0, 1, h)
		cr.fill()
		cr.rectangle(w-1, 0, 1, h)
		cr.fill()
		cr.clip()
Example #3
0
 def highlight(self, widget=None, event=None):
     #self.drag_highlight()
     if self.get_window()==None:
         return
     cr = self.get_window().cairo_create()
     setColor(cr, self.highlightColor)
     #print(tuple(self.get_allocation()), tuple(self.label.get_allocation()))
     w = self.get_allocation().width
     h = self.get_allocation().height
     cr.rectangle(0, 0, w, 1)
     cr.fill()
     cr.rectangle(0, h-1, w, 1)
     cr.fill()
     cr.rectangle(0, 0, 1, h)
     cr.fill()
     cr.rectangle(w-1, 0, 1, h)
     cr.fill()
     cr.clip()
Example #4
0
 def drawBoxEditingHelperLines(self, cr):
     if not self.boxEditing:
         return
     editType, event, box, x0, t0 = self.boxEditing
     setColor(cr, fgColor)
     d = editingBoxHelperLineWidth
     cr.rectangle(
         box.x,
         0,
         d,
         box.y,
     )
     cr.fill()
     cr.rectangle(
         box.x + box.w - d,
         0,
         d,
         box.y,
     )
     cr.fill()
Example #5
0
 def drawAll(self, cr):
     width = self.get_allocation().width
     height = self.get_allocation().height
     pixelPerSec = self.pixelPerSec
     dayPixel = dayLen * pixelPerSec ## pixel
     maxTickHeight = maxTickHeightRatio * height
     #####
     cr.rectangle(0, 0, width, height)
     fillColor(cr, bgColor)
     #####
     setColor(cr, holidayBgBolor)
     for x in self.data['holidays']:
         cr.rectangle(x, 0, dayPixel, height)
         cr.fill()
     #####
     for tick in self.data['ticks']:
         self.drawTick(cr, tick, maxTickHeight)
     ######
     beforeBoxH = maxTickHeight ## FIXME
     maxBoxH = height - beforeBoxH
     for box in self.data['boxes']:
         box.setPixelValues(self.timeStart, pixelPerSec, beforeBoxH, maxBoxH)
         self.drawBox(cr, box)
     self.drawBoxEditingHelperLines(cr)
     ###### Draw Current Time Marker
     dt = self.currentTime - self.timeStart
     if 0 <= dt <= self.timeWidth:
         setColor(cr, currentTimeMarkerColor)
         cr.rectangle(
             dt*pixelPerSec - currentTimeMarkerWidth/2.0,
             0,
             currentTimeMarkerWidth,
             currentTimeMarkerHeightRatio * self.get_allocation().height
         )
         cr.fill()
     ######
     for button in self.buttons:
         button.draw(cr, width, height)
Example #6
0
 def drawAll(self, cr):
     width = self.get_allocation().width
     height = self.get_allocation().height
     pixelPerSec = self.pixelPerSec
     dayPixel = dayLen * pixelPerSec  ## pixel
     maxTickHeight = maxTickHeightRatio * height
     #####
     cr.rectangle(0, 0, width, height)
     fillColor(cr, bgColor)
     #####
     setColor(cr, holidayBgBolor)
     for x in self.data['holidays']:
         cr.rectangle(x, 0, dayPixel, height)
         cr.fill()
     #####
     for tick in self.data['ticks']:
         self.drawTick(cr, tick, maxTickHeight)
     ######
     beforeBoxH = maxTickHeight  ## FIXME
     maxBoxH = height - beforeBoxH
     for box in self.data['boxes']:
         box.setPixelValues(self.timeStart, pixelPerSec, beforeBoxH,
                            maxBoxH)
         self.drawBox(cr, box)
     self.drawBoxEditingHelperLines(cr)
     ###### Draw Current Time Marker
     dt = self.currentTime - self.timeStart
     if 0 <= dt <= self.timeWidth:
         setColor(cr, currentTimeMarkerColor)
         cr.rectangle(
             dt * pixelPerSec - currentTimeMarkerWidth / 2.0, 0,
             currentTimeMarkerWidth,
             currentTimeMarkerHeightRatio * self.get_allocation().height)
         cr.fill()
     ######
     for button in self.buttons:
         button.draw(cr, width, height)
Example #7
0
 def onExposeEvent(self, widget=None, event=None):
     t0 = time.time()
     w = self.allocation.width
     h = self.allocation.height
     cr = self.window.cairo_create()
     cr.rectangle(0, 0, w, h)
     fillColor(cr, ui.bgColor)
     setColor(cr, ui.wcalTextColor)
     status = getCurrentWeekStatus()
     rowH = (h-self.topMargin)/7
     widthList = []
     expandIndex = []
     for (i, item) in enumerate(self.rowItems):
         widthList.append(item.width + self.widthSpacing)
         if item.expand:
             expandIndex.append(i)
     extraWidth = float(w - sum(widthList)) / len(expandIndex)
     for i in expandIndex:
         widthList[i] += extraWidth
     del expandIndex
     for (i, row) in enumerate(status):
         y = self.topMargin + i*rowH
         cr.rectangle(0, 0, w, h)
         #fillColor(cr, bgColor)
         if rtl:
             x = w
         else:
             x = 0
         for (j, item) in enumerate(self.rowItems):
             itemW = widthList[j]
             text = item.getText(row).decode('utf8')
             if text:
                 layout = newLimitedWidthTextLayout(self, text, itemW)
                 if layout:
                     layoutW, layoutH = layout.get_pixel_size()
                     layoutX = x + item.textAlign * (itemW-layoutW)
                     if rtl:
                         layoutX -= itemW
                     cr.move_to(layoutX, y+(rowH - layoutH)/2)
                     if row.holiday and item.holidayColorize:
                         setColor(cr, ui.holidayColor)
                     else:
                         setColor(cr, ui.wcalTextColor)
                     cr.show_layout(layout)
             x = x - rtlSgn() * itemW
     for button in self.buttons:
         button.draw(cr, w, h)
     #print time.time()-t0
     return False