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

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

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

revision 278 by bh, Mon Aug 26 12:50:23 2002 UTC revision 299 by bh, Fri Aug 30 17:41:04 2002 UTC
# Line 193  class MainWindow(wxFrame): Line 193  class MainWindow(wxFrame):
193              else:              else:
194                  print "Unknown command %s" % name                  print "Unknown command %s" % name
195    
196        def Context(self):
197            """Return the context object for a command invoked from this window
198            """
199            return Context(self.application, self.application.Session(), self)
200    
201      def invoke_command(self, event):      def invoke_command(self, event):
202          name = self.id_to_name.get(event.GetId())          name = self.id_to_name.get(event.GetId())
203          if name is not None:          if name is not None:
204              command = registry.Command(name)              command = registry.Command(name)
205              context = Context(self.application, self.application.Session(),              command.Execute(self.Context())
                               self)  
             command.Execute(context)  
206          else:          else:
207              print "Unknown command ID %d" % event.GetId()              print "Unknown command ID %d" % event.GetId()
208    
209      def update_command_ui(self, event):      def update_command_ui(self, event):
210          #print "update_command_ui", self.id_to_name[event.GetId()]          #print "update_command_ui", self.id_to_name[event.GetId()]
211          context = Context(self.application, self.application.Session(), self)          context = self.Context()
212          command = registry.Command(self.id_to_name[event.GetId()])          command = registry.Command(self.id_to_name[event.GetId()])
213          if command is not None:          if command is not None:
214              event.Enable(command.Sensitive(context))              event.Enable(command.Sensitive(context))
# Line 357  class MainWindow(wxFrame): Line 360  class MainWindow(wxFrame):
360          if layer is not None:          if layer is not None:
361              self.canvas.Map().RemoveLayer(layer)              self.canvas.Map().RemoveLayer(layer)
362    
363        def CanRemoveLayer(self):
364            """Return true if the currently selected layer can be deleted.
365    
366            If no layer is selected return false.
367    
368            The return value of this method determines whether the remove
369            layer command is sensitive in menu.
370            """
371            layer = self.current_layer()
372            if layer is not None:
373                return self.canvas.Map().CanRemoveLayer(layer)
374            return 0
375    
376      def RaiseLayer(self):      def RaiseLayer(self):
377          layer = self.current_layer()          layer = self.current_layer()
378          if layer is not None:          if layer is not None:
# Line 533  def _has_selected_layer(context): Line 549  def _has_selected_layer(context):
549      """Return true if a layer is selected in the context"""      """Return true if a layer is selected in the context"""
550      return context.mainwindow.has_selected_layer()      return context.mainwindow.has_selected_layer()
551    
552    def _can_remove_layer(context):
553        return context.mainwindow.CanRemoveLayer()
554    
555  def _has_tree_window_shown(context):  def _has_tree_window_shown(context):
556      """Return true if the tree window is shown"""      """Return true if the tree window is shown"""
557      return context.mainwindow.get_open_dialog("session_tree") is None      return context.mainwindow.get_open_dialog("session_tree") is None
# Line 572  _method_command("layer_add", "&Add Layer Line 591  _method_command("layer_add", "&Add Layer
591                  helptext = "Add a new layer to active map")                  helptext = "Add a new layer to active map")
592  _method_command("layer_remove", "&Remove Layer", "RemoveLayer",  _method_command("layer_remove", "&Remove Layer", "RemoveLayer",
593                  helptext = "Remove selected layer(s)",                  helptext = "Remove selected layer(s)",
594                  sensitive = _has_selected_layer)                  sensitive = _can_remove_layer)
595  _method_command("layer_fill_color", "&Fill Color", "LayerFillColor",  _method_command("layer_fill_color", "&Fill Color", "LayerFillColor",
596                  helptext = "Set the fill color of selected layer(s)",                  helptext = "Set the fill color of selected layer(s)",
597                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)

Legend:
Removed from v.278  
changed lines
  Added in v.299

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26