Esempio n. 1
0
	def onConfigChange(self, *a, **kw):
		CustomizableCalObj.onConfigChange(self, *a, **kw)
		#####
		for child in self.get_children():
			child.destroy()
		###
		monthLabels = []
		mode = calTypes.primary
		##
		box = YearLabelButtonBox(mode)
		pack(self, box)
		self.appendItem(box.label)
		##
		pack(self, gtk.VSeparator(), 1, 1)
		##
		box = MonthLabelButtonBox(mode)
		pack(self, box)
		self.appendItem(box.label)
		monthLabels.append(box.label)
		####
		for i, mode in list(enumerate(calTypes.active))[1:]:
			pack(self, gtk.VSeparator(), 1, 1)
			label = YearLabel(mode)
			pack(self, label)
			self.appendItem(label)
			###############
			label = gtk.Label("")
			label.set_property("width-request", 5)
			pack(self, label)
			###############
			label = MonthLabel(mode)
			pack(self, label)
			monthLabels.append(label)
			self.appendItem(label)
		####
		## updateTextWidth
		lay = newTextLayout(self)
		for label in monthLabels:
			wm = 0
			for m in range(12):
				name = getMonthName(label.mode, m)
				if ui.boldYmLabel:
					lay.set_markup("<b>%s</b>" % name, -1)
				else:
					lay.set_markup(name, -1)
					# lay.set_text(name) gives exception in Fedora with gtk 3.24.14 and gi 3.34.0
					# while works in Debian with same gtk and gi version
				w = lay.get_pixel_size()[0]
				if w > wm:
					wm = w
			label.set_property("width-request", wm)
		#####
		self.show_all()
		#####
		self.onDateChange()
Esempio n. 2
0
 def onConfigChange(self, *a, **kw):
     CustomizableCalObj.onConfigChange(self, *a, **kw)
     #####
     for child in self.get_children():
         child.destroy()
     ###
     monthLabels = []
     mode = calTypes.primary
     ##
     box = YearLabelButtonBox(mode)
     pack(self, box)
     self.appendItem(box.label)
     ##
     pack(self, gtk.VSeparator(), 1, 1)
     ##
     box = MonthLabelButtonBox(mode)
     pack(self, box)
     self.appendItem(box.label)
     monthLabels.append(box.label)
     ####
     for i, mode in list(enumerate(calTypes.active))[1:]:
         pack(self, gtk.VSeparator(), 1, 1)
         label = YearLabel(mode)
         pack(self, label)
         self.appendItem(label)
         ###############
         label = gtk.Label("")
         label.set_property("width-request", 5)
         pack(self, label)
         ###############
         label = MonthLabel(mode)
         pack(self, label)
         monthLabels.append(label)
         self.appendItem(label)
     ####
     ## updateTextWidth
     lay = newTextLayout(self)
     for label in monthLabels:
         wm = 0
         for m in range(12):
             name = getMonthName(label.mode, m)
             if ui.boldYmLabel:
                 lay.set_markup("<b>%s</b>" % name)
             else:
                 lay.set_text(name)  ## OR lay.set_markup
             w = lay.get_pixel_size()[0]
             if w > wm:
                 wm = w
         label.set_property("width-request", wm)
     #####
     self.show_all()
     #####
     self.onDateChange()
