commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/designer/src/schema VisualEditor.py Visual...


From: Jan Ischebeck
Subject: gnue/designer/src/schema VisualEditor.py Visual...
Date: Sat, 27 Jul 2002 20:46:24 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jan Ischebeck <address@hidden>  02/07/27 20:46:24

Modified files:
        designer/src/schema: VisualEditor.py VisualTable.py 

Log message:
        implemented a blue marker for the current object and a way to move 
objects around

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/schema/VisualEditor.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/schema/VisualTable.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gnue/designer/src/schema/VisualEditor.py
diff -c gnue/designer/src/schema/VisualEditor.py:1.1 
gnue/designer/src/schema/VisualEditor.py:1.2
*** gnue/designer/src/schema/VisualEditor.py:1.1        Sat Jul 27 14:43:57 2002
--- gnue/designer/src/schema/VisualEditor.py    Sat Jul 27 20:46:23 2002
***************
*** 37,43 ****
--- 37,45 ----
      self.panelColor = wxWHITE #wxNamedColor("blue") # 
self.GetBackgroundColour()
      self._instance = instance
      self.rootObject = root
+     self.current = root
      self._app = instance._app
+     self.dragmode = false
      self.tables=[]
      self.rootObject.walk(self.inventoryObject)
  
***************
*** 45,51 ****
                                    style=wxSUNKEN_BORDER)
      self.calculateTablePositions()
      
!     self.diagram.SetBackgroundColour(wxWHITE)
      
      self.diagram.EnableScrolling(true, true)
      
--- 47,53 ----
                                    style=wxSUNKEN_BORDER)
      self.calculateTablePositions()
      
!     #self.diagram.SetBackgroundColour(wxWHITE)
      
      self.diagram.EnableScrolling(true, true)
      
***************
*** 53,60 ****
                                 self.panelheight / 20)
          
      EVT_PAINT(self.diagram, self.onPaintEvent)
!     EVT_LEFT_DOWN(self.diagram, self.onDoubleClickEvent)
!     # EVT_LEFT_DCLICK
  
      Sizer = wxBoxSizer(wxHORIZONTAL)
      #Sizer.Add(self.toolPalette, 0)
--- 55,65 ----
                                 self.panelheight / 20)
          
      EVT_PAINT(self.diagram, self.onPaintEvent)
! #    EVT_LEFT_DOWN(self.diagram, self.onLeftClickEvent)
!     EVT_MOTION(self.diagram, self.onMouseEvent)
!     EVT_LEFT_UP(self.diagram, self.onMouseEvent)
!     EVT_LEFT_DOWN(self.diagram, self.onMouseEvent)
!     EVT_LEFT_DCLICK(self.diagram, self.onDoubleClickEvent)
  
      Sizer = wxBoxSizer(wxHORIZONTAL)
      #Sizer.Add(self.toolPalette, 0)
***************
*** 97,103 ****
  
    def onSetCurrentObject (self, object, handler):
      # mark actual object (in blue?)
!     pass
  
    def onCreateObject (self, object, handler):
      pass
--- 102,110 ----
  
    def onSetCurrentObject (self, object, handler):
      # mark actual object (in blue?)
!     if self.current!=object:
!       self.current=object
!       self.onPaintEvent(None)
  
    def onCreateObject (self, object, handler):
      pass
***************
*** 108,119 ****
    def onDeleteObject (self, object, handler):
      pass
      
!   def onPaintEvent(self, event):
        dc = wxPaintDC(self.diagram)
!       self.diagram.PrepareDC(dc)
        dc.BeginDrawing()
        for vTbl in self.tables:
!         vTbl.drawMe(dc) 
            
        dc.EndDrawing()
  
--- 115,129 ----
    def onDeleteObject (self, object, handler):
      pass
      
!   def onPaintEvent(self, event, clear=false):
        dc = wxPaintDC(self.diagram)
!       self.diagram.PrepareDC(dc)      
        dc.BeginDrawing()
+       if clear:
+         dc.SetBackground(wxLIGHT_GREY_BRUSH)
+         dc.Clear()
        for vTbl in self.tables:
