/[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 980 by frank, Thu May 22 11:41:14 2003 UTC revision 1063 by frank, Tue May 27 14:08:28 2003 UTC
# Line 30  from Thuban.UI.scalebar import ScaleBar Line 30  from Thuban.UI.scalebar import ScaleBar
30    
31  from Thuban.Lib.connector import ConnectorError  from Thuban.Lib.connector import ConnectorError
32    
33  ID_LEGEND_RAISE = 4001  ID_LEGEND_TOP = 4001
34  ID_LEGEND_LOWER = 4002  ID_LEGEND_RAISE = 4002
35  ID_LEGEND_TREE = 4003  ID_LEGEND_LOWER = 4003
36  ID_LEGEND_PROPS = 4004  ID_LEGEND_BOTTOM = 4004
37  ID_LEGEND_SHOWLAYER = 4005  ID_LEGEND_TREE = 4005
38  ID_LEGEND_HIDELAYER = 4006  ID_LEGEND_PROPS = 4006
39    ID_LEGEND_SHOWLAYER = 4007
40    ID_LEGEND_HIDELAYER = 4008
41    
42  BMP_SIZE_W = 30  BMP_SIZE_W = 15
43  BMP_SIZE_H = 15  BMP_SIZE_H = 15
44    
45    TOP_BMP = "top_layer"
46  RAISE_BMP = "raise_layer"  RAISE_BMP = "raise_layer"
47  LOWER_BMP = "lower_layer"  LOWER_BMP = "lower_layer"
48    BOTTOM_BMP = "bottom_layer"
49  SHOW_BMP  = "show_layer"  SHOW_BMP  = "show_layer"
50  HIDE_BMP  = "hide_layer"  HIDE_BMP  = "hide_layer"
51  PROPS_BMP = "layer_properties"  PROPS_BMP = "layer_properties"
# Line 62  class LegendPanel(DockPanel): Line 66  class LegendPanel(DockPanel):
66          self.toolBar = wxToolBar(self, -1)          self.toolBar = wxToolBar(self, -1)
67          self.toolBar.SetToolBitmapSize(wxSize(24, 24))          self.toolBar.SetToolBitmapSize(wxSize(24, 24))
68    
69            bmp = resource.GetBitmapResource(TOP_BMP, wxBITMAP_TYPE_XPM)
70            self.toolBar.AddTool(ID_LEGEND_TOP, bmp,
71                shortHelpString=_("Top Layer"))
72    
73          bmp = resource.GetBitmapResource(RAISE_BMP, wxBITMAP_TYPE_XPM)          bmp = resource.GetBitmapResource(RAISE_BMP, wxBITMAP_TYPE_XPM)
74          self.toolBar.AddTool(ID_LEGEND_RAISE, bmp,          self.toolBar.AddTool(ID_LEGEND_RAISE, bmp,
75              shortHelpString=_("Raise Layer"))              shortHelpString=_("Raise Layer"))
# Line 70  class LegendPanel(DockPanel): Line 78  class LegendPanel(DockPanel):
78          self.toolBar.AddTool(ID_LEGEND_LOWER, bmp,          self.toolBar.AddTool(ID_LEGEND_LOWER, bmp,
79              shortHelpString=_("Lower Layer"))              shortHelpString=_("Lower Layer"))
80    
81            bmp = resource.GetBitmapResource(BOTTOM_BMP, wxBITMAP_TYPE_XPM)
82            self.toolBar.AddTool(ID_LEGEND_BOTTOM, bmp,
83                shortHelpString=_("Bottom Layer"))
84    
85          bmp = resource.GetBitmapResource(SHOW_BMP, wxBITMAP_TYPE_XPM)          bmp = resource.GetBitmapResource(SHOW_BMP, wxBITMAP_TYPE_XPM)
86          self.toolBar.AddTool(ID_LEGEND_SHOWLAYER, bmp,          self.toolBar.AddTool(ID_LEGEND_SHOWLAYER, bmp,
87              shortHelpString=_("Show Layer"))              shortHelpString=_("Show Layer"))
# Line 85  class LegendPanel(DockPanel): Line 97  class LegendPanel(DockPanel):
97          self.toolBar.Realize()          self.toolBar.Realize()
98          panelBox.Add(self.toolBar, 0, wxGROW, 0)          panelBox.Add(self.toolBar, 0, wxGROW, 0)
99    
100            EVT_TOOL(self, ID_LEGEND_TOP, self._OnMoveTop)
101          EVT_TOOL(self, ID_LEGEND_RAISE, self._OnMoveUp)          EVT_TOOL(self, ID_LEGEND_RAISE, self._OnMoveUp)
102          EVT_TOOL(self, ID_LEGEND_LOWER, self._OnMoveDown)          EVT_TOOL(self, ID_LEGEND_LOWER, self._OnMoveDown)
103            EVT_TOOL(self, ID_LEGEND_BOTTOM, self._OnMoveBottom)
104          EVT_TOOL(self, ID_LEGEND_PROPS, self._OnProperties)          EVT_TOOL(self, ID_LEGEND_PROPS, self._OnProperties)
105          EVT_TOOL(self, ID_LEGEND_SHOWLAYER, self._OnShowLayer)          EVT_TOOL(self, ID_LEGEND_SHOWLAYER, self._OnShowLayer)
106          EVT_TOOL(self, ID_LEGEND_HIDELAYER, self._OnHideLayer)          EVT_TOOL(self, ID_LEGEND_HIDELAYER, self._OnHideLayer)
# Line 139  class LegendPanel(DockPanel): Line 153  class LegendPanel(DockPanel):
153      def _OnProperties(self, event):      def _OnProperties(self, event):
154          self.DoOnProperties()          self.DoOnProperties()
155    
156        def _OnMoveTop(self, event):
157            self.tree.MoveCurrentItemTop()
158            
159      def _OnMoveUp(self, event):      def _OnMoveUp(self, event):
160          self.tree.MoveCurrentItemUp()          self.tree.MoveCurrentItemUp()
161    
162      def _OnMoveDown(self, event):      def _OnMoveDown(self, event):
163          self.tree.MoveCurrentItemDown()          self.tree.MoveCurrentItemDown()
164    
165        def _OnMoveBottom(self, event):
166            self.tree.MoveCurrentItemBottom()
167    
168      def _OnShowLayer(self, event):      def _OnShowLayer(self, event):
169          self.tree.DoOnShowLayer()          self.tree.DoOnShowLayer()
170          pass          pass
# Line 160  class LegendPanel(DockPanel): Line 180  class LegendPanel(DockPanel):
180          pass          pass
181    
182      def __EnableButtons(self, on):      def __EnableButtons(self, on):
183            self.toolBar.EnableTool(ID_LEGEND_TOP, on)
184          self.toolBar.EnableTool(ID_LEGEND_RAISE, on)          self.toolBar.EnableTool(ID_LEGEND_RAISE, on)
185          self.toolBar.EnableTool(ID_LEGEND_LOWER, on)          self.toolBar.EnableTool(ID_LEGEND_LOWER, on)
186            self.toolBar.EnableTool(ID_LEGEND_BOTTOM, on)
187          self.toolBar.EnableTool(ID_LEGEND_SHOWLAYER,  on)          self.toolBar.EnableTool(ID_LEGEND_SHOWLAYER,  on)
188          self.toolBar.EnableTool(ID_LEGEND_HIDELAYER,  on)          self.toolBar.EnableTool(ID_LEGEND_HIDELAYER,  on)
189          self.toolBar.EnableTool(ID_LEGEND_PROPS, on)          self.toolBar.EnableTool(ID_LEGEND_PROPS, on)
# Line 226  class LegendTree(wxTreeCtrl): Line 248  class LegendTree(wxTreeCtrl):
248                  #self._OnMsgMapsChanged)                  #self._OnMsgMapsChanged)
249              self.__FillTree(self.map)              self.__FillTree(self.map)
250    
251        def MoveCurrentItemTop(self):
252            layer, group = self.GetSelectedHierarchy()
253    
254            if layer is not None:
255                self.map.TopLayer(layer)
256            else:
257                assert False, "Shouldn't be allowed."
258                pass
259    
260      def MoveCurrentItemUp(self):      def MoveCurrentItemUp(self):
261          layer, group = self.GetSelectedHierarchy()          layer, group = self.GetSelectedHierarchy()
262    
# Line 244  class LegendTree(wxTreeCtrl): Line 275  class LegendTree(wxTreeCtrl):
275              assert False, "Shouldn't be allowed."              assert False, "Shouldn't be allowed."
276              pass              pass
277    
278        def MoveCurrentItemBottom(self):
279            layer, group = self.GetSelectedHierarchy()
280    
281            if layer is not None:
282                self.map.BottomLayer(layer)
283            else:
284                assert False, "Shouldn't be allowed."
285                pass
286    
287      def OnCompareItems(self, item1, item2):      def OnCompareItems(self, item1, item2):
288    
289          data1 = self.GetPyData(item1)          data1 = self.GetPyData(item1)
# Line 360  class LegendTree(wxTreeCtrl): Line 400  class LegendTree(wxTreeCtrl):
400              self.emptyImageIndex = \              self.emptyImageIndex = \
401                  self.image_list.AddWithColourMask(bmp, wxColour(0, 0, 0))                  self.image_list.AddWithColourMask(bmp, wxColour(0, 0, 0))
402                                                                                                                                                                    
403                bmp = resource.GetBitmapResource("legend_icon_layer",
404                                                  wxBITMAP_TYPE_XPM)
405                self.mapImageIndex = \
406                    self.image_list.Add(bmp)
407    
408              self.AssignImageList(self.image_list)              self.AssignImageList(self.image_list)
409    
410              root = self.AddRoot("")              root = self.AddRoot("")
411    
412              for l in map.Layers():              for l in map.Layers():
413                  id = self.PrependItem(root, l.Title())                  id = self.PrependItem(root, l.Title())
414                    self.SetItemImage(id, self.mapImageIndex)
415                    self.SetItemSelectedImage(id, self.mapImageIndex)
416    
417                  l.Subscribe(LAYER_CHANGED, self._OnMsgLayerChanged)                  l.Subscribe(LAYER_CHANGED, self._OnMsgLayerChanged)
418                  l.Subscribe(LAYER_VISIBILITY_CHANGED,                  l.Subscribe(LAYER_VISIBILITY_CHANGED,
419                              self._OnMsgLayerVisibilityChanged)                              self._OnMsgLayerVisibilityChanged)
# Line 403  class LegendTree(wxTreeCtrl): Line 451  class LegendTree(wxTreeCtrl):
451                      bmp = self.__BuildGroupImage(g, shapeType)                      bmp = self.__BuildGroupImage(g, shapeType)
452    
453                      if bmp is None:                      if bmp is None:
454                          self.SetItemImage(id, self.emptyImageIndex)                          self.SetItemImage(id, -1)
455                            self.SetItemSelectedImage(id, -1)
456                      else:                      else:
457                          i = self.image_list.Add(bmp)                          i = self.image_list.Add(bmp)
458                          self.SetItemImage(id, i)                          self.SetItemImage(id, i)
459                            self.SetItemSelectedImage(id, i)
460    
461          self.Thaw()          self.Thaw()
462    
# Line 468  class ScaleBarBitmap(wxBoxSizer): Line 518  class ScaleBarBitmap(wxBoxSizer):
518          # While the width is fixed, get the height _now_.          # While the width is fixed, get the height _now_.
519          dc = wxMemoryDC()          dc = wxMemoryDC()
520          textwidth, textheight = dc.GetTextExtent("%d"%0)          textwidth, textheight = dc.GetTextExtent("%d"%0)
521          self.width = 200          self.width = 210
522          self.height = textheight + 3*2 + 8          self.height = textheight + 3*2 + 8
523    
524          wxBoxSizer.__init__(self, wxVERTICAL)          wxBoxSizer.__init__(self, wxVERTICAL)

Legend:
Removed from v.980  
changed lines
  Added in v.1063

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26