eric6/Graphics/ClassItem.py

changeset 7529
2b8a0d8ba12a
parent 7360
9190402e4505
child 7780
41420f82c0ac
equal deleted inserted replaced
7528:0345f54d3959 7529:2b8a0d8ba12a
73 Class implementing an UML like class item. 73 Class implementing an UML like class item.
74 """ 74 """
75 ItemType = "class" 75 ItemType = "class"
76 76
77 def __init__(self, model=None, external=False, x=0, y=0, 77 def __init__(self, model=None, external=False, x=0, y=0,
78 rounded=False, noAttrs=False, parent=None, scene=None): 78 rounded=False, noAttrs=False, colors=None, parent=None,
79 scene=None):
79 """ 80 """
80 Constructor 81 Constructor
81 82
82 @param model class model containing the class data (ClassModel) 83 @param model class model containing the class data
84 @type ClassModel
83 @param external flag indicating a class defined outside our scope 85 @param external flag indicating a class defined outside our scope
84 (boolean) 86 @type boolean
85 @param x x-coordinate (integer) 87 @param x x-coordinate
86 @param y y-coordinate (integer) 88 @type int
87 @keyparam rounded flag indicating a rounded corner (boolean) 89 @param y y-coordinate
88 @keyparam noAttrs flag indicating, that no attributes should be shown 90 @type int
89 (boolean) 91 @param rounded flag indicating a rounded corner
90 @keyparam parent reference to the parent object (QGraphicsItem) 92 @type bool
91 @keyparam scene reference to the scene object (QGraphicsScene) 93 @param noAttrs flag indicating, that no attributes should be shown
92 """ 94 @type bool
93 UMLItem.__init__(self, model, x, y, rounded, parent) 95 @param colors tuple containing the foreground and background colors
96 @type tuple of (QColor, QColor)
97 @param parent reference to the parent object
98 @type QGraphicsItem
99 @param scene reference to the scene object
100 @type QGraphicsScene
101 """
102 UMLItem.__init__(self, model, x, y, rounded, colors, parent)
94 103
95 self.external = external 104 self.external = external
96 self.noAttrs = noAttrs 105 self.noAttrs = noAttrs
97 106
98 scene.addItem(self) 107 scene.addItem(self)
115 meths = self.model.getMethods() 124 meths = self.model.getMethods()
116 125
117 x = self.margin + self.rect().x() 126 x = self.margin + self.rect().x()
118 y = self.margin + self.rect().y() 127 y = self.margin + self.rect().y()
119 self.header = QGraphicsSimpleTextItem(self) 128 self.header = QGraphicsSimpleTextItem(self)
129 self.header.setBrush(self._colors[0])
120 self.header.setFont(boldFont) 130 self.header.setFont(boldFont)
121 self.header.setText(self.model.getName()) 131 self.header.setText(self.model.getName())
122 self.header.setPos(x, y) 132 self.header.setPos(x, y)
123 y += self.header.boundingRect().height() + self.margin 133 y += self.header.boundingRect().height() + self.margin
124 if not self.noAttrs and not self.external: 134 if not self.noAttrs and not self.external:
125 if attrs: 135 if attrs:
126 txt = "\n".join(attrs) 136 txt = "\n".join(attrs)
127 else: 137 else:
128 txt = " " 138 txt = " "
129 self.attrs = QGraphicsSimpleTextItem(self) 139 self.attrs = QGraphicsSimpleTextItem(self)
140 self.attrs.setBrush(self._colors[0])
130 self.attrs.setFont(self.font) 141 self.attrs.setFont(self.font)
131 self.attrs.setText(txt) 142 self.attrs.setText(txt)
132 self.attrs.setPos(x, y) 143 self.attrs.setPos(x, y)
133 y += self.attrs.boundingRect().height() + self.margin 144 y += self.attrs.boundingRect().height() + self.margin
134 else: 145 else:
136 if meths: 147 if meths:
137 txt = "\n".join(meths) 148 txt = "\n".join(meths)
138 else: 149 else:
139 txt = " " 150 txt = " "
140 self.meths = QGraphicsSimpleTextItem(self) 151 self.meths = QGraphicsSimpleTextItem(self)
152 self.meths.setBrush(self._colors[0])
141 self.meths.setFont(self.font) 153 self.meths.setFont(self.font)
142 self.meths.setText(txt) 154 self.meths.setText(txt)
143 self.meths.setPos(x, y) 155 self.meths.setPos(x, y)
144 156
145 def __calculateSize(self): 157 def __calculateSize(self):

eric ide

mercurial