commit-gnue
[Top][All Lists]
Advanced

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

gnue/designer templates/schema/Introspection.py...


From: Jan Ischebeck
Subject: gnue/designer templates/schema/Introspection.py...
Date: Tue, 06 Aug 2002 11:06:31 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jan Ischebeck <address@hidden>  02/08/06 11:06:30

Modified files:
        designer/templates/schema: Introspection.py 
        designer/src/schema: Incubator.py Instance.py TreeView.py 
                             VisualEditor.py VisualTable.py 

Log message:
        * add basic popup menu with create/delete functions to the visual editor
        * improved moving of elements
        * add onCreateObj/onDeleteObj etc. handler to react on changes in other 
tools
        * activated the object navigator again an added a small fix for its 
segfault
        problem (I hope so)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/templates/schema/Introspection.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/schema/Incubator.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/schema/Instance.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/schema/TreeView.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/schema/VisualEditor.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/schema/VisualTable.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gnue/designer/src/schema/Incubator.py
diff -c gnue/designer/src/schema/Incubator.py:1.1 
gnue/designer/src/schema/Incubator.py:1.2
*** gnue/designer/src/schema/Incubator.py:1.1   Fri Jun 28 00:03:38 2002
--- gnue/designer/src/schema/Incubator.py       Tue Aug  6 11:06:29 2002
***************
*** 93,99 ****
      parent = object._parent
  
    for child in object._children:
!     child.deleteObject(instance, schema, child, firstRun=0)
  
    instance.onDeleteObject(object, __name__)
  
--- 93,99 ----
      parent = object._parent
  
    for child in object._children:
!     deleteObject(instance, schema, child, firstRun=0)
  
    instance.onDeleteObject(object, __name__)
  
Index: gnue/designer/src/schema/Instance.py
diff -c gnue/designer/src/schema/Instance.py:1.8 
gnue/designer/src/schema/Instance.py:1.9
*** gnue/designer/src/schema/Instance.py:1.8    Sat Jul 27 14:43:57 2002
--- gnue/designer/src/schema/Instance.py        Tue Aug  6 11:06:29 2002
***************
*** 80,87 ****
  
    def createTools(self):
      self.addTool(_('propertyEditor'), _('Property Inspector'), PropertyEditor)
! ## TODO: Causing a segfault with Wizards!!!!
! ##    self.addTool(_('treeEditor'), _('Object Navigator'), TreeView)
      self.addTool(_('schemaViewer'), _('Schema Navigator'), SchemaViewer)
      self.addTool(_('visualEditor'), _('Visual Editor'), VisualEditor)
      self.loadWizards(wizards)
--- 80,86 ----
  
    def createTools(self):
      self.addTool(_('propertyEditor'), _('Property Inspector'), PropertyEditor)
!     self.addTool(_('treeEditor'), _('Object Navigator'), TreeView)
      self.addTool(_('schemaViewer'), _('Schema Navigator'), SchemaViewer)
      self.addTool(_('visualEditor'), _('Visual Editor'), VisualEditor)
      self.loadWizards(wizards)
Index: gnue/designer/src/schema/TreeView.py
diff -c gnue/designer/src/schema/TreeView.py:1.2 
gnue/designer/src/schema/TreeView.py:1.3
*** gnue/designer/src/schema/TreeView.py:1.2    Mon Jul 22 00:09:40 2002
--- gnue/designer/src/schema/TreeView.py        Tue Aug  6 11:06:29 2002
***************
*** 49,54 ****
--- 49,61 ----
          parentTreeItem = object._parent._treeItem
        except AttributeError: 
          parentTreeItem = None
+         # TODO:
+         print "The parent object of this object has not been registered to "+\
+               "the TreeView inventory. It is not possible to add this "+\
+               "object to the inventory at the moment. This needs to be "+\
+               "fixed. (Obj: ",object,")."
+         
+         return 
        if object._type == 'GSTables':
          icon = 'datasource'
        elif object._type == 'GSTable':
Index: gnue/designer/src/schema/VisualEditor.py
diff -c gnue/designer/src/schema/VisualEditor.py:1.2 
gnue/designer/src/schema/VisualEditor.py:1.3
*** gnue/designer/src/schema/VisualEditor.py:1.2        Sat Jul 27 20:46:23 2002
--- gnue/designer/src/schema/VisualEditor.py    Tue Aug  6 11:06:29 2002
***************
*** 29,58 ****
  
  from wxPython.wx import *
  from VisualTable import *
  
  class VisualEditor (wxPanel):
    def __init__(self, instance, root, parent):
      wxPanel.__init__(self,parent,-1)
      self.frame = instance
