~ubuntu-branches/ubuntu/utopic/python-chaco/utopic

« back to all changes in this revision

Viewing changes to enthought/chaco/attic/advanced_datamodel/anchors.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-04-06 19:03:54 UTC
  • mfrom: (7.2.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110406190354-rwd55l2ezjecfo41
Tags: 3.4.0-2
d/rules: fix pyshared directory path (Closes: #621116)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
#  This file is not used at the moment.  It just consists of the ramblings
3
 
#  of an insane man.   -- pzw 3/2/06
4
 
#
5
 
 
6
 
class Anchor(HasTraits):
7
 
    
8
 
    position = Property
9
 
    
10
 
    # The AlignmentGroup this anchor belongs to
11
 
    group = Instance("AnchorGroup")
12
 
    
13
 
    # Shadow trait for position
14
 
    _position = Float
15
 
    
16
 
    def align(self, anchor_or_element, A, B):
17
 
        """
18
 
        Pins this element's position to the position of the given anchor
19
 
        The relationship of this anchor's position relative to its
20
 
        group's position can be expressed as::
21
 
            
22
 
            self.position = A*group.position + B
23
 
        """
24
 
        if isinstance(anchor_or_element, AnchorGroup):
25
 
            self.group = anchor_or_element
26
 
            self.group.add(self)
27
 
        else:
28
 
            # Create a new anchor group
29
 
            self.group = AnchorGroup()
30
 
            self.position
31
 
 
32
 
    def unalign(self):
33
 
        """Removes this element from its anchor group"""
34
 
        pass
35
 
 
36
 
    def _get_position(self):
37
 
        pass
38
 
    
39
 
    def _set_position(self, pos):
40
 
        if self.group is not None:
41
 
            self.group.position = pos
42
 
        else:
43
 
            self._position = pos
44
 
        return
45
 
 
46
 
 
47
 
class AnchorGroup(Anchor):
48
 
    
49
 
    anchors = List(Anchor)
50
 
 
51
 
    def add(self, anchor):
52
 
        pass
53
 
    
54
 
    def remove(self, anchor):
55
 
        pass
56
 
 
57
 
 
58
 
class LayoutContext(HasTraits):
59
 
 
60
 
    anchors = List(Anchors)
61
 
 
62
 
 
63
 
class LayoutElement(HasTraits):
64
 
    
65
 
    frame = Instance(LayoutContext)
66
 
    
67
 
 
68
 
# EOF