Esempio n. 1
0
 def create_labels(self):
     """Create the labels for the socket."""
     Element.create_labels(self)
     self._bg_color = Colors.get_color(self.get_color())
     # create the layout
     layout = gtk.DrawingArea().create_pango_layout('')
     layout.set_markup(
         Utils.parse_template(PORT_MARKUP_TMPL, port=self, font=PORT_FONT))
     self.w, self.h = layout.get_pixel_size()
     self.W = 2 * PORT_LABEL_PADDING + self.w
     self.H = 2 * PORT_LABEL_PADDING + self.h * (3 if self.get_type()
                                                 == 'bus' else 1)
     self.H += self.H % 2
     # create the pixmap
     pixmap = self.get_parent().get_parent().new_pixmap(self.w, self.h)
     gc = pixmap.new_gc()
     gc.set_foreground(self._bg_color)
     pixmap.draw_rectangle(gc, True, 0, 0, self.w, self.h)
     pixmap.draw_layout(gc, 0, 0, layout)
     # create vertical and horizontal pixmaps
     self.horizontal_label = pixmap
     if self.is_vertical():
         self.vertical_label = self.get_parent().get_parent().new_pixmap(
             self.h, self.w)
         Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
Esempio n. 2
0
 def create_labels(self):
     """Create the labels for the signal block."""
     Element.create_labels(self)
     self._bg_color = self.is_dummy_block() and Colors.MISSING_BLOCK_BACKGROUND_COLOR or \
                      self.get_enabled() and Colors.BLOCK_ENABLED_COLOR or Colors.BLOCK_DISABLED_COLOR
     layouts = list()
     #create the main layout
     layout = gtk.DrawingArea().create_pango_layout('')
     layouts.append(layout)
     layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self))
     self.label_width, self.label_height = layout.get_pixel_size()
     #display the params
     if self.is_dummy_block():
         markups = [
             '<span foreground="black" font_desc="Sans 7.5"><b>key: </b>{}</span>'
             .format(self._key)
         ]
     else:
         markups = [
             param.get_markup() for param in self.get_params()
             if param.get_hide() not in ('all', 'part')
         ]
     if markups:
         layout = gtk.DrawingArea().create_pango_layout('')
         layout.set_spacing(LABEL_SEPARATION * pango.SCALE)
         layout.set_markup('\n'.join(markups))
         layouts.append(layout)
         w, h = layout.get_pixel_size()
         self.label_width = max(w, self.label_width)
         self.label_height += h + LABEL_SEPARATION
     width = self.label_width
     height = self.label_height
     #setup the pixmap
     pixmap = self.get_parent().new_pixmap(width, height)
     gc = pixmap.new_gc()
     gc.set_foreground(self._bg_color)
     pixmap.draw_rectangle(gc, True, 0, 0, width, height)
     #draw the layouts
     h_off = 0
     for i, layout in enumerate(layouts):
         w, h = layout.get_pixel_size()
         if i == 0: w_off = (width - w) / 2
         else: w_off = 0
         pixmap.draw_layout(gc, w_off, h_off, layout)
         h_off = h + h_off + LABEL_SEPARATION
     #create vertical and horizontal pixmaps
     self.horizontal_label = pixmap
     if self.is_vertical():
         self.vertical_label = self.get_parent().new_pixmap(height, width)
         Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
     #calculate width and height needed
     self.W = self.label_width + 2 * BLOCK_LABEL_PADDING
     self.H = max(*(
         [self.label_height+2*BLOCK_LABEL_PADDING] + [2*PORT_BORDER_SEPARATION + \
         sum([port.H + PORT_SEPARATION for port in ports]) - PORT_SEPARATION
         for ports in (self.get_sources_gui(), self.get_sinks_gui())] +
         [4*PORT_BORDER_SEPARATION + \
         sum([(port.H) + PORT_SEPARATION for port in ports]) - PORT_SEPARATION
         for ports in ([i for i in self.get_sources_gui() if i.get_type() == 'bus'], [i for i in self.get_sinks_gui() if i.get_type() == 'bus'])]
     ))
