/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/dock.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/dock.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 973 by jonathan, Wed May 21 17:39:31 2003 UTC revision 1527 by jonathan, Wed Jul 30 15:43:28 2003 UTC
# Line 5  Line 5 
5  # This program is free software under the GPL (>=v2)  # This program is free software under the GPL (>=v2)
6  # Read the file COPYING coming with Thuban for details.  # Read the file COPYING coming with Thuban for details.
7    
8  """Classes for creating dockable windows"""  """Classes for creating dockable windows.
9    
10    The DockFrame is the main window that will be the parent for the
11    dockable windows.
12    
13    The DockPanel is a panel that all windows that wish to be dockable
14    should derive from.
15    """
16    
17  __version__ = "$Revision$"  __version__ = "$Revision$"
18    
# Line 31  UNDOCK_BMP = "undock_12" Line 38  UNDOCK_BMP = "undock_12"
38  CLOSE_BMP  = "close_12"  CLOSE_BMP  = "close_12"
39    
40  class DockPanel(wxPanel):  class DockPanel(wxPanel):
41        """A DockPanel is a panel that should be derived from to create panels
42        that can be docked in a DockFrame.
43        """
44    
45      def __init__(self, parent, id):      def __init__(self, parent, id):
46            """parent should be a DockableWindow created from
47            DockFrame.CreateDock().
48            """
49    
50          if not isinstance(parent, DockableWindow):          if not isinstance(parent, DockableWindow):
51              raise TypeError("")              raise TypeError("")
# Line 54  class DockPanel(wxPanel): Line 67  class DockPanel(wxPanel):
67          return self.__dockParent          return self.__dockParent
68    
69      def SetDock(self, dock):      def SetDock(self, dock):
70            """Specifically set the docked state of the panel
71            to dock (True or False).
72            """
73          #if dock == self.IsDocked(): return          #if dock == self.IsDocked(): return
74    
75          if dock:          if dock:
# Line 62  class DockPanel(wxPanel): Line 78  class DockPanel(wxPanel):
78              self.UnDock()              self.UnDock()
79    
80      def Dock(self):      def Dock(self):
81            """Dock the panel in the DockFrame."""
82          self.GetDockParent().Dock()          self.GetDockParent().Dock()
83    
84      def UnDock(self):      def UnDock(self):
85            """Undock the panel in the DockFrame."""
86          self.GetDockParent().UnDock()          self.GetDockParent().UnDock()
87    
88      def IsDocked(self):      def IsDocked(self):
89            """Return True if the panel is docked."""
90          return self.GetDockParent().IsDocked()          return self.GetDockParent().IsDocked()
91    
92  class DockableWindow(Publisher):  class DockableWindow(Publisher):
# Line 143  class DockableWindow(Publisher): Line 162  class DockableWindow(Publisher):
162              self.UnDock()              self.UnDock()
163    
164      def Dock(self):      def Dock(self):
165            """Dock the window."""
166          self.__CheckAllGood()          self.__CheckAllGood()
167    
168          wasVisible = self.IsShown()          wasVisible = self.IsShown()
# Line 176  class DockableWindow(Publisher): Line 196  class DockableWindow(Publisher):
196          self.issue(DOCKABLE_DOCKED, self.__id, self)          self.issue(DOCKABLE_DOCKED, self.__id, self)
197    
198      def UnDock(self):      def UnDock(self):
199            """Undock the window."""
200          self.__CheckAllGood()          self.__CheckAllGood()
201    
202          wasVisible = self.IsShown()          wasVisible = self.IsShown()
# Line 215  class DockableWindow(Publisher): Line 236  class DockableWindow(Publisher):
236          return self.__docked          return self.__docked
237    
238      def Show(self, show = True):      def Show(self, show = True):
239            """Show or hide the window."""
240          if show:          if show:
241              self.__DoShow()              self.__DoShow()
242          else:          else:
243              self.__DoHide()              self.__DoHide()
244    
245      def SetDockSize(self, rect = None):      def SetDockSize(self, rect = None):
246            """Set the size of the dock window to rect."""
247    
248          w0, h0 = self.__dockPanel.GetBestSize()          w0, h0 = self.__dockPanel.GetBestSize()
249          w, h = self.__panel.GetBestSize()          w, h = self.__panel.GetBestSize()
# Line 374  class DockableWindow(Publisher): Line 397  class DockableWindow(Publisher):
397    
398    
399  class DockFrame(wxFrame):  class DockFrame(wxFrame):
400        """A DockFrame is a frame that will contain dockable panels."""
401    
402      def __init__(self, parent, id, title, position, size):      def __init__(self, parent, id, title, position, size):
403          wxFrame.__init__(self, parent, id, title, position, size)          wxFrame.__init__(self, parent, id, title, position, size)
# Line 415  class DockFrame(wxFrame): Line 439  class DockFrame(wxFrame):
439          # since we're going away          # since we're going away
440    
441      def CreateDock(self, name, id, title, align):      def CreateDock(self, name, id, title, align):
442            """Create a new dock. align specifies where the dock will
443            be placed. It can be one of wxLAYOUT_NONE, wxLAYOUT_LEFT,
444            wxLAYOUT_RIGHT.
445            """
446    
447          if align in (wxLAYOUT_NONE, wxLAYOUT_LEFT, wxLAYOUT_RIGHT):          if align in (wxLAYOUT_NONE, wxLAYOUT_LEFT, wxLAYOUT_RIGHT):
448              orient = wxLAYOUT_VERTICAL              orient = wxLAYOUT_VERTICAL
# Line 435  class DockFrame(wxFrame): Line 463  class DockFrame(wxFrame):
463          return win          return win
464    
465      def FindRegisteredDock(self, name):      def FindRegisteredDock(self, name):
466            """Return a reference to a dock that has name."""
467          return self.openWindows.get(name)          return self.openWindows.get(name)
468    
469      def OnDockDestroy(self, win):      def OnDockDestroy(self, win):

Legend:
Removed from v.973  
changed lines
  Added in v.1527

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26