/[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 651 by jonathan, Fri Apr 11 14:27:53 2003 UTC revision 659 by jonathan, Mon Apr 14 14:07:05 2003 UTC
# Line 39  class DockPanel(wxPanel): Line 39  class DockPanel(wxPanel):
39    
40          wxPanel.__init__(self, parent.GetCurrentParent(), id)          wxPanel.__init__(self, parent.GetCurrentParent(), id)
41    
42            self.parent = parent
43    
44          #self.SetDockParent(None)          #self.SetDockParent(None)
45          parent.SetPanel(self)          #parent.SetPanel(self)
46    
47        def Create(self):
48            self.parent.SetPanel(self)
49            
50      def SetDockParent(self, parent):      def SetDockParent(self, parent):
51          self.__dockParent = parent          self.__dockParent = parent
52    
# Line 68  class DockPanel(wxPanel): Line 73  class DockPanel(wxPanel):
73  class DockableWindow(Publisher):  class DockableWindow(Publisher):
74    
75      def __getattr__(self, attr):      def __getattr__(self, attr):
   
         #print attr  
76          return getattr(self.__topWindow, attr)          return getattr(self.__topWindow, attr)
         #try:  
         #except AttributeError:  
             #raise  
             #return self.__dict__[attr]  
             #return getattr(self, attr)  
             #pass  
77    
78      def __init__(self, parent, id, name,      def __init__(self, parent, id, name, title, dockWindow, orient):
79                   title, dockWindow, orient): #, panel, docked = False, show = True):          """Create the dockable window.
80    
81            Initially, the window is hidden, but in an undocked state.
82            """
83    
84          if not isinstance(parent, DockFrame): raise TypeError("")          if not isinstance(parent, DockFrame): raise TypeError("")
85    
# Line 90  class DockableWindow(Publisher): Line 90  class DockableWindow(Publisher):
90          self.__orientation = orient          self.__orientation = orient
91    
92          self.__dockWindow  = dockWindow          self.__dockWindow  = dockWindow
         #self.__floatWindow = NonModalDialog(parent, name, title)  
93          self.__floatWindow = wxFrame(parent, id, title)          self.__floatWindow = wxFrame(parent, id, title)
94    
95          self.__docked      = False          self.__docked      = False
   
         self.__dockPanel  = None  
   
96          if self.__docked:          if self.__docked:
97              self.__topWindow = self.__dockWindow              self.__topWindow = self.__dockWindow
98          else:          else:
# Line 105  class DockableWindow(Publisher): Line 101  class DockableWindow(Publisher):
101          self.__floatSize     = None          self.__floatSize     = None
102          self.__floatPosition = None          self.__floatPosition = None
103    
104            self.__dockPanel  = None
105          self.__panel = None          self.__panel = None
106    
107          self.__dockWindow.Hide()          self.__dockWindow.Hide()
# Line 166  class DockableWindow(Publisher): Line 163  class DockableWindow(Publisher):
163          self.__topWindow = self.__dockWindow          self.__topWindow = self.__dockWindow
164          self.__dockPanel.Reparent(self.__topWindow)          self.__dockPanel.Reparent(self.__topWindow)
165    
166          if self.bmpUnDock is not None:          if self.__bmpUnDock is not None:
167              self.__dockButton.SetBitmapLabel(self.bmpUnDock)              self.__dockButton.SetBitmapLabel(self.__bmpUnDock)
168              self.__dockButton.SetBitmapFocus(self.bmpUnDock)              self.__dockButton.SetBitmapFocus(self.__bmpUnDock)
169              self.__dockButton.SetToolTip(wxToolTip(_("Undock")))              self.__dockButton.SetToolTip(wxToolTip(_("Undock")))
170          else:          else:
171              self.__dockButton.SetLabel(_("Undock"))              self.__dockButton.SetLabel(_("Undock"))
# Line 196  class DockableWindow(Publisher): Line 193  class DockableWindow(Publisher):
193          self.__topWindow = self.__floatWindow          self.__topWindow = self.__floatWindow
194          self.__dockPanel.Reparent(self.__topWindow)          self.__dockPanel.Reparent(self.__topWindow)
195    
196          if self.bmpDock is not None:          if self.__bmpDock is not None:
197              self.__dockButton.SetBitmapLabel(self.bmpDock)              self.__dockButton.SetBitmapLabel(self.__bmpDock)
198              self.__dockButton.SetBitmapFocus(self.bmpDock)              self.__dockButton.SetBitmapFocus(self.__bmpDock)
199              self.__dockButton.SetToolTip(wxToolTip(_("Dock")))              self.__dockButton.SetToolTip(wxToolTip(_("Dock")))
200          else:          else:
201              self.__dockButton.SetLabel(_("Dock"))              self.__dockButton.SetLabel(_("Dock"))
# Line 229  class DockableWindow(Publisher): Line 226  class DockableWindow(Publisher):
226    
227      def SetDockSize(self, rect = None):      def SetDockSize(self, rect = None):
228    
         #  
         # adjust the size to get the  
229          w0, h0 = self.__dockPanel.GetBestSize()          w0, h0 = self.__dockPanel.GetBestSize()
230          w, h = self.__panel.GetBestSize()          w, h = self.__panel.GetBestSize()
231    
         #print (w0, h0), (w, h)  
   
232          if (w, h) < (w0, h0):          if (w, h) < (w0, h0):
233              w = w0              w = w0
234              h = h0              h = h0
235                                                                                          
236          if rect is not None:          if rect is not None:
237              rw = rect.width              rw = rect.width
238              rh = rect.height              rh = rect.height
             #print "   ", (rw, rh)  
239              if rw < w: rw = w              if rw < w: rw = w
240              if rh < h: rh = h              if rh < h: rh = h
241          else:          else:
# Line 289  class DockableWindow(Publisher): Line 281  class DockableWindow(Publisher):
281    
282      def __DoShow(self):      def __DoShow(self):
283          if self.IsShown(): return          if self.IsShown(): return
         #print "__DoShow()", self.IsShown()  
284    
285          self.__topWindow.Show()          self.__topWindow.Show()
286    
# Line 301  class DockableWindow(Publisher): Line 292  class DockableWindow(Publisher):
292                            
293      def __DoHide(self):      def __DoHide(self):
294          if not self.IsShown(): return          if not self.IsShown(): return
         #print "__DoHide()", self.IsShown()  
295          self.__topWindow.Show(False)          self.__topWindow.Show(False)
296    
297          if self.__topWindow is self.__dockWindow:          if self.__topWindow is self.__dockWindow:
# Line 313  class DockableWindow(Publisher): Line 303  class DockableWindow(Publisher):
303          #self.__panel.Reparent(self) # Make sure we hang on to the panel          #self.__panel.Reparent(self) # Make sure we hang on to the panel
304    
305          self.__dockPanel = wxPanel(self.__topWindow, -1, style=wxSUNKEN_BORDER)          self.__dockPanel = wxPanel(self.__topWindow, -1, style=wxSUNKEN_BORDER)
306          #self.__dockPanel.SetBackgroundColour(wxColour(255, 0, 0))  
307            self.__panel.Reparent(self.__dockPanel)
308            self.__panel.SetId(PANEL_ID)
309    
310          if self.__orientation == wxLAYOUT_VERTICAL:          if self.__orientation == wxLAYOUT_VERTICAL:
311              sizer = wxBoxSizer(wxVERTICAL)              sizer = wxBoxSizer(wxVERTICAL)
# Line 343  class DockableWindow(Publisher): Line 335  class DockableWindow(Publisher):
335          # Perhaps using wxToggleButton would be better, but it's only          # Perhaps using wxToggleButton would be better, but it's only
336          # supported under wxMSW and wxGTK as of v2.4.0.3          # supported under wxMSW and wxGTK as of v2.4.0.3
337          #          #
338          self.bmpDock   = \          self.__bmpDock   = \
339              resource.GetBitmapResource(DOCK_BMP, wxBITMAP_TYPE_XPM)              resource.GetBitmapResource(DOCK_BMP, wxBITMAP_TYPE_XPM)
340          self.bmpUnDock = \          self.__bmpUnDock = \
341              resource.GetBitmapResource(UNDOCK_BMP, wxBITMAP_TYPE_XPM)              resource.GetBitmapResource(UNDOCK_BMP, wxBITMAP_TYPE_XPM)
342    
343          if self.bmpDock is not None \          if self.__bmpDock is not None \
344              and self.bmpUnDock is not None:              and self.__bmpUnDock is not None:
345              self.__dockButton = wxBitmapButton(              self.__dockButton = wxBitmapButton(
346                  self.__dockPanel, ID_BUTTON_DOCK,                  self.__dockPanel, ID_BUTTON_DOCK,
347                  self.bmpUnDock,                  self.__bmpUnDock,
348                  size = wxSize(self.bmpDock.GetWidth() + 4,                  size = wxSize(self.__bmpDock.GetWidth() + 4,
349                                self.bmpDock.GetHeight() + 4),                                self.__bmpDock.GetHeight() + 4),
350                  style = wxBU_EXACTFIT | wxADJUST_MINSIZE)                  style = wxBU_EXACTFIT | wxADJUST_MINSIZE)
351          else:          else:
352              self.bmpDock = \              self.__bmpDock = \
353              self.bmpUnDock = None              self.__bmpUnDock = None
354    
355              self.__dockButton = wxButton(              self.__dockButton = wxButton(
356                  self.__dockPanel, ID_BUTTON_DOCK,                  self.__dockPanel, ID_BUTTON_DOCK,
# Line 382  class DockableWindow(Publisher): Line 374  class DockableWindow(Publisher):
374          if self.__orientation == wxLAYOUT_VERTICAL:          if self.__orientation == wxLAYOUT_VERTICAL:
375              headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0)              headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0)
376              headerBox.Add(1, 5, 1, wxGROW)              headerBox.Add(1, 5, 1, wxGROW)
             #headerBox.Add(buttonBox, 0, wxGROW | wxALIGN_RIGHT, 0)  
377              headerBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0)              headerBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0)
378              headerBox.Add(closeX, 0, wxALIGN_RIGHT | wxLEFT, 4)              headerBox.Add(closeX, 0, wxALIGN_RIGHT | wxLEFT, 4)
379          else:          else:
# Line 391  class DockableWindow(Publisher): Line 382  class DockableWindow(Publisher):
382              headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0)              headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0)
383    
384          sizer.Add(headerBox, 0, wxGROW, 0)          sizer.Add(headerBox, 0, wxGROW, 0)
   
         self.__panel.Reparent(self.__dockPanel)  
         self.__panel.SetId(PANEL_ID)  
   
385          sizer.Add(self.__panel, 1, wxGROW, 0)          sizer.Add(self.__panel, 1, wxGROW, 0)
386    
         sizer.Fit(self.__dockPanel)  
   
         self.__dockPanel.SetSizer(sizer)  
387          self.__dockPanel.SetAutoLayout(True)          self.__dockPanel.SetAutoLayout(True)
388            self.__dockPanel.SetSizer(sizer)
389          sizer.SetSizeHints(self.__dockPanel)          sizer.SetSizeHints(self.__dockPanel)
390    
391            sizer.SetSizeHints(self.__topWindow)
392    
393          EVT_BUTTON(self.__dockPanel, ID_BUTTON_DOCK, self._OnToggleDock)          EVT_BUTTON(self.__dockPanel, ID_BUTTON_DOCK, self._OnToggleDock)
394          EVT_BUTTON(self.__dockPanel, ID_BUTTON_CLOSE, self._OnButtonClose)          EVT_BUTTON(self.__dockPanel, ID_BUTTON_CLOSE, self._OnButtonClose)
395    
# Line 459  class DockFrame(wxFrame): Line 445  class DockFrame(wxFrame):
445          sash = wxSashLayoutWindow(self, id, style=wxNO_BORDER|wxSW_3D)          sash = wxSashLayoutWindow(self, id, style=wxNO_BORDER|wxSW_3D)
446          sash.SetOrientation(orient)          sash.SetOrientation(orient)
447          sash.SetAlignment(align)          sash.SetAlignment(align)
         #print align, DockFrame.layout2oppSash[align]  
448          sash.SetSashVisible(DockFrame.layout2oppSash[align], True)          sash.SetSashVisible(DockFrame.layout2oppSash[align], True)
449          sash.SetSashBorder(DockFrame.layout2oppSash[align], True)          sash.SetSashBorder(DockFrame.layout2oppSash[align], True)
450    
# Line 482  class DockFrame(wxFrame): Line 467  class DockFrame(wxFrame):
467          self._UpdateDocks()          self._UpdateDocks()
468                    
469      def _UpdateDocks(self):      def _UpdateDocks(self):
         #print "_UpdateDocks()"  
470          if self.__update_lock == 0:          if self.__update_lock == 0:
471              wxLayoutAlgorithm().LayoutWindow(self, self.__mainWindow)              wxLayoutAlgorithm().LayoutWindow(self, self.__mainWindow)
472    
# Line 494  class DockFrame(wxFrame): Line 478  class DockFrame(wxFrame):
478          sash = self.FindWindowById(id)          sash = self.FindWindowById(id)
479          #assert(isinstance(win, wxPanel))          #assert(isinstance(win, wxPanel))
480          dockPanel = sash.GetChildren()[0]          dockPanel = sash.GetChildren()[0]
         #print dockPanel  
481          panel = dockPanel.FindWindowById(PANEL_ID)          panel = dockPanel.FindWindowById(PANEL_ID)
         #print panel  
482          assert isinstance(panel, DockPanel)          assert isinstance(panel, DockPanel)
483          win = panel.GetDockParent()          win = panel.GetDockParent()
         #print win  
484          assert isinstance(win, DockableWindow)          assert isinstance(win, DockableWindow)
485    
486          assert win.IsDocked()          assert win.IsDocked()

Legend:
Removed from v.651  
changed lines
  Added in v.659

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26