commit-gnue
[Top][All Lists]
Advanced

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

gnue-designer/src base/tools/SchemaNavigator.py...


From: Jason Cater
Subject: gnue-designer/src base/tools/SchemaNavigator.py...
Date: Thu, 10 Jul 2003 18:56:21 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue-designer
Branch:         
Changes by:     Jason Cater <address@hidden>    03/07/10 18:56:21

Modified files:
        src/base/tools : SchemaNavigator.py TreeView.py 
        src/forms/LayoutEditor: DisplayDropTarget.py 

Log message:
        * Changed the schema navigator to a plain tree control
        * Fixed the automatic form resize issue when dragging schema onto the 
layout editor
        * Misc bug fixes

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-designer/src/base/tools/SchemaNavigator.py.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-designer/src/base/tools/TreeView.py.diff?tr1=1.37&tr2=1.38&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-designer/src/forms/LayoutEditor/DisplayDropTarget.py.diff?tr1=1.19&tr2=1.20&r1=text&r2=text

Patches:
Index: gnue-designer/src/base/tools/SchemaNavigator.py
diff -c gnue-designer/src/base/tools/SchemaNavigator.py:1.8 
gnue-designer/src/base/tools/SchemaNavigator.py:1.9
*** gnue-designer/src/base/tools/SchemaNavigator.py:1.8 Thu Jul 10 18:15:36 2003
--- gnue-designer/src/base/tools/SchemaNavigator.py     Thu Jul 10 18:56:21 2003
***************
*** 76,91 ****
  
      self.current = None
  
! 
!     self.scroller = scroller = wxSplitterScrolledWindow(self, -1, #(50,50), 
(350, 250),
!                                       style=wxNO_BORDER | wxCLIP_CHILDREN | 
wxVSCROLL)
!     self.splitter = splitter = wxThinSplitterWindow(scroller, -1, 
style=wxSP_3DBORDER | wxCLIP_CHILDREN)
!     splitter.SetSashSize(2)
! 
!     print dir(scroller)
! 
!     self.tree = tree = TreeCtrl(splitter, self)
!     root = self.tree.AddRoot('Schema')
      tree.SetItemHasChildren(root, 1)
      tree.SetPyData(root, self)
      for connection in self.connectionNames:
--- 76,83 ----
  
      self.current = None
  
!     self.tree = tree = TreeCtrl(self, self)
!     root = tree.AddRoot('Schema')
      tree.SetItemHasChildren(root, 1)
      tree.SetPyData(root, self)
      for connection in self.connectionNames:
***************
*** 93,109 ****
      tree.Expand(root)
  
  
!     valueWindow = ListWindow(splitter)
! 
!     splitter.SplitVertically(tree, valueWindow, 150)
!     scroller.SetTargetWindow(tree)
!     scroller.EnableScrolling(False, False)
! 
!     valueWindow.SetTreeCtrl(tree)
!     tree.SetCompanionWindow(valueWindow)
  
      sizer = wxBoxSizer(wxVERTICAL)
!     sizer.Add(scroller, 1, wxEXPAND|wxALL, 0)
      self.SetAutoLayout(True)
      self.SetSizer(sizer)
  
--- 85,94 ----
      tree.Expand(root)
  
  
! #    scroller.EnableScrolling(False, False)
  
      sizer = wxBoxSizer(wxVERTICAL)
!     sizer.Add(tree, 1, wxEXPAND|wxALL, 6)
      self.SetAutoLayout(True)
      self.SetSizer(sizer)
  
***************
*** 117,137 ****
  ##                      })
  
      self.expanded = 1
      EVT_TREE_BEGIN_DRAG(self, self.tree.GetId(), self.OnBeginDrag)
      EVT_TREE_BEGIN_RDRAG(self, self.tree.GetId(), self.OnBeginRDrag)
  
  
    def createToolbar(self, parent):
      return _SchemaToolbar(parent, self.instance)
  
    def __OnSize(self, event):
! #    self.scroll.SetSize(self.GetClientSize())
! #    self.scroller.SetScrollbars(10,10,10,10)
!     # This is some hackery since the earlier
!     # SetSashPosition is doing absolutely no good :(
!     if self.splitter.GetSashPosition() < 30:
!       self.splitter.SetSashPosition(int(self.splitter.GetSizeTuple()[0]*.6))
! 
      event.Skip()
  
    # Since this class is the root node, we need to
--- 102,121 ----
  ##                      })
  
      self.expanded = 1
+     EVT_TREE_SEL_CHANGED(self, self.tree.GetId(), self.OnSelectionChange)
      EVT_TREE_BEGIN_DRAG(self, self.tree.GetId(), self.OnBeginDrag)
      EVT_TREE_BEGIN_RDRAG(self, self.tree.GetId(), self.OnBeginRDrag)
  
