예제 #1
0
 def highlight(self, widget=None, event=None):
     #self.drag_highlight()
     if self.get_window() is 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()
예제 #2
0
파일: labelBox.py 프로젝트: ilius/starcal
 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()
예제 #3
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()
예제 #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()
예제 #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)
예제 #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)
예제 #7
0
파일: timeline.py 프로젝트: ilius/starcal
	def drawAll(self, cr):
		timeStart = self.timeStart
		timeWidth = self.timeWidth
		timeEnd = timeStart + timeWidth
		####
		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(timeStart, pixelPerSec, beforeBoxH, maxBoxH)
			self.drawBox(cr, box)
		self.drawBoxEditingHelperLines(cr)
		###### Show (possible) Daylight Saving change
		if timeStart > 0 and 2 * 3600 < timeWidth < 30 * dayLen:
			if getUtcOffsetByEpoch(timeStart) != getUtcOffsetByEpoch(timeEnd):
				startJd = getJdFromEpoch(timeStart)
				endJd = getJdFromEpoch(timeEnd)
				lastOffset = getUtcOffsetByJd(startJd, localTz)
				dstChangeJd = None
				deltaSec = 0
				for jd in range(startJd + 1, endJd + 1):
					offset = getUtcOffsetByJd(jd, localTz)
					deltaSec = offset - lastOffset
					if deltaSec != 0:
						dstChangeJd = jd
						break
				if dstChangeJd is not None:
					deltaHour = deltaSec / 3600.0
					dstChangeEpoch = getEpochFromJd(dstChangeJd)
					#print("dstChangeEpoch = %s" % dstChangeEpoch)
				else:
					print("dstChangeEpoch not found")

		###### Draw Current Time Marker
		dt = self.currentTime - timeStart
		if 0 <= dt <= 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)
예제 #8
0
    def drawAll(self, cr):
        timeStart = self.timeStart
        timeWidth = self.timeWidth
        timeEnd = timeStart + timeWidth
        ####
        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(timeStart, pixelPerSec, beforeBoxH, maxBoxH)
            self.drawBox(cr, box)
        self.drawBoxEditingHelperLines(cr)
        ###### Show (possible) Daylight Saving change
        if timeStart > 0 and 2 * 3600 < timeWidth < 30 * dayLen:
            if getUtcOffsetByEpoch(timeStart) != getUtcOffsetByEpoch(timeEnd):
                startJd = getJdFromEpoch(timeStart)
                endJd = getJdFromEpoch(timeEnd)
                lastOffset = getUtcOffsetByJd(startJd, localTz)
                dstChangeJd = None
                deltaSec = 0
                for jd in range(startJd + 1, endJd + 1):
                    offset = getUtcOffsetByJd(jd, localTz)
                    deltaSec = offset - lastOffset
                    if deltaSec != 0:
                        dstChangeJd = jd
                        break
                if dstChangeJd is not None:
                    deltaHour = deltaSec / 3600.0
                    dstChangeEpoch = getEpochFromJd(dstChangeJd)
                    #print("dstChangeEpoch = %s" % dstChangeEpoch)
                else:
                    print("dstChangeEpoch not found")

        ###### Draw Current Time Marker
        dt = self.currentTime - timeStart
        if 0 <= dt <= 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)