!     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)
  
      self.diagram=wxScrolledWindow(self, -1,
                                    style=wxSUNKEN_BORDER)
      self.calculateTablePositions()
      
-     #self.diagram.SetBackgroundColour(wxWHITE)
      
-     self.diagram.EnableScrolling(true, true)
-     
-     self.diagram.SetScrollbars(20, 20, self.panelwidth / 20,
-                                self.panelheight / 20)
          
      EVT_PAINT(self.diagram, self.onPaintEvent)
  #    EVT_LEFT_DOWN(self.diagram, self.onLeftClickEvent)
--- 29,61 ----
  
  from wxPython.wx import *
  from VisualTable import *
+ from parser.Objects import *
+ from Incubator import *
  
  class VisualEditor (wxPanel):
    def __init__(self, instance, root, parent):
      wxPanel.__init__(self,parent,-1)
      self.frame = instance
!     self.panelColor = self.GetBackgroundColour()
      self._instance = instance
      self.rootObject = root
      self.current = root
      self._app = instance._app
      self.dragmode = false
      self.tables=[]
+     self.hasNewObj = false
      self.rootObject.walk(self.inventoryObject)
  
      self.diagram=wxScrolledWindow(self, -1,
                                    style=wxSUNKEN_BORDER)
+     self.panelheight=100
+     self.panelwidth=200
+     self.diagram.EnableScrolling(true, true)
+     self.redrawBackground()
+     #self.diagram.SetBackgroundColour(wxWHITE)
      self.calculateTablePositions()
      
      
          
      EVT_PAINT(self.diagram, self.onPaintEvent)
  #    EVT_LEFT_DOWN(self.diagram, self.onLeftClickEvent)
***************
*** 60,65 ****
--- 63,69 ----
      EVT_LEFT_UP(self.diagram, self.onMouseEvent)
      EVT_LEFT_DOWN(self.diagram, self.onMouseEvent)
      EVT_LEFT_DCLICK(self.diagram, self.onDoubleClickEvent)
+     EVT_RIGHT_DOWN(self.diagram, self.onRightClickEvent)
  
      Sizer = wxBoxSizer(wxHORIZONTAL)
      #Sizer.Add(self.toolPalette, 0)
***************
*** 69,75 ****
      self.SetSizer(Sizer)
  
    def calculateTablePositions(self):
!       dc = wxPaintDC(self.diagram)
        self.diagram.PrepareDC(dc)
        dc.BeginDrawing()
        x=10
--- 73,79 ----
      self.SetSizer(Sizer)
  
    def calculateTablePositions(self):
!       dc = wxMemoryDC()
        self.diagram.PrepareDC(dc)
        dc.BeginDrawing()
        x=10
***************
*** 89,101 ****
            y=maxy+10
          
        dc.EndDrawing()
!       self.panelheight=maxy
!       self.panelwidth=maxx
        
        # Rules for better positioning:
        #   tables with most connections in the middle
        #   ...
  
    def inventoryObject(self, object):
      if object._type=="GSTable":
        self.tables.append(VisualTable(object))
--- 93,105 ----
            y=maxy+10
          
        dc.EndDrawing()
!       self.resizeCanvas(maxx,maxy)
        
        # Rules for better positioning:
        #   tables with most connections in the middle
        #   ...
  
+ 
    def inventoryObject(self, object):
      if object._type=="GSTable":
        self.tables.append(VisualTable(object))
***************
*** 106,132 ****
        self.current=object
        self.onPaintEvent(None)
  
    def onCreateObject (self, object, handler):
!     pass
  
    def onModifyObject (self, object, handler, modifications):
!     pass
  
    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()
  
    def calculateMousePos(self,event):
      originX, originY = self.diagram.GetViewStart()
      unitX, unitY = self.diagram.GetScrollPixelsPerUnit()
--- 110,228 ----
        self.current=object
        self.onPaintEvent(None)
  
