/[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 1252 by jonathan, Fri Jun 20 09:28:08 2003 UTC revision 1837 by frank, Tue Oct 21 09:29:52 2003 UTC
# Line 42  ID_LEGEND_PROPS = 4006 Line 42  ID_LEGEND_PROPS = 4006
42  ID_LEGEND_SHOWLAYER = 4007  ID_LEGEND_SHOWLAYER = 4007
43  ID_LEGEND_HIDELAYER = 4008  ID_LEGEND_HIDELAYER = 4008
44    
45    ID_POPUP_TOP = 4501
46    ID_POPUP_UP  = 4502
47    ID_POPUP_DOWN = 4503
48    ID_POPUP_BOTTOM = 4504
49    ID_POPUP_PROPS  = 4506
50    ID_POPUP_VISIBLE = 4507
51    ID_POPUP_PROJ = 4509
52    
53  BMP_SIZE_W = 15  BMP_SIZE_W = 15
54  BMP_SIZE_H = 15  BMP_SIZE_H = 15
55    
# Line 108  class LegendPanel(DockPanel): Line 116  class LegendPanel(DockPanel):
116          EVT_TOOL(self, ID_LEGEND_SHOWLAYER, self._OnShowLayer)          EVT_TOOL(self, ID_LEGEND_SHOWLAYER, self._OnShowLayer)
117          EVT_TOOL(self, ID_LEGEND_HIDELAYER, self._OnHideLayer)          EVT_TOOL(self, ID_LEGEND_HIDELAYER, self._OnHideLayer)
118    
119            EVT_MENU(self, ID_POPUP_PROPS, self._OnProperties)
120            EVT_MENU(self, ID_POPUP_TOP, self._OnMoveTop)
121            EVT_MENU(self, ID_POPUP_UP, self._OnMoveUp)
122            EVT_MENU(self, ID_POPUP_DOWN, self._OnMoveDown)
123            EVT_MENU(self, ID_POPUP_BOTTOM, self._OnMoveBottom)
124            EVT_MENU(self, ID_POPUP_VISIBLE, self._OnToggleVisibility)
125            EVT_MENU(self, ID_POPUP_PROJ, self._OnProjection)
126            
127          self.tree = LegendTree(self, ID_LEGEND_TREE, map, mainWindow)          self.tree = LegendTree(self, ID_LEGEND_TREE, map, mainWindow)
128    
129          panelBox.Add(self.tree, 1, wxGROW, 0)          panelBox.Add(self.tree, 1, wxGROW, 0)
# Line 182  class LegendPanel(DockPanel): Line 198  class LegendPanel(DockPanel):
198          self.tree.DoOnHideLayer()          self.tree.DoOnHideLayer()
199          pass          pass
200    
201        def _OnToggleVisibility(self, event):
202            self.tree.ToggleVisibility()
203    
204        def _OnProjection(self, event):
205            self.tree.LayerProjection()
206    
207      def __EnableButtons(self, on):      def __EnableButtons(self, on):
208          self.toolBar.EnableTool(ID_LEGEND_TOP, on)          self.toolBar.EnableTool(ID_LEGEND_TOP, on)
209          self.toolBar.EnableTool(ID_LEGEND_RAISE, on)          self.toolBar.EnableTool(ID_LEGEND_RAISE, on)
# Line 230  class LegendTree(wxTreeCtrl): Line 252  class LegendTree(wxTreeCtrl):
252          EVT_TREE_SEL_CHANGED(self, ID_LEGEND_TREE, self._OnSelChanged)          EVT_TREE_SEL_CHANGED(self, ID_LEGEND_TREE, self._OnSelChanged)
253          EVT_TREE_ITEM_EXPANDING(self, ID_LEGEND_TREE, self.OnItemExpandCollapse)          EVT_TREE_ITEM_EXPANDING(self, ID_LEGEND_TREE, self.OnItemExpandCollapse)
254          EVT_TREE_ITEM_COLLAPSING(self, ID_LEGEND_TREE, self.OnItemExpandCollapse)          EVT_TREE_ITEM_COLLAPSING(self, ID_LEGEND_TREE, self.OnItemExpandCollapse)
255            EVT_TREE_ITEM_RIGHT_CLICK(self, ID_LEGEND_TREE, self._OnRightClick)
256    
257          EVT_CLOSE(self, self._OnClose)          EVT_CLOSE(self, self._OnClose)
258    
# Line 333  class LegendTree(wxTreeCtrl): Line 356  class LegendTree(wxTreeCtrl):
356          layer, group = self.GetSelectedHierarchy()          layer, group = self.GetSelectedHierarchy()
357          layer.SetVisible(False)          layer.SetVisible(False)
358    
359        def ToggleVisibility(self):
360            layer, group = self.GetSelectedHierarchy()
361    
362            layer.SetVisible(not layer.Visible())
363    
364        def LayerProjection(self):
365            self.parent.mainWindow.LayerProjection()
366    
367      def Sort(self):      def Sort(self):
368          self.SortChildren(self.GetRootItem())          self.SortChildren(self.GetRootItem())
369    
# Line 394  class LegendTree(wxTreeCtrl): Line 425  class LegendTree(wxTreeCtrl):
425              event.Veto()              event.Veto()
426              self.preventExpandCollapse = False              self.preventExpandCollapse = False
427    
428        def _OnRightClick(self, event):
429            """Select item and pop up a context menu"""
430    
431            # The pop up menu is related to the legend tree, so we have direct
432            # access on the tree items. The events issued by the menu are handled
433            # by the legend panel, since most of the handlers are already
434            # implemented there.
435    
436            # Update item selection to the right click
437            item = event.GetItem()
438            self.SelectItem(item)
439    
440            # Create the menu
441            menu = wxMenu("", 0)
442    
443            # The "Visible" item is a special ...
444            menuitem = wxMenuItem(menu, ID_POPUP_VISIBLE, _("Visible"),
445                                    "", wxITEM_CHECK)
446            menu.AppendItem(menuitem)
447            layer, group = self.GetSelectedHierarchy()
448            menuitem.Check(layer.Visible())
449    
450            menu.AppendSeparator()
451            menu.Append(ID_POPUP_PROPS, _("Properties"))
452            menu.Append(ID_POPUP_PROJ, _("Projection"))
453            menu.AppendSeparator()
454            menu.Append(ID_POPUP_TOP, _("Top"))
455            menu.Append(ID_POPUP_UP, _("Up"))
456            menu.Append(ID_POPUP_DOWN, _("Down"))
457            menu.Append(ID_POPUP_BOTTOM, _("Bottom"))
458    
459            # Display the menu
460            pos = event.GetPoint()
461            shift = self.ClientToScreen((0,0))
462            self.PopupMenu(menu, pos)
463    
464      def _OnItemActivated(self, event):      def _OnItemActivated(self, event):
465          # The following looks strange but is need under Windows to          # The following looks strange but is need under Windows to
466          # raise the Properties on double-click: The tree control          # raise the Properties on double-click: The tree control

Legend:
Removed from v.1252  
changed lines
  Added in v.1837

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26