commit-gnue
[Top][All Lists]
Advanced

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

gnue/designer/src DataSourceEditor.py Instance....


From: Jason Cater
Subject: gnue/designer/src DataSourceEditor.py Instance....
Date: Tue, 15 Jan 2002 18:12:56 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/01/15 18:12:56

Modified files:
        designer/src   : DataSourceEditor.py Instance.py LayoutEditor.py 
                         MenuBar.py TriggerEditor.py 

Log message:
        First working drag-and-drop schema implementation (via Data Source 
editor); not fully useful yet, but almost...

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/DataSourceEditor.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/Instance.py.diff?tr1=1.40&tr2=1.41&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/LayoutEditor.py.diff?tr1=1.31&tr2=1.32&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/MenuBar.py.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/TriggerEditor.py.diff?tr1=1.12&tr2=1.13&r1=text&r2=text

Patches:
Index: gnue/designer/src/DataSourceEditor.py
diff -c gnue/designer/src/DataSourceEditor.py:1.2 
gnue/designer/src/DataSourceEditor.py:1.3
*** gnue/designer/src/DataSourceEditor.py:1.2   Tue Jan 15 14:08:01 2002
--- gnue/designer/src/DataSourceEditor.py       Tue Jan 15 18:12:56 2002
***************
*** 27,33 ****
  # NOTES:
  #
  
! import sys, os
  from wxPython.wx import *
  from gnue.common import GDebug, GConfig, GDataSource
  import RuntimeSettings
--- 27,33 ----
  # NOTES:
  #
  
! import sys, os, cPickle
  from wxPython.wx import *
  from gnue.common import GDebug, GConfig, GDataSource
  import RuntimeSettings
***************
*** 38,43 ****
--- 38,44 ----
      wxPanel.__init__(self,parentWindow,-1)
      self.instance = instance
      self.rootObject = instance.rootObject
+     self.connections = self.instance._app.connections
      self.runtime_section = "DataSourceEditor"
  
      self.toolBar = ToolBar(self, parentWindow)
***************
*** 107,113 ****
        # TODO: Implement sorting?
        index = self.list.GetItemCount()
        self.list.InsertStringItem(index, object.name)
- #      self.list.SetStringItem(index, 0, object.name)
        self.list.SetStringItem(index, 1,
               hasattr(object,'table') and object.table or '')
        self.list.SetStringItem(index, 2,
--- 108,113 ----
***************
*** 125,133 ****
      if object == None:
        return
  
-     if hasattr(object, '_widgetHandler'):
-       self.propBar.setCurrentObject(object)
- 
      if handler != __name__:
        if isinstance(object, GDataSource.GDataSource):
  
--- 125,130 ----
***************
*** 138,143 ****
--- 135,142 ----
  
          self.list.EnsureVisible(object.__listIndex)
  
+     self.schemas.onSetCurrentObject(object, handler)
+ 
  
    def onCreateObject (self, object, handler):
      self._currentSelection = {}
***************
*** 225,230 ****
--- 224,232 ----
          RuntimeSettings.getint(
             self.runtime_section, "schemaCol%s" % i, -2))
  
+     self.list.Refresh()
+     self.Refresh()
+ 
  
    def saveRuntimeSettings(self):
      sash = self.GetPositionTuple()
***************
*** 249,254 ****
--- 251,257 ----
    # A Datasource was selected in the menu
    def OnDSSelected(self, event):
      self.current = self.datasourceMap[event.GetData()]
+     self.instance.onSetCurrentObject(self.current, __name__)
  
  
    def OnAddDSSelected(self, event):
***************
*** 275,281 ****
      wxToolBar.__init__(self, parent, -1, style=wxTB_DOCKABLE)
      self.editor = editor
      parent.SetToolBar(self)
-     self.connections = self.editor.instance._app.connections
  
      self.addButtonId = wxNewId()
      self.deleteButtonId = wxNewId()
--- 278,283 ----
***************
*** 318,333 ****
  
      self.list.InsertColumn(SCH_FIELD, 'Field')
      self.list.InsertColumn(SCH_TYPE,  'Base Type')
!     self.list.InsertColumn(SCH_SIZE,  'Size')
      self.list.InsertColumn(SCH_NATIVE,'Native Type')
      self.list.InsertColumn(SCH_REQ,   'Required')
  
      EVT_SIZE(self, self.OnSize)
  
  
    def fillList(self):
! #    self.editor.
!     pass
  
    def onSetCurrentObject(self, object, controller):
      if isinstance(object, GDataSource.GDataSource):