+   def findFreePosition(self, x,y,w,h):
+     conflict=true
+     while conflict:
+       conflict=false
+       for i in self.tables:
+         if i.isInRectangle(x,y,x+w,y+h):
+           x=i.xpos+i.width+10
+           if x>500:
+             x=10
+             y=i.ypos+i.height+10
+           conflict=true
+     self.resizeCanvas(x+w,y+h)
+     return (x,y)
+ 
+ 
+   def resizeCanvas(self,xmax,ymax):
+     # resize canvas
+     if xmax>self.panelwidth:
+       self.panelwidth=xmax+10
+       self.diagram.SetScrollbars(20, 20, self.panelwidth / 20,
+                                  self.panelheight / 20)
+     if ymax>self.panelheight:
+       self.panelheight=ymax+10
+       self.diagram.SetScrollbars(20, 20, self.panelwidth / 20,
+                                 self.panelheight / 20)     
+ 
+ 
    def onCreateObject (self, object, handler):
!     if object._type=="GSTable":
!       self.tables.append(VisualTable(object))
!       self.hasNewObj=true
!       self.refresh()      
!       return
!       vTbl=VisualTable(object)       
!       dc = wxClientDC(self.diagram)
!       self.diagram.PrepareDC(dc)  
!       (w,h)=vTbl.calculateDimensions(dc)
! 
!       # position new Table
!       (x,y)=self.findFreePosition(10,10,w,h)
!       vTbl.moveTo(x,y)
!       
!       self.tables.append(vTbl)
!     if object._type=="GSField":
!       self.hasNewObj=true
!       self.onModifyObject(object,None,None)
!       
  
    def onModifyObject (self, object, handler, modifications):
!     self.refresh()
!     return
!     tbl=object.findParentOfType('GSTable')
!     if tbl!=None:
!       for i in self.tables:
!         if i.instance==tbl:
!           dc = wxClientDC(self.diagram)
!           self.diagram.PrepareDC(dc)  
!           (w,h)=i.calculateDimensions(dc)
!           # check if still freepos
!           (x,y)=self.findFreePosition(i.xpos,i.ypos,w,h)
!           i.moveTo(x,y)
!           i.drawMe(dc,self.current)
!           return
! 
!   def refresh(self):
!     self.diagram.Refresh(true)   
  
    def onDeleteObject (self, object, handler):
!     if object._type=="GSTable":
!       # search for GSTable and remove the VisualTable assigned to it
!       for vTbl in self.tables:
!         if vTbl.instance==object:
!           self.tables.remove(vTbl)
!           self.refresh()
! 
!     if object._type=="GSField":
!       # search for GSTable and update corresponding vtable
!       tbl=object.findParentOfType("GSTable")
!       for vTbl in self.tables:
!         if vTbl.instance==tbl:
!           dc = wxMemoryDC()
!           vTbl.calculateDimensions(dc)
!           self.refresh()
!                  
! 
      
    def onPaintEvent(self, event, clear=false):
+       if self.hasNewObj:
+         self.calculateTablePositions()
+         self.hasNewObj=false
        dc = wxPaintDC(self.diagram)
!       self.diagram.PrepareDC(dc)
        dc.BeginDrawing()
+       #dc.Blit(0,0,self.panelheight,self.panelwidth,self.imagedc,0,0)
+       #dc.EndDrawing()
+       #return
+       #dc.BeginDrawing()
        if clear:
!         dc.SetBackground(self.panelColor)
          dc.Clear()
        for vTbl in self.tables:
          vTbl.drawMe(dc,self.current) 
            
        dc.EndDrawing()
  
+   def redrawBackground(self):
+     btm=wxEmptyBitmap(self.panelheight,self.panelwidth,-1)
+     dc=wxMemoryDC()
+     dc.SelectObject(btm);
+     for vTbl in self.tables:
+         vTbl.drawMe(dc,self.current)
+     self.imagedc=dc
+ 
    def calculateMousePos(self,event):
      originX, originY = self.diagram.GetViewStart()
      unitX, unitY = self.diagram.GetScrollPixelsPerUnit()
***************
*** 139,148 ****
      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()):
--- 235,245 ----
      for vTbl in self.tables:
        object=vTbl.getObjectAt(x,y)
        if object != None:
!         self.tables.reverse()        
          return object
      self.tables.reverse()
!     # in case, that no object is selected, choose root object
!     return self.rootObject
  
    def onMouseEvent(self,event):
      if not (event.LeftDown() or event.Dragging() or event.LeftUp()):
