[GRASS-SVN] r40184 - in grass/trunk/gui/wxpython: . gui_modules vdigit xml

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jan 2 08:58:22 EST 2010


Author: martinl
Date: 2010-01-02 08:58:21 -0500 (Sat, 02 Jan 2010)
New Revision: 40184

Modified:
   grass/trunk/gui/wxpython/gui_modules/georect.py
   grass/trunk/gui/wxpython/gui_modules/goutput.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
   grass/trunk/gui/wxpython/gui_modules/menuform.py
   grass/trunk/gui/wxpython/gui_modules/profile.py
   grass/trunk/gui/wxpython/gui_modules/toolbars.py
   grass/trunk/gui/wxpython/gui_modules/vdigit.py
   grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
   grass/trunk/gui/wxpython/vdigit/Makefile
   grass/trunk/gui/wxpython/vdigit/digit.cpp
   grass/trunk/gui/wxpython/wxgui.py
   grass/trunk/gui/wxpython/xml/menudata.xml
Log:
wxGUI: toolbar clean up + various minor fixes


Modified: grass/trunk/gui/wxpython/gui_modules/georect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/georect.py	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/gui_modules/georect.py	2010-01-02 13:58:21 UTC (rev 40184)
@@ -1,4 +1,4 @@
-"""
+"""!
 @package georect.py
 
 @brief Georectification module for GRASS GIS. Includes ground control
@@ -15,7 +15,7 @@
  - EditGCP
  - GrSettingsDialog
 
-(C) 2006-2008 by the GRASS Development Team
+(C) 2006-2009 by the GRASS Development Team
 
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -735,7 +735,7 @@
         #
         # toolbar and display for xy map
         #
-        self.toolbar = toolbars.GCPToolbar(parent=self, tbframe=self).GetToolbar()
+        self.toolbar = toolbars.GCPToolbar(parent=self)
         self.SetToolBar(self.toolbar)
         
         self.SetMapDisplay(self.mapdisp)

Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py	2010-01-02 13:58:21 UTC (rev 40184)
@@ -422,10 +422,7 @@
                 self.parent.cmdinput.SetHistoryItems()
             except AttributeError:
                 pass
-
-        # allow writing to output window
-        self.cmd_output.SetReadOnly(False)
-                
+        
         if cmdlist[0] in globalvar.grassCmd['all']:
             # send GRASS command without arguments to GUI command interface
             # except display commands (they are handled differently)
@@ -513,10 +510,7 @@
                                   self.cmd_stdout, self.cmd_stderr)                                         
             self.btn_abort.Enable()
             self.cmd_output_timer.Start(50)
-        
-        # reset output window to read only
-        self.cmd_output.SetReadOnly(True)
-        
+                
         return None
 
     def ClearHistory(self, event):
@@ -948,6 +942,9 @@
 
         String is wrapped and linesep is also added to the end
         of the string"""
+        # allow writing to output window
+        self.SetReadOnly(False)
+        
         if wrap:
             txt = textwrap.fill(txt, wrap) + '\n'
         else:
@@ -976,4 +973,8 @@
                 else:
                     txt = _('Unable to encode text. Please set encoding in GUI preferences.') + '\n'
                     
-                self.AddText(txt) 
+                self.AddText(txt)
+        
+        # reset output window to read only
+        self.SetReadOnly(True)
+    

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2010-01-02 13:58:21 UTC (rev 40184)
@@ -314,14 +314,14 @@
         if name == "map":
             self.toolbars['map'] = toolbars.MapToolbar(self, self.Map)
 
-            self._mgr.AddPane(self.toolbars['map'].toolbar,
+            self._mgr.AddPane(self.toolbars['map'],
                               wx.aui.AuiPaneInfo().
                               Name("maptoolbar").Caption(_("Map Toolbar")).
                               ToolbarPane().Top().
                               LeftDockable(False).RightDockable(False).
                               BottomDockable(False).TopDockable(True).
                               CloseButton(False).Layer(2).
-                              BestSize((self.toolbars['map'].GetToolbar().GetSize())))
+                              BestSize((self.toolbars['map'].GetSize())))
 	
         # vector digitizer
         elif name == "vdigit":
@@ -343,20 +343,19 @@
                 log = self._layerManager.goutput
             else:
                 log = None
-            self.toolbars['vdigit'] = toolbars.VDigitToolbar(parent=self, map=self.Map,
+            self.toolbars['vdigit'] = toolbars.VDigitToolbar(parent=self, mapcontent=self.Map,
                                                              layerTree=self.tree,
                                                              log=log)
-
-            for toolRow in range(0, self.toolbars['vdigit'].numOfRows):
-                self._mgr.AddPane(self.toolbars['vdigit'].toolbar[toolRow],
-                                  wx.aui.AuiPaneInfo().
-                                  Name("vdigittoolbar" + str(toolRow)).Caption(_("Vector digitizer toolbar")).
-                                  ToolbarPane().Top().Row(toolRow + 1).
-                                  LeftDockable(False).RightDockable(False).
-                                  BottomDockable(False).TopDockable(True).
-                                  CloseButton(False).Layer(2).
-                                  BestSize((self.toolbars['vdigit'].GetToolbar().GetSize())))
-	
+            
+            self._mgr.AddPane(self.toolbars['vdigit'],
+                              wx.aui.AuiPaneInfo().
+                              Name("vdigittoolbar").Caption(_("Vector digitizer toolbar")).
+                              ToolbarPane().Top().Row(1).
+                              LeftDockable(False).RightDockable(False).
+                              BottomDockable(False).TopDockable(True).
+                              CloseButton(False).Layer(2).
+                              BestSize((self.toolbars['vdigit'].GetSize())))
+            
             # change mouse to draw digitized line
             self.MapWindow.mouse['box'] = "point"
             self.MapWindow.zoomtype = 0
@@ -366,7 +365,7 @@
         elif name == "georect":
             self.toolbars['georect'] = toolbars.GRToolbar(self, self.Map)
 
-            self._mgr.AddPane(self.toolbars['georect'].toolbar,
+            self._mgr.AddPane(self.toolbars['georect'],
                               wx.aui.AuiPaneInfo().
                               Name("georecttoolbar").Caption(_("Georectification toolbar")).
                               ToolbarPane().Top().
@@ -446,7 +445,7 @@
                               Dockable(False).BestSize((-1,-1)).
                               CloseButton(False).DestroyOnClose(True).
                               Layer(0))
-            self._mgr.AddPane(self.toolbars['nviz'].toolbar,
+            self._mgr.AddPane(self.toolbars['nviz'],
                               wx.aui.AuiPaneInfo().
                               Name("nviztoolbar").Caption(_("Nviz toolbar")).
                               ToolbarPane().Top().Row(1).
@@ -471,12 +470,11 @@
             return
         elif name == "vdigit":
             # TODO: not destroy only hide
-            for toolRow in range(0, self.toolbars['vdigit'].numOfRows):
-                self._mgr.DetachPane (self.toolbars['vdigit'].toolbar[toolRow])
-                self.toolbars['vdigit'].toolbar[toolRow].Destroy()
+            self._mgr.DetachPane(self.toolbars['vdigit'])
+            self.toolbars['vdigit'].Destroy()
         else:
-            self._mgr.DetachPane (self.toolbars[name].toolbar)
-            self.toolbars[name].toolbar.Destroy()
+            self._mgr.DetachPane (self.toolbars[name])
+            self.toolbars[name].Destroy()
 
         self.toolbars[name] = None
 

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py	2010-01-02 13:58:21 UTC (rev 40184)
@@ -454,6 +454,7 @@
         """!Key pressed"""
         shift = event.ShiftDown()
         kc = event.GetKeyCode()
+        
         vdigitToolbar = self.parent.toolbars['vdigit']
         ### vdigit
         if vdigitToolbar:

Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2010-01-02 13:58:21 UTC (rev 40184)
@@ -869,6 +869,7 @@
             return
         
         if not event.ControlDown():
+            event.Skip()
             return
         
         if kc == 'Q':

Modified: grass/trunk/gui/wxpython/gui_modules/profile.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/profile.py	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/gui_modules/profile.py	2010-01-02 13:58:21 UTC (rev 40184)
@@ -91,7 +91,7 @@
         #
         # Add toolbar
         #
-        self.toolbar = toolbars.ProfileToolbar(parent=self, tbframe=self).GetToolbar()
+        self.toolbar = toolbars.ProfileToolbar(parent=self)
         self.SetToolBar(self.toolbar)
         
         #

Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py	2010-01-02 13:58:21 UTC (rev 40184)
@@ -1,7 +1,7 @@
-"""
+"""!
 @package toolbar
 
- at brief Toolbars for Map Display window
+ at brief wxGUI toolbar widgets
 
 Classes:
  - AbstractToolbar
@@ -12,21 +12,23 @@
  - ProfileToolbar
  - NvizToolbar
 
-(C) 2007-2008 by the GRASS Development Team This program is free
-software under the GNU General Public License (>=v2). Read the file
-COPYING that comes with GRASS for details.
+(C) 2007-2009 by the GRASS Development Team
+This program is free software under the GNU General Public License
+(>=v2). Read the file COPYING that comes with GRASS for details.
 
 @author Michael Barton
 @author Jachym Cepicky
 @author Martin Landa <landa.martin gmail.com>
 """
 
