[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/designer/src base/ToolDock.py base/ToolPan...
From: |
Jason Cater |
Subject: |
gnue/designer/src base/ToolDock.py base/ToolPan... |
Date: |
Sat, 24 May 2003 14:01:08 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jason Cater <address@hidden> 03/05/24 14:01:08
Modified files:
designer/src/base: ToolDock.py ToolPanel.py
designer/src/forms/LayoutEditor: LayoutEditor.py
Log message:
* Switched to sash and custom sizer based dock
* Fixed comboblock error when opening a form
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/base/ToolDock.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/base/ToolPanel.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/forms/LayoutEditor/LayoutEditor.py.diff?tr1=1.76&tr2=1.77&r1=text&r2=text
Patches:
Index: gnue/designer/src/base/ToolDock.py
diff -c gnue/designer/src/base/ToolDock.py:1.7
gnue/designer/src/base/ToolDock.py:1.8
*** gnue/designer/src/base/ToolDock.py:1.7 Fri May 23 23:19:49 2003
--- gnue/designer/src/base/ToolDock.py Sat May 24 14:01:08 2003
***************
*** 31,37 ****
from wxPython.wx import *
from gnue.common.apps import RuntimeSettings
- SPLITTER_STYLE = wxSP_NOBORDER | wxSP_3DSASH # | wxSP_LIVE_UPDATE
class ToolDock(wxPanel):
def __init__(self, parent, instance, name):
--- 31,36 ----
***************
*** 40,153 ****
self.name = name
self.instance = instance
self.panels = []
- self.splitters = []
self.child = None
self.sashSize = 0
! EVT_SIZE(self, self.__OnSize)
#
# Rebuild our dock
#
def refresh(self):
- # Very crude... destroys itself, then recreates all panes
-
- # We create (# tools - 1) splitter panels.
- #
- # Splitter 1
- # - Tool 1
- # - Splitter 2
- # - Tool 2
- # - Splitter 3
- # - Tool 3
- # - Tool 4
- #
-
- # Number of splitter panes we need
- neededSplitters = len(self.panels) - 1
-
- # Handle the special case of a single tool:
- if neededSplitters == 0:
- panel = self.child = self.panels[0][-1]
- panel.Reparent(self)
-
- # No splitters needed? Then destroy any
- # existing ones and go home.
- if neededSplitters < 1:
- for splitter in self.splitters:
- splitter.Destroy()
- self.splitters = []
- return
# Get the panels in the order the user wants
self.panels.sort()
! #
! # If we don't have enough splitter panes, create more...
! if self.splitters:
! # If we have existing splitters, then the next splitter
! # will be a child of the last recorded splitter.
! parent = self.splitters[-1]
! else:
! # If we have no existing splitters, then the next splitter
! # will be a child of this panel.
! parent = self
! # Create new splitters
! for i in range(neededSplitters - len(self.splitters)):
! parent = wxSplitterWindow(parent, -1, style=SPLITTER_STYLE)
! self.splitters.append(parent)
#
# Now, reparent all the tools
index = 0
! for nothing, panel in self.panels:
# Reparent...
! if index >= neededSplitters:
! # The last two tools share the same splitter as parents
! panel.Reparent(self.splitters[-1])
! else:
! # But all others share a splitter with another splitter
! panel.Reparent(self.splitters[index])
! # Make a note of the tool's dock position
panel.dock = "%s-%s" % (self.name, index)
- index += 1
! # Now that all panels are reparented,
! # destroy the unneeded splitters
! while len(self.splitters) > neededSplitters:
! splitter = self.splitters.pop()
! splitter.Destroy()
!
! # ... and split the needed splitters
! for index in range(neededSplitters-1):
! splitter = self.splitters[index]
! splitter.SplitHorizontally(self.panels[index][1],
! self.splitters[index+1], 200)
!
!
! # The last two are a special case...
! splitter = self.splitters[-1]
! splitter.SplitHorizontally(self.panels[-2][1],
! self.panels[-1][1], 100)
! splitter.SetMinimumPaneSize(self.panels[-1][1].minimumVerticalSize)
!
! # We will need to resize the top-most splitter
! # manually, so make a note of it:
! self.child = self.splitters[0]
# Redraw screen
! self.Refresh()
! self.sashSize = self.GetClientSizeTuple()[1] - \
! self.splitters[0].GetWindow1().GetClientSizeTuple()[1] - \
! self.splitters[0].GetWindow2().GetClientSizeTuple()[1]
! self.titlebarSize = self.panels[0][1].minimumVerticalSize -2
! self.minimumPaneSize = self.titlebarSize + self.sashSize
! for splitter in self.splitters:
! splitter.SetMinimumPaneSize(self.minimumPaneSize)
#
--- 39,93 ----
self.name = name
self.instance = instance
self.panels = []
self.child = None
self.sashSize = 0
! self.sizer = MySizer()
! self.SetAutoLayout(1)
! self.SetSizer(self.sizer)
#
# Rebuild our dock
#
def refresh(self):
# Get the panels in the order the user wants
self.panels.sort()
! # Remove old sizers
! while self.sizer.Remove(0):
! pass
#
# Now, reparent all the tools
index = 0
! for foo, panel in self.panels:
# Reparent...
! panel.Reparent(self)
!
! # Make sashes visible
! if index:
! panel.SetSashVisible(wxSASH_TOP,1)
!
! self.sizer.Add(panel, 1, wxEXPAND)
panel.dock = "%s-%s" % (self.name, index)
! index += 1
!
# Redraw screen
! self.Layout()
! ## self.sashSize = self.GetClientSizeTuple()[1] - \
! ## self.splitters[0].GetWindow1().GetClientSizeTuple()[1]
- \
! ## self.splitters[0].GetWindow2().GetClientSizeTuple()[1]
! ## self.titlebarSize = self.panels[0][1].minimumVerticalSize -2
! ## self.minimumPaneSize = self.titlebarSize + self.sashSize
! ## for splitter in self.splitters:
! ## splitter.SetMinimumPaneSize(self.minimumPaneSize)
#
***************
*** 173,181 ****
def restoreSettings(self, section):
baseName = 'Docker%s-' % self.name
index = 0
! for splitter in self.splitters:
! splitter.SetSashPosition(RuntimeSettings.getint(section, baseName +
str(index), 100))
! index += 1
#
# Save sizes.. used by RuntimeSettings
--- 113,121 ----
def restoreSettings(self, section):
baseName = 'Docker%s-' % self.name
index = 0
! ## for splitter in self.splitters:
! ## splitter.SetSashPosition(RuntimeSettings.getint(section, baseName +
str(index), 100))
! ## index += 1
#
# Save sizes.. used by RuntimeSettings
***************
*** 184,192 ****
baseName = 'Docker%s-' % self.name
rs = {}
index = 0
! for splitter in self.splitters:
! rs[baseName + str(index)] = splitter.GetSashPosition()
! index += 1
return rs
--- 124,132 ----
baseName = 'Docker%s-' % self.name
rs = {}
index = 0
! ## for splitter in self.splitters:
! ## rs[baseName + str(index)] = splitter.GetSashPosition()
! ## index += 1
return rs
***************
*** 207,220 ****
# Minimize a tool, so only title bar is showing
#
def minimize(self, panel):
# No splitters in use? Nothing to do.
# Already minimized? Ditto.
! if not self.splitters or panel.minimized:
return
# One splitter? Treat as special case...
# Only one of the tools can be minimized.
! if len(self.splitters) == 1:
other = self.panels[0][1] != panel and self.panels[0][1] or
self.panels[1][1]
other.minimized = 0
else:
--- 147,161 ----
# Minimize a tool, so only title bar is showing
#
def minimize(self, panel):
+ numPanels = len(self.panels)
# No splitters in use? Nothing to do.
# Already minimized? Ditto.
! if numPanels < 2 or panel.minimized:
return
# One splitter? Treat as special case...
# Only one of the tools can be minimized.
! if numPanels == 2:
other = self.panels[0][1] != panel and self.panels[0][1] or
self.panels[1][1]
other.minimized = 0
else:
***************
*** 225,231 ****
for foo, p in self.panels:
if p.minimized:
numMinimized += 1
! if numMinimized == len(self.splitters):
return
--- 166,172 ----
for foo, p in self.panels:
if p.minimized:
numMinimized += 1
! if numMinimized == numPanels - 1:
return
***************
*** 233,241 ****
# tool can be restored later
panel.lastSize = panel.GetSizeTuple()[1]
panel.minimized = 1
!
! # Use the handy-dandy resize function
! self.resize(panel, self.minimumPaneSize)
#
--- 174,180 ----
# tool can be restored later
panel.lastSize = panel.GetSizeTuple()[1]
panel.minimized = 1
! self.Layout()
#
***************
*** 244,256 ****
def restore(self, panel):
# No splitters in use? Nothing to do.
# Already minimized? Ditto.
! if not self.splitters or not panel.minimized:
return
# Restore to the last known size
- self.resize(panel, panel.lastSize or 100)
-
panel.minimized = 0
#
--- 183,195 ----
def restore(self, panel):
# No splitters in use? Nothing to do.
# Already minimized? Ditto.
! if len(self.panels) < 2 or not panel.minimized:
return
# Restore to the last known size
panel.minimized = 0
+ self.sizer.RecalcSizes(panel, panel.lastSize)
+
#
***************
*** 259,289 ****
def resize(self, panel, size):
# This is used several times...
! numSplitters = len(self.splitters)
! # No splitters in use? Nothing to do.
! if not numSplitters:
return
! # Current size of panel
! currSize = panel.GetSizeTuple()[1]
! delta = currSize - size
!
! # Determine number of panels minimized
! numMinimized = 0
for foo, p in self.panels:
! if p.minimized:
! numMinimized += 1
! parent = panel.GetParent()
! direction = parent.GetWindow2() == panel or -1
! parent.SetSashPosition(parent.GetSashPosition() + delta * direction)
! workableArea = self.GetClientSizeTuple()[1] \
! - numMinimized * self.titlebarSize \
! - numSplitters * self.sashSize \
! - (not panel.minimized) and delta
#
--- 198,226 ----
def resize(self, panel, size):
# This is used several times...
! numPanels = len(self.panels)
! # Not enought panels? Nothing to do.
! if numPanels < 2:
return
! above = None
! maxResize = panel.GetSizeTuple()[1]
for foo, p in self.panels:
! if p == panel:
! break
! elif not p.minimized:
! above = p
! maxResize += p.GetSizeTuple()[1] - p.minimumVerticalSize
! # Nothing to resize above us?
! if not above:
! return
! # Don't resize
! size = min(maxResize, size)
! self.sizer.RecalcSizes(panel, size, above)
#
***************
*** 297,306 ****
self.minimize(panel)
! #
! # Resize our child window (the
! # wxSplitterWindow will take care
! # of the rest)
! #
! def __OnSize(self, event):
! self.child.SetSize(self.GetClientSize())
\ No newline at end of file
--- 234,313 ----
self.minimize(panel)
! ######################################################################
! #
! # Custom wxSizer class to handle our tool docks
! #
! class MySizer(wxPySizer):
! def __init__(self):
! wxPySizer.__init__(self)
! self.__objects = []
! self.__childHideSize = 10
! self.__oldw = 0
! self.__oldh = 0
!
! def Add(self, window, option=0, flag=0, border=0, userData = None):
! self.__objects.append(window)
! try:
! self.__childHideSize = window.minimumVerticalSize + 1
! except AttributeError:
! pass
!
! def CalcMin(self):
! return (50, self.__childHideSize * len(self.__objects))
!
! def RecalcSizes(self, absolute=None, absheight=0, absrelative=None):
! size = self.GetSize()
! w = size.x
! h = size.y
!
! allocated = 0
! sizes = {}
! variable = []
! for child in self.__objects:
! if child.minimized:
! sizes[child] = self.__childHideSize
! allocated += self.__childHideSize
! elif child == absolute:
! ch = child.GetSizeTuple()[1]
! sizes[child] = absheight
! allocated += absheight
! if absrelative:
! adj = absrelative.GetSizeTuple()[1] - (absheight - ch)
! sizes[absrelative] = adj
! allocated += adj
! elif not absrelative:
! variable.append(child)
! else:
! sizes[child] = child.GetSizeTuple()[1]
!
!
! if variable:
! each = int((h - allocated)/len(variable))
! first = h - allocated - each * (len(variable) - 1)
!
! for child in variable:
! if first:
! sizes[child] = first
! first = 0
! else:
! sizes[child] = each
!
! y = 0
! for child in self.__objects:
! h = sizes[child]
! child.SetSize((w, h))
! child.SetPosition((0, y))
! y += h
!
! def Remove(self, thingy):
! try:
! del self.__objects[thingy]
! return 1
! except:
! try:
! self.__objects.remove(thingy)
! return 1
! except:
! return 0
!
Index: gnue/designer/src/base/ToolPanel.py
diff -c gnue/designer/src/base/ToolPanel.py:1.11
gnue/designer/src/base/ToolPanel.py:1.12
*** gnue/designer/src/base/ToolPanel.py:1.11 Fri May 23 23:23:56 2003
--- gnue/designer/src/base/ToolPanel.py Sat May 24 14:01:08 2003
***************
*** 75,85 ****
#
#
#
! class DockedToolPane(wxPanel, ToolPanel):
def __init__(self, parent, menutool):
! wxPanel.__init__(self, parent, -1)
ToolPanel.__init__(self, parent, menutool)
self.manager = None
def SetManager(self, manager):
self.manager = manager
--- 75,87 ----
#
#
#
! class DockedToolPane(wxSashWindow, ToolPanel):
def __init__(self, parent, menutool):
! wxSashWindow.__init__(self, parent, -1, style=wxSW_3DSASH|wxCLIP_CHILDREN)
ToolPanel.__init__(self, parent, menutool)
self.manager = None
+ EVT_SIZE(self, self.__OnSize)
+ EVT_SASH_DRAGGED(self, self.GetId(), self.__OnDrag)
def SetManager(self, manager):
self.manager = manager
***************
*** 87,93 ****
def AddTool(self, title, baseclass, rootObject, instance):
self.control = control = baseclass(instance, rootObject, self)
! sizer = wxBoxSizer(wxVERTICAL)
tp = self.__titlePanel = wxPanel(self,-1, wxPoint(0,0))#,
style=wxSIMPLE_BORDER)
tp.SetBackgroundColour(TITLEBAR_ACTIVE)
--- 89,95 ----
def AddTool(self, title, baseclass, rootObject, instance):
self.control = control = baseclass(instance, rootObject, self)
! self.sizer = sizer = wxBoxSizer(wxVERTICAL)
tp = self.__titlePanel = wxPanel(self,-1, wxPoint(0,0))#,
style=wxSIMPLE_BORDER)
tp.SetBackgroundColour(TITLEBAR_ACTIVE)
***************
*** 164,166 ****
--- 166,176 ----
def __BreakAway(self, event):
print _("This function not yet supported!") # TODO
+
+ def __OnSize(self, event):
+ if self.GetAutoLayout():
+ self.Layout()
+
+ def __OnDrag(self, event):
+ newHeight = event.GetDragRect().height
+ self.manager.resize(self, newHeight)
Index: gnue/designer/src/forms/LayoutEditor/LayoutEditor.py
diff -c gnue/designer/src/forms/LayoutEditor/LayoutEditor.py:1.76
gnue/designer/src/forms/LayoutEditor/LayoutEditor.py:1.77
*** gnue/designer/src/forms/LayoutEditor/LayoutEditor.py:1.76 Fri May 23
23:19:49 2003
--- gnue/designer/src/forms/LayoutEditor/LayoutEditor.py Sat May 24
14:01:08 2003
***************
*** 182,202 ****
block = object._block
if block:
self.block = block
! self.blockCombo.SetValue(block.name)
## self._setFeedback()
def _rebuildBlockCombo(self):
! # TODO
! srt = self.blockMap.keys()
! srt.sort()
! self.blockComboList = []
! self.blockCombo.Clear()
! for key in srt:
! block = self.blockMap[key]
! self.blockCombo.Append(block.name)
! self.blockComboList.append(block)
! if self.block:
! self.blockCombo.SetValue(self.block.name)
def OnBlockSelected(self, event):
s= event.GetSelection()
--- 182,205 ----
block = object._block
if block:
self.block = block
! if hasattr(self,'blockCombo'):
! self.blockCombo.SetValue(block.name)
## self._setFeedback()
def _rebuildBlockCombo(self):
! if hasattr(self,'blockCombo'):
! # TODO
! srt = self.blockMap.keys()
! srt.sort()
! self.blockComboList = []
! self.blockCombo.Clear()
!
! for key in srt:
! block = self.blockMap[key]
! self.blockCombo.Append(block.name)
! self.blockComboList.append(block)
! if self.block:
! self.blockCombo.SetValue(self.block.name)
def OnBlockSelected(self, event):
s= event.GetSelection()