***************
*** 150,180 ****
      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
--- 247,284 ----
      if event.LeftDown():
        (x,y) = self.calculateMousePos(event)   
        object=self.getObjectAt(x,y)
!       if object._type!='VisualTable':
!         self._instance.onSetCurrentObject(object, __name__)
!         return
!       else:
!         self.dragx=x-object.xpos
!         self.dragy=y-object.ypos
!         self.dragobj=object
!         dc = wxClientDC(self.diagram)
!         self.diagram.PrepareDC(dc)
!         self.spriteOn=false
!         self.dragmode=true
  
      elif event.LeftUp() and self.dragmode:
        self.dragmode=false
!       self.refresh()
        
      elif event.Dragging() and self.dragmode:
        (x,y) = self.calculateMousePos(event)   
!       dc = wxClientDC(self.diagram)
        self.diagram.PrepareDC(dc)
        dc.BeginDrawing()
        dc.SetLogicalFunction(wxXOR)
!       if self.spriteOn:
!         self.dragobj.drawMe(dc,self.current,true)
!         
        self.dragobj.moveTo(x-self.dragx,y-self.dragy)
!       self.spriteOn=true
!       self.dragobj.drawMe(dc,self.current,true)
! 
! #     TODO: implement a way to move tables as a whole and not
! #     only showing the border of the window.
! #     one way would be to use a wxMemoryDC to paint into, 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
***************
*** 182,189 ****
--- 286,437 ----
  
        dc.EndDrawing()
  
+   # in case of a right mouse click show a context menu
+   def onRightClickEvent(self,event):    
+     (x,y) = self.calculateMousePos(event)
+     object=self.getObjectAt(x,y)
+     menu = wxMenu()
+ 
+     popup_NEWTABLE =1
+     popup_NEWFIELD =2
+     popup_NEWINDEX =3
+     popup_NEWUINDEX=4
+     popup_EDIT     =5
+     popup_RENAME   =6
+     popup_DUPPL    =7
+     popup_DEL      =8
+ 
+     # TODO: Use a generalized popup menu like in the forms designer
+     #       instead of this one. the popup menu in the treeview and
+     #       the visual editor should look the same
+ 
+     if object._type=='VisualTable':
+       object=object.instance
+       
+     self._instance.onSetCurrentObject(object, __name__)
+ 
+     if object._type=='VisualTable' or object._type=="GSTable":
+       menu.Append(popup_NEWFIELD, "Add Field")
+       EVT_MENU(self,popup_NEWFIELD,self.onAddField)
+       
+     elif object._type=="GSField":
+       menu.Append(popup_NEWINDEX, "Add Index")      
+       EVT_MENU(self,popup_NEWINDEX,self.onAddIndex)
+ 
+       menu.Append(popup_NEWUINDEX, "Add Unique Index")      
+       EVT_MENU(self,popup_NEWUINDEX,self.onAddUniqueIndex)
+       
+     else: 
+       menu.Append(popup_NEWTABLE, "New Table")
+       EVT_MENU(self,popup_NEWTABLE,self.onNewTable)
+ 
+     if object._type!='GSSchema':
+       menu.AppendSeparator()
+       
+       menu.Append(popup_EDIT, "Edit")
+       EVT_MENU(self,popup_EDIT,self.onEdit)
+ 
+       menu.Append(popup_RENAME, "Rename")
+       EVT_MENU(self,popup_RENAME,self.onRename)
        
+       menu.Append(popup_DUPPL, "Duplicate")
+       EVT_MENU(self,popup_DUPPL,self.onDuplicate)
        