Esempio n. 3
0
	def create_labels(self):
		"""Create the labels for the signal block."""
		Element.create_labels(self)
		self._bg_color = self.get_enabled() and Colors.BLOCK_ENABLED_COLOR or Colors.BLOCK_DISABLED_COLOR
		layouts = list()
	
		#create the main layout
		layout = gtk.DrawingArea().create_pango_layout('')
		layouts.append(layout)

		layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self))
		
		self.label_width, self.label_height = layout.get_pixel_size()
		height_rect = self.label_height
		#display the params
		markups = [param.get_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')]
		if markups:
			layout = gtk.DrawingArea().create_pango_layout('')
			layout.set_spacing(LABEL_SEPARATION*pango.SCALE)
			layout.set_markup('\n'.join(markups))
			layouts.append(layout)
			w,h = layout.get_pixel_size()
			self.label_width = max(w, self.label_width)
			#print w,self.label_width
			self.label_height += h + LABEL_SEPARATION
		width = self.label_width
		height = self.label_height
	
		#setup the pixmap
		pixmap = self.get_parent().new_pixmap(width, height)
		gc = pixmap.new_gc()
		gc.set_foreground(self._bg_color)
		pixmap.draw_rectangle(gc, True, 0, 0, width, height)
		#draw the layouts
	#	width_rect=width

		h_off = 0
		for i,layout in enumerate(layouts):
			w,h = layout.get_pixel_size()
			if i == 0: w_off = (width-w)/2
			else: w_off = 0
			pixmap.draw_layout(gc, w_off, h_off, layout)
			h_off = h + h_off + LABEL_SEPARATION
		#create vertical and horizontal pixmaps
		gc.set_foreground(Colors.BORDER_COLOR)
		pixmap.draw_rectangle(gc,False,0,0,width-1,height_rect-1)
		gc.set_foreground(self._bg_color)
		self.horizontal_label = pixmap
		if self.is_vertical():
			self.vertical_label = self.get_parent().new_pixmap(height, width)
			Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
		#calculate width and height needed
		self.W = self.label_width + 2*BLOCK_LABEL_PADDING
		self.H = max(*(
			[self.label_height+2*BLOCK_LABEL_PADDING] + [2*PORT_BORDER_SEPARATION + \
			sum([port.H + PORT_SEPARATION for port in ports]) - PORT_SEPARATION
			for ports in (self.get_sources(), self.get_sinks())]
		))
Esempio n. 4
0
 def create_labels(self):
     """Create the labels for the signal block."""
     Element.create_labels(self)
     self._bg_color = self.is_dummy_block() and Colors.MISSING_BLOCK_BACKGROUND_COLOR or \
                      self.get_enabled() and Colors.BLOCK_ENABLED_COLOR or Colors.BLOCK_DISABLED_COLOR
     layouts = list()
     #create the main layout
     layout = gtk.DrawingArea().create_pango_layout('')
     layouts.append(layout)
     layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self))
     self.label_width, self.label_height = layout.get_pixel_size()
     #display the params
     if self.is_dummy_block():
         markups = ['<span foreground="black" font_desc="Sans 7.5"><b>key: </b>{}</span>'.format(self._key)]
     else:
         markups = [param.get_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')]
     if markups:
         layout = gtk.DrawingArea().create_pango_layout('')
         layout.set_spacing(LABEL_SEPARATION*pango.SCALE)
         layout.set_markup('\n'.join(markups))
         layouts.append(layout)
         w,h = layout.get_pixel_size()
         self.label_width = max(w, self.label_width)
         self.label_height += h + LABEL_SEPARATION
     width = self.label_width
     height = self.label_height
     #setup the pixmap
     pixmap = self.get_parent().new_pixmap(width, height)
     gc = pixmap.new_gc()
     gc.set_foreground(self._bg_color)
     pixmap.draw_rectangle(gc, True, 0, 0, width, height)
     #draw the layouts
     h_off = 0
     for i,layout in enumerate(layouts):
         w,h = layout.get_pixel_size()
         if i == 0: w_off = (width-w)/2
         else: w_off = 0
         pixmap.draw_layout(gc, w_off, h_off, layout)
         h_off = h + h_off + LABEL_SEPARATION
     #create vertical and horizontal pixmaps
     self.horizontal_label = pixmap
     if self.is_vertical():
         self.vertical_label = self.get_parent().new_pixmap(height, width)
         Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
     #calculate width and height needed
     self.W = self.label_width + 2*BLOCK_LABEL_PADDING
     self.H = max(*(
         [self.label_height+2*BLOCK_LABEL_PADDING] + [2*PORT_BORDER_SEPARATION + \
         sum([port.H + PORT_SEPARATION for port in ports]) - PORT_SEPARATION
         for ports in (self.get_sources_gui(), self.get_sinks_gui())] + 
         [4*PORT_BORDER_SEPARATION + \
         sum([(port.H) + PORT_SEPARATION for port in ports]) - PORT_SEPARATION
         for ports in ([i for i in self.get_sources_gui() if i.get_type() == 'bus'], [i for i in self.get_sinks_gui() if i.get_type() == 'bus'])]
     ))
Esempio n. 5
0
File: Block.py Progetto: jinjoh/SDR
	def create_labels(self):
		"""Create the labels for the signal block."""
		Element.create_labels(self)
		self._bg_color = self.get_enabled() and Colors.BLOCK_ENABLED_COLOR or Colors.BLOCK_DISABLED_COLOR
		layouts = list()
		#create the main layout
		layout = gtk.DrawingArea().create_pango_layout('')
		layouts.append(layout)
		layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self))
		self.label_width, self.label_height = layout.get_pixel_size()
		#display the params
		for param in filter(lambda p: p.get_hide() not in ('all', 'part'), self.get_params()):
			layout = param.get_layout()
			layouts.append(layout)
			w,h = layout.get_pixel_size()
			self.label_width = max(w, self.label_width)
			self.label_height += h + LABEL_SEPARATION
		width = self.label_width
		height = self.label_height
		#setup the pixmap
		pixmap = self.get_parent().new_pixmap(width, height)
		gc = pixmap.new_gc()
		gc.set_foreground(self._bg_color)
		pixmap.draw_rectangle(gc, True, 0, 0, width, height)
		#draw the layouts
		h_off = 0
		for i,layout in enumerate(layouts):
			w,h = layout.get_pixel_size()
			if i == 0: w_off = (width-w)/2
			else: w_off = 0
			pixmap.draw_layout(gc, w_off, h_off, layout)
			h_off = h + h_off + LABEL_SEPARATION
		#create vertical and horizontal images
		self.horizontal_label = image = pixmap.get_image(0, 0, width, height)
		if self.is_vertical():
			self.vertical_label = vimage = gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), height, width)
			for i in range(width):
				for j in range(height): vimage.put_pixel(j, width-i-1, image.get_pixel(i, j))
		#calculate width and height needed
		self.W = self.label_width + 2*BLOCK_LABEL_PADDING
		self.H = max(*(
			[self.label_height+2*BLOCK_LABEL_PADDING] + [2*PORT_BORDER_SEPARATION + \
			sum([port.H + PORT_SEPARATION for port in ports]) - PORT_SEPARATION
			for ports in (self.get_sources(), self.get_sinks())]
		))
