/[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 577 by jonathan, Mon Mar 31 18:31:33 2003 UTC revision 651 by jonathan, Fri Apr 11 14:27:53 2003 UTC
# Line 9  Line 9 
9    
10  __version__ = "$Revision$"  __version__ = "$Revision$"
11    
12    import resource
13    
14  from Thuban import _  from Thuban import _
15    
16  from wxPython.wx import *  from wxPython.wx import *
# Line 19  from dialogs import NonModalDialog Line 21  from dialogs import NonModalDialog
21    
22  from messages import DOCKABLE_DOCKED, DOCKABLE_UNDOCKED, DOCKABLE_CLOSED  from messages import DOCKABLE_DOCKED, DOCKABLE_UNDOCKED, DOCKABLE_CLOSED
23    
 import gc  
   
24  ID_BUTTON_DOCK = 4001  ID_BUTTON_DOCK = 4001
25  ID_BUTTON_CLOSE = 4002  ID_BUTTON_CLOSE = 4002
26    
27  PANEL_ID = 3141  PANEL_ID = 3141
28    
29    DOCK_BMP   = "dock_12"
30    UNDOCK_BMP = "undock_12"
31    CLOSE_BMP  = "close_12"
32    
33  class DockPanel(wxPanel):  class DockPanel(wxPanel):
34    
35      def __init__(self, parent, id):      def __init__(self, parent, id):
# Line 162  class DockableWindow(Publisher): Line 166  class DockableWindow(Publisher):
166          self.__topWindow = self.__dockWindow          self.__topWindow = self.__dockWindow
167          self.__dockPanel.Reparent(self.__topWindow)          self.__dockPanel.Reparent(self.__topWindow)
168    
169          self.__dockButton.SetLabel(_("Undock"))          if self.bmpUnDock is not None:
170                self.__dockButton.SetBitmapLabel(self.bmpUnDock)
171                self.__dockButton.SetBitmapFocus(self.bmpUnDock)
172                self.__dockButton.SetToolTip(wxToolTip(_("Undock")))
173            else:
174                self.__dockButton.SetLabel(_("Undock"))
175    
176          self.SetDockSize(self.__dockWindow.GetSize())          self.SetDockSize(self.__dockWindow.GetSize())
177    
# Line 187  class DockableWindow(Publisher): Line 196  class DockableWindow(Publisher):
196          self.__topWindow = self.__floatWindow          self.__topWindow = self.__floatWindow
197          self.__dockPanel.Reparent(self.__topWindow)          self.__dockPanel.Reparent(self.__topWindow)
198    
199          self.__dockButton.SetLabel(_("Dock"))          if self.bmpDock is not None:
200                self.__dockButton.SetBitmapLabel(self.bmpDock)
201                self.__dockButton.SetBitmapFocus(self.bmpDock)
202                self.__dockButton.SetToolTip(wxToolTip(_("Dock")))
203            else:
204                self.__dockButton.SetLabel(_("Dock"))
205    
206          if wasVisible: self.Show()          if wasVisible: self.Show()
207    
# Line 197  class DockableWindow(Publisher): Line 211  class DockableWindow(Publisher):
211          if self.__floatPosition is not None: self.SetPosition(self.__floatPosition)          if self.__floatPosition is not None: self.SetPosition(self.__floatPosition)
212          if self.__floatSize     is not None: self.SetSize(self.__floatSize)          if self.__floatSize     is not None: self.SetSize(self.__floatSize)
213    
214            self.__dockPanel.SetSize(self.__topWindow.GetClientSize())
215    
216          self.issue(DOCKABLE_UNDOCKED, self.__id, self)          self.issue(DOCKABLE_UNDOCKED, self.__id, self)
217    
218      def IsDocked(self):      def IsDocked(self):
# Line 245  class DockableWindow(Publisher): Line 261  class DockableWindow(Publisher):
261          self.__panel.Destroy()          self.__panel.Destroy()
262          self.__floatWindow.Destroy()          self.__floatWindow.Destroy()
263          self.__dockWindow.Destroy()          self.__dockWindow.Destroy()
264          self.__parent.OnDockClose(self)          self.__parent.OnDockDestroy(self)
265                    
266      ##      ##
267      # Event handlers      # Event handlers
268      #      #
269    
270      def _OnButtonClose(self, event):      def _OnButtonClose(self, event):
271          self.Close()          #self.Close()
272            self.Show(False)
273    
274      def _OnClose(self, force = False):      def _OnClose(self, force = False):
275          self.Destroy()          self.Show(False)
276    
277      def _OnToggleDock(self, event):      def _OnToggleDock(self, event):
278          self.__CheckAllGood()          self.__CheckAllGood()
# Line 309  class DockableWindow(Publisher): Line 326  class DockableWindow(Publisher):
326          headerBox = wxStaticBoxSizer(          headerBox = wxStaticBoxSizer(
327                          wxStaticBox(self.__dockPanel, -1, ""), headerBoxOrient)                          wxStaticBox(self.__dockPanel, -1, ""), headerBoxOrient)
328    
329          buttonBox = wxBoxSizer(wxHORIZONTAL)          #buttonBox = wxBoxSizer(wxHORIZONTAL)
330    
331          #          #
332          # ideally, we should be able to rotate this text depending on          # ideally, we should be able to rotate this text depending on
333          # our orientation          # our orientation
334          #          #
335          text = wxStaticText(self.__dockPanel, -1, self.GetTitle(),          text = wxStaticText(self.__dockPanel, -1, self.GetTitle(),
336                               style = wxSIMPLE_BORDER | wxALIGN_CENTRE)                               style = wxALIGN_CENTRE)
337    
338            font = text.GetFont()
339            font.SetPointSize(10)
340            text.SetFont(font)
341    
342          #          #
343          # Perhaps using wxToggleButton would be better, but it's only          # Perhaps using wxToggleButton would be better, but it's only
344          # supported under wxMSW and wxGTK as of v2.4.0.3          # supported under wxMSW and wxGTK as of v2.4.0.3
345          #          #
346          self.__dockButton = wxButton(self.__dockPanel, ID_BUTTON_DOCK, "WWWWWW",          self.bmpDock   = \
347                                       style = wxBU_EXACTFIT | wxADJUST_MINSIZE)              resource.GetBitmapResource(DOCK_BMP, wxBITMAP_TYPE_XPM)
348            self.bmpUnDock = \
349                resource.GetBitmapResource(UNDOCK_BMP, wxBITMAP_TYPE_XPM)
350    
351            if self.bmpDock is not None \
352                and self.bmpUnDock is not None:
353                self.__dockButton = wxBitmapButton(
354                    self.__dockPanel, ID_BUTTON_DOCK,
355                    self.bmpUnDock,
356                    size = wxSize(self.bmpDock.GetWidth() + 4,
357                                  self.bmpDock.GetHeight() + 4),
358                    style = wxBU_EXACTFIT | wxADJUST_MINSIZE)
359            else:
360                self.bmpDock = \
361                self.bmpUnDock = None
362    
363                self.__dockButton = wxButton(
364                    self.__dockPanel, ID_BUTTON_DOCK,
365                    "WW", style = wxBU_EXACTFIT | wxADJUST_MINSIZE)
366    
367            bmp = resource.GetBitmapResource(CLOSE_BMP, wxBITMAP_TYPE_XPM)
368    
369            closeX = wxBitmapButton(self.__dockPanel, ID_BUTTON_CLOSE, bmp,
370                              size = wxSize(bmp.GetWidth() + 4,
371                                            bmp.GetHeight() + 4),
372                              style = wxBU_EXACTFIT | wxADJUST_MINSIZE)
373            closeX.SetToolTip(wxToolTip(_("Close")))
374    
375    
376          closeX = wxButton(self.__dockPanel, ID_BUTTON_CLOSE, "X",          #closeX = wxButton(self.__dockPanel, ID_BUTTON_CLOSE, "X",
377                           style = wxBU_EXACTFIT | wxADJUST_MINSIZE)                           #style = wxBU_EXACTFIT | wxADJUST_MINSIZE)
378    
379          buttonBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0)          #buttonBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0)
380          buttonBox.Add(closeX, 0, wxALIGN_RIGHT, 0)          #buttonBox.Add(closeX, 0, wxALIGN_RIGHT, 0)
381    
382          if self.__orientation == wxLAYOUT_VERTICAL:          if self.__orientation == wxLAYOUT_VERTICAL:
383              headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0)              headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0)
384              headerBox.Add(1, 20, 1, wxGROW)              headerBox.Add(1, 5, 1, wxGROW)
385              headerBox.Add(buttonBox, 0, wxGROW | wxALIGN_RIGHT, 0)              #headerBox.Add(buttonBox, 0, wxGROW | wxALIGN_RIGHT, 0)
386                headerBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0)
387                headerBox.Add(closeX, 0, wxALIGN_RIGHT | wxLEFT, 4)
388          else:          else:
389              headerBox.Add(buttonBox, 0, wxGROW, 0)              headerBox.Add(closeX, 0, wxALIGN_RIGHT | wxBOTTOM, 4)
390                headerBox.Add(self.__dockButton, 0, wxALIGN_RIGHT, 0)
391              headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0)              headerBox.Add(text, 0, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL, 0)
392    
393          sizer.Add(headerBox, 0, wxGROW, 0)          sizer.Add(headerBox, 0, wxGROW, 0)
# Line 422  class DockFrame(wxFrame): Line 473  class DockFrame(wxFrame):
473      def FindRegisteredDock(self, name):      def FindRegisteredDock(self, name):
474          return self.openWindows.get(name)          return self.openWindows.get(name)
475    
476      def OnDockClose(self, win):      def OnDockDestroy(self, win):
477          del self.openWindows[win.GetName()]          del self.openWindows[win.GetName()]
478          self._UpdateDocks()          self._UpdateDocks()
479    
# Line 446  class DockFrame(wxFrame): Line 497  class DockFrame(wxFrame):
497          #print dockPanel          #print dockPanel
498          panel = dockPanel.FindWindowById(PANEL_ID)          panel = dockPanel.FindWindowById(PANEL_ID)
499          #print panel          #print panel
500          assert(isinstance(panel, DockPanel))          assert isinstance(panel, DockPanel)
501          win = panel.GetDockParent()          win = panel.GetDockParent()
502          #print win          #print win
503          assert(isinstance(win, DockableWindow))          assert isinstance(win, DockableWindow)
504    
505          assert(win.IsDocked())          assert win.IsDocked()
506    
507          rect = event.GetDragRect()          rect = event.GetDragRect()
508    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26