Changeset 815
- Timestamp:
- 03/26/06 12:01:29 (3 years ago)
- Files:
-
- trunk/gaphas/examples.py (modified) (1 diff)
- trunk/gaphas/item.py (modified) (2 diffs)
- trunk/gaphas/view.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gaphas/examples.py
r814 r815 16 16 c = context.cairo 17 17 c.rectangle(0,0, self._width, self._height) 18 c.set_source_rgb(0,0, 0)18 c.set_source_rgb(0,0,80) 19 19 c.stroke() 20 20 context.draw_children() trunk/gaphas/item.py
r814 r815 3 3 4 4 from geometry import Matrix 5 from solver import solvable 5 6 6 7 class Handle(object): … … 8 9 """ 9 10 10 def __init__(self, pos=(0,0)): 11 self._pos = pos 12 13 pos = property(lambda s: s._pos) 11 x = solvable() 12 y = solvable() 13 def __init__(self, x, y): 14 self.x = x 15 self.y = y 16 # Flags.. can't have enough of those 17 self._connectable = True 18 self._movable = True 19 self._visible = True 20 21 def _set_pos(self, pos): 22 self.x, self.y = pos 23 24 pos = property(lambda s: (s.x, s.y), _set_pos) 14 25 15 26 def update(self, context): trunk/gaphas/view.py
r814 r815 19 19 20 20 class View(gtk.DrawingArea): 21 # just defined a name to make GTK register this entity. 21 22 __gtype_name__ = 'GaphasView' 22 23 23 24 def __init__(self, canvas=None): 24 25 super(View, self).__init__() 26 self.set_flags(gtk.CAN_FOCUS) 25 27 self.add_events(gtk.gdk.BUTTON_PRESS_MASK 26 28 | gtk.gdk.BUTTON_RELEASE_MASK … … 55 57 cairo=cairo_context, 56 58 children=self._canvas.get_children(item))) 59 self._draw_handles(item, cairo_context) 57 60 finally: 58 61 cairo_context.restore() 62 63 def _draw_handles(self, item, cairo_context): 64 size = 7 65 cairo_context.save() 66 cairo_context.rectangle(0, 0, size, size) 67 cairo_context.set_source_rgba(0, 1, 0, .6) 68 cairo_context.fill_preserve() 69 cairo_context.move_to(2, 2) 70 cairo_context.line_to(5, 5) 71 cairo_context.move_to(5, 2) 72 cairo_context.line_to(2, 5) 73 cairo_context.set_source_rgba(0, 0, 0, 0.6) 74 cairo_context.set_line_width(1.0) 75 cairo_context.stroke() 76 77 cairo_context.restore() 59 78 60 79 def do_expose_event(self, event): … … 67 86 viewport = self.get_allocation() 68 87 area = event.area 88 self.window.draw_rectangle(self.style.white_gc, True, area.x, area.y, area.width, area.height) 89 69 90 print 'expose', area.x, area.y, area.width, area.height, event.count 70 91 if self._canvas: … … 108 129 w.show_all() 109 130 131 gtk.rc_parse_string(""" 132 style "background" { bg[NORMAL] = "white" fg[NORMAL] = "white" } 133 class "GaphasView" style "background" 134 """) 110 135 c=Canvas() 111 136 v.canvas = c 137 print 'view', v 112 138 b=Box() 113 139 b.matrix=(1.0, 0.0, 0.0, 1, 20,20)