+       menu.Append(popup_DEL, "Delete")
+       EVT_MENU(self,popup_DEL,self.onDelete)
+ 
+       
+     clickPt = wxPoint(x + self.diagram.GetPosition().x,
+                         y + self.diagram.GetPosition().y)
+     self.diagram.PopupMenu(menu, clickPt)
+     menu.Destroy()
+ 
+   def onNewTable(self,event):
+     dialog = wxTextEntryDialog(self.diagram,'Name of the new table:')
+   
+     if dialog.ShowModal() == wxID_OK:
+       tables=self.rootObject.findChildOfType("GSTables")
+       if tables==None:
+         tables = createObject(self._instance, self.rootObject, 'tables',
+                               None,None,self.rootObject)
+       createObject(self._instance, self.rootObject, 'table',
+                    None,None,tables,{"name":dialog.GetValue()})
+              
+     dialog.Destroy()
+ 
+   def onAddField(self,event):
+     dialog = wxTextEntryDialog(self.diagram,'Name of the new field:')
+   
+     if dialog.ShowModal() == wxID_OK:
+       fields=self.current.findChildOfType("GSFields")          
+       if fields==None:
+         tbl=self.current.findChildOfType("GSTable")
+         fields=createObject(self._instance, self.rootObject,'fields',
+                             None,None,tbl)
+         
+       createObject(self._instance, self.rootObject, 'field',
+                    None,None,fields,{"name":dialog.GetValue(),
+                                      "type":"varchar",
+                                      "size":20})
+ 
+     dialog.Destroy()
+    
+   def onAddIndex(self,event):
+     tbl=self.current.findParentOfType("GSTable")          
+     indexes=tbl.findChildOfType("GSIndexes")          
+     if indexes==None:
+       indexes = createObject(self._instance, self.rootObject, 'indexes',
+                               None,None,tbl)
+     idx=createObject(self._instance, self.rootObject, 'index',
+                  None,None,indexes,
+                  {"name":"%s_%s" % (tbl.name,self.current.name)})        
+     createObject(self._instance, self.rootObject, 'index',
+                  None,None,idx,
+                  {"name":self.current.name})        
+     self.refresh()
+ 
+   def onAddUniqueIndex(self,event):
+     tbl=self.current.findParentOfType("GSTable")          
+     indexes=tbl.findChildOfType("GSIndexes")          
+     if indexes==None:
+       indexes = createObject(self._instance, self.rootObject, 'indexes',
+                               None,None,tbl)
+     idx=createObject(self._instance, self.rootObject, 'index',
+                  None,None,indexes,
+                  {"name":"%s_%s" % (tbl.name,self.current.name),
+                   "unique":"Y"})        
+     createObject(self._instance, self.rootObject, 'index',
+                  None,None,idx,
+                  {"name":self.current.name})        
+     self.refresh()
+ 
+ 
+   def onAddConstraint(self,event):
+     pass
+ 
+   def onRename(self,event):
+     dialog = wxTextEntryDialog(self.diagram,'New Name')
+     if hasattr(self.current,'name'):
+       dialog.SetValue(self.current.name)
+       
+     if dialog.ShowModal() == wxID_OK:
+       self.current.name=dialog.GetValue()
+       self._instance.onModifyObject(self.current,"schema",
+                                     [('name',self.current.name)])
+       self.refresh()
+ 
+     dialog.Destroy()
+   
+   def onDuplicate(self,event):
+     pass
+ 
+   def onEdit(self,event):
+     print "EDIT occured"
+     pass
+   
+   def onDelete(self,event):
+     deleteObject(self._instance, self.rootObject, self.current, firstRun=1)
+ 
  
    def onLeftClickEvent(self,event):    
      (x,y) = self.calculateMousePos(event)   
Index: gnue/designer/src/schema/VisualTable.py
diff -c gnue/designer/src/schema/VisualTable.py:1.2 
gnue/designer/src/schema/VisualTable.py:1.3
*** gnue/designer/src/schema/VisualTable.py:1.2 Sat Jul 27 20:46:24 2002
--- gnue/designer/src/schema/VisualTable.py     Tue Aug  6 11:06:29 2002
***************
*** 37,42 ****
--- 37,50 ----
      self.pen = wxBLACK_PEN # wxPen(...)
      self.pen_highlighted = wxPen(wxBLUE, 1, wxSOLID)
      self.brush = wxWHITE_BRUSH # wxTRANSPARENT_BRUSH # wxBLACK_BRUSH
+     self.pen_inv = wxWHITE_PEN # wxPen(...)
+     self.brush_inv = wxBLACK_BRUSH # wxTRANSPARENT_BRUSH # wxBLACK_BRUSH
+     self.xpos=-100    
+     self.ypos=-100
+     self.width=10
+     self.height=10
+     self.textheight=10
+     
    
    def calculateDimensions(self,dc):
      (w,h)=dc.GetTextExtent(self.instance.name)
***************
*** 44,54 ****
      self.height=h
      self.textheight=h
      fields=self.instance.findChildOfType('GSFields')