Esempio n. 6
0
	def create_labels(self):
		"""Create the labels for the socket."""
		Element.create_labels(self)
		self._bg_color = Colors.get_color(self.get_color())
		#create the layout
		layout = gtk.DrawingArea().create_pango_layout('')
		layout.set_markup(Utils.parse_template(PORT_MARKUP_TMPL, port=self))
		self.w, self.h = layout.get_pixel_size()
		self.W, self.H = 2*PORT_LABEL_PADDING+self.w, 2*PORT_LABEL_PADDING+self.h
		#create the pixmap
		pixmap = self.get_parent().get_parent().new_pixmap(self.w, self.h)
		gc = pixmap.new_gc()
		gc.set_foreground(self._bg_color)
		pixmap.draw_rectangle(gc, True, 0, 0, self.w, self.h)
		pixmap.draw_layout(gc, 0, 0, layout)
		#create vertical and horizontal pixmaps
		self.horizontal_label = pixmap
		if self.is_vertical():
			self.vertical_label = self.get_parent().get_parent().new_pixmap(self.h, self.w)
			Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
Esempio n. 7
0
File: Port.py Progetto: jinjoh/SDR
	def create_labels(self):
		"""Create the labels for the socket."""
		Element.create_labels(self)
		self._bg_color = Colors.get_color(self.get_color())
		#create the layout
		layout = gtk.DrawingArea().create_pango_layout('')
		layout.set_markup(Utils.parse_template(PORT_MARKUP_TMPL, port=self))
		self.w, self.h = layout.get_pixel_size()
		self.W, self.H = 2*PORT_LABEL_PADDING+self.w, 2*PORT_LABEL_PADDING+self.h
		#create the pixmap
		pixmap = self.get_parent().get_parent().new_pixmap(self.w, self.h)
		gc = pixmap.new_gc()
		gc.set_foreground(self._bg_color)
		pixmap.draw_rectangle(gc, True, 0, 0, self.w, self.h)
		pixmap.draw_layout(gc, 0, 0, layout)
		#create the images
		self.horizontal_label = image = pixmap.get_image(0, 0, self.w, self.h)
		if self.is_vertical():
			self.vertical_label = vimage = gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), self.h, self.w)
			for i in range(self.w):
				for j in range(self.h): vimage.put_pixel(j, self.w-i-1, image.get_pixel(i, j))