!         vTbl.drawMe(dc,self.current) 
            
        dc.EndDrawing()
  
***************
*** 124,132 ****
              event.GetY() + (originY * unitY))
  
  
!   def onDoubleClickEvent(self,event):    
      (x,y) = self.calculateMousePos(event)   
      for vTbl in self.tables:
        object=vTbl.getObjectAt(x,y)
        if object != None:
          self._instance.onSetCurrentObject(object, __name__)
--- 134,201 ----
              event.GetY() + (originY * unitY))
  
  
!   def getObjectAt(self,x,y):
!     self.tables.reverse()
!     for vTbl in self.tables:
!       object=vTbl.getObjectAt(x,y)
!       if object != None:
!         self.tables.reverse()
!         return object
!     self.tables.reverse()
!     return None
! 
!   def onMouseEvent(self,event):
!     if not (event.LeftDown() or event.Dragging() or event.LeftUp()):
!       return # Ignore mouse movement without click/drag.
!     if event.LeftDown():
!       (x,y) = self.calculateMousePos(event)   
!       object=self.getObjectAt(x,y)
!       if object != None:
!         if object._type!='VisualTable':
!           self._instance.onSetCurrentObject(object, __name__)
!           return
!         else:
!           self.dragx=x-object.xpos
!           self.dragy=y-object.ypos
!           self.dragobj=object
!           self.dragmode=true
! 
!     elif event.LeftUp() and self.dragmode:
!       self.dragmode=false
!       self.onPaintEvent(None,true)
!       
!     elif event.Dragging() and self.dragmode:
!       (x,y) = self.calculateMousePos(event)   
!       dc = wxPaintDC(self.diagram)
!       self.diagram.PrepareDC(dc)
!       dc.BeginDrawing()
!       dc.SetLogicalFunction(wxXOR)
!       self.dragobj.drawMe(dc,self.current)
!       self.dragobj.moveTo(x-self.dragx,y-self.dragy)
!       self.dragobj.drawMe(dc,self.current)
! #      dc.drawRec
! #     TODO: Begin to use a wxMemoryDC where the screen is drawn, and
! #     which is copied into the real window -> no flickering screen
! #     when a object should be moved, first delete it, and repaint the
! #     wxMemoryDC, then you can move it on the real DC and you can
! #     restore the background by using Blit
! 
!       dc.EndDrawing()
! 
!       
!       
! 
!   def onLeftClickEvent(self,event):    
      (x,y) = self.calculateMousePos(event)   
      for vTbl in self.tables:
        object=vTbl.getObjectAt(x,y)
        if object != None:
          self._instance.onSetCurrentObject(object, __name__)
+         return
+ 
+   def onDoubleClickEvent(self,event):    
+     (x,y) = self.calculateMousePos(event)   
+     object=self.getObjectAt(x,y)
+     if object != None and object._type!='VisualTable': 
+       # begin to edit this object
+       self._instance.onSetCurrentObject(object, __name__)
Index: gnue/designer/src/schema/VisualTable.py
diff -c gnue/designer/src/schema/VisualTable.py:1.1 
gnue/designer/src/schema/VisualTable.py:1.2
*** gnue/designer/src/schema/VisualTable.py:1.1 Sat Jul 27 14:43:57 2002
--- gnue/designer/src/schema/VisualTable.py     Sat Jul 27 20:46:24 2002
***************
*** 32,41 ****
  class VisualTable:
    def __init__(self, tableinstance):
      self.instance=tableinstance
!     
      #self.font = wxFont(self.textSize, wxDEFAULT, 
wxNORMAL,wxNORMAL,0,fontname )
      self.pen = wxBLACK_PEN # wxPen(...)
!     self.brush = wxTRANSPARENT_BRUSH # wxBLACK_BRUSH
    
    def calculateDimensions(self,dc):
      (w,h)=dc.GetTextExtent(self.instance.name)
--- 32,42 ----
  class VisualTable:
    def __init__(self, tableinstance):
      self.instance=tableinstance
!     self._type='VisualTable'
      #self.font = wxFont(self.textSize, wxDEFAULT, 