-import wx
-import os, sys
+import os
+import sys
 import platform
 
 from grass.script import core as grass
 
+import wx
+
 import globalvar
 import gcmd
 import gdialogs
@@ -39,57 +41,54 @@
 gmpath = os.path.join(globalvar.ETCWXDIR, "icons")
 sys.path.append(gmpath)
 
-class AbstractToolbar(object):
+class AbstractToolbar(wx.ToolBar):
     """!Abstract toolbar class"""
-    def __init__(self):
+    def __init__(self, parent):
+        self.parent = parent
+        wx.ToolBar.__init__(self, parent = self.parent, id = wx.ID_ANY)
+        
+        self.SetToolBitmapSize(globalvar.toolbarSize)
+        
+        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
+        
+    def OnKeyDown(self, event):
         pass
-    
-    def InitToolbar(self, parent, toolbar, toolData):
-        """!Initialize toolbar, i.e. add tools to the toolbar
-
-        @return list of ids (of added tools)
+        
+    def InitToolbar(self, toolData):
+        """!Initialize toolbar, add tools to the toolbar
         """
-
         for tool in toolData:
-            self.CreateTool(parent, toolbar, *tool)
-
-        self._toolbar = toolbar
+            self.CreateTool(*tool)
+        
         self._data = toolData
         
-        self.parent = parent
-        
     def ToolbarData(self):
-        """!Toolbar data"""
+        """!Toolbar data (virtual)"""
         return None
-
-    def CreateTool(self, parent, toolbar, tool, label, bitmap, kind,
+    
+    def CreateTool(self, tool, label, bitmap, kind,
                    shortHelp, longHelp, handler):
         """!Add tool to the toolbar
-
+        
         @return id of tool
         """
-
         bmpDisabled=wx.NullBitmap
-
+        
         if label:
             Debug.msg(3, "CreateTool(): tool=%d, label=%s bitmap=%s" % \
                   (tool, label, bitmap))
-            toolWin = toolbar.AddLabelTool(tool, label, bitmap,
+            toolWin = self.AddLabelTool(tool, label, bitmap,
                                            bmpDisabled, kind,
                                            shortHelp, longHelp)
-            parent.Bind(wx.EVT_TOOL, handler, toolWin)
-        else: # add separator
-            toolbar.AddSeparator()
-
+            self.Bind(wx.EVT_TOOL, handler, toolWin)
+        else: # separator
+            self.AddSeparator()
+        
         return tool
-
-    def GetToolbar(self):
-        """!Get toolbar widget reference"""
-        return self._toolbar
-
+    
     def EnableLongHelp(self, enable=True):
         """!Enable/disable long help
-
+        
         @param enable True for enable otherwise disable
         """
         for tool in self._data:
@@ -97,39 +96,39 @@
                 continue
             
             if enable:
-                self._toolbar.SetToolLongHelp(tool[0], tool[5])
+                self.SetToolLongHelp(tool[0], tool[5])
             else:
-                self._toolbar.SetToolLongHelp(tool[0], "")
-
+                self.SetToolLongHelp(tool[0], "")
+        
     def OnTool(self, event):
         """!Tool selected"""
         if self.parent.toolbars['vdigit']:
             # update vdigit toolbar (unselect currently selected tool)
             id = self.parent.toolbars['vdigit'].GetAction(type='id')
-            self.parent.toolbars['vdigit'].GetToolbar().ToggleTool(id, False)
+            self.parent.toolbars['vdigit'].ToggleTool(id, False)
         
         if event:
             # deselect previously selected tool
             id = self.action.get('id', -1)
             if id != event.GetId():
-                self._toolbar.ToggleTool(self.action['id'], False)
+                self.ToggleTool(self.action['id'], False)
             else:
-                self._toolbar.ToggleTool(self.action['id'], True)
+                self.ToggleTool(self.action['id'], True)
             
             self.action['id'] = event.GetId()
             
             event.Skip()
         else:
             # initialize toolbar
-            self._toolbar.ToggleTool(self.action['id'], True)
-    
+            self.ToggleTool(self.action['id'], True)
+        
     def GetAction(self, type='desc'):
         """!Get current action info"""
         return self.action.get(type, '')
-
+    
     def SelectDefault(self, event):
         """!Select default tool"""
-        self._toolbar.ToggleTool(self.defaultAction['id'], True)
+        self.ToggleTool(self.defaultAction['id'], True)
         self.defaultAction['bind'](event)
         self.action = { 'id' : self.defaultAction['id'],
                         'desc' : self.defaultAction.get('desc', '') }
@@ -140,35 +139,33 @@
 	@todo Determine why combobox causes problems here
 	"""
         if platform.system() == 'Windows':
-            size = self._toolbar.GetBestSize()
-            self._toolbar.SetSize((size[0] + width, size[1]))
+            size = self.GetBestSize()
+            self.SetSize((size[0] + width, size[1]))
         
 class MapToolbar(AbstractToolbar):
+    """!Map Display toolbar
     """
-    Main Map Display toolbar
-    """
+    def __init__(self, parent, mapcontent):
+        """!Map Display constructor
 