+     self.Layout()
  
    def createToolbar(self, parent):
      return _SchemaToolbar(parent, self.instance)
  
    def __OnSize(self, event):
!     self.scroller.SetSize(self.GetClientSize())
! #    self.scroller.SetVirtualSize(self.tree.GetSize())
!     print self.scroller.GetVirtualSize()
!     self.scroller.SetScrollbars(10,10,10,10)
      event.Skip()
  
    # Since this class is the root node, we need to
***************
*** 152,157 ****
--- 136,147 ----
    def OnBeginRDrag(self, event):
      self.OnBeginDrag(event, right=1)
  
+   def OnSelectionChange(self, event):
+     o = self.tree.GetPyData(event.GetItem())
+     if o.getColumn():
+       self.setFeedback(o.getLabel() + ':  ' + o.getColumn())
+     else:
+       self.setFeedback('')
  
    def __addTable(self, object):
      # Find the "connection" node
***************
*** 212,223 ****
      return [{'Type': 'SchemaDrop', 'Data': rs, 'ShowMenu': right}]
  
  
! class TreeCtrl(wxRemotelyScrolledTreeCtrl):
  
    def __init__(self, parent, tool):
!     wxRemotelyScrolledTreeCtrl.__init__(self, parent, -1,
!            style=wxTR_HAS_BUTTONS|wxTR_NO_LINES| #wxTR_HIDE_ROOT|
!                  wxTR_ROW_LINES|wxNO_BORDER|wxTR_MULTIPLE)
  
      self.tool = tool
      EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.__OnExpand)
--- 202,215 ----
      return [{'Type': 'SchemaDrop', 'Data': rs, 'ShowMenu': right}]
  
  
! class TreeCtrl(wxTreeCtrl):
  
    def __init__(self, parent, tool):
!     wxTreeCtrl.__init__(self, parent, -1,
! ##           style=wxTR_HAS_BUTTONS|wxTR_NO_LINES| wxTR_HIDE_ROOT|
! ##                 wxNO_BORDER|wxTR_MULTIPLE|wxTR_ROW_LINES)
!            style=wxTR_HAS_BUTTONS|wxTR_HIDE_ROOT|wxTR_LINES_AT_ROOT|
!                  wxSIMPLE_BORDER|wxTR_MULTIPLE|wxTR_FULL_ROW_HIGHLIGHT )
  
      self.tool = tool
      EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.__OnExpand)
***************
*** 231,269 ****
      node = self.GetPyData(parent)
      if node and not node.expanded:
        node.expand()
-       self.tool.scroller.AdjustScrollbars()
-       self.tool.splitter.Refresh()
  
      event.Skip()
  
- 
- 
- class ListWindow(wxTreeCompanionWindow):
-   def __init__(self, parent):
-     wxTreeCompanionWindow.__init__(self, parent, -1,
-                  style=wxNO_BORDER )
-     self.SetBackgroundColour("WHITE")
- ##    EVT_ERASE_BACKGROUND(self, self._OnEraseBackground)
- 
-   def _OnEraseBackground(self, evt):
-     pass
- 
- 
-   # This method is called to draw each item in the value window
-   def DrawItem(self, dc, itemId, rect):
-     tree = self.GetTreeCtrl()
-     if tree:
-       text = tree.GetPyData(itemId).getColumn()
-       pen = wxPen(wxSystemSettings_GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, 
wxSOLID)
-       dc.SetPen(pen)
-       dc.SetBrush(wxBrush(self.GetBackgroundColour(), wxSOLID))
-       dc.DrawRectangle(rect.x, rect.y, rect.width+1, rect.height+1)
-       dc.SetTextForeground("BLACK")
-       dc.SetBackgroundMode(wxTRANSPARENT)
-       tw, th = dc.GetTextExtent(text)
-       x = 5
-       y = rect.y + max(0, (rect.height - th) / 2)
-       dc.DrawText(text, x, y)
  
  
  
--- 223,231 ----
Index: gnue-designer/src/base/tools/TreeView.py
diff -c gnue-designer/src/base/tools/TreeView.py:1.37 
gnue-designer/src/base/tools/TreeView.py:1.38
*** gnue-designer/src/base/tools/TreeView.py:1.37       Fri Jun  6 19:53:46 2003
--- gnue-designer/src/base/tools/TreeView.py    Thu Jul 10 18:56:21 2003
***************
*** 59,65 ****
      EVT_SIZE(self, self.onSize)
  
      self.tree = wxTreeCtrl(self.panel, wxNewId(),
!        style=wxTR_HAS_BUTTONS|wxTR_EDIT_LABELS|wxTR_HAS_VARIABLE_ROW_HEIGHT)
      self._handler = None
  
      self.tree.SetImageList(treeIconList)