Esempio n. 8
0
    def create_labels(self):
        """Create the labels for the signal block."""
        Element.create_labels(self)
        self._bg_color = self.is_dummy_block() and Colors.MISSING_BLOCK_BACKGROUND_COLOR or \
                         self.get_bypassed() and Colors.BLOCK_BYPASSED_COLOR or \
                         self.get_enabled() and Colors.BLOCK_ENABLED_COLOR or Colors.BLOCK_DISABLED_COLOR

        layouts = list()
        #create the main layout
        layout = gtk.DrawingArea().create_pango_layout('')
        layouts.append(layout)
        layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self, font=BLOCK_FONT))
        self.label_width, self.label_height = layout.get_pixel_size()
        #display the params
        if self.is_dummy_block():
            markups = [
                '<span foreground="black" font_desc="$font"><b>key: </b>{key}</span>'.format(font=PARAM_FONT, key=self._key)
            ]
        else:
            markups = [param.get_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')]
        if markups:
            layout = gtk.DrawingArea().create_pango_layout('')
            layout.set_spacing(LABEL_SEPARATION*pango.SCALE)
            layout.set_markup('\n'.join(markups))
            layouts.append(layout)
            w,h = layout.get_pixel_size()
            self.label_width = max(w, self.label_width)
            self.label_height += h + LABEL_SEPARATION
        width = self.label_width
        height = self.label_height
        #setup the pixmap
        pixmap = self.get_parent().new_pixmap(width, height)
        gc = pixmap.new_gc()
        gc.set_foreground(self._bg_color)
        pixmap.draw_rectangle(gc, True, 0, 0, width, height)
        #draw the layouts
        h_off = 0
        for i,layout in enumerate(layouts):
            w,h = layout.get_pixel_size()
            if i == 0: w_off = (width-w)/2
            else: w_off = 0
            pixmap.draw_layout(gc, w_off, h_off, layout)
            h_off = h + h_off + LABEL_SEPARATION
        #create vertical and horizontal pixmaps
        self.horizontal_label = pixmap
        if self.is_vertical():
            self.vertical_label = self.get_parent().new_pixmap(height, width)
            Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
        #calculate width and height needed
        self.W = self.label_width + 2 * BLOCK_LABEL_PADDING

        def get_min_height_for_ports():
            visible_ports = filter(lambda p: not p.get_hide(), ports)
            H = 2*PORT_BORDER_SEPARATION + len(visible_ports) * PORT_SEPARATION
            if visible_ports: H -= ports[0].H
            return H
        self.H = max(
            [  # labels
                self.label_height + 2 * BLOCK_LABEL_PADDING
            ] +
            [  # ports
                get_min_height_for_ports() for ports in (self.get_sources_gui(), self.get_sinks_gui())
            ] +
            [  # bus ports only
                2 * PORT_BORDER_SEPARATION +
                sum([port.H + PORT_SPACING for port in ports if port.get_type() == 'bus']) - PORT_SPACING
                for ports in (self.get_sources_gui(), self.get_sinks_gui())
            ]
        )
        self.has_busses = [
            any(port.get_type() == 'bus' for port in ports)
            for ports in (self.get_sources_gui(), self.get_sinks_gui())
        ]
        self.create_comment_label()
Esempio n. 9
0
    def create_labels(self):
        """Create the labels for the signal block."""
        Element.create_labels(self)
        self._bg_color = self.is_dummy_block() and Colors.MISSING_BLOCK_BACKGROUND_COLOR or \
                         self.get_bypassed() and Colors.BLOCK_BYPASSED_COLOR or \
                         self.get_enabled() and Colors.BLOCK_ENABLED_COLOR or Colors.BLOCK_DISABLED_COLOR

        layouts = list()
        #create the main layout
        layout = gtk.DrawingArea().create_pango_layout('')
        layouts.append(layout)
        layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self, font=BLOCK_FONT))
        self.label_width, self.label_height = layout.get_pixel_size()
        #display the params
        if self.is_dummy_block():
            markups = [
                '<span foreground="black" font_desc="$font"><b>key: </b>{key}</span>'.format(font=PARAM_FONT, key=self._key)
            ]
        else:
            markups = [param.get_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')]
        if markups:
            layout = gtk.DrawingArea().create_pango_layout('')
            layout.set_spacing(LABEL_SEPARATION*pango.SCALE)
            layout.set_markup('\n'.join(markups))
            layouts.append(layout)
            w,h = layout.get_pixel_size()
            self.label_width = max(w, self.label_width)
            self.label_height += h + LABEL_SEPARATION
        width = self.label_width
        height = self.label_height
        #setup the pixmap
        pixmap = self.get_parent().new_pixmap(width, height)
        gc = pixmap.new_gc()
        gc.set_foreground(self._bg_color)
        pixmap.draw_rectangle(gc, True, 0, 0, width, height)
        #draw the layouts
        h_off = 0
        for i,layout in enumerate(layouts):
            w,h = layout.get_pixel_size()
            if i == 0: w_off = (width-w)/2
            else: w_off = 0
            pixmap.draw_layout(gc, w_off, h_off, layout)
            h_off = h + h_off + LABEL_SEPARATION
        #create vertical and horizontal pixmaps
        self.horizontal_label = pixmap
        if self.is_vertical():
            self.vertical_label = self.get_parent().new_pixmap(height, width)
            Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
        #calculate width and height needed
        self.W = self.label_width + 2 * BLOCK_LABEL_PADDING

        def get_min_height_for_ports():
            visible_ports = filter(lambda p: not p.get_hide(), ports)
            H = 2*PORT_BORDER_SEPARATION + len(visible_ports) * PORT_SEPARATION
            if visible_ports: H -= ports[0].H
            return H
        self.H = max(
            [  # labels
                self.label_height + 2 * BLOCK_LABEL_PADDING
            ] +
            [  # ports
                get_min_height_for_ports() for ports in (self.get_sources_gui(), self.get_sinks_gui())
            ] +
            [  # bus ports only
                2 * PORT_BORDER_SEPARATION +
                sum([port.H + PORT_SPACING for port in ports if port.get_type() == 'bus']) - PORT_SPACING
                for ports in (self.get_sources_gui(), self.get_sinks_gui())
            ]
        )
        self.has_busses = [
            any(port.get_type() == 'bus' for port in ports)
            for ports in (self.get_sources_gui(), self.get_sinks_gui())
        ]
        self.create_comment_label()