Changeset 815

Show
Ignore:
Timestamp:
03/26/06 12:01:29 (3 years ago)
Author:
arjanmol
Message:

first setup for drawing handles.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gaphas/examples.py

    r814 r815  
    1616        c = context.cairo 
    1717        c.rectangle(0,0, self._width, self._height) 
    18         c.set_source_rgb(0,0,0) 
     18        c.set_source_rgb(0,0,80) 
    1919        c.stroke() 
    2020        context.draw_children() 
  • trunk/gaphas/item.py

    r814 r815  
    33 
    44from geometry import Matrix 
     5from solver import solvable 
    56 
    67class Handle(object): 
     
    89    """ 
    910 
    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) 
    1425 
    1526    def update(self, context): 
  • trunk/gaphas/view.py

    r814 r815  
    1919 
    2020class View(gtk.DrawingArea): 
     21    # just defined a name to make GTK register this entity. 
    2122    __gtype_name__ = 'GaphasView' 
    2223 
    2324    def __init__(self, canvas=None): 
    2425        super(View, self).__init__() 
     26        self.set_flags(gtk.CAN_FOCUS) 
    2527        self.add_events(gtk.gdk.BUTTON_PRESS_MASK 
    2628                        | gtk.gdk.BUTTON_RELEASE_MASK 
     
    5557                                      cairo=cairo_context, 
    5658                                      children=self._canvas.get_children(item))) 
     59                self._draw_handles(item, cairo_context) 
    5760            finally: 
    5861                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() 
    5978 
    6079    def do_expose_event(self, event): 
     
    6786        viewport = self.get_allocation() 
    6887        area = event.area 
     88        self.window.draw_rectangle(self.style.white_gc, True, area.x, area.y, area.width, area.height) 
     89 
    6990        print 'expose', area.x, area.y, area.width, area.height, event.count 
    7091        if self._canvas: 
     
    108129    w.show_all() 
    109130 
     131    gtk.rc_parse_string(""" 
     132    style "background" { bg[NORMAL] = "white" fg[NORMAL] = "white" } 
     133    class "GaphasView" style "background" 
     134    """) 
    110135    c=Canvas() 
    111136    v.canvas = c 
     137    print 'view', v 
    112138    b=Box() 
    113139    b.matrix=(1.0, 0.0, 0.0, 1, 20,20)