[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/designer/src/base Instance.py docks/Docker.py
From: |
Jason Cater |
Subject: |
gnue/designer/src/base Instance.py docks/Docker.py |
Date: |
Fri, 13 Jun 2003 13:10:06 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Branch:
Changes by: Jason Cater <address@hidden> 03/06/13 13:10:06
Modified files:
designer/src/base: Instance.py
designer/src/base/docks: Docker.py
Log message:
moved the docking logic out of Instance.py and into docks/Docker.py
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/base/Instance.py.diff?tr1=1.110&tr2=1.111&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/base/docks/Docker.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: gnue/designer/src/base/Instance.py
diff -c gnue/designer/src/base/Instance.py:1.110
gnue/designer/src/base/Instance.py:1.111
*** gnue/designer/src/base/Instance.py:1.110 Fri Jun 13 12:39:22 2003
--- gnue/designer/src/base/Instance.py Fri Jun 13 13:10:06 2003
***************
*** 38,48 ****
from gnue.common.events import EventController, Event
from gnue.designer.base.MenuBar import MenuBar
from gnue.designer.base.UndoManager import UndoManager
- from gnue.designer.base.docks.FloatingPane import FloatingPane
from gnue.designer.base.ToolBase import ToolBase
! from gnue.designer.base.docks.FloatingPane import FloatingPane
! from gnue.designer.base.docks.SplitDock import SplitDock
! from gnue.designer.base.docks.DockedPane import *
from gnue.designer.base.ObjectList import ObjectList
from gnue.designer.base import TemplateBase
from gnue.designer.base.TemplateParser import WizardRunner
--- 38,45 ----
from gnue.common.events import EventController, Event
from gnue.designer.base.MenuBar import MenuBar
from gnue.designer.base.UndoManager import UndoManager
from gnue.designer.base.ToolBase import ToolBase
! from gnue.designer.base.docks.Docker import Docker
from gnue.designer.base.ObjectList import ObjectList
from gnue.designer.base import TemplateBase
from gnue.designer.base.TemplateParser import WizardRunner
***************
*** 311,379 ****
def _initTools(self):
!
! self.__horizSplitter = wxSplitterWindow(self, -1, style=wxSP_3D)
! self.__leftDock = leftWin = SplitDock(self.__horizSplitter, self, 'left')
! self.__rightDock = rightWin = SplitDock(self.__horizSplitter,
self,'right')
!
! # Add each tool
! for id, title, baseclass, hotkey, group in self._toolCache:
!
! GDebug.printMesg(2,'Adding tool %s [%s]' % (title,id))
!
! pos = RuntimeSettings.get(self.runtime_section, 'Dock-%s' % id,
baseclass.default_dock)
!
! #### Historical stuff... remove before 1.0 ####
! if pos in ('topleft','topright','bottomleft','bottomright'):
! pos = baseclass.default_dock
! ####
!
! appd = (id, title, baseclass, hotkey, pos)
!
! indx = '0'
! if '-' in pos:
! pos, indx = pos.split('-')
!
! if pos not in ('left','right'): # i.e., 'frame' or something old
! # Frame type
! window = FloatingPane(self, id, title, baseclass.uses_feedback_bar)
! control = baseclass(self, self.rootObject, window)
! window.control = control
! window.dock = 'frame'
! enableMenu = 1
! if baseclass.uses_feedback_bar:
! frame.setStatusBar(frame.statusbar)
! else:
! # Docked type
! pane = DockedPane(self.__horizSplitter, self)
! control = pane.AddTool(title, baseclass, self.rootObject, self)
! if pos == 'left':
! window = leftWin
! elif pos == 'right':
! window = rightWin
! pane.setStatusBar(self.statusbar)
!
!
! window.add(pane, indx)
! enableMenu = 0
!
! # Add ourselves to the Window menu
! self.menubar.addAction(location='View', text=title, event='Tool:' + id,
! grouping=group, canToggle=1, canDisable=0,
! icon=None, hotkey=hotkey)
!
! window.finalize()
!
! self.__dict__["%sWindow" % id] = window
! self.__dict__[id] = control
!
!
! leftWin.refresh()
! rightWin.refresh()
! self.__horizSplitter.SplitVertically(leftWin, rightWin,
! RuntimeSettings.getint(self.runtime_section,
'DockSplitter-TopBottom',500))
! leftWin.restoreSettings(self.runtime_section)
!
def addTool(self, id, title, baseclass, hotkey=None, menuGroup=499):
self._toolCache.append( (id, title, baseclass, hotkey, menuGroup) )
--- 308,314 ----
def _initTools(self):
! self.docker = Docker(self, self, self._toolCache)
def addTool(self, id, title, baseclass, hotkey=None, menuGroup=499):
self._toolCache.append( (id, title, baseclass, hotkey, menuGroup) )
***************
*** 456,466 ****
'height': height,
'width': width }
! if self.__horizSplitter:
! settings['docksplitter-topbottom'] =
self.__horizSplitter.GetSashPosition()
!
! settings.update(self.__leftDock.saveSettings())
! settings.update(self.__rightDock.saveSettings())
return ( self.runtime_section, settings )
--- 391,397 ----
'height': height,
'width': width }
! settings.update(self.docker.saveSettings())
return ( self.runtime_section, settings )
Index: gnue/designer/src/base/docks/Docker.py
diff -c gnue/designer/src/base/docks/Docker.py:1.1
gnue/designer/src/base/docks/Docker.py:1.2
*** gnue/designer/src/base/docks/Docker.py:1.1 Fri Jun 13 12:39:22 2003
--- gnue/designer/src/base/docks/Docker.py Fri Jun 13 13:10:06 2003
***************
*** 28,320 ****
# NOTES:
#
! __all__ = ['ToolDock']
from wxPython.wx import *
! from gnue.common.apps import RuntimeSettings
! class ToolDocker(wxPanel):
! def __init__(self, parent, instance,
!
!
! class ToolDock(wxPanel):
! def __init__(self, parent, instance, name):
wxPanel.__init__(self, parent, -1)
self.parent = parent
- 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)
!
!
! #
! # Add a tool panel to our control
! #
! def add(self, panel, indx = '0'):
!
! # We do it as (index, panel) so we can
! # later do a self.panels.sort().
!
! # the sort() routine will sort by
! # the first list element.
! self.panels.append((indx, panel))
!
! # Save state information on the tool panel
! panel._dock_ = self
! panel._dock_index = indx
! panel.SetManager(self)
!
! #
! # Restore sizes.. used by RuntimeSettings
! #
! 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
! #
! def saveSettings(self):
! baseName = 'Docker%s-' % self.name
! rs = {}
! index = 0
! ## for splitter in self.splitters:
! ## rs[baseName + str(index)] = splitter.GetSashPosition()
! ## index += 1
! return rs
!
!
! #
! # Remove a tool panel from our control
! #
! def remove(self, panel):
! self.panels.remove((panel._dock_index, panel))
! panel.SetManager(None)
!
! #
! # Redock a tool panel
! #
! def redock(self, panel, relation):
! pass
!
! #
! # 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:
!
! # Find out how many are already minimized.
! # One must remain visible at all times.
! numMinimized = 0
! for foo, p in self.panels:
! if p.minimized:
! numMinimized += 1
! if numMinimized == numPanels - 1:
! return
!
!
! # Save the current size so
! # tool can be restored later
! panel.lastSize = panel.GetSizeTuple()[1]
! panel.minimized = 1
! self.Layout()
!
!
! #
! # Restore a minimized tool
! #
! 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)
!
!
!
! #
! # Resize a tool
! #
! 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)
!
!
! #
! # Change the "minimized" state of a tool.
! # i.e., if it is minimized, restore it;
! # if it is not minimized, minimize it.
! def toggleMinimized(self, panel):
! if panel.minimized:
! self.restore(panel)
! else:
! self.minimize(panel)
!
! def finalize(self):
! pass
!
! ######################################################################
! #
! # 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
--- 28,120 ----
# NOTES:
#
! __all__ = ['Docker']
from wxPython.wx import *
! from gnue.common.apps import RuntimeSettings, GDebug
! from FloatingPane import FloatingPane
! from SplitDock import SplitDock
! from DockedPane import DockedPane
! class Docker(wxPanel):
! def __init__(self, parent, instance, tools):
wxPanel.__init__(self, parent, -1)
self.parent = parent
self.instance = instance
! self.horizSplitter = horizSplitter = wxSplitterWindow(self, -1,
style=wxSP_3D)
! self.leftDock = leftWin = SplitDock(horizSplitter, self, 'left')
! self.rightDock = rightWin = SplitDock(horizSplitter, self,'right')
! EVT_SIZE(instance, self.__OnSize)
!
! # Add each tool
! for id, title, baseclass, hotkey, group in tools:
!
! GDebug.printMesg(2,'Adding tool %s [%s]' % (title,id))
!
! pos = RuntimeSettings.get(instance.runtime_section, 'Dock-%s' % id,
baseclass.default_dock)
!
! #### Historical stuff... remove before 1.0 ####
! if pos in ('topleft','topright','bottomleft','bottomright'):
! pos = baseclass.default_dock
! ####
!
! appd = (id, title, baseclass, hotkey, pos)
!
! indx = '0'
! if '-' in pos:
! pos, indx = pos.split('-')
!
! if pos not in ('left','right'): # i.e., 'frame' or something old
! # Frame type
! window = FloatingPane(instance, id, title,
baseclass.uses_feedback_bar)
! control = baseclass(instance, instance.rootObject, window)
! window.control = control
! window.dock = 'frame'
! enableMenu = 1
! if baseclass.uses_feedback_bar:
! frame.setStatusBar(frame.statusbar)
else:
! # Docked type
! pane = DockedPane(horizSplitter, self)
! control = pane.AddTool(title, baseclass, instance.rootObject,
instance)
! if pos == 'left':
! window = leftWin
! elif pos == 'right':
! window = rightWin
! pane.setStatusBar(instance.statusbar)
!
!
! window.add(pane, indx)
! enableMenu = 0
!
! # Add ourselves to the Window menu
! instance.menubar.addAction(location='View', text=title, event='Tool:' +
id,
! grouping=group, canToggle=1, canDisable=0,
! icon=None, hotkey=hotkey)
!
! window.finalize()
!
! instance.__dict__["%sWindow" % id] = window
! instance.__dict__[id] = control
!
!
! leftWin.refresh()
! rightWin.refresh()
! horizSplitter.SplitVertically(leftWin, rightWin,
! RuntimeSettings.getint(instance.runtime_section,
'DockSplitter-TopBottom',500))
! leftWin.restoreSettings(instance.runtime_section)
!
! def __OnSize(self, event):
! self.SetSize(self.instance.GetClientSize())
! self.horizSplitter.SetSize(self.GetClientSize())
+ def saveSettings(self):
+ settings = {}
+ if self.horizSplitter:
+ settings['docksplitter-topbottom'] =
self.horizSplitter.GetSashPosition()
! settings.update(self.leftDock.saveSettings())
! settings.update(self.rightDock.saveSettings())
+ return settings
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/designer/src/base Instance.py docks/Docker.py,
Jason Cater <=