--- 320,387 ----
  
      self.list.InsertColumn(SCH_FIELD, 'Field')
      self.list.InsertColumn(SCH_TYPE,  'Base Type')
!     self.list.InsertColumn(SCH_SIZE,  'Size', wxLIST_FORMAT_RIGHT)
      self.list.InsertColumn(SCH_NATIVE,'Native Type')
      self.list.InsertColumn(SCH_REQ,   'Required')
  
+     self.schemaMap = []
+ 
      EVT_SIZE(self, self.OnSize)
+     EVT_LIST_BEGIN_DRAG(self, self.list.GetId(), self.OnBeginDrag)
  
  
    def fillList(self):
! 
!    try:
!     conn = self.editor.current.database
! 
!     # TODO: This is very, very temporary...
!     # TODO: Designer shouldn't care about gconnection's internal
!     # TODO: attributes.  AS SOON AS common goes to 0.3.0, create
!     # TODO: an isConnectionActive(conn_name) method in GConnections
!     # TODO: and reuse here.
! 
!     if not self.editor.connections._openConnections.has_key(conn) and \
!        not int(GConfig.get("AutoConnect","0")):
! 
!       # TODO: Some other form of feedback
!       if not hasattr(self.editor,'_schemaMessageDisplayed'):
!         print "You are not logged in to %s... not retrieving schema" % (conn)
!         self.editor._schemaMessageDisplayed = 1
! 
!       return
! 
!     # TODO: Much error catching... any DB errors should be
!     # TODO: trapped so the designing session can continue,
!     # TODO: albeit without schema support.
! 
!     dataObject = self.editor.connections.getDataObject(conn, "object")
! 
!     self.editor.connections.requestConnection(dataObject, conn)
! 
!     schema = dataObject.getSchemaByName(self.editor.current.table)
! 
!     index = 0
!     self.list.DeleteAllItems()
!     if schema:
!       for field in schema.getChildSchema(schema):
!         self.list.InsertStringItem(index, field.name)
!         self.list.SetStringItem(index, SCH_TYPE,
!            string.upper(field.datatype[0]) + field.datatype[1:])
!         self.list.SetStringItem(index, SCH_NATIVE,
!            hasattr(field, 'nativetype') and field.nativetype or '(unknown)')
!         self.list.SetStringItem(index, SCH_REQ,
!            field.required and "Yes" or "No")
!         self.list.SetStringItem(index, SCH_SIZE,
!            hasattr(field, 'length') and ("%s"%field.length) or '-')
!         self.list.SetItemData(index, index)
!         self.schemaMap.append(field)
!         index += 1
! 
!    except:
!      # TODO: actually filter connection errors
!      pass
! 
  
    def onSetCurrentObject(self, object, controller):
      if isinstance(object, GDataSource.GDataSource):
***************
*** 337,340 ****
--- 391,414 ----
    def OnSize(self, event):
      self.list.SetSize(self.GetSize())
  
+ 
+   def OnBeginDrag(self, event):
+ 
+     object = self.schemaMap[event.GetData()]
+ 
+     data = { "Type" : "entry",
+              "Attributes": {
+                "datasource": self.current.name,
+                "name": "fld%s__%s" % (self.current.name,
+                        string.lower(object.name))
+              }
+            }
+ 
+     do = wxCustomDataObject(wxCustomDataFormat("GNUeDesVisualElement"))
+     do.SetData(cPickle.dumps(data,1))
+ 
+ 
+     dropSource = wxDropSource(self)
+     dropSource.SetData(do)
+     result = dropSource.DoDragDrop(false)
  
Index: gnue/designer/src/Instance.py
diff -c gnue/designer/src/Instance.py:1.40 gnue/designer/src/Instance.py:1.41
*** gnue/designer/src/Instance.py:1.40  Mon Jan 14 18:19:29 2002
--- gnue/designer/src/Instance.py       Tue Jan 15 18:12:56 2002
***************
*** 283,288 ****
--- 283,289 ----
  
  
    def onSetCurrentObject (self, object, handler):
+     self._currentObject = object
      for listener in self.objectListeners:
        listener.onSetCurrentObject(object, handler)
  
***************
*** 405,415 ****
--- 406,431 ----
  
      self.makeClean()
  
+ 
+   def OnConnectTo(self, event):
+     # connectionMap is built by MenuBar
+     conn = self.connectionMap[event.GetId()]
+     tempDO = self.connections.getDataObject(conn, 'object')
+     try:
+       self.connections.requestConnection(tempDO, conn)
+       self._menubar._fileConnect.Enable(event.GetId(),0)
+       self.onSetCurrentObject(self._currentObject, __name__)
+     except:
+       print "Unable to connect to %s" % conn
+ 
+ 
+ 
    def OnSave(self, event):
      if not len(self._path):
        self.OnSaveAs(event)
      else:
        self.saveForm()