-    def __init__(self, mapdisplay, map):
-        AbstractToolbar.__init__(self)
-
-        self.mapcontent = map
-        self.mapdisplay = mapdisplay
-
-        self.toolbar = wx.ToolBar(parent=self.mapdisplay, id=wx.ID_ANY)
-        self.toolbar.SetToolBitmapSize(globalvar.toolbarSize)
-
-        self.InitToolbar(self.mapdisplay, self.toolbar, self.ToolbarData())
+        @param parent reference to MapFrame
+        @param mapcontent reference to render.Map (registred by MapFrame)
+        """
+        self.mapcontent = mapcontent # render.Map
+        AbstractToolbar.__init__(self, parent = parent) # MapFrame
         
+        self.InitToolbar(self.ToolbarData())
+        
         # optional tools
-        self.combo = wx.ComboBox(parent=self.toolbar, id=wx.ID_ANY, value=_('2D view'),
+        self.combo = wx.ComboBox(parent=self, id=wx.ID_ANY, value=_('2D view'),
                                  choices=[_('2D view'), _('3D view'), _('Digitize')],
                                  style=wx.CB_READONLY, size=(90, -1))
         
-        self.comboid = self.toolbar.AddControl(self.combo)
-        self.mapdisplay.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid)
-
+        self.comboid = self.AddControl(self.combo)
+        self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid)
+        
         # realize the toolbar
-        self.toolbar.Realize()
+        self.Realize()
         
         # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
         self.combo.Hide()
@@ -177,16 +174,15 @@
         # default action
         self.action = { 'id' : self.pointer }
         self.defaultAction = { 'id' : self.pointer,
-                               'bind' : self.mapdisplay.OnPointer }
+                               'bind' : self.parent.OnPointer }
         self.OnTool(None)
         
-        self.toolbar.EnableTool(self.zoomback, False)
+        self.EnableTool(self.zoomback, False)
         
         self.FixSize(width = 90)
         
     def ToolbarData(self):
         """!Toolbar data"""
-
         self.displaymap = wx.NewId()
         self.rendermap = wx.NewId()
         self.erase = wx.NewId()
@@ -201,60 +197,60 @@
         self.dec = wx.NewId()
         self.savefile = wx.NewId()
         self.printmap = wx.NewId()
-
+        
         # tool, label, bitmap, kind, shortHelp, longHelp, handler
         return (
             (self.displaymap, "displaymap", Icons["displaymap"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["displaymap"].GetLabel(), Icons["displaymap"].GetDesc(),
-             self.mapdisplay.OnDraw),
+             self.parent.OnDraw),
             (self.rendermap, "rendermap", Icons["rendermap"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["rendermap"].GetLabel(), Icons["rendermap"].GetDesc(),
-             self.mapdisplay.OnRender),
+             self.parent.OnRender),
             (self.erase, "erase", Icons["erase"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(),
-             self.mapdisplay.OnErase),
+             self.parent.OnErase),
             ("", "", "", "", "", "", ""),
             (self.pointer, "pointer", Icons["pointer"].GetBitmap(),
              wx.ITEM_CHECK, Icons["pointer"].GetLabel(), Icons["pointer"].GetDesc(),
-             self.mapdisplay.OnPointer),
+             self.parent.OnPointer),
             (self.query, "query", Icons["query"].GetBitmap(),
              wx.ITEM_CHECK, Icons["query"].GetLabel(), Icons["query"].GetDesc(),
-             self.mapdisplay.OnQuery),
+             self.parent.OnQuery),
             (self.pan, "pan", Icons["pan"].GetBitmap(),
              wx.ITEM_CHECK, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(),
-             self.mapdisplay.OnPan),
+             self.parent.OnPan),
             (self.zoomin, "zoom_in", Icons["zoom_in"].GetBitmap(),
              wx.ITEM_CHECK, Icons["zoom_in"].GetLabel(), Icons["zoom_in"].GetDesc(),
-             self.mapdisplay.OnZoomIn),
+             self.parent.OnZoomIn),
             (self.zoomout, "zoom_out", Icons["zoom_out"].GetBitmap(),
              wx.ITEM_CHECK, Icons["zoom_out"].GetLabel(), Icons["zoom_out"].GetDesc(),
-             self.mapdisplay.OnZoomOut),
+             self.parent.OnZoomOut),
             (self.zoomback, "zoom_back", Icons["zoom_back"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["zoom_back"].GetLabel(), Icons["zoom_back"].GetDesc(),
-             self.mapdisplay.OnZoomBack),
+             self.parent.OnZoomBack),
             (self.zoommenu, "zoommenu", Icons["zoommenu"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["zoommenu"].GetLabel(), Icons["zoommenu"].GetDesc(),
-             self.mapdisplay.OnZoomMenu),
+             self.parent.OnZoomMenu),
             ("", "", "", "", "", "", ""),
             (self.analyze, "analyze", Icons["analyze"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["analyze"].GetLabel(), Icons["analyze"].GetDesc(),
-             self.mapdisplay.OnAnalyze),
+             self.parent.OnAnalyze),
             ("", "", "", "", "", "", ""),
             (self.dec, "overlay", Icons["overlay"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["overlay"].GetLabel(), Icons["overlay"].GetDesc(),
-             self.mapdisplay.OnDecoration),
+             self.parent.OnDecoration),
             ("", "", "", "", "", "", ""),
             (self.savefile, "savefile", Icons["savefile"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["savefile"].GetLabel(), Icons["savefile"].GetDesc(),
-             self.mapdisplay.SaveToFile),
+             self.parent.SaveToFile),
             (self.printmap, "printmap", Icons["printmap"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["printmap"].GetLabel(), Icons["printmap"].GetDesc(),
-             self.mapdisplay.PrintMenu),
+             self.parent.PrintMenu),
             ("", "", "", "", "", "", "")
             )
-
+    
     def OnSelectTool(self, event):
-        """
+        """!
         Select / enable tool available in tools list
         """
         tool =  event.GetSelection()
@@ -262,22 +258,22 @@
         if tool == 0:
             self.ExitToolbars()
             self.Enable2D(True)
-
-        elif tool == 1 and not self.mapdisplay.toolbars['nviz']:
+        
+        elif tool == 1 and not self.parent.toolbars['nviz']:
             self.ExitToolbars()
-            self.mapdisplay.AddToolbar("nviz")
+            self.parent.AddToolbar("nviz")
             
-        elif tool == 2 and not self.mapdisplay.toolbars['vdigit']:
+        elif tool == 2 and not self.parent.toolbars['vdigit']:
             self.ExitToolbars()
-            self.mapdisplay.AddToolbar("vdigit")
-            self.mapdisplay.MapWindow.SetFocus()
+            self.parent.AddToolbar("vdigit")
+            self.parent.MapWindow.SetFocus()
         
     def ExitToolbars(self):
-        if self.mapdisplay.toolbars['vdigit']:
-            self.mapdisplay.toolbars['vdigit'].OnExit()
-        if self.mapdisplay.toolbars['nviz']:       
-            self.mapdisplay.toolbars['nviz'].OnExit()
-
+        if self.parent.toolbars['vdigit']:
+            self.parent.toolbars['vdigit'].OnExit()
+        if self.parent.toolbars['nviz']:       
+            self.parent.toolbars['nviz'].OnExit()
+    
     def Enable2D(self, enabled):
         """!Enable/Disable 2D display mode specific tools"""
         for tool in (self.pointer,
@@ -291,11 +287,11 @@
                      self.dec,
                      self.savefile,
                      self.printmap):
-            self.toolbar.EnableTool(tool, enabled)
-
+            self.EnableTool(tool, enabled)
+        
     def Enable(self, tool, enable = True):
         """!Enable defined tool
-
+        
         @param tool name
         @param enable True to enable otherwise disable tool
         """
@@ -304,30 +300,29 @@
         except AttributeError:
             return
         
-        self.toolbar.EnableTool(self.zoomback, enable)
+        self.EnableTool(self.zoomback, enable)
 
 class GRToolbar(AbstractToolbar):
     """
-    Georectification Display toolbar
+    Georectification toolbar
     """
+    def __init__(self, parent, mapcontent):
+        """!
+        Georectification toolbar constructor
 
-    def __init__(self, mapdisplay, map):
+        @param parent reference to MapFrame
+        @param mapcontent reference to render.Map (registred by MapFrame)
+        """
         self.mapcontent = map
-        self.mapdisplay = mapdisplay
-
-        self.toolbar = wx.ToolBar(parent=self.mapdisplay, id=wx.ID_ANY)
-
-        # self.SetToolBar(self.toolbar)
-        self.toolbar.SetToolBitmapSize(globalvar.toolbarSize)
-
-        self.InitToolbar(self.mapdisplay, self.toolbar, self.ToolbarData())
-
+        AbstractToolbar.__init__(self, parent)
+        
+        self.InitToolbar(self.ToolbarData())
+        
         # realize the toolbar
-        self.toolbar.Realize()
-
+        self.Realize()
+        
     def ToolbarData(self):
         """!Toolbar data"""
-
         self.displaymap = wx.NewId()
         self.rendermap = wx.NewId()
         self.erase = wx.NewId()
@@ -337,66 +332,61 @@
         self.zoomout = wx.NewId()
         self.zoomback = wx.NewId()
         self.zoomtomap = wx.NewId()
-
+        
         # tool, label, bitmap, kind, shortHelp, longHelp, handler
         return (
             (self.displaymap, "displaymap", Icons["displaymap"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["displaymap"].GetLabel(), Icons["displaymap"].GetDesc(),
-             self.mapdisplay.OnDraw),
+             self.parent.OnDraw),
             (self.rendermap, "rendermap", Icons["rendermap"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["rendermap"].GetLabel(), Icons["rendermap"].GetDesc(),
-             self.mapdisplay.OnRender),
+             self.parent.OnRender),
             (self.erase, "erase", Icons["erase"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(),
-             self.mapdisplay.OnErase),
+             self.parent.OnErase),
             ("", "", "", "", "", "", ""),
             (self.gcpset, "grGcpSet", Icons["grGcpSet"].GetBitmap(),
              wx.ITEM_RADIO, Icons["grGcpSet"].GetLabel(), Icons["grGcpSet"].GetDesc(),
-             self.mapdisplay.OnPointer),
+             self.parent.OnPointer),
             (self.pan, "pan", Icons["pan"].GetBitmap(),
              wx.ITEM_RADIO, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(),
-             self.mapdisplay.OnPan),
+             self.parent.OnPan),
             (self.zoomin, "zoom_in", Icons["zoom_in"].GetBitmap(),
              wx.ITEM_RADIO, Icons["zoom_in"].GetLabel(), Icons["zoom_in"].GetDesc(),
-             self.mapdisplay.OnZoomIn),
+             self.parent.OnZoomIn),
             (self.zoomout, "zoom_out", Icons["zoom_out"].GetBitmap(),
              wx.ITEM_RADIO, Icons["zoom_out"].GetLabel(), Icons["zoom_out"].GetDesc(),
-             self.mapdisplay.OnZoomOut),
+             self.parent.OnZoomOut),
             (self.zoomback, "zoom_back", Icons["zoom_back"].GetBitmap(),
              wx.ITEM_NORMAL, Icons["zoom_back"].GetLabel(), Icons["zoom_back"].GetDesc(),
-             self.mapdisplay.OnZoomBack),
+             self.parent.OnZoomBack),
             (self.zoomtomap, "zoomtomap", Icons["zoommenu"].GetBitmap(),
              wx.ITEM_NORMAL, _("Zoom to map"), _("Zoom to displayed map"),
              self.OnZoomMap),
             ("", "", "", "", "", "", ""),
             )
