Merge branch 'dfsg-orig'
[debian/gnuradio] / grc / gui / Port.py
index d1f36f8b963659aea5d5e8130c8def7ffb3bd965..2896d04c18e0efae889198a503ed1bf99aaeaf52 100644 (file)
@@ -1,5 +1,5 @@
 """
-Copyright 2007 Free Software Foundation, Inc.
+Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
 This file is part of GNU Radio
 
 GNU Radio Companion is free software; you can redistribute it and/or
@@ -34,7 +34,7 @@ PORT_MARKUP_TMPL="""\
 class Port(Element):
        """The graphical port."""
 
-       def __init__(self, *args, **kwargs):
+       def __init__(self):
                """
                Port contructor.
                Create list of connector coordinates.
@@ -42,9 +42,9 @@ class Port(Element):
                Element.__init__(self)
                self.connector_coordinates = dict()
 
-       def update(self):
+       def create_shapes(self):
                """Create new areas and labels for the port."""
-               self.clear()
+               Element.create_shapes(self)
                #get current rotation
                rotation = self.get_rotation()
                #get all sibling ports
@@ -82,8 +82,9 @@ class Port(Element):
                #the connector length
                self._connector_length = CONNECTOR_EXTENSION_MINIMAL + CONNECTOR_EXTENSION_INCREMENT*index
 
-       def _create_labels(self):
+       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('')
@@ -96,12 +97,11 @@ class Port(Element):
                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)
+               #create vertical and horizontal pixmaps
+               self.horizontal_label = pixmap
                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))
+                       self.vertical_label = self.get_parent().get_parent().new_pixmap(self.h, self.w)
+                       Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
 
        def draw(self, gc, window):
                """
@@ -114,11 +114,11 @@ class Port(Element):
                        border_color=self.is_highlighted() and Colors.HIGHLIGHT_COLOR or Colors.BORDER_COLOR,
                )
                X,Y = self.get_coordinate()
-               (x,y),(w,h) = self.areas_dict[self.get_rotation()][0] #use the first area's sizes to place the labels
+               (x,y),(w,h) = self._areas_list[0] #use the first area's sizes to place the labels
                if self.is_horizontal():
-                       window.draw_image(gc, self.horizontal_label, 0, 0, x+X+(self.W-self.w)/2, y+Y+(self.H-self.h)/2, -1, -1)
+                       window.draw_drawable(gc, self.horizontal_label, 0, 0, x+X+(self.W-self.w)/2, y+Y+(self.H-self.h)/2, -1, -1)
                elif self.is_vertical():
-                       window.draw_image(gc, self.vertical_label, 0, 0, x+X+(self.H-self.h)/2, y+Y+(self.W-self.w)/2, -1, -1)
+                       window.draw_drawable(gc, self.vertical_label, 0, 0, x+X+(self.H-self.h)/2, y+Y+(self.W-self.w)/2, -1, -1)
 
        def get_connector_coordinate(self):
                """