wxNORMAL,wxNORMAL,0,fontname )
      self.pen = wxBLACK_PEN # wxPen(...)
!     self.pen_highlighted = wxPen(wxBLUE, 1, wxSOLID)
!     self.brush = wxWHITE_BRUSH # wxTRANSPARENT_BRUSH # wxBLACK_BRUSH
    
    def calculateDimensions(self,dc):
      (w,h)=dc.GetTextExtent(self.instance.name)
***************
*** 59,65 ****
      self.xpos=x
      self.ypos=y
  
!   def drawMe(self,dc):
        dc.SetPen(self.pen) 
        dc.SetBrush(self.brush)
  
--- 60,66 ----
      self.xpos=x
      self.ypos=y
  
!   def drawMe(self,dc,current):
        dc.SetPen(self.pen) 
        dc.SetBrush(self.brush)
  
***************
*** 68,98 ****
                    self.xpos+self.width,self.ypos+self.textheight+20)
        dc.DrawLine(self.xpos,self.ypos+self.textheight+24,
                    self.xpos+self.width,self.ypos+self.textheight+24)
!       x=self.xpos
!       y=self.ypos
        # dc.SetFont(self.font)
!       dc.DrawText(self.instance.name,x+10,y+10)
!       y=y+34
        fields=self.instance.findChildOfType('GSFields')
!       for c in fields._children:        
!         dc.DrawText(c.name,x+10,y+10)
          y=y+self.textheight+5
  
    # return pointer to field/table object depending on position
    def getObjectAt(self,x,y):
      if x>=self.xpos and x<=self.xpos+self.width and \
             y>=self.ypos and y<=self.ypos+self.height:
        hy=self.ypos+34
        if y<hy:
          return self.instance
        fields=self.instance.findChildOfType('GSFields')
        for c in fields._children:        
          hy=hy+self.textheight+5
          if y<hy:
!           return c        
      else:
- #      print "not in ( %s,%s - %s,%s )" % (self.xpos,self.xpos+self.width, \
- #                                          self.ypos,self.ypos+self.height)
        return None
  
    # return pointer to field/table object depending on position
--- 69,120 ----
                    self.xpos+self.width,self.ypos+self.textheight+20)
        dc.DrawLine(self.xpos,self.ypos+self.textheight+24,
                    self.xpos+self.width,self.ypos+self.textheight+24)
! 
        # dc.SetFont(self.font)
!       dc.DrawText(self.instance.name,self.xpos+10,self.ypos+10)
!       y=self.ypos+34
        fields=self.instance.findChildOfType('GSFields')
!       for c in fields._children:
!         
!         # check if this field is the current selected object
!         if c==current:
!           dc.SetPen(self.pen_highlighted)
!           dc.SetBrush(wxTRANSPARENT_BRUSH)
!           dc.DrawRectangle(self.xpos+3,y+8,self.width-6,self.textheight+4)
!           
!         dc.DrawText(c.name,self.xpos+10,y+10)
          y=y+self.textheight+5
  
+       # check if the table is selected
+       if self.instance==current:
+         dc.SetPen(self.pen_highlighted)
+         dc.SetBrush(wxTRANSPARENT_BRUSH)
+         dc.DrawRectangle(self.xpos+3,self.ypos+8,
+                          self.width-6,self.textheight+4)
+ 
+ 
    # return pointer to field/table object depending on position
    def getObjectAt(self,x,y):
      if x>=self.xpos and x<=self.xpos+self.width and \
             y>=self.ypos and y<=self.ypos+self.height:
+       
+       # cursor in upper part  -> return table
        hy=self.ypos+34
        if y<hy:
          return self.instance
+       
+       # cursor in the middle  -> return fields
        fields=self.instance.findChildOfType('GSFields')
        for c in fields._children:        
          hy=hy+self.textheight+5
          if y<hy:
!           return c
!         
!       # cursor at the bottom part ->  return table
!       return self
!       return self.instance
!     
      else:
        return None
  
    # return pointer to field/table object depending on position



reply via email to

[Prev in Thread] Current Thread [Next in Thread]