-
+    
     def OnZoomMap(self, event):
         """!Zoom to selected map"""
-        self.mapdisplay.MapWindow.ZoomToMap(layers = self.mapcontent.GetListOfLayers())
+        self.parent.MapWindow.ZoomToMap(layers = self.mapcontent.GetListOfLayers())
 
         event.Skip()
         
 class GCPToolbar(AbstractToolbar):
-    """
+    """!
     Toolbar for managing ground control points during georectification
-    """
-    def __init__(self, parent, tbframe):
-        self.parent  = parent # GCP
-        self.tbframe = tbframe
 
-        self.toolbar = wx.ToolBar(parent=self.tbframe, id=wx.ID_ANY)
-
-        # self.SetToolBar(self.toolbar)
-        self.toolbar.SetToolBitmapSize(globalvar.toolbarSize)
-
-        self.InitToolbar(self.tbframe, self.toolbar, self.ToolbarData())
-
+    @param parent reference to GCP widget
+    """
+    def __init__(self, parent):
+        AbstractToolbar.__init__(self, parent)
+        
+        self.InitToolbar(self.ToolbarData())
+        
         # realize the toolbar
-        self.toolbar.Realize()
+        self.Realize()
 
     def ToolbarData(self):
-        
         self.gcpSave = wx.NewId()
         self.gcpAdd = wx.NewId()
         self.gcpDelete = wx.NewId()
@@ -444,38 +434,26 @@
     """
     Toolbar for digitization
     """
-
-    def __init__(self, parent, map, layerTree=None, log=None):
-        self.mapcontent    = map       # Map class instance
-        self.parent        = parent    # MapFrame
-        self.layerTree     = layerTree # reference to layer tree associated to map display
-        self.log           = log       # log area
+    def __init__(self, parent, mapcontent, layerTree=None, log=None):
+        self.mapcontent    = mapcontent # Map class instance
+        self.layerTree     = layerTree  # reference to layer tree associated to map display
+        self.log           = log        # log area
+        AbstractToolbar.__init__(self, parent)
         
         # currently selected map layer for editing (reference to MapLayer instance)
         self.mapLayer = None
         # list of vector layers from Layer Manager (only in the current mapset)
         self.layers   = [] 
-
+        
         self.comboid    = None
-
+        
         # only one dialog can be open
         self.settingsDialog   = None
-
+        
         # create toolbars (two rows optionally)