+ 
  
    def OnSaveAs(self, event):
      dlg = wxFileDialog(NULL, "Save GNUe Form As...", defaultDir=os.getcwd(),
Index: gnue/designer/src/LayoutEditor.py
diff -c gnue/designer/src/LayoutEditor.py:1.31 
gnue/designer/src/LayoutEditor.py:1.32
*** gnue/designer/src/LayoutEditor.py:1.31      Mon Jan 14 15:29:54 2002
--- gnue/designer/src/LayoutEditor.py   Tue Jan 15 18:12:56 2002
***************
*** 26,36 ****
  # NOTES:
  
  
! import sys, os
  from wxPython.wx import *
  from gnue.common import GDebug, GConfig
  from gnue.forms import UIwxpython, GFObjects
  from PopupMenu import PageMenu
  
  class LayoutEditor (wxPanel):
    def __init__(self, instance, parentWindow):
--- 26,37 ----
  # NOTES:
  
  
! import sys, os, cPickle
  from wxPython.wx import *
  from gnue.common import GDebug, GConfig
  from gnue.forms import UIwxpython, GFObjects
  from PopupMenu import PageMenu
+ import Incubator
  
  class LayoutEditor (wxPanel):
    def __init__(self, instance, parentWindow):
***************
*** 60,72 ****
      instance.rootObject.walk (self.inventoryObject)
  
  
!   def inventoryObject(self, object): 
!     if object._type == 'GFPage': 
        index = self.notebook.GetPageCount()
        self._notebookMap[object] = index
        self._notebookMap[index] = object
  
!       self.workspace = wxScrolledWindow(self.notebook, -1, pos=wxPoint(0,0), 
           style=wxCLIP_CHILDREN|wxHSCROLL|wxVSCROLL|wxSUNKEN_BORDER)
  
        # TODO: self.workspace needs to have SetScrollbars called with
--- 61,73 ----
      instance.rootObject.walk (self.inventoryObject)
  
  
!   def inventoryObject(self, object):
!     if object._type == 'GFPage':
        index = self.notebook.GetPageCount()
        self._notebookMap[object] = index
        self._notebookMap[index] = object
  
!       self.workspace = wxScrolledWindow(self.notebook, -1, pos=wxPoint(0,0),
           style=wxCLIP_CHILDREN|wxHSCROLL|wxVSCROLL|wxSUNKEN_BORDER)
  
        # TODO: self.workspace needs to have SetScrollbars called with
***************
*** 77,130 ****
        self.notebook.AddPage(self.workspace,object.name)
        object.__workspace = self.workspace
        self.drawPage(object)
!       
  
    def onSetCurrentObject (self, object, handler):
      self._currentObject = object
!     if object == None: 
        for o in self._currentSelection.keys():
          o.setSelected(0)
        return
      if hasattr(object, '_widgetHandler'):
        self.propBar.setCurrentObject(object)
!     if handler != __name__: 
        self._setCurrentPage(object)
  
  
!   def _setCurrentPage(self, object): 
  
      page = isinstance(object, GFObjects.GFPage) and object or \
             object.findParentOfType('GFPage')
  
!     if page != None and page != self.page: 
!       self.page = page 
        self.notebook.SetSelection(self._notebookMap[page])
!       try: 
          self.workspace = page.__workspace
          self.panel = self.page.__panel
!       except AttributeError: 
!         # This simply means we are setting up 
!         # our notebook for the first time. 
          pass
  
  
!   def __setCurrentObject(self,object): 
!     if hasattr(object, '_widgetHandler'): 
        self._currentSelection[object._widgetHandler] = 1
        object._widgetHandler.setSelected(1)
  
  
    def onCreateObject (self, object, handler):
      self._currentSelection = {}
!     if object == None: 
        return
  
      if handler != __name__:
        origpage = self.page
  
!       if object._type != 'GFPage': 
          page = object.findParentOfType('GFPage')
!         if page: 
            self._setCurrentPage(page)
            self.__drawItem(object)
  
--- 78,131 ----
        self.notebook.AddPage(self.workspace,object.name)
        object.__workspace = self.workspace
        self.drawPage(object)
! 
  
    def onSetCurrentObject (self, object, handler):
      self._currentObject = object
!     if object == None:
        for o in self._currentSelection.keys():
          o.setSelected(0)
        return
      if hasattr(object, '_widgetHandler'):
        self.propBar.setCurrentObject(object)
!     if handler != __name__:
        self._setCurrentPage(object)
  
  
!   def _setCurrentPage(self, object):
  
      page = isinstance(object, GFObjects.GFPage) and object or \
             object.findParentOfType('GFPage')
  
!     if page != None and page != self.page:
!       self.page = page
        self.notebook.SetSelection(self._notebookMap[page])
!       try:
          self.workspace = page.__workspace
          self.panel = self.page.__panel
!       except AttributeError:
!         # This simply means we are setting up
!         # our notebook for the first time.
          pass
  
  
!   def __setCurrentObject(self,object):
!     if hasattr(object, '_widgetHandler'):
        self._currentSelection[object._widgetHandler] = 1
        object._widgetHandler.setSelected(1)
  
  
    def onCreateObject (self, object, handler):
      self._currentSelection = {}
!     if object == None:
        return
  
      if handler != __name__:
        origpage = self.page
  
!       if object._type != 'GFPage':
          page = object.findParentOfType('GFPage')
!         if page:
            self._setCurrentPage(page)
            self.__drawItem(object)
  
***************
*** 155,161 ****
      if handler != __name__:
        if object._type == 'GFPage': 
          index = self._notebookMap[object]
!         for i in range(index+1, len(self._notebookMap.keys())/2): 
            self._notebookMap[i-1] = self._notebookMap[i]
          del self._notebookMap[int(len(self._notebookMap.keys())/2)-1]
          del self._notebookMap[object]
--- 156,162 ----
      if handler != __name__:
        if object._type == 'GFPage': 
          index = self._notebookMap[object]
!         for i in range(index+1, len(self._notebookMap.keys())/2):
            self._notebookMap[i-1] = self._notebookMap[i]
          del self._notebookMap[int(len(self._notebookMap.keys())/2)-1]
          del self._notebookMap[object]
***************
*** 163,190 ****
        if hasattr(object, '_widgetHandler') and object._widgetHandler != None:
          object._widgetHandler.Destroy()
  
!   def refreshPage(self, page): 
!     try: 
        page.__panel.Destroy()
        del page.__panel
!     except AttributeError: 
        pass
  
      self.drawPage(page)
  
  
!   def drawPage(self, page): 
      self._currentSelection = {}
      self.page = page
  
!     try: 
        self.panel = self.page.__panel
!     except AttributeError: 
        self.panel = GridPane(self, self.workspace, wxPoint(10,12))
        self.page.__panel = self.panel
        self.panelColor = self.panel.GetBackgroundColour()
        self.panelGridColor = wxColour(self.panelColor.Red()+16,
!                  self.panelColor.Green()+16,    
                   self.panelColor.Blue()+16)
  
        UIwxpython.initFont(self.panel)
--- 164,196 ----
        if hasattr(object, '_widgetHandler') and object._widgetHandler != None:
          object._widgetHandler.Destroy()
  
!   def refreshPage(self, page):
!     try:
        page.__panel.Destroy()
        del page.__panel
!     except AttributeError:
        pass
  
      self.drawPage(page)
  
  
!   def drawPage(self, page):
      self._currentSelection = {}
      self.page = page
  
!     try:
        self.panel = self.page.__panel
!     except AttributeError:
        self.panel = GridPane(self, self.workspace, wxPoint(10,12))
+ 
+       # We are a drop target for Drag-and-Drop
+       self.panel.SetDropTarget(DisplayDropTarget(self))
+ 
+ 
        self.page.__panel = self.panel
        self.panelColor = self.panel.GetBackgroundColour()
        self.panelGridColor = wxColour(self.panelColor.Red()+16,
!                  self.panelColor.Green()+16,
                   self.panelColor.Blue()+16)
  
        UIwxpython.initFont(self.panel)
***************
*** 193,199 ****
  
        # need to add string.punctionation if we dump python 1.5.2
        checkchars = string.letters+string.digits+"-\|" + string.punctuation
!       for letter in checkchars:   
          width,height,descent,leading = self.panel.GetFullTextExtent(letter)
          maxWidth = maxWidth > width and maxWidth or width
          maxHeight = maxHeight > height and maxHeight or height
--- 199,205 ----
  
        # need to add string.punctionation if we dump python 1.5.2
        checkchars = string.letters+string.digits+"-\|" + string.punctuation
!       for letter in checkchars:
          width,height,descent,leading = self.panel.GetFullTextExtent(letter)
          maxWidth = maxWidth > width and maxWidth or width
          maxHeight = maxHeight > height and maxHeight or height
***************
*** 202,208 ****
  
        self.charWidth = maxWidth+maxLeading
        self.charHeight = maxHeight+maxDescent
!     
        self.borderPercentage = (int(GConfig.get('borderPercentage')) / 100.0)
        self.textPercentage = (int(GConfig.get('textPercentage')) / 100.0)
  
--- 208,214 ----
  
        self.charWidth = maxWidth+maxLeading
        self.charHeight = maxHeight+maxDescent
! 
        self.borderPercentage = (int(GConfig.get('borderPercentage')) / 100.0)
        self.textPercentage = (int(GConfig.get('textPercentage')) / 100.0)
  
***************
*** 213,219 ****
        self.widgetHeight = (self.charHeight * self.borderPercentage) + 3
        self.textWidth = self.charWidth * self.textPercentage
        self.textHeight = self.charHeight * self.textPercentage
!  
        self.gridWidth = self.widgetWidth
        self.gridHeight = self.widgetHeight
  
--- 219,225 ----
        self.widgetHeight = (self.charHeight * self.borderPercentage) + 3
        self.textWidth = self.charWidth * self.textPercentage
        self.textHeight = self.charHeight * self.textPercentage
! 
        self.gridWidth = self.widgetWidth
        self.gridHeight = self.widgetHeight
  
***************
*** 236,242 ****
  
    def __drawItem(self, object):
      if self.widgets.has_key(object.getObjectType()) and \
!        (not hasattr(object, 'hidden') or not object.hidden): 
        if hasattr(object, 'name'): 
          GDebug.printMesg(7, 'Drawing item %s of type %s' % (object.name, 
object.getObjectType()))
        else: 
--- 242,248 ----
  
    def __drawItem(self, object):
      if self.widgets.has_key(object.getObjectType()) and \
!        (not hasattr(object, 'hidden') or not object.hidden):
        if hasattr(object, 'name'): 
          GDebug.printMesg(7, 'Drawing item %s of type %s' % (object.name, 
object.getObjectType()))
        else: 
***************
*** 270,277 ****
      self._instance.onSetCurrentObject(b, None)
   
   
!   def OnRightUp(self, event): 
!     x, y = event.GetPositionTuple() 
  
      x = int(x / self.gridWidth)
      y = int(y / self.gridHeight)
--- 276,283 ----
      self._instance.onSetCurrentObject(b, None)
   
   
!   def OnRightUp(self, event):
!     x, y = event.GetPositionTuple()
  
      x = int(x / self.gridWidth)
      y = int(y / self.gridHeight)
***************
*** 313,319 ****
            for widget in self._currentSelection.keys(): 
              widget.relativeMove(-1,0)
          if event.KeyCode() == WXK_RIGHT:
!           for widget in self._currentSelection.keys(): 
              widget.relativeMove(1,0)
          if event.KeyCode() == WXK_UP: 
            for widget in self._currentSelection.keys(): 
--- 319,325 ----
            for widget in self._currentSelection.keys(): 
              widget.relativeMove(-1,0)
          if event.KeyCode() == WXK_RIGHT:
!           for widget in self._currentSelection.keys():
              widget.relativeMove(1,0)
          if event.KeyCode() == WXK_UP: 
            for widget in self._currentSelection.keys(): 
***************
*** 365,371 ****
  
    def recalcBoundaries(self): 
      x1,y1,x2,y2 = (9999999,9999999,0,0)
!    
      for widget in self.mainWidget.widgets:
        tx, ty = widget.GetPositionTuple()
        tw, th = widget.GetSizeTuple()
--- 371,377 ----
  
    def recalcBoundaries(self): 
      x1,y1,x2,y2 = (9999999,9999999,0,0)
! 
      for widget in self.mainWidget.widgets:
        tx, ty = widget.GetPositionTuple()
        tw, th = widget.GetSizeTuple()
***************
*** 408,414 ****
  
      self.mouseStartX, self.mouseStartY = event.GetPositionTuple()
  
!     if not event.ShiftDown(): 
        for selection in self.instance._currentSelection.keys(): 
          selection.setSelected(0)
        self.instance._currentSelection = {}
--- 414,420 ----
  
      self.mouseStartX, self.mouseStartY = event.GetPositionTuple()
  
!     if not event.ShiftDown():
        for selection in self.instance._currentSelection.keys(): 
          selection.setSelected(0)
        self.instance._currentSelection = {}
***************
*** 451,457 ****
  #                         (self.mouseStartX,self.mouseStartY, 
relativeX,relativeY,xshift,yshift))
          self.relativeMove(xshift,yshift)
          