--- 59,66 ----
      EVT_SIZE(self, self.onSize)
  
      self.tree = wxTreeCtrl(self.panel, wxNewId(),
!        style=wxTR_HAS_BUTTONS|#wxTR_EDIT_LABELS|
!            wxTR_FULL_ROW_HIGHLIGHT)#|wxTR_HIDE_ROOT)
      self._handler = None
  
      self.tree.SetImageList(treeIconList)
Index: gnue-designer/src/forms/LayoutEditor/DisplayDropTarget.py
diff -c gnue-designer/src/forms/LayoutEditor/DisplayDropTarget.py:1.19 
gnue-designer/src/forms/LayoutEditor/DisplayDropTarget.py:1.20
*** gnue-designer/src/forms/LayoutEditor/DisplayDropTarget.py:1.19      Wed Jun 
 4 19:24:12 2003
--- gnue-designer/src/forms/LayoutEditor/DisplayDropTarget.py   Thu Jul 10 
18:56:21 2003
***************
*** 328,333 ****
--- 328,334 ----
      maxWidth = x
      page = self.editor.page
      instance = self.editor.instance
+     selection = []
      for f in fields:
        try:
          label=f['label'] + ':'
***************
*** 391,397 ****
  
  
        # Create the labels
!       instance.incubator.createObject(
                  instance.rootObject,
                  'label',
                  page,
--- 392,398 ----
  
  
        # Create the labels
!       selection.append(instance.incubator.createObject(
                  instance.rootObject,
                  'label',
                  page,
***************
*** 400,409 ****
                              'Char:x': x,
                              'Char:y': y,
                              'Char:width': len(label)},
!                 select=0)
  
        # Create the entry
!       instance.incubator.createObject(
                  instance.rootObject,
                  'entry',
                  page,
--- 401,410 ----
                              'Char:x': x,
                              'Char:y': y,
                              'Char:width': len(label)},
!                 select=0))
  
        # Create the entry
!       selection.append(instance.incubator.createObject(
                  instance.rootObject,
                  'entry',
                  page,
***************
*** 413,419 ****
                              'Char:x': x + len(label) + 1,
                              'Char:y': y,
                              'Char:width': width},
!                 select=0)
  
        maxWidth = max(maxWidth, x + len(label) + width + 2)
        y += 1
--- 414,420 ----
                              'Char:x': x + len(label) + 1,
                              'Char:y': y,
                              'Char:width': width},
!                 select=0))
  
        maxWidth = max(maxWidth, x + len(label) + width + 2)
        y += 1
***************
*** 421,436 ****
      # Adjust form height if necessary
      if y > instance.rootObject._layout.Char__height or \
         maxWidth > instance.rootObject._layout.Char__width:
        instance.dispatchEvent('ObjectModified',
               object=instance.rootObject._layout,
!              old={'Char:height': instance.rootObject._layout.Char__height,
!                   'Char:width': instance.rootObject._layout.Char__width},
!              new={'Char:height': y,
!                   'Char:width': maxWidth},
               originator=__name__)
  
      # Select the new block
!     instance.dispatchEvent('ObjectSelected', object=block, 
originator=__name__)
  
    #
    # User requested we create a new block and add fields
--- 422,459 ----
      # Adjust form height if necessary
      if y > instance.rootObject._layout.Char__height or \
         maxWidth > instance.rootObject._layout.Char__width:
+ 
+       old = {}
+       new = {}
+ 
+       if y > instance.rootObject._layout.Char__height:
+         old['Char:height'] = instance.rootObject._layout.Char__height
+         new['Char:height'] = y
+         instance.rootObject._layout.Char__height = y
+ 
+       if maxWidth > instance.rootObject._layout.Char__width:
+         old['Char:width'] = instance.rootObject._layout.Char__width
+         new['Char:width'] = maxWidth
+         instance.rootObject._layout.Char__width = maxWidth
+ 
        instance.dispatchEvent('ObjectModified',
               object=instance.rootObject._layout,
!              old=old,
!              new=new,
               originator=__name__)
  
      # Select the new block
!     if selection:
!       o = selection[0]
!     else:
!       o = block
! 
!     instance.dispatchEvent('ObjectSelected', object=o,
!                            originator=__name__,
!                            selection=selection)
! 
!     # Move the focus onto our grid panel
!     self.editor.panel.SetFocus()
  
    #
    # User requested we create a new block and add fields




reply via email to

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