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

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

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

revision 1102 by jonathan, Fri May 30 06:29:05 2003 UTC revision 1113 by bh, Fri May 30 15:59:49 2003 UTC
# Line 202  class LegendTree(wxTreeCtrl): Line 202  class LegendTree(wxTreeCtrl):
202          self.map = None          self.map = None
203          self.parent = parent          self.parent = parent
204          self.layer2id = {}          self.layer2id = {}
205            self.changing_selection = 0
206    
207          #          #
208          # The image list used by the wxTreeCtrl causes problems when          # The image list used by the wxTreeCtrl causes problems when
# Line 340  class LegendTree(wxTreeCtrl): Line 341  class LegendTree(wxTreeCtrl):
341          self.SetMap(self.mainWindow.Map())          self.SetMap(self.mainWindow.Map())
342                    
343      def _OnSelChanged(self, event):      def _OnSelChanged(self, event):
344            # If we change the selection from normalize_selection do nothing.
345            if self.changing_selection:
346                return
347    
348            self.normalize_selection()
349          self.__UpdateSelection()          self.__UpdateSelection()
350    
351        def normalize_selection(self):
352            """Select the layer containing currently selected item"""
353            # This is really a workaround for a bug in wx where deleting a
354            # subtree with DeleteChildren does not update the selection
355            # properly and can lead to segfaults later because the return
356            # value of GetSelection points to invalid data.
357            item = self.GetSelection()
358            while item.IsOk():
359                object = self.GetPyData(item)
360                if isinstance(object, BaseLayer):
361                    break
362                item = self.GetItemParent(item)
363            else:
364                # No layer was found in the chain of parents, so there's
365                # nothing we can do.
366                return
367    
368            self.changing_selection = 1
369            try:
370                self.SelectItem(item)
371            finally:
372                self.changing_selection = 0
373    
374    
375      def _OnItemActivated(self, event):      def _OnItemActivated(self, event):
376          self.parent.DoOnProperties()          self.parent.DoOnProperties()
377    

Legend:
Removed from v.1102  
changed lines
  Added in v.1113

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26