[GRASS-SVN] r63424 - in grass/trunk/gui/wxpython: lmgr mapdisp mapwin

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Dec 7 07:29:56 PST 2014


Author: martinl
Date: 2014-12-07 07:29:56 -0800 (Sun, 07 Dec 2014)
New Revision: 63424

Modified:
   grass/trunk/gui/wxpython/lmgr/giface.py
   grass/trunk/gui/wxpython/mapdisp/frame.py
   grass/trunk/gui/wxpython/mapdisp/main.py
   grass/trunk/gui/wxpython/mapdisp/statusbar.py
   grass/trunk/gui/wxpython/mapwin/buffered.py
Log:
wxGUI: allow to hide/show toolbars and statusbar in map display


Modified: grass/trunk/gui/wxpython/lmgr/giface.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/giface.py	2014-12-07 13:38:13 UTC (rev 63423)
+++ grass/trunk/gui/wxpython/lmgr/giface.py	2014-12-07 15:29:56 UTC (rev 63424)
@@ -194,8 +194,24 @@
 
     def UpdateCmdHistory(self, cmd):
         self.lmgr.goutput.GetPrompt().UpdateCmdHistory(cmd)
+        
+    def ShowStatusbar(self, show=True):
+        self.lmgr.GetMapDisplay().statusbarManager.Show(show)
 
+    def IsStatusbarShown(self):
+        return self.lmgr.GetMapDisplay().statusbarManager.IsShown()
 
+    def ShowAllToolbars(self, show=True):
+        if not show: # hide
+            action = self.lmgr.GetMapDisplay().RemoveToolbar
+        else:
+            action = self.lmgr.GetMapDisplay().AddToolbar
+        for toolbar in self.lmgr.GetMapDisplay().GetToolbarNames():
+            action(toolbar)
+            
+    def AreAllToolbarsShown(self):
+        return self.lmgr.GetMapDisplay().GetMapToolbar().IsShown()
+
 class LayerManagerGrassInterfaceForMapDisplay(object):
     """Provides reference only to the given layer list (according to tree),
         not to the current.

Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py	2014-12-07 13:38:13 UTC (rev 63423)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py	2014-12-07 15:29:56 UTC (rev 63424)
@@ -298,9 +298,10 @@
         elif self._mgr.GetPane('3d').IsShown():
             self._mgr.GetPane('3d').Hide()
         self._mgr.GetPane('vdigit').Show()
-        self.toolbars['vdigit'] = VDigitToolbar(parent=self, toolSwitcher=self._toolSwitcher,
-                                                MapWindow = self.MapWindow,
-                                                digitClass=VDigit, giface=self._giface)
+        if 'vdigit' not in self.toolbars:
+            self.toolbars['vdigit'] = VDigitToolbar(parent=self, toolSwitcher=self._toolSwitcher,
+                                                    MapWindow = self.MapWindow,
+                                                    digitClass=VDigit, giface=self._giface)
         self.MapWindowVDigit.SetToolbar(self.toolbars['vdigit'])
         
         self._mgr.AddPane(self.toolbars['vdigit'],
@@ -463,7 +464,8 @@
         """
         # default toolbar
         if name == "map":