Esempio n. 3
0
	def onConfigChange(self, *a, **kw):
		CustomizableCalObj.onConfigChange(self, *a, **kw)
		#####
		for child in self.get_children():
			child.destroy()
		###
		monthLabels = []
		mode = calTypes.primary
		##
		box = YearLabelButtonBox(mode)
		pack(self, box)
		self.appendItem(box.label)
		##
		pack(self, gtk.VSeparator(), 1, 1)
		##
		box = MonthLabelButtonBox(mode)
		pack(self, box)
		self.appendItem(box.label)
		monthLabels.append(box.label)
		####
		for i, mode in list(enumerate(calTypes.active))[1:]:
			pack(self, gtk.VSeparator(), 1, 1)
			label = YearLabel(mode)
			pack(self, label)
			self.appendItem(label)
			###############
			label = gtk.Label('')
			label.set_property('width-request', 5)
			pack(self, label)
			###############
			label = MonthLabel(mode)
			pack(self, label)
			monthLabels.append(label)
			self.appendItem(label)
		####
		## updateTextWidth
		lay = newTextLayout(self)
		for label in monthLabels:
			wm = 0
			for m in range(12):
				name = getMonthName(label.mode, m)
				if ui.boldYmLabel:
					lay.set_markup('<b>%s</b>'%name)
				else:
					lay.set_text(name) ## OR lay.set_markup
				w = lay.get_pixel_size()[0]
				if w > wm:
					wm = w
			label.set_property('width-request', wm)
		#####
		self.show_all()
		#####
		self.onDateChange()
Esempio n. 4
0
	def drawTick(self, cr, tick, maxTickHeight):
		tickH = tick.height
		tickW = tick.width
		tickH = min(tickH, maxTickHeight)
		###
		tickX = tick.pos - tickW / 2.0
		tickY = 1
		cr.rectangle(tickX, tickY, tickW, tickH)
		try:
			fillColor(cr, tick.color)
		except:
			print(
				"error in fill" +
				", x=%.2f, y=%.2f" % (tickX, tickY) +
				", w=%.2f, h=%.2f" % (tickW, tickH)
			)
		###
		font = [
			fontFamily,
			False,
			False,
			tick.fontSize,
		]
		#layout = newLimitedWidthTextLayout(
		#	self,
		#	tick.label,
		#	tick.maxLabelWidth,
		#	font=font,
		#	truncate=truncateTickLabel,
		#)  # FIXME
		layout = newTextLayout(
			self,
			text=tick.label,
			font=font,
			maxSize=(tick.maxLabelWidth, 0),
			maximizeScale=1.0,
			truncate=truncateTickLabel,
		)  # FIXME
		if layout:
			#layout.set_auto_dir(0)  # FIXME
			#print("layout.get_auto_dir() = %s"%layout.get_auto_dir())
			layoutW, layoutH = layout.get_pixel_size()
			layoutX = tick.pos - layoutW / 2.0
			layoutY = tickH * labelYRatio
			try:
				cr.move_to(layoutX, layoutY)
			except:
				print("error in move_to, x=%.2f, y=%.2f" % (layoutX, layoutY))
			else:
				show_layout(cr, layout)## with the same tick.color
Esempio n. 5
0
 def drawTick(self, cr, tick, maxTickHeight):
     tickH = tick.height
     tickW = tick.width
     tickH = min(tickH, maxTickHeight)
     ###
     tickX = tick.pos - tickW / 2.0
     tickY = 1
     cr.rectangle(tickX, tickY, tickW, tickH)
     try:
         fillColor(cr, tick.color)
     except:
         print('error in fill, x=%.2f, y=%.2f, w=%.2f, h=%.2f' %
               (tickX, tickY, tickW, tickH))
     ###
     font = [
         fontFamily,
         False,
         False,
         tick.fontSize,
     ]
     #layout = newLimitedWidthTextLayout(
     #    self,
     #    tick.label,
     #    tick.maxLabelWidth,
     #    font=font,
     #    truncate=truncateTickLabel,
     #)## FIXME
     layout = newTextLayout(
         self,
         text=tick.label,
         font=font,
         maxSize=(tick.maxLabelWidth, 0),
         maximizeScale=1.0,
         truncate=truncateTickLabel,
     )  ## FIXME
     if layout:
         #layout.set_auto_dir(0)## FIXME
         #print('layout.get_auto_dir() = %s'%layout.get_auto_dir())
         layoutW, layoutH = layout.get_pixel_size()
         layoutX = tick.pos - layoutW / 2.0
         layoutY = tickH * labelYRatio
         try:
             cr.move_to(layoutX, layoutY)
         except:
             print('error in move_to, x=%.2f, y=%.2f' % (layoutX, layoutY))
         else:
             show_layout(cr, layout)  ## with the same tick.color