!   def OnRightDown(self, event): 
      pass
   
    def OnRightUp(self, event): 
--- 457,463 ----
  #                         (self.mouseStartX,self.mouseStartY, 
relativeX,relativeY,xshift,yshift))
          self.relativeMove(xshift,yshift)
          
!   def OnRightDown(self, event):
      pass
   
    def OnRightUp(self, event): 
***************
*** 495,501 ****
   
  
    #
!   # Move the current widget. dx and dy are increments. 
    # (e.g., (-1,-2) means move the object up one unit 
    # and left two units. 
    #
--- 501,507 ----
   
  
    #
!   # Move the current widget. dx and dy are increments.
    # (e.g., (-1,-2) means move the object up one unit 
    # and left two units. 
    #
***************
*** 528,534 ****
    def Destroy(self): 
      self.highlightBox.Destroy()
      for widget in self.mainWidget.widgets: 
!       widget.Destroy() 
  
  #
  #
--- 534,540 ----
    def Destroy(self): 
      self.highlightBox.Destroy()
      for widget in self.mainWidget.widgets: 
!       widget.Destroy()
  
  #
  #
***************
*** 571,577 ****
         self.west.SetPosition(wxPoint(x1,y1))  
         self.west.SetSize(wxSize(1,y2-y1+1)) 
       if self.east: 