-            self.toolbars['map'] = MapToolbar(self, toolSwitcher=self._toolSwitcher)
+            if 'map' not in self.toolbars:
+                self.toolbars['map'] = MapToolbar(self, toolSwitcher=self._toolSwitcher)
             
             self._mgr.AddPane(self.toolbars['map'],
                               wx.aui.AuiPaneInfo().
@@ -484,20 +486,19 @@
          
         self._mgr.Update()
         
-    def RemoveToolbar (self, name):
+    def RemoveToolbar (self, name, destroy=False):
         """Removes defined toolbar from the window
 
-        .. todo::
-            Only hide, activate by calling AddToolbar()
+        :param name toolbar to remove
+        :param destroy True to destroy otherwise toolbar is only hidden
         """
-        # cannot hide main toolbar
-        if name == "map":
-            return
-        
         self._mgr.DetachPane(self.toolbars[name])
         self._toolSwitcher.RemoveToolbarFromGroup('mouseUse', self.toolbars[name])
-        self.toolbars[name].Destroy()
-        self.toolbars.pop(name)
+        if destroy:
+            self.toolbars[name].Destroy()
+            self.toolbars.pop(name)
+        else:
+            self.toolbars[name].Hide()
         
         if name == 'vdigit':
             self._mgr.GetPane('vdigit').Hide()
@@ -1412,8 +1413,12 @@
 
     def GetMapToolbar(self):
         """Returns toolbar with zooming tools"""
-        return self.toolbars['map']
+        return self.toolbars['map'] if 'map' in self.toolbars else None
 
+    def GetToolbarNames(self):
+        """Return toolbar names"""
+        return self.toolbars.keys()
+    
     def OnVNet(self, event):
         """Dialog for v.net* modules 
         """

Modified: grass/trunk/gui/wxpython/mapdisp/main.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/main.py	2014-12-07 13:38:13 UTC (rev 63423)
+++ grass/trunk/gui/wxpython/mapdisp/main.py	2014-12-07 15:29:56 UTC (rev 63424)
@@ -327,7 +327,7 @@
     def __init__(self, mapframe):
         StandaloneGrassInterface.__init__(self)
         self._mapframe = mapframe
-
+        
     def GetLayerList(self):
         return LayerList(self._mapframe.GetMap(), giface=self)
 
@@ -337,7 +337,23 @@
     def GetProgress(self):
         return self._mapframe.GetProgressBar()
 
+    def ShowStatusbar(self, show=True):
+        self._mapframe.statusbarManager.Show(show)
 
+    def IsStatusbarShown(self):
+        return self._mapframe.statusbarManager.IsShown()
+
+    def ShowAllToolbars(self, show=True):
+        if not show: # hide
+            action = self._mapframe.RemoveToolbar
+        else:
+            action = self._mapframe.AddToolbar
+        for toolbar in self._mapframe.GetToolbarNames():
+            action(toolbar)
+    
+    def AreAllToolbarsShown(self):
+        return self._mapframe.GetMapToolbar().IsShown()
+
 class DMonFrame(MapFrame):
     def OnZoomToMap(self, event):
         layers = self.MapWindow.GetMap().GetListOfLayers()

Modified: grass/trunk/gui/wxpython/mapdisp/statusbar.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/statusbar.py	2014-12-07 13:38:13 UTC (rev 63423)
+++ grass/trunk/gui/wxpython/mapdisp/statusbar.py	2014-12-07 15:29:56 UTC (rev 63424)
@@ -319,7 +319,15 @@
         self.progressbar.SetValue(value)
         if text:
             self.statusbar.SetStatusText(text)
-        
+
+    def Show(self, show=True):
+        """Show/hide statusbar"""
+        self.statusbar.Show(show)
+
+    def IsShown(self):
+        """Check if statusbar is shown"""
+        return self.statusbar.IsShown()
+
 class SbItem:
     """Base class for statusbar items.
     

Modified: grass/trunk/gui/wxpython/mapwin/buffered.py
===================================================================
--- grass/trunk/gui/wxpython/mapwin/buffered.py	2014-12-07 13:38:13 UTC (rev 63423)
+++ grass/trunk/gui/wxpython/mapwin/buffered.py	2014-12-07 15:29:56 UTC (rev 63424)
@@ -232,10 +232,23 @@
             self.popupCopyCoordinates = wx.NewId()
             self.Bind(wx.EVT_MENU, self.OnCopyCoordinates, id = self.popupCopyCoordinates)
         menu.Append(self.popupCopyCoordinates, _("Copy coordinates to clipboard"))
+        menu.AppendSeparator()
+        if not hasattr(self, "popupShowAllToolbars"):
+            self.popupShowAllToolbars = wx.NewId()
+            self.Bind(wx.EVT_MENU, self.OnShowAllToolbars, id = self.popupShowAllToolbars)
+        menu.Append(self.popupShowAllToolbars, _("Hide all toolbars") if self._giface.AreAllToolbarsShown() else _("Show all toolbars"))
+        if not hasattr(self, "popupShowStatusbar"):
+            self.popupShowStatusbar = wx.NewId()
+            self.Bind(wx.EVT_MENU, self.OnShowStatusbar, id = self.popupShowStatusbar)
+        menu.Append(self.popupShowStatusbar, _("Hide statusbar") if self._giface.IsStatusbarShown() else _("Show statusbar"))
 
         pos = self.ScreenToClient(event.GetPosition())
         idlist = self.pdc.FindObjects(pos[0], pos[1], self.hitradius)
+        separator = True
         if idlist and idlist[0] in (0, 1, 2):  # legend, scale bar, north arrow
+            if separator:
+                menu.AppendSeparator()
+                separator = False
             self._hide = wx.NewId()
             self.Bind(wx.EVT_MENU,
                       lambda evt: self.overlayHidden.emit(overlayId=idlist[0]),
@@ -1542,6 +1555,14 @@
             wx.TheClipboard.SetData(do)
             wx.TheClipboard.Close()
 
+    def OnShowStatusbar(self, event):
+        """Show/hide statusbar"""
+        self._giface.ShowStatusbar(not self._giface.IsStatusbarShown())
+
+    def OnShowAllToolbars(self, event):
+        """Show/hide all toolbars"""
+        self._giface.ShowAllToolbars(not self._giface.AreAllToolbarsShown())
+
     def ClearLines(self, pdc = None):
         """Clears temporary drawn lines from PseudoDC
         """



More information about the grass-commit mailing list