Changeset 1193
- Timestamp:
- 04/04/07 22:50:42 (1 year ago)
- Files:
-
- gaphor/trunk/gaphor/adapters/editors.py (modified) (1 diff)
- gaphor/trunk/gaphor/diagram/__init__.py (modified) (1 diff)
- gaphor/trunk/gaphor/diagram/activitynodes.py (modified) (2 diffs)
- gaphor/trunk/gaphor/diagram/association.py (modified) (3 diffs)
- gaphor/trunk/gaphor/diagram/classifier.py (modified) (9 diffs)
- gaphor/trunk/gaphor/diagram/comment.py (modified) (1 diff)
- gaphor/trunk/gaphor/diagram/diagramline.py (modified) (2 diffs)
- gaphor/trunk/gaphor/diagram/feature.py (modified) (4 diffs)
- gaphor/trunk/gaphor/diagram/nameditem.py (modified) (2 diffs)
- gaphor/trunk/gaphor/diagram/package.py (modified) (2 diffs)
- gaphor/trunk/gaphor/diagram/style.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphor/trunk/gaphor/adapters/editors.py
r1121 r1193 154 154 155 155 self._edit = None 156 # Edit is in name compartment -> edit name 156 157 name_comp_height = self._item.get_name_size()[1] 157 158 if y < name_comp_height: 158 159 self._edit = self._item 159 160 return True 161 162 padding = self._item.style.compartment_padding 163 vspacing = self._item.style.compartment_vspacing 164 165 # place offset at top of first comparement 160 166 y -= name_comp_height 161 margin = self._item.style.compartment_margin[0] 162 vspacing = self._item.style.compartment_vspacing 167 y += vspacing / 2.0 163 168 for comp in self._item.compartments: 164 y -= margin169 y -= padding[0] 165 170 for item in comp: 166 y -= vspacing167 y -= item.height168 171 if y < item.height: 169 172 self._edit = item 170 173 return True 171 y -= margin 174 y -= item.height 175 y -= vspacing 176 y -= padding[2] 177 # Compensate for last substraction action 178 y += vspacing 172 179 return False 173 180 gaphor/trunk/gaphor/diagram/__init__.py
r1170 r1193 97 97 from gaphor.undomanager import get_undo_manager, transactional 98 98 99 print 'state', state100 99 state.observers.add(state.revert_handler) 101 100 gaphor/trunk/gaphor/diagram/activitynodes.py
r1178 r1193 5 5 import math 6 6 7 from gaphas.util import path_ellipse 7 from gaphas.util import path_ellipse, text_align 8 8 from gaphas.state import observed, reversible_property 9 9 … … 217 217 218 218 if isinstance(self.subject, UML.JoinNode): 219 cr.move_to(self._join_spec_x, self._join_spec_y)220 cr.show_text(self.subject.joinSpec.value)219 text_align(cr, self._join_spec_x, self._join_spec_y, 220 self.subject.joinSpec.value, align_x=1, align_y=1) 221 221 222 222 cr.stroke() gaphor/trunk/gaphor/diagram/association.py
r1178 r1193 16 16 from math import atan2, pi 17 17 18 from gaphas.util import text_extents, text_ multiline18 from gaphas.util import text_extents, text_align, text_multiline 19 19 from gaphas.state import reversible_property 20 20 from gaphas import Item … … 368 368 369 369 if self.subject and self.subject.name: 370 cr.move_to(self._label_bounds[0], self._label_bounds[1]) 371 cr.show_text(self.subject.name or '') 370 #cr.move_to(self._label_bounds[0], self._label_bounds[1]) 371 #cr.show_text(self.subject.name or '') 372 text_align(cr, self._label_bounds[0], self._label_bounds[1], 373 self.subject.name or '', align_x=1, align_y=1) 372 374 373 375 … … 707 709 708 710 cr = context.cairo 709 #cr.move_to(self._name_bounds[0], self._name_bounds[3]) 710 #cr.show_text(self._name or '') 711 text_multiline(cr, self._name_bounds[0], self._name_bounds[3], self._name) 712 #cr.move_to(self._mult_bounds[0], self._mult_bounds[3]) 713 #cr.show_text(self._mult or '') 714 text_multiline(cr, self._mult_bounds[0], self._mult_bounds[3], self._mult) 711 text_multiline(cr, self._name_bounds[0], self._name_bounds[1], self._name) 712 text_multiline(cr, self._mult_bounds[0], self._mult_bounds[1], self._mult) 715 713 cr.stroke() 716 714 gaphor/trunk/gaphor/diagram/classifier.py
r1178 r1193 4 4 import itertools 5 5 6 from gaphas.util import text_extents, text_ center, text_set_font6 from gaphas.util import text_extents, text_align, text_set_font 7 7 from gaphas.state import observed, reversible_property 8 8 from gaphor import UML … … 12 12 from gaphor.diagram.feature import FeatureItem 13 13 14 from gaphas.util import text_center15 14 import font 16 15 … … 47 46 48 47 def pre_update(self, context): 49 """Pre update, determine width and height of the compartment. 48 """ 49 Pre update, determine width and height of the compartment. 50 50 """ 51 51 self.width = self.height = 0 … … 58 58 self.height = sum(map(lambda p: p[1], sizes)) 59 59 vspacing = self.owner.style.compartment_vspacing 60 self.height += vspacing * len(sizes)60 self.height += vspacing * (len(sizes) - 1) 61 61 padding = self.owner.style.compartment_padding 62 62 self.width += padding[1] + padding[3] … … 77 77 cr.save() 78 78 try: 79 offset += item.height80 cr.move_to(0, offset)79 cr.translate(0, offset) 80 #cr.move_to(0, offset) 81 81 item.draw(context) 82 offset += vspacing 82 offset += vspacing + item.height 83 83 finally: 84 84 cr.restore() … … 120 120 'from-padding': (7, 2, 7, 2), 121 121 'compartment-padding': (5, 5, 5, 5), # (top, right, bottom, left) 122 'compartment-vspacing': 2,122 'compartment-vspacing': 3, 123 123 # Fix name, stereotype and from drawing! 124 124 'name-padding': (10, 10, 10, 10), … … 355 355 y += padding[0] 356 356 text_set_font(cr, font.FONT) 357 text_ center(cr, width / 2, y, self.stereotype)357 text_align(cr, width / 2, y, self.stereotype) 358 358 y += padding[2] 359 359 … … 364 364 text_set_font(cr, self.subject.isAbstract and \ 365 365 font.FONT_ABSTRACT_NAME or font.FONT_NAME) 366 text_ center(cr, width / 2, y + n_h/2, self.subject.name)366 text_align(cr, width / 2, y + n_h/2, self.subject.name) 367 367 y += padding[2] + n_h/2 368 368 … … 372 372 y += padding[0] 373 373 text_set_font(cr, font.FONT_SMALL) 374 text_ center(cr, width / 2, y, self._from)374 text_align(cr, width / 2, y, self._from) 375 375 y += padding[2] 376 376 gaphor/trunk/gaphor/diagram/comment.py
r1121 r1193 79 79 if self.subject.body: 80 80 # Do not print empty string, since cairo-win32 can't handle it. 81 text_multiline(c, 5, 5, self.subject.body, padding=2)81 text_multiline(c, 5, 15, self.subject.body, padding=2) 82 82 #c.move_to(10, 15) 83 83 #c.show_text(self.subject.body) gaphor/trunk/gaphor/diagram/diagramline.py
r1178 r1193 6 6 7 7 import gaphas 8 from gaphas.util import text_extents 8 from gaphas.util import text_extents, text_align 9 9 from gaphas.geometry import Rectangle 10 10 from diagramitem import DiagramItem … … 78 78 cr = context.cairo 79 79 if self._stereotype: 80 cr.move_to(self._stereotype_bounds[0], self._stereotype_bounds[1])81 cr.show_text(self._stereotype)80 text_align(cr, self._stereotype_bounds[0], self._stereotype_bounds[1], 81 self._stereotype, align_x=1, align_y=1) 82 82 83 83 gaphor/trunk/gaphor/diagram/feature.py
r1178 r1193 8 8 from diagramitem import DiagramItem 9 9 from gaphor.diagram import DiagramItemMeta 10 from gaphas.util import text_extents, text_set_font 10 from gaphas.util import text_extents, text_set_font, text_align 11 11 import font 12 12 … … 41 41 42 42 def get_size(self, update=False): 43 """Return the size of the feature. If update == True the item is 43 """ 44 Return the size of the feature. If update == True the item is 44 45 directly updated. 45 46 """ … … 127 128 cr = context.cairo 128 129 text_set_font(cr, font.FONT) 129 cr.show_text(self.subject.render() or '') 130 text_align(cr, 0, 0, self.subject.render() or '', align_x=1, align_y=1) 131 #cr.show_text(self.subject.render() or '') 130 132 131 133 … … 178 180 cr = context.cairo 179 181 text_set_font(cr, font.FONT) 180 cr.show_text(self.subject.render() or '') 182 text_align(cr, 0, 0, self.subject.render() or '', align_x=1, align_y=1) 183 #cr.show_text(self.subject.render() or '') 181 184 182 185 gaphor/trunk/gaphor/diagram/nameditem.py
r1137 r1193 4 4 """ 5 5 6 from gaphas.util import text_extents 6 from gaphas.util import text_extents, text_align 7 7 8 8 from gaphor.diagram.elementitem import ElementItem … … 91 91 text = self.subject.name 92 92 if text: 93 cr.move_to(self.name_x, self.name_y) 94 cr.show_text(text) 93 #cr.move_to(self.name_x, self.name_y) 94 #cr.show_text(text) 95 text_align(cr, self.name_x, self.name_y, text, *self.style.name_align) 95 96 super(NamedItem, self).draw(context) gaphor/trunk/gaphor/diagram/package.py
r1121 r1193 3 3 """ 4 4 5 from gaphas.util import text_ center, text_extents, text_set_font5 from gaphas.util import text_align, text_extents, text_set_font 6 6 from gaphor import UML 7 7 from gaphor.diagram.nameditem import NamedItem … … 49 49 cr.stroke() 50 50 if self.stereotype: 51 text_ center(cr, w / 2, y + 10, self.stereotype)51 text_align(cr, w / 2, y + 10, self.stereotype) 52 52 53 53 super(PackageItem, self).draw(context) gaphor/trunk/gaphor/diagram/style.py
r1121 r1193 7 7 8 8 # horizontal align 9 ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT = range(3)9 ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT = -1, 0, 1 10 10 11 11 # vertical align 12 ALIGN_TOP, ALIGN_MIDDLE, ALIGN_BOTTOM = range(3)12 ALIGN_TOP, ALIGN_MIDDLE, ALIGN_BOTTOM = -1, 0, 1 13 13 14 14