!        self.east.SetPosition(wxPoint(x2,y1))  
         self.east.SetSize(wxSize(1,y2-y1+1)) 
       if self.south:
         self.south.SetPosition(wxPoint(x1,y2))  
--- 577,583 ----
         self.west.SetPosition(wxPoint(x1,y1))  
         self.west.SetSize(wxSize(1,y2-y1+1)) 
       if self.east: 
!        self.east.SetPosition(wxPoint(x2,y1))
         self.east.SetSize(wxSize(1,y2-y1+1)) 
       if self.south:
         self.south.SetPosition(wxPoint(x1,y2))  
***************
*** 580,587 ****
         self.north.SetPosition(wxPoint(x1,y1))  
         self.north.SetSize(wxSize(x2-x1+1,1)) 
  
!   def GetChildren(self): 
!     if self.west: 
        return (self.north, self.south, self.east, self.west)
      else: 
        return ()
--- 586,593 ----
         self.north.SetPosition(wxPoint(x1,y1))  
         self.north.SetSize(wxSize(x2-x1+1,1)) 
  
!   def GetChildren(self):
!     if self.west:
        return (self.north, self.south, self.east, self.west)
      else: 
        return ()
***************
*** 623,630 ****
      dc.Clear()
      if self.selected: 
        dc.SetPen(wxPen(self.activeBorderColor))