-        self.toolbar = []
-        self.numOfRows = 1 # number of rows for toolbar
-        for row in range(0, self.numOfRows):
-            self.toolbar.append(wx.ToolBar(parent=self.parent, id=wx.ID_ANY))
-            self.toolbar[row].SetToolBitmapSize(globalvar.toolbarSize)
-            self.toolbar[row].Bind(wx.EVT_TOOL, self.OnTool)
-            
-            # create toolbar
-            if self.numOfRows ==  1:
-                rowdata=None
-            else:
-                rowdata = row
-            self.InitToolbar(self.parent, self.toolbar[row], self.ToolbarData(rowdata))
-
+        self.Bind(wx.EVT_TOOL, self.OnTool)
+        self.InitToolbar(self.ToolbarData())
+        
         # default action (digitize new point, line, etc.)
         self.action = { 'desc' : 'addLine',
                         'type' : 'point',
@@ -483,140 +461,135 @@
         
         # list of available vector maps
         self.UpdateListOfLayers(updateTool=True)
-
+        
         # realize toolbar
-        for row in range(0, self.numOfRows):
-            self.toolbar[row].Realize()
-            # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
-            self.combo.Hide()
-            self.combo.Show()
-
-
+        self.Realize()
+        # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
+        self.combo.Hide()
+        self.combo.Show()
+        
         # disable undo/redo
-        self.toolbar[0].EnableTool(self.undo, False)
+        self.EnableTool(self.undo, False)
         
         # toogle to pointer by default
         self.OnTool(None)
         
         self.FixSize(width = 105)
         
-    def ToolbarData(self, row=None):
-        """
+    def ToolbarData(self):
+        """!
         Toolbar data
         """
         data = []
-        if row is None or row == 0:
-            self.addPoint = wx.NewId()
-            self.addLine = wx.NewId()
-            self.addBoundary = wx.NewId()
-            self.addCentroid = wx.NewId()
-            self.moveVertex = wx.NewId()
-            self.addVertex = wx.NewId()
-            self.removeVertex = wx.NewId()
-            self.splitLine = wx.NewId()
-            self.editLine = wx.NewId()
-            self.moveLine = wx.NewId()
-            self.deleteLine = wx.NewId()
-            self.additionalTools = wx.NewId()
-            self.displayCats = wx.NewId()
-            self.displayAttr = wx.NewId()
-            self.copyCats = wx.NewId()
-
-            data = [("", "", "", "", "", "", ""),
-                    (self.addPoint, "digAddPoint", Icons["digAddPoint"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digAddPoint"].GetLabel(), Icons["digAddPoint"].GetDesc(),
-                     self.OnAddPoint),
-                    (self.addLine, "digAddLine", Icons["digAddLine"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digAddLine"].GetLabel(), Icons["digAddLine"].GetDesc(),
-                     self.OnAddLine),
-                    (self.addBoundary, "digAddBoundary", Icons["digAddBoundary"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digAddBoundary"].GetLabel(), Icons["digAddBoundary"].GetDesc(),
-                     self.OnAddBoundary),
-                    (self.addCentroid, "digAddCentroid", Icons["digAddCentroid"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digAddCentroid"].GetLabel(), Icons["digAddCentroid"].GetDesc(),
-                     self.OnAddCentroid),
-                    (self.moveVertex, "digMoveVertex", Icons["digMoveVertex"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digMoveVertex"].GetLabel(), Icons["digMoveVertex"].GetDesc(),
-                     self.OnMoveVertex),
-                    (self.addVertex, "digAddVertex", Icons["digAddVertex"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digAddVertex"].GetLabel(), Icons["digAddVertex"].GetDesc(),
-                     self.OnAddVertex),
-                    (self.removeVertex, "digRemoveVertex", Icons["digRemoveVertex"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digRemoveVertex"].GetLabel(), Icons["digRemoveVertex"].GetDesc(),
-                     self.OnRemoveVertex),
-                    (self.splitLine, "digSplitLine", Icons["digSplitLine"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digSplitLine"].GetLabel(), Icons["digSplitLine"].GetDesc(),
-                     self.OnSplitLine),
-                    (self.editLine, "digEditLine", Icons["digEditLine"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digEditLine"].GetLabel(), Icons["digEditLine"].GetDesc(),
-                     self.OnEditLine),
-                    (self.moveLine, "digMoveLine", Icons["digMoveLine"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digMoveLine"].GetLabel(), Icons["digMoveLine"].GetDesc(),
-                     self.OnMoveLine),
-                    (self.deleteLine, "digDeleteLine", Icons["digDeleteLine"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digDeleteLine"].GetLabel(), Icons["digDeleteLine"].GetDesc(),
-                     self.OnDeleteLine),
-                    (self.displayCats, "digDispCats", Icons["digDispCats"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digDispCats"].GetLabel(), Icons["digDispCats"].GetDesc(),
-                     self.OnDisplayCats),
-                    (self.copyCats, "digCopyCats", Icons["digCopyCats"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digCopyCats"].GetLabel(), Icons["digCopyCats"].GetDesc(),
-                     self.OnCopyCA),
-                    (self.displayAttr, "digDispAttr", Icons["digDispAttr"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digDispAttr"].GetLabel(), Icons["digDispAttr"].GetDesc(),
-                     self.OnDisplayAttr),
-                    (self.additionalTools, "digAdditionalTools", Icons["digAdditionalTools"].GetBitmap(),
-                     wx.ITEM_CHECK, Icons["digAdditionalTools"].GetLabel(),
-                     Icons["digAdditionalTools"].GetDesc(),
-                     self.OnAdditionalToolMenu)]
-
-        if row is None or row == 1:
-            self.undo = wx.NewId()
-            self.settings = wx.NewId()
-            self.exit = wx.NewId()
-
-            data.append(("", "", "", "", "", "", ""))
-            data.append((self.undo, "digUndo", Icons["digUndo"].GetBitmap(),
-                         wx.ITEM_NORMAL, Icons["digUndo"].GetLabel(), Icons["digUndo"].GetDesc(),
-                         self.OnUndo))
-            # data.append((self.undo, "digRedo", Icons["digRedo"].GetBitmap(),
-            #             wx.ITEM_NORMAL, Icons["digRedo"].GetLabel(), Icons["digRedo"].GetDesc(),
-            #             self.OnRedo))
-            data.append((self.settings, "digSettings", Icons["digSettings"].GetBitmap(),
-                         wx.ITEM_NORMAL, Icons["digSettings"].GetLabel(), Icons["digSettings"].GetDesc(),
-                         self.OnSettings))
-            data.append((self.exit, "digExit", Icons["quit"].GetBitmap(),
-                         wx.ITEM_NORMAL, Icons["digExit"].GetLabel(), Icons["digExit"].GetDesc(),
-                         self.OnExit))
-
+        
+        self.addPoint = wx.NewId()
+        self.addLine = wx.NewId()
+        self.addBoundary = wx.NewId()
+        self.addCentroid = wx.NewId()
+        self.moveVertex = wx.NewId()
+        self.addVertex = wx.NewId()
+        self.removeVertex = wx.NewId()
+        self.splitLine = wx.NewId()
+        self.editLine = wx.NewId()
+        self.moveLine = wx.NewId()
+        self.deleteLine = wx.NewId()
+        self.additionalTools = wx.NewId()
+        self.displayCats = wx.NewId()
+        self.displayAttr = wx.NewId()
+        self.copyCats = wx.NewId()
+        self.undo = wx.NewId()
+        self.settings = wx.NewId()
+        self.exit = wx.NewId()
+        
+        data = [("", "", "", "", "", "", ""),
+                (self.addPoint, "digAddPoint", Icons["digAddPoint"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digAddPoint"].GetLabel(), Icons["digAddPoint"].GetDesc(),
+                 self.OnAddPoint),
+                (self.addLine, "digAddLine", Icons["digAddLine"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digAddLine"].GetLabel(), Icons["digAddLine"].GetDesc(),
+                 self.OnAddLine),
+                (self.addBoundary, "digAddBoundary", Icons["digAddBoundary"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digAddBoundary"].GetLabel(), Icons["digAddBoundary"].GetDesc(),
+                 self.OnAddBoundary),
+                (self.addCentroid, "digAddCentroid", Icons["digAddCentroid"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digAddCentroid"].GetLabel(), Icons["digAddCentroid"].GetDesc(),
+                 self.OnAddCentroid),
+                (self.moveVertex, "digMoveVertex", Icons["digMoveVertex"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digMoveVertex"].GetLabel(), Icons["digMoveVertex"].GetDesc(),
+                 self.OnMoveVertex),
+                (self.addVertex, "digAddVertex", Icons["digAddVertex"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digAddVertex"].GetLabel(), Icons["digAddVertex"].GetDesc(),
+                 self.OnAddVertex),
+                (self.removeVertex, "digRemoveVertex", Icons["digRemoveVertex"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digRemoveVertex"].GetLabel(), Icons["digRemoveVertex"].GetDesc(),
+                 self.OnRemoveVertex),
+                (self.splitLine, "digSplitLine", Icons["digSplitLine"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digSplitLine"].GetLabel(), Icons["digSplitLine"].GetDesc(),
+                 self.OnSplitLine),
+                (self.editLine, "digEditLine", Icons["digEditLine"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digEditLine"].GetLabel(), Icons["digEditLine"].GetDesc(),
+                 self.OnEditLine),
+                (self.moveLine, "digMoveLine", Icons["digMoveLine"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digMoveLine"].GetLabel(), Icons["digMoveLine"].GetDesc(),
+                 self.OnMoveLine),
+                (self.deleteLine, "digDeleteLine", Icons["digDeleteLine"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digDeleteLine"].GetLabel(), Icons["digDeleteLine"].GetDesc(),
+                 self.OnDeleteLine),
+                (self.displayCats, "digDispCats", Icons["digDispCats"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digDispCats"].GetLabel(), Icons["digDispCats"].GetDesc(),
+                 self.OnDisplayCats),
+                (self.copyCats, "digCopyCats", Icons["digCopyCats"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digCopyCats"].GetLabel(), Icons["digCopyCats"].GetDesc(),
+                 self.OnCopyCA),
+                (self.displayAttr, "digDispAttr", Icons["digDispAttr"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digDispAttr"].GetLabel(), Icons["digDispAttr"].GetDesc(),
+                 self.OnDisplayAttr),
+                (self.additionalTools, "digAdditionalTools", Icons["digAdditionalTools"].GetBitmap(),
+                 wx.ITEM_CHECK, Icons["digAdditionalTools"].GetLabel(),
+                 Icons["digAdditionalTools"].GetDesc(),
+                 self.OnAdditionalToolMenu),
+                ("", "", "", "", "", "", ""),
+                (self.undo, "digUndo", Icons["digUndo"].GetBitmap(),
+                 wx.ITEM_NORMAL, Icons["digUndo"].GetLabel(), Icons["digUndo"].GetDesc(),
+                 self.OnUndo),
+                # data.append((self.undo, "digRedo", Icons["digRedo"].GetBitmap(),
+                #             wx.ITEM_NORMAL, Icons["digRedo"].GetLabel(), Icons["digRedo"].GetDesc(),
+                #             self.OnRedo))
+                (self.settings, "digSettings", Icons["digSettings"].GetBitmap(),
+                 wx.ITEM_NORMAL, Icons["digSettings"].GetLabel(), Icons["digSettings"].GetDesc(),
+                 self.OnSettings),
+                (self.exit, "digExit", Icons["quit"].GetBitmap(),
+                 wx.ITEM_NORMAL, Icons["digExit"].GetLabel(), Icons["digExit"].GetDesc(),
+                 self.OnExit)]
+        
         return data
-
+    
     def OnTool(self, event):
         """!Tool selected -> disable selected tool in map toolbar"""
         # update map toolbar (unselect currently selected tool)
         id = self.parent.toolbars['map'].GetAction(type='id')
-        self.parent.toolbars['map'].toolbar.ToggleTool(id, False)
-
+        self.parent.toolbars['map'].ToggleTool(id, False)
+        
         # set cursor
         cursor = self.parent.cursors["cross"]
         self.parent.MapWindow.SetCursor(cursor)
-
+        
         # pointer
         self.parent.OnPointer(None)
-
+        
         if event:
             # deselect previously selected tool
             id = self.action.get('id', -1)
             if id != event.GetId():
-                self.toolbar[0].ToggleTool(self.action['id'], False)
+                self.ToggleTool(self.action['id'], False)
             else:
-                self.toolbar[0].ToggleTool(self.action['id'], True)
+                self.ToggleTool(self.action['id'], True)
             
             self.action['id'] = event.GetId()
             event.Skip()
         
-        self.toolbar[0].ToggleTool(self.action['id'], True)
-
+        self.ToggleTool(self.action['id'], True)
+        
         # clear tmp canvas
         if self.action['id'] != id:
             self.parent.MapWindow.ClearLines(pdc=self.parent.MapWindow.pdcTmp)
@@ -669,19 +642,19 @@
         # stop editing of the currently selected map layer
         if self.mapLayer:
             self.StopEditing()
-
+        
         # close dialogs if still open
         if self.settingsDialog:
             self.settingsDialog.OnCancel(None)
-        
-        # disable the toolbar
-        self.parent.RemoveToolbar ("vdigit")
-
+            
         # set default mouse settings
         self.parent.MapWindow.mouse['use'] = "pointer"
         self.parent.MapWindow.mouse['box'] = "point"
         self.parent.MapWindow.polycoords = []
         
+        # disable the toolbar
+        self.parent.RemoveToolbar("vdigit")
+                
     def OnMoveVertex(self, event):
         """!Move line vertex"""
         Debug.msg(2, "Digittoolbar.OnMoveVertex():")
@@ -695,8 +668,7 @@
         self.action = { 'desc' : "addVertex",
                         'id'   : self.addVertex }
         self.parent.MapWindow.mouse['box'] = 'point'
-
-
+        
     def OnRemoveVertex(self, event):
         """!Remove line vertex"""
         Debug.msg(2, "Digittoolbar.OnRemoveVertex():")
@@ -704,7 +676,6 @@
                         'id'   : self.removeVertex }
         self.parent.MapWindow.mouse['box'] = 'point'
 
-
     def OnSplitLine(self, event):
         """!Split line"""
         Debug.msg(2, "Digittoolbar.OnSplitLine():")
@@ -759,7 +730,7 @@
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnCopyCats, cats)
         if self.action['desc'] == "copyCats":
             cats.Check(True)
-
+        
         attrb = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
                             text=_('Duplicate attributes'),
                             kind=wx.ITEM_CHECK)
@@ -767,20 +738,20 @@
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnCopyAttrb, attrb)
         if self.action['desc'] == "copyAttrs":
             attrb.Check(True)
-
+        
         # Popup the menu.  If an item is selected then its handler
         # will be called before PopupMenu returns.
         self.parent.MapWindow.PopupMenu(toolMenu)
         toolMenu.Destroy()
         
         if self.action['desc'] == "addPoint":
-            self.toolbar[0].ToggleTool(self.copyCats, False)
+            self.ToggleTool(self.copyCats, False)
         
     def OnCopyCats(self, event):
         """!Copy categories"""
         if self.action['desc'] == 'copyCats': # select previous action
-            self.toolbar[0].ToggleTool(self.addPoint, True)
-            self.toolbar[0].ToggleTool(self.copyCats, False)
+            self.ToggleTool(self.addPoint, True)
+            self.ToggleTool(self.copyCats, False)
             self.OnAddPoint(event)
             return
         
@@ -791,8 +762,8 @@
 
     def OnCopyAttrb(self, event):
         if self.action['desc'] == 'copyAttrs': # select previous action
-            self.toolbar[0].ToggleTool(self.addPoint, True)
-            self.toolbar[0].ToggleTool(self.copyCats, False)
+            self.ToggleTool(self.addPoint, True)
+            self.ToggleTool(self.copyCats, False)
             self.OnAddPoint(event)
             return
         
@@ -804,29 +775,31 @@
     def OnUndo(self, event):
         """!Undo previous changes"""
         self.parent.digit.Undo()
-
+        
         event.Skip()
 
     def EnableUndo(self, enable=True):
         """!Enable 'Undo' in toolbar
-
+        
         @param enable False for disable
         """
         if enable:
-            if self.toolbar[0].GetToolEnabled(self.undo) is False:
-                self.toolbar[0].EnableTool(self.undo, True)
+            if self.GetToolEnabled(self.undo) is False:
+                self.EnableTool(self.undo, True)
         else:
-            if self.toolbar[0].GetToolEnabled(self.undo) is True:
-                self.toolbar[0].EnableTool(self.undo, False)
+            if self.GetToolEnabled(self.undo) is True:
+                self.EnableTool(self.undo, False)
         
     def OnSettings(self, event):
         """!Show settings dialog"""
-
         if self.parent.digit is None:
             reload(vdigit)
-            from vdigit import Digit as Digit
-            self.parent.digit = Digit(mapwindow=self.parent.MapWindow)
-            
+            from vdigit import VDigit as VDigit
+            try:
+                self.parent.digit = VDigit(mapwindow=self.parent.MapWindow)
+            except SystemExit:
+                self.parent.digit = None
+        
         if not self.settingsDialog:
             self.settingsDialog = VDigitSettingsDialog(parent=self.parent, title=_("Digitization settings"),
                                                        style=wx.DEFAULT_DIALOG_STYLE)
@@ -844,7 +817,7 @@
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnCopy, copy)
         if self.action['desc'] == "copyLine":
             copy.Check(True)
-
+        
         flip = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
                            text=_('Flip selected lines/boundaries'),
                            kind=wx.ITEM_CHECK)
@@ -852,7 +825,7 @@
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnFlip, flip)
         if self.action['desc'] == "flipLine":
             flip.Check(True)
-
+        
         merge = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
                             text=_('Merge selected lines/boundaries'),
                             kind=wx.ITEM_CHECK)
@@ -860,7 +833,7 @@
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnMerge, merge)
         if self.action['desc'] == "mergeLine":
             merge.Check(True)
-
+        
         breakL = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
                              text=_('Break selected lines/boundaries at intersection'),
                              kind=wx.ITEM_CHECK)
@@ -868,7 +841,7 @@
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnBreak, breakL)
         if self.action['desc'] == "breakLine":
             breakL.Check(True)
-
+        
         snap = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
                            text=_('Snap selected lines/boundaries (only to nodes)'),
                            kind=wx.ITEM_CHECK)
@@ -876,7 +849,7 @@
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnSnap, snap)
         if self.action['desc'] == "snapLine":
             snap.Check(True)
-
+        
         connect = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
                               text=_('Connect selected lines/boundaries'),
                               kind=wx.ITEM_CHECK)
@@ -884,7 +857,7 @@
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnConnect, connect)
         if self.action['desc'] == "connectLine":
             connect.Check(True)
-
+        
         query = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
                             text=_('Query features'),
                             kind=wx.ITEM_CHECK)
@@ -892,7 +865,7 @@
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnQuery, query)
         if self.action['desc'] == "queryLine":
             query.Check(True)
-
+        
         zbulk = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
                             text=_('Z bulk-labeling of 3D lines'),
                             kind=wx.ITEM_CHECK)
@@ -900,7 +873,7 @@
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnZBulk, zbulk)
         if self.action['desc'] == "zbulkLine":
             zbulk.Check(True)
-
+        
         typeconv = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
                                text=_('Feature type conversion'),
                                kind=wx.ITEM_CHECK)
@@ -908,20 +881,20 @@
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnTypeConversion, typeconv)
         if self.action['desc'] == "typeConv":
             typeconv.Check(True)
-
+        
         # Popup the menu.  If an item is selected then its handler
         # will be called before PopupMenu returns.
         self.parent.MapWindow.PopupMenu(toolMenu)
         toolMenu.Destroy()
         
         if self.action['desc'] == 'addPoint':
-            self.toolbar[0].ToggleTool(self.additionalTools, False)
+            self.ToggleTool(self.additionalTools, False)
         
     def OnCopy(self, event):
         """!Copy selected features from (background) vector map"""
         if self.action['desc'] == 'copyLine': # select previous action
-            self.toolbar[0].ToggleTool(self.addPoint, True)
-            self.toolbar[0].ToggleTool(self.additionalTools, False)
+            self.ToggleTool(self.addPoint, True)
+            self.ToggleTool(self.additionalTools, False)
             self.OnAddPoint(event)
             return
         
@@ -933,8 +906,8 @@
     def OnFlip(self, event):
         """!Flip selected lines/boundaries"""
         if self.action['desc'] == 'flipLine': # select previous action
-            self.toolbar[0].ToggleTool(self.addPoint, True)
-            self.toolbar[0].ToggleTool(self.additionalTools, False)
+            self.ToggleTool(self.addPoint, True)
+            self.ToggleTool(self.additionalTools, False)
             self.OnAddPoint(event)
             return
         
@@ -946,8 +919,8 @@
     def OnMerge(self, event):
         """!Merge selected lines/boundaries"""
         if self.action['desc'] == 'mergeLine': # select previous action
-            self.toolbar[0].ToggleTool(self.addPoint, True)
-            self.toolbar[0].ToggleTool(self.additionalTools, False)
+            self.ToggleTool(self.addPoint, True)
+            self.ToggleTool(self.additionalTools, False)
             self.OnAddPoint(event)
             return
         
@@ -959,8 +932,8 @@
     def OnBreak(self, event):
         """!Break selected lines/boundaries"""
         if self.action['desc'] == 'breakLine': # select previous action
-            self.toolbar[0].ToggleTool(self.addPoint, True)
-            self.toolbar[0].ToggleTool(self.additionalTools, False)
+            self.ToggleTool(self.addPoint, True)
+            self.ToggleTool(self.additionalTools, False)
             self.OnAddPoint(event)
             return
         
@@ -972,8 +945,8 @@
     def OnSnap(self, event):
         """!Snap selected features"""
         if self.action['desc'] == 'snapLine': # select previous action
-            self.toolbar[0].ToggleTool(self.addPoint, True)
-            self.toolbar[0].ToggleTool(self.additionalTools, False)
+            self.ToggleTool(self.addPoint, True)
+            self.ToggleTool(self.additionalTools, False)
             self.OnAddPoint(event)
             return
         
@@ -985,8 +958,8 @@
     def OnConnect(self, event):
         """!Connect selected lines/boundaries"""
         if self.action['desc'] == 'connectLine': # select previous action
-            self.toolbar[0].ToggleTool(self.addPoint, True)
-            self.toolbar[0].ToggleTool(self.additionalTools, False)
+            self.ToggleTool(self.addPoint, True)
+            self.ToggleTool(self.additionalTools, False)
             self.OnAddPoint(event)
             return
         
@@ -998,8 +971,8 @@
     def OnQuery(self, event):
         """!Query selected lines/boundaries"""
         if self.action['desc'] == 'queryLine': # select previous action
-            self.toolbar[0].ToggleTool(self.addPoint, True)
-            self.toolbar[0].ToggleTool(self.additionalTools, False)
+            self.ToggleTool(self.addPoint, True)
+            self.ToggleTool(self.additionalTools, False)
             self.OnAddPoint(event)
             return
         
@@ -1018,8 +991,8 @@
             return
         
         if self.action['desc'] == 'zbulkLine': # select previous action
-            self.toolbar[0].ToggleTool(self.addPoint, True)
-            self.toolbar[0].ToggleTool(self.additionalTools, False)
+            self.ToggleTool(self.addPoint, True)
+            self.ToggleTool(self.additionalTools, False)
             self.OnAddPoint(event)
             return
         
@@ -1036,8 +1009,8 @@
          - line <-> boundary
         """
         if self.action['desc'] == 'typeConv': # select previous action
-            self.toolbar[0].ToggleTool(self.addPoint, True)
-            self.toolbar[0].ToggleTool(self.additionalTools, False)
+            self.ToggleTool(self.addPoint, True)
+            self.ToggleTool(self.additionalTools, False)
             self.OnAddPoint(event)
             return
         
@@ -1083,18 +1056,18 @@
                 return 
         else:
             selection = event.GetSelection() - 1 # first option is 'New vector map'
-
+        
         # skip currently selected map
         if self.layers[selection] == self.mapLayer:
             return False
-
+        
         if self.mapLayer:
             # deactive map layer for editing
             self.StopEditing()
-
+        
         # select the given map layer for editing
         self.StartEditing(self.layers[selection])
-
+        
         event.Skip()
 
         return True
@@ -1107,10 +1080,10 @@
         """
         # deactive layer
         self.mapcontent.ChangeLayerActive(mapLayer, False)
-
+        
         # clean map canvas
         ### self.parent.MapWindow.EraseMap()
-
+        
         # unset background map if needed
         if mapLayer:
             if UserSettings.Get(group='vdigit', key='bgmap',
@@ -1125,10 +1098,10 @@
         
         # reload vdigit module
         reload(vdigit)
-        from vdigit import Digit as Digit
+        from vdigit import VDigit as VDigit
         # use vdigit's PseudoDC
         self.parent.MapWindow.DefinePseudoDC(vdigit = True)
-        self.parent.digit = Digit(mapwindow=self.parent.MapWindow)
+        self.parent.digit = VDigit(mapwindow=self.parent.MapWindow)
         
         self.mapLayer = mapLayer
         
@@ -1144,7 +1117,7 @@
             self.StopEditing()
             print >> sys.stderr, e # wxMessageBox
             return False
-
+        
         # update toolbar
         self.combo.SetValue(mapLayer.GetName())
         self.parent.toolbars['map'].combo.SetValue (_('Digitize'))
@@ -1161,7 +1134,7 @@
 
         if not self.parent.MapWindow.resize:
             self.parent.MapWindow.UpdateMap(render=True)
-
+        
         opacity = mapLayer.GetOpacity(float=True)
         if opacity < 1.0:
             alpha = int(opacity * 255)
@@ -1213,7 +1186,7 @@
         # disable pseudodc for vector map layer
         self.parent.MapWindow.pdcVector = None
         self.parent.digit.driver.SetDevice(None)
-
+        
         # close dialogs
         for dialog in ('attributes', 'category'):
             if self.parent.dialogs[dialog]:
@@ -1230,21 +1203,20 @@
         return True
     
     def UpdateListOfLayers (self, updateTool=False):
-        """
+        """!
         Update list of available vector map layers.
         This list consists only editable layers (in the current mapset)
 
         Optionally also update toolbar
         """
-
         Debug.msg (4, "VDigitToolbar.UpdateListOfLayers(): updateTool=%d" % \
                    updateTool)
-
+        
         layerNameSelected = None
          # name of currently selected layer
         if self.mapLayer:
             layerNameSelected = self.mapLayer.GetName()
-
+        
         # select vector map layer in the current mapset
         layerNameList = []
         self.layers = self.mapcontent.GetListOfLayers(l_type="vector",
@@ -1252,7 +1224,7 @@
         for layer in self.layers:
             if not layer.name in layerNameList: # do not duplicate layer
                 layerNameList.append (layer.GetName())
-
+        
         if updateTool: # update toolbar
             if not self.mapLayer:
                 value = _('Select vector map')
@@ -1260,43 +1232,36 @@
                 value = layerNameSelected
 
             if not self.comboid:
-                self.combo = wx.ComboBox(self.toolbar[self.numOfRows-1], id=wx.ID_ANY, value=value,
+                self.combo = wx.ComboBox(self, id=wx.ID_ANY, value=value,
                                          choices=[_('New vector map'), ] + layerNameList, size=(85, -1),
                                          style=wx.CB_READONLY)
-                self.comboid = self.toolbar[self.numOfRows-1].InsertControl(0, self.combo)
+                self.comboid = self.InsertControl(0, self.combo)
                 self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectMap, self.comboid)
             else:
                 self.combo.SetItems([_('New vector map'), ] + layerNameList)
             
-            self.toolbar[self.numOfRows-1].Realize()
-
+            self.Realize()
+        
         return layerNameList
 
     def GetLayer(self):
         """!Get selected layer for editing -- MapLayer instance"""
         return self.mapLayer
-
+    
 class ProfileToolbar(AbstractToolbar):
-    """
+    """!
     Toolbar for profiling raster map
     """ 
-    def __init__(self, parent, tbframe):
-        self.parent  = parent # GCP
-        self.tbframe = tbframe
-
-        self.toolbar = wx.ToolBar(parent=self.tbframe, id=wx.ID_ANY)
-
-        # self.SetToolBar(self.toolbar)
-        self.toolbar.SetToolBitmapSize(globalvar.toolbarSize)
-
-        self.InitToolbar(self.tbframe, self.toolbar, self.ToolbarData())
-
+    def __init__(self, parent):
+        AbstractToolbar.__init__(self, parent)
+        
+        self.InitToolbar(self.ToolbarData())
+        
         # realize the toolbar
-        self.toolbar.Realize()
-
+        self.Realize()
+        
     def ToolbarData(self):
         """!Toolbar data"""
-
         self.transect = wx.NewId()
         self.addraster = wx.NewId()
         self.draw = wx.NewId()
@@ -1348,29 +1313,23 @@
             )
     
 class NvizToolbar(AbstractToolbar):
-    """
+    """!
     Nviz toolbar
     """
-    def __init__(self, parent, map):
-        self.parent     = parent
-        self.mapcontent = map
-
-        self.toolbar = wx.ToolBar(parent=self.parent, id=wx.ID_ANY)
-
-        # self.SetToolBar(self.toolbar)
-        self.toolbar.SetToolBitmapSize(globalvar.toolbarSize)
-
-        self.InitToolbar(self.parent, self.toolbar, self.ToolbarData())
-
+    def __init__(self, parent, mapcontent):
+        self.mapcontent = mapcontent
+        AbstractToolbar.__init__(self, parent)
+        
+        self.InitToolbar(self.ToolbarData())
+        
         # realize the toolbar
-        self.toolbar.Realize()
-
+        self.Realize()
+        
     def ToolbarData(self):
         """!Toolbar data"""
-
         self.settings = wx.NewId()
         self.quit = wx.NewId()
-                
+        
         # tool, label, bitmap, kind, shortHelp, longHelp, handler
         return   (
             (self.settings, "settings", Icons["nvizSettings"].GetBitmap(),
@@ -1380,7 +1339,7 @@
              wx.ITEM_NORMAL, Icons["quit"].GetLabel(), Icons["quit"].GetDesc(),
              self.OnExit),
             )
-
+    
     def OnSettings(self, event):
         win = self.parent.nvizToolWin
         if not win.IsShown():
@@ -1390,16 +1349,16 @@
 
     def OnExit (self, event=None):
         """!Quit nviz tool (swith to 2D mode)"""
-
         # hide dialogs if still open
         if self.parent.nvizToolWin:
             self.parent.nvizToolWin.Hide()
-
-        # disable the toolbar
-        self.parent.RemoveToolbar ("nviz")
-
+        
         # set default mouse settings
         self.parent.MapWindow.mouse['use'] = "pointer"
         self.parent.MapWindow.mouse['box'] = "point"
         self.parent.MapWindow.polycoords = []
+        
+        # disable the toolbar
+        self.parent.RemoveToolbar("nviz")
+        
 

Modified: grass/trunk/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/vdigit.py	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/gui_modules/vdigit.py	2010-01-02 13:58:21 UTC (rev 40184)
@@ -224,16 +224,13 @@
         return ids
 
 class VDigit(AbstractDigit):
+    """!Prototype of digitization class based on v.digit
+    reimplementation (wxWidgets C/C++)
     """
-    Prototype of digitization class based on v.digit reimplementation
-
-    Under development (wxWidgets C/C++ background)
-    """
     def __init__(self, mapwindow):
-        """!Initialization
-
+        """!VDigit constructor
+        
         @param mapwindow reference to mapwindow (MapFrame) instance
-        @param settings  initial settings of digitization tool
         """
         AbstractDigit.__init__(self, mapwindow)
         
@@ -251,7 +248,6 @@
             # print traceback
             traceback.print_exc(file = self.log)
             self.digit = None
-            
         self.UpdateSettings()
         
     def __del__(self):
@@ -763,15 +759,6 @@
 
         return (snap, thresh)
 
-class Digit(VDigit):
-    """!Default digit class"""
-    def __init__(self, mapwindow):
-        VDigit.__init__(self, mapwindow)
-        self.type = 'vdigit'
-        
-    def __del__(self):
-        VDigit.__del__(self)
-        
 class AbstractDisplayDriver:
     """!Abstract classs for display driver"""
     def __init__(self, parent, mapwindow):

Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2010-01-02 13:58:21 UTC (rev 40184)
@@ -214,15 +214,12 @@
     def OnKeyUp(self, event):
         """!Key pressed"""
         key = event.GetKeyCode()
+        
         if key == wx.WXK_DELETE and self.lmgr:
             self.lmgr.OnDeleteLayer(None)
 
         event.Skip()
-
-    #def OnChangeLayerName (self, event):
-    #    """!Change layer name"""
-    #    Debug.msg (3, "LayerTree.OnChangeLayerName: name=%s" % event.GetLabel())
-
+        
     def OnLayerContextMenu (self, event):
         """!Contextual menu for item/layer"""
         if not self.layer_selected:

Modified: grass/trunk/gui/wxpython/vdigit/Makefile
===================================================================
--- grass/trunk/gui/wxpython/vdigit/Makefile	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/vdigit/Makefile	2010-01-02 13:58:21 UTC (rev 40184)
@@ -32,7 +32,8 @@
 
 $(LIB_NAME).py: $(SHLIB)
 
-$(SHLIB): $(LIB_NAME).i
+$(SHLIB): $(LIB_NAME).i cats.cpp digit.cpp driver.cpp driver_draw.cpp \
+	driver_select.cpp line.cpp message.cpp select.cpp undo.cpp vertex.cpp
 	GISBASE="$(GISBASE)" \
 	ARCH_DISTDIR="$(ARCH_DISTDIR)" \
 	GDALCFLAGS="$(GDALCFLAGS)" \

Modified: grass/trunk/gui/wxpython/vdigit/digit.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/digit.cpp	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/vdigit/digit.cpp	2010-01-02 13:58:21 UTC (rev 40184)
@@ -34,8 +34,9 @@
 Digit::Digit(DisplayDriver *ddriver, wxWindow *window)
 {
     display = ddriver;
-    display->parentWin = window;
-
+    if (!display)
+	return;
+    
     if (display->mapInfo) {
 	InitCats();
     }

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/wxgui.py	2010-01-02 13:58:21 UTC (rev 40184)
@@ -94,10 +94,10 @@
 UserSettings = preferences.globalSettings
 
 class GMFrame(wx.Frame):
-    """
+    """!
     GIS Manager frame with notebook widget for controlling
     GRASS GIS. Includes command console page for typing GRASS
-    (and other) commands, tree widget page for managing GIS map layers.
+    (and other) commands, tree widget page for managing map layers.
     """
     def __init__(self, parent, id=wx.ID_ANY, title=_("GRASS GIS Layer Manager"),
                  workspace=None):
@@ -136,7 +136,7 @@
         
         # bindings
         self.Bind(wx.EVT_CLOSE,    self.OnCloseWindow)
-        self.Bind(wx.EVT_KEY_UP,   self.OnKey)
+        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
 
         # minimal frame size
         self.SetMinSize((500, 400))
@@ -1449,10 +1449,10 @@
                 self.curr_page.maptree.DeleteChildren(layer)
             self.curr_page.maptree.Delete(layer)
         
-    def OnKey(self, event):
-        """!Check hotkey"""
+    def OnKeyDown(self, event):
+        """!Key pressed"""
         kc = event.GetKeyCode()
-                
+        print kc
         if event.ControlDown():
             if kc == wx.WXK_TAB:
                 # switch layer list / command output
@@ -1467,7 +1467,7 @@
             event.Skip()
             return
         
-        if event.AltDown():
+        if event.CtrlDown():
             if kc == 'R':
                 self.OnAddRaster(None)
             elif kc == 'V':

Modified: grass/trunk/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.xml	2010-01-02 12:12:54 UTC (rev 40183)
+++ grass/trunk/gui/wxpython/xml/menudata.xml	2010-01-02 13:58:21 UTC (rev 40184)
@@ -1,7 +1,7 @@
 <menudata>
   <menubar>
     <menu>
-      <label>File</label>
+      <label>&amp;File</label>
       <items>
 	<menu>
 	  <label>Workspace</label>
@@ -665,7 +665,7 @@
       </items>
     </menu>
     <menu>
-      <label>Config</label>
+      <label>&amp;Config</label>
       <items>
 	<menu>
 	  <label>Region</label>
@@ -786,7 +786,7 @@
       </items>
     </menu>
     <menu>
-      <label>Raster</label>
+      <label>&amp;Raster</label>
       <items>
 	<menu>
 	  <label>Develop raster map</label>
@@ -1710,7 +1710,7 @@
       </items>
     </menu>
     <menu>
-      <label>Vector</label>
+      <label>&amp;Vector</label>
       <items>
 	<menu>
 	  <label>Develop vector map</label>
@@ -2263,7 +2263,7 @@
       </items>
     </menu>
     <menu>
-      <label>Imagery</label>
+      <label>&amp;Imagery</label>
       <items>
 	<menu>
 	  <label>Develop images and groups</label>
@@ -2580,7 +2580,7 @@
       </items>
     </menu>
     <menu>
-      <label>Volumes</label>
+      <label>V&amp;olumes</label>
       <items>
 	<menu>
 	  <label>Develop volumes</label>
@@ -2665,7 +2665,7 @@
       </items>
     </menu>
     <menu>
-      <label>Database</label>
+      <label>&amp;Database</label>
       <items>
 	<menu>
 	  <label>Database information</label>
@@ -2821,7 +2821,7 @@
       </items>
     </menu>
     <menu>
-      <label>Help</label>
+      <label>&amp;Help</label>
       <items>
 	<menuitem>
 	  <label>GRASS help</label>



More information about the grass-commit mailing list