!     for c in fields._children:
!       (w,h)=dc.GetTextExtent(c.name)
!       if w>self.width:
!         self.width=w
!       self.height=self.height+5+h
  
      # add some space for the borders
      self.height=self.height+40
--- 52,82 ----
      self.height=h
      self.textheight=h
      fields=self.instance.findChildOfType('GSFields')
!     if fields!=None:
!       for c in fields._children:
!         (w,h)=dc.GetTextExtent(c.name)
!         if w>self.width:
!           self.width=w
!         self.height=self.height+5+h
! 
!     # add some space for the borders
!     self.height=self.height+40
!     self.width=self.width+20
!             
!     return (self.width,self.height)
! 
!   def recalculateDimensions(self,dc):
!     (w,h)=dc.GetTextExtent(self.instance.name)
!     self.width=w
!     self.height=h
!     self.textheight=h
!     fields=self.instance.findChildOfType('GSFields')
!     if fields!=None:
!       for c in fields._children:
!         (w,h)=dc.GetTextExtent(c.name)
!         if w>self.width:
!           self.width=w
!         self.height=self.height+5+h
  
      # add some space for the borders
      self.height=self.height+40
***************
*** 60,68 ****
      self.xpos=x
      self.ypos=y
  
!   def drawMe(self,dc,current):
!       dc.SetPen(self.pen) 
!       dc.SetBrush(self.brush)
  
        dc.DrawRectangle(self.xpos,self.ypos,self.width,self.height)
        dc.DrawLine(self.xpos,self.ypos+self.textheight+20,
--- 88,100 ----
      self.xpos=x
      self.ypos=y
  
!   def drawMe(self,dc,current,inverse=false):
!       if inverse: 
!         dc.SetPen(self.pen_inv) 
!         dc.SetBrush(self.brush_inv)
!       else:
!         dc.SetPen(self.pen) 
!         dc.SetBrush(self.brush)
  
        dc.DrawRectangle(self.xpos,self.ypos,self.width,self.height)
        dc.DrawLine(self.xpos,self.ypos+self.textheight+20,
***************
*** 74,89 ****
        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:
--- 106,122 ----
        dc.DrawText(self.instance.name,self.xpos+10,self.ypos+10)
        y=self.ypos+34
        fields=self.instance.findChildOfType('GSFields')
!       if fields!=None:
!         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:
***************
*** 105,114 ****
        
        # 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
--- 138,148 ----
        
        # cursor in the middle  -> return fields
        fields=self.instance.findChildOfType('GSFields')
!       if fields!=None:
!         for c in fields._children:        
!           hy=hy+self.textheight+5
!           if y<hy:
!             return c
          
        # cursor at the bottom part ->  return table
        return self
***************
*** 118,128 ****
        return None
  
    # return pointer to field/table object depending on position
!   def isInRectangle(self,x,y,x2,y2):
!     #
!     #if x>=self.xpos and x<=self.xpos+self.height and \
!     #       y>=self.ypos and y<=self.ypos+self.width:
!     #  return self.instance
!     #else:
        return false
      
--- 152,161 ----
        return None
  
    # return pointer to field/table object depending on position
!   def isInRectangle(self,x,y,x2,y2):    
!     if (not (x>self.xpos+self.width or x2<self.xpos)) and \
!        (not (y>self.ypos+self.width and y2<self.ypos)):
!       return true
!     else:
        return false
      
Index: gnue/designer/templates/schema/Introspection.py
diff -c gnue/designer/templates/schema/Introspection.py:1.4 
gnue/designer/templates/schema/Introspection.py:1.5
*** gnue/designer/templates/schema/Introspection.py:1.4 Mon Jul 29 13:12:51 2002
--- gnue/designer/templates/schema/Introspection.py     Tue Aug  6 11:06:29 2002
***************
*** 122,132 ****
    def Finalize(self):
  
      # Set the basic attributes of the schema
! ###################################################
! ## Temporary! ModifyElement is causing segfault! ##
!     self.root.title = self.variables['title']
! ##    self.ModifyElement(self.root, title=self.variables['title'])
! ###################################################
  
      conn = self.variables['connection']
  
--- 122,128 ----
    def Finalize(self):
  
      # Set the basic attributes of the schema
!     self.ModifyElement(self.root, title=self.variables['title'])
  
      conn = self.variables['connection']
  



reply via email to

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