!     else: 
!       dc.SetPen(wxPen(self.inactiveBorderColor))    
      x1,y1 = object.GetSizeTuple()
      dc.DrawRectangle(0,0,x1,y1)
      dc.EndDrawing()
--- 629,636 ----
      dc.Clear()
      if self.selected: 
        dc.SetPen(wxPen(self.activeBorderColor))
!     else:
!       dc.SetPen(wxPen(self.inactiveBorderColor))
      x1,y1 = object.GetSizeTuple()
      dc.DrawRectangle(0,0,x1,y1)
      dc.EndDrawing()
***************
*** 666,672 ****
      self.parent = parent
      self.object = None
      self.nameLabel = wxStaticText(self, -1, "Name:", pos=wxPoint(4,8)) 
!     self.nameEditor = wxTextCtrl(self, -1,  
            pos=calcRelPos(self.nameLabel, dx=6, absy=4))
      self.typeLabel = wxStaticText(self, -1, "Class:", 
            pos=calcRelPos(self.nameEditor, absx=4, dy=8))
--- 672,678 ----
      self.parent = parent
      self.object = None
      self.nameLabel = wxStaticText(self, -1, "Name:", pos=wxPoint(4,8)) 
!     self.nameEditor = wxTextCtrl(self, -1,
            pos=calcRelPos(self.nameLabel, dx=6, absy=4))
      self.typeLabel = wxStaticText(self, -1, "Class:", 
            pos=calcRelPos(self.nameEditor, absx=4, dy=8))
***************
*** 710,716 ****
      self.object.name = self.nameEditor.GetValue()
  #    self.parent._instance.onModifyObject(self.object, __name__, 
  
!   def OnXUpdated(self, event): 
      if hasattr(self.object, 'x'):
        dx = self.xEditor.GetValue() - self.object.x
        if dx: 
