Changeset 1201

Show
Ignore:
Timestamp:
04/09/07 23:14:40 (2 years ago)
Author:
arj..@yirdis.nl
Message:

Updated drawing of items.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/trunk/gaphor/actions/itemactions.py

    r1132 r1201  
    10781078            item = get_parent_focus_item(self._window) 
    10791079            if isinstance(item, items.ObjectNodeItem): 
    1080                 self.active = (item.get_ordering() == self.ordering) 
     1080                self.active = (item.ordering == self.ordering) 
    10811081        except NoFocusItemError: 
    10821082            pass 
     
    10861086        if self.active: 
    10871087            item = get_parent_focus_item(self._window) 
    1088             item.set_ordering(self.ordering) 
     1088            item.ordering = self.ordering 
    10891089 
    10901090 
     
    11401140        else: 
    11411141            if isinstance(item, items.ObjectNodeItem): 
    1142                 self.active = item.props.show_ordering 
     1142                self.active = item.show_ordering 
    11431143 
    11441144    @transactional 
    11451145    def execute(self): 
    11461146        item = get_parent_focus_item(self._window) 
    1147         item.props.show_ordering = self.active 
     1147        item.show_ordering = self.active 
    11481148 
    11491149register_action(ObjectNodeOrderingVisibiltyAction, 'ItemFocus') 
  • gaphor/trunk/gaphor/diagram/action.py

    r1121 r1201  
    1616        'name-align': (ALIGN_CENTER, ALIGN_MIDDLE), 
    1717    } 
     18 
     19    def pre_update(self, context): 
     20        self.update_name_size(context) 
     21        self.min_width, self.min_height = self.get_name_size() 
     22        super(ActionItem, self).pre_update(context) 
    1823 
    1924    def draw(self, context): 
     
    4045 
    4146 
    42  
    4347# vim:sw=4:et 
  • gaphor/trunk/gaphor/diagram/activitynodes.py

    r1193 r1201  
    131131        ActivityNodeItem.__init__(self, id) 
    132132        self._combined = None 
    133         self.set_prop_persistent('combined') 
     133        #self.set_prop_persistent('combined') 
     134 
     135    def save(self, save_func): 
     136        if self._combined: 
     137            save_func('combined', self._combined, reference=True) 
     138        super(ForkDecisionNodeItem, self).save(save_func) 
     139 
     140    def load(self, name, value): 
     141        if name == 'combined': 
     142            self._combined = value 
     143        else: 
     144            super(ForkDecisionNodeItem, self).load(name, value) 
    134145 
    135146    @observed 
  • gaphor/trunk/gaphor/diagram/classifier.py

    r1193 r1201  
    339339 
    340340    def draw_compartment(self, context): 
    341         #if not self.subject: return 
    342341        cr = context.cairo 
    343342        cr.rectangle(0, 0, self.width, self.height) 
  • gaphor/trunk/gaphor/diagram/comment.py

    r1193 r1201  
    7979        if self.subject.body: 
    8080            # Do not print empty string, since cairo-win32 can't handle it. 
    81             text_multiline(c, 5, 15, self.subject.body, padding=2) 
     81            text_multiline(c, 5, 5, self.subject.body, padding=2) 
    8282            #c.move_to(10, 15) 
    8383            #c.show_text(self.subject.body) 
  • gaphor/trunk/gaphor/diagram/elementitem.py

    r1121 r1201  
    4141        self.update_stereotype() 
    4242 
     43 
    4344# vim:sw=4 
  • gaphor/trunk/gaphor/diagram/extension.py

    r1121 r1201  
    1515 
    1616class ExtensionItem(DiagramLine): 
    17     """ExtensionItem represents associations.  
     17    """ 
     18    ExtensionItem represents associations.  
    1819    An ExtensionItem has two ExtensionEnd items. Each ExtensionEnd item 
    1920    represents a Property (with Property.association == my association). 
     
    2425    def __init__(self, id=None): 
    2526        DiagramLine.__init__(self, id) 
    26  
    27     def save (self, save_func): 
    28         DiagramLine.save(self, save_func) 
    29         if self._head_end.subject: 
    30             save_func('head_subject', self._head_end.subject) 
    31         if self._tail_end.subject: 
    32             save_func('tail_subject', self._tail_end.subject) 
    33  
    34     def load (self, name, value): 
    35         # end_head and end_tail were used in an older Gaphor version 
    36         if name in ( 'head_end', 'head_subject' ): 
    37             #type(self._head_end).subject.load(self._head_end, value) 
    38             self._head_end.load('subject', value) 
    39         elif name in ( 'tail_end', 'tail_subject' ): 
    40             #type(self._tail_end).subject.load(self._tail_end, value) 
    41             self._tail_end.load('subject', value) 
    42         else: 
    43             DiagramLine.load(self, name, value) 
    44  
    45     def postload(self): 
    46         DiagramLine.postload(self) 
    47         self._head_end.postload() 
    48         self._tail_end.postload() 
    4927 
    5028    def on_subject_notify(self, pspec, notifiers=()): 
  • gaphor/trunk/gaphor/diagram/nameditem.py

    r1193 r1201  
    5656            padding = self.style.name_padding 
    5757            self._name_size = width + padding[0] + padding[2], height + padding[1] + padding[3] 
    58 #            if self.min_width < self._name_size[0]: 
    59 #                self.min_width = self._name_size[0] 
    60 #            if self.min_height < self._name_size[1]: 
    61 #                self.min_height = self._name_size[1] 
    62 #            self.min_width, self.min_height = get_min_size(width, height, 
    63 #                    self.style.min_size, 
    64 #                    self.style.name_padding) 
    65 # 
    66 #        super(NamedItem, self).pre_update(context) 
    67  
    6858 
    6959    def update(self, context): 
     
    9383            #cr.move_to(self.name_x, self.name_y) 
    9484            #cr.show_text(text) 
    95             text_align(cr, self.name_x, self.name_y, text, *self.style.name_align
     85            text_align(cr, self.name_x, self.name_y, text, 1, -1
    9686        super(NamedItem, self).draw(context) 
  • gaphor/trunk/gaphor/diagram/objectnode.py

    r1178 r1201  
    8181        """ 
    8282        NamedItem.on_subject_notify(self, pspec, notifiers) 
    83         if self.subject: 
    84             if not self.subject.upperBound: 
    85                 self.subject.upperBound = UML.create(UML.LiteralSpecification) 
    86                 self.subject.upperBound.value = '*' 
    87             #self._upper_bound.subject = self.subject.upperBound 
    88         #else: 
    89         #    self._upper_bound.subject = None 
     83        if self.subject and not self.subject.upperBound: 
     84            self.subject.upperBound = UML.create(UML.LiteralSpecification) 
     85            self.subject.upperBound.value = '*' 
    9086        self.request_update() 
    9187 
     
    9490        Update object node, its ordering and upper bound specification. 
    9591        """ 
    96         NamedItem.update(self, context) 
     92        NamedItem.pre_update(self, context) 
    9793 
    98         # TODO: format tag properly: 
    9994        if self.subject.upperBound: 
    10095            self._tag = '{ upperBound = %s }\n' % self.subject.upperBound.value 
  • gaphor/trunk/gaphor/diagram/package.py

    r1193 r1201  
    3232        super(PackageItem, self).pre_update(context) 
    3333 
    34  
    3534    def draw(self, context): 
    3635        cr = context.cairo 
     
    4948        cr.stroke() 
    5049        if self.stereotype: 
    51             text_align(cr, w / 2, y + 10, self.stereotype) 
     50            y += 10 
     51            text_align(cr, w / 2, y, self.stereotype) 
     52            y += 10 
    5253 
    53         super(PackageItem, self).draw(context) 
     54        if self.subject and self.subject.name: 
     55            text_align(cr, w / 2, y + 10, self.subject.name) 
    5456 
    5557 
  • gaphor/trunk/gaphor/event.py

    r1170 r1201  
     1""" 
     2Application wide events are managed here. 
     3""" 
     4 
    15from zope import interface 
    26from gaphor.interfaces import * 
    37 
     8class TransactionBegin(object): 
     9    """ 
     10    This event denotes the beginning of an transaction. 
     11    Nested (sub-) transactions should not emit this signal. 
     12    """ 
     13    interface.implements(ITransactionEvent) 
     14 
     15 
     16class TransactionCommit(object): 
     17    """ 
     18    This event is emitted when a transaction (toplevel) is successfully 
     19    commited. 
     20    """ 
     21    interface.implements(ITransactionEvent) 
     22 
     23class TransactionRollback(object): 
     24    """ 
     25    If a set of operations fail (e.i. due to an exception) the transaction 
     26    should be marked for rollback. This event is emitted to tell the operation 
     27    has failed. 
     28    """ 
     29    interface.implements(ITransactionEvent) 
     30 
     31 
     32# vim:sw=4:et:ai 
     33 
  • gaphor/trunk/gaphor/interfaces.py

    r1170 r1201  
    2525 
    2626 
     27class ITransaction(interface.Interface): 
     28    """ 
     29    The methods each transaction should adhere. 
     30    """ 
     31 
     32    def commit(self): 
     33        """ 
     34        Commit the transaction. 
     35        """ 
     36 
     37    def rollback(self): 
     38        """ 
     39        Roll back the transaction. 
     40        """ 
     41 
     42 
     43class ITransactionEvent(interface.Interface): 
     44    """ 
     45    Events related to transaction workflow (begin/commit/rollback) implements 
     46    this interface. 
     47    """ 
     48 
     49 
    2750# vim:sw=4:et