--- 716,722 ----
      self.object.name = self.nameEditor.GetValue()
  #    self.parent._instance.onModifyObject(self.object, __name__, 
  
!   def OnXUpdated(self, event):
      if hasattr(self.object, 'x'):
        dx = self.xEditor.GetValue() - self.object.x
        if dx: 
***************
*** 739,745 ****
        dh = self.hEditor.GetValue() - self.object.height
        if dh: 
          self.object._widgetHandler.relativeResize(0,dh)
!     else: 
        self.hEditor.SetValue(0)
  
    def setCurrentObject(self, object): 
--- 745,751 ----
        dh = self.hEditor.GetValue() - self.object.height
        if dh: 
          self.object._widgetHandler.relativeResize(0,dh)
!     else:
        self.hEditor.SetValue(0)
  
    def setCurrentObject(self, object): 
***************
*** 796,821 ****
            self.wEditor.SetValue(value)
          elif field == 'height': 
            self.hEditor.SetValue(value)
!         elif field == 'name': 
            self.nameEditor.SetValue(value)
  
  
! def calcRelPos(xsource, ysource=None, absx=None, absy=None, dx=None, 
dy=None): 
!   if ysource == None: 
      ysource = xsource
    x = xsource.GetPosition().x
    y = ysource.GetPosition().y
    w = xsource.GetSize().width
    h = ysource.GetSize().height
  
!   if absx != None: 
      x = absx
!   else: 
      x = x + w + dx
  
!   if absy != None: 
      y = absy
!   else: 
      y = y + h + dy
  
!   return wxPoint (x,y) 
--- 802,882 ----
            self.wEditor.SetValue(value)
          elif field == 'height': 
            self.hEditor.SetValue(value)
!         elif field == 'name':
            self.nameEditor.SetValue(value)
  
  
! def calcRelPos(xsource, ysource=None, absx=None, absy=None, dx=None, dy=None):
!   if ysource == None:
      ysource = xsource
    x = xsource.GetPosition().x
    y = ysource.GetPosition().y
    w = xsource.GetSize().width
    h = ysource.GetSize().height
  
!   if absx != None:
      x = absx
!   else:
      x = x + w + dx
  
!   if absy != None:
      y = absy
!   else:
      y = y + h + dy
  
!   return wxPoint (x,y)
! 
! 
! #
! # Drag and Drop support for our grid
! #
! class DisplayDropTarget(wxPyDropTarget):
! 
!   def __init__(self, editor):
!     wxPyDropTarget.__init__(self)
!     self.editor = editor
! 
!     self.data = wxCustomDataObject(wxCustomDataFormat("GNUeDesVisualElement"))
!     self.SetDataObject(self.data)
! 
!   def OnEnter(self, x, y, d):
!     return d
! 
!   def OnLeave(self):
!     pass
! 
!   def OnDrop(self, x, y):
!     pass
! 
!   def OnDragOver(self, x, y, d):
!     return d
! 
!   # Called when OnDrop returns true.  We need to get the data and
!   # do something with it.
!   def OnData(self, x, y, d):
! 
!     # copy the data from the drag source to our data object
!     if self.GetData():
!       # convert it back to our format
!       data = self.data.GetData()
!       params = cPickle.loads(data)
! 
!       x = int(x / self.editor.gridWidth)
!       y = int(y / self.editor.gridHeight)
! 
!       attributes = params['Attributes']
!       attributes['x'] = x
!       attributes['y'] = y
! 
!       # TODO: Apply to a block!!!
! 
!       Incubator.createObject(self.editor._instance,
!          self.editor._instance.rootObject,
!          params['Type'], parent=self.editor.page,
!          attributes=attributes)
! 
!     return d  # what is returned signals the source what to do
!               # with the original data (move, copy, etc.)  In this
!               # case we just return the suggested value given to us.
! 
! 
Index: gnue/designer/src/MenuBar.py
diff -c gnue/designer/src/MenuBar.py:1.15 gnue/designer/src/MenuBar.py:1.16
*** gnue/designer/src/MenuBar.py:1.15   Mon Jan 14 15:29:54 2002
--- gnue/designer/src/MenuBar.py        Tue Jan 15 18:12:56 2002
***************
*** 37,42 ****
--- 37,43 ----
  ID_SAVE = wxNewId()
  ID_SAVE_AS = wxNewId()
  ID_SAVE_ALL = wxNewId()
+ ID_CONNECT = wxNewId()
  ID_CLOSE = wxNewId()
  ID_RELOAD = wxNewId()
  ID_EXIT = wxNewId()
***************
*** 71,88 ****
       self._file = wxMenu()
       self._fileNew = wxMenu()
       self._fileRecent = wxMenu()
       self._file.AppendMenu(ID_NEW, "&New", self._fileNew,"Create a new 
object")
       self._file.Append(ID_OPEN, "&Open...", "Open an existing object")
!      self._file.AppendMenu(ID_OPEN_RECENT, "Open &Recent", self._fileRecent, \
                             "Open an existing object")
       self._file.AppendSeparator()
       self._file.Append(ID_SAVE, "&Save", "Save the current object")
!      self._file.Append(ID_SAVE_AS, "Save &As...", \
                         "Save the current form under a new name")
!      self._file.Append(ID_SAVE_ALL, "Save A&ll", \
                         "Save all open objects")
       self._file.AppendSeparator()
!      self._file.Append(ID_RELOAD, "Reload", \
          "Reload the current object as of its last save (abandoning any 
changes)")
       self._file.AppendSeparator()
       self._file.Append(ID_CLOSE, "&Close", "Close the current object")
--- 72,94 ----
       self._file = wxMenu()
       self._fileNew = wxMenu()
       self._fileRecent = wxMenu()
+      self._fileConnect = wxMenu()
+ 
       self._file.AppendMenu(ID_NEW, "&New", self._fileNew,"Create a new 
object")
       self._file.Append(ID_OPEN, "&Open...", "Open an existing object")
!      self._file.AppendMenu(ID_OPEN_RECENT, "Open &Recent", self._fileRecent,
                             "Open an existing object")
       self._file.AppendSeparator()
       self._file.Append(ID_SAVE, "&Save", "Save the current object")
!      self._file.Append(ID_SAVE_AS, "Save &As...", 
                         "Save the current form under a new name")
!      self._file.Append(ID_SAVE_ALL, "Save A&ll",
                         "Save all open objects")
       self._file.AppendSeparator()
!      self._file.AppendMenu(ID_CONNECT, "Connect &to", self._fileConnect,
!                            "Connect to a database")
!      self._file.AppendSeparator()
!      self._file.Append(ID_RELOAD, "Reload",
          "Reload the current object as of its last save (abandoning any 
changes)")
       self._file.AppendSeparator()
       self._file.Append(ID_CLOSE, "&Close", "Close the current object")
***************
*** 102,113 ****
       # Set up out MRU list
       frame._app.mru.addMenu(self._fileRecent, frame)
  
- 
       self._fileNew.Append(ID_NEW_FORM,'&Form', "Create a new form")
       self._fileNew.Append(ID_NEW_REPORT,'&Report', "Create a new report")
       self._fileNew.AppendSeparator()
       self._fileNew.Append(ID_NEW_WIZARD,'from &Wizard...', \
                            "Create a new object from a wizard")
  
       self._fileNew.Enable(ID_NEW_REPORT,0)
       self._file.Enable(ID_RELOAD,0)
--- 108,126 ----
       # Set up out MRU list
       frame._app.mru.addMenu(self._fileRecent, frame)
  
       self._fileNew.Append(ID_NEW_FORM,'&Form', "Create a new form")
       self._fileNew.Append(ID_NEW_REPORT,'&Report', "Create a new report")
       self._fileNew.AppendSeparator()
       self._fileNew.Append(ID_NEW_WIZARD,'from &Wizard...', \
                            "Create a new object from a wizard")
+ 
+      # Build a connection list
+      frame.connectionMap = {}
+      for conn in frame.connections.getAllConnectionParameters().keys():
+        id = wxNewId()
+        self._fileConnect.Append(id, conn, "Login to %s connection" % conn)
+        frame.connectionMap[id] = conn
+        EVT_MENU(frame, id, frame.OnConnectTo)
  
       self._fileNew.Enable(ID_NEW_REPORT,0)
       self._file.Enable(ID_RELOAD,0)
Index: gnue/designer/src/TriggerEditor.py
diff -c gnue/designer/src/TriggerEditor.py:1.12 
gnue/designer/src/TriggerEditor.py:1.13
*** gnue/designer/src/TriggerEditor.py:1.12     Tue Jan 15 14:08:01 2002
--- gnue/designer/src/TriggerEditor.py  Tue Jan 15 18:12:56 2002
***************
*** 163,170 ****
--- 163,172 ----
  
  
  try:
+ 
   if int(GConfig.get('ForceSimpleEditor','0')):
     raise ImportError
+    
   from wxPython.stc import *
   USE_STC = 1
  



reply via email to

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