/[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 193 by bh, Wed May 29 10:33:41 2002 UTC revision 222 by bh, Thu Jul 18 13:03:08 2002 UTC
# Line 29  import tableview, identifyview Line 29  import tableview, identifyview
29  from menu import Menu  from menu import Menu
30    
31  import main  import main
32    from context import Context
33  from command import registry, Command  from command import registry, Command
34  from messages import SELECTED_SHAPE, VIEW_POSITION  from messages import SELECTED_SHAPE, VIEW_POSITION
35    
# Line 196  class MainWindow(wxFrame): Line 197  class MainWindow(wxFrame):
197          name = self.id_to_name.get(event.GetId())          name = self.id_to_name.get(event.GetId())
198          if name is not None:          if name is not None:
199              command = registry.Command(name)              command = registry.Command(name)
200              command.Execute(self)              command.Execute(Context(main.app, main.app.Session(), self))
201          else:          else:
202              print "Unknown command ID %d" % event.GetId()              print "Unknown command ID %d" % event.GetId()
203    
204      def update_command_ui(self, event):      def update_command_ui(self, event):
205          #print "update_command_ui", self.id_to_name[event.GetId()]          #print "update_command_ui", self.id_to_name[event.GetId()]
206            context = Context(main.app, main.app.Session(), self)
207          command = registry.Command(self.id_to_name[event.GetId()])          command = registry.Command(self.id_to_name[event.GetId()])
208          if command is not None:          if command is not None:
209              event.Enable(command.Sensitive(self))              event.Enable(command.Sensitive(context))
210              event.SetText(command.DynText(self))              event.SetText(command.DynText(context))
211              if command.IsCheckCommand():              if command.IsCheckCommand():
212                  event.Check(command.Checked(self))                  event.Check(command.Checked(context))
213    
214      def RunMessageBox(self, title, text, flags = wxOK | wxICON_INFORMATION):      def RunMessageBox(self, title, text, flags = wxOK | wxICON_INFORMATION):
215          """Run a modal message box with the given text, title and flags          """Run a modal message box with the given text, title and flags
# Line 357  class MainWindow(wxFrame): Line 359  class MainWindow(wxFrame):
359          layer = self.current_layer()          layer = self.current_layer()
360          if layer is not None:          if layer is not None:
361              self.canvas.Map().RaiseLayer(layer)              self.canvas.Map().RaiseLayer(layer)
362            
363      def LowerLayer(self):      def LowerLayer(self):
364          layer = self.current_layer()          layer = self.current_layer()
365          if layer is not None:          if layer is not None:
# Line 497  class MainWindow(wxFrame): Line 499  class MainWindow(wxFrame):
499    
500  # Helper functions to define common command implementations  # Helper functions to define common command implementations
501  def call_method(context, methodname, *args):  def call_method(context, methodname, *args):
502      """Call the context's method methodname with args *args"""      """Call the mainwindow's method methodname with args *args"""
503      apply(getattr(context, methodname), args)      apply(getattr(context.mainwindow, methodname), args)
504    
505  def _method_command(name, title, method, helptext = "",  def _method_command(name, title, method, helptext = "",
506                      icon = "", sensitive = None):                      icon = "", sensitive = None):
507      """Add a command implemented by a method of the context object"""      """Add a command implemented by a method of the mainwindow object"""
508      registry.Add(Command(name, title, call_method, args=(method,),      registry.Add(Command(name, title, call_method, args=(method,),
509                           helptext = helptext, icon = icon,                           helptext = helptext, icon = icon,
510                           sensitive = sensitive))                           sensitive = sensitive))
# Line 511  def _tool_command(name, title, method, t Line 513  def _tool_command(name, title, method, t
513                    icon = ""):                    icon = ""):
514      """Add a tool command"""      """Add a tool command"""
515      def check_current_tool(context, name=toolname):      def check_current_tool(context, name=toolname):
516          return context.canvas.CurrentTool() == name          return context.mainwindow.canvas.CurrentTool() == name
517      registry.Add(Command(name, title, call_method, args=(method,),      registry.Add(Command(name, title, call_method, args=(method,),
518                           helptext = helptext, icon = icon,                           helptext = helptext, icon = icon,
519                           checked = check_current_tool))                           checked = check_current_tool))
520    
521  def _has_selected_layer(context):  def _has_selected_layer(context):
522      """Return true if a layer is selected in the context"""      """Return true if a layer is selected in the context"""
523      return context.has_selected_layer()      return context.mainwindow.has_selected_layer()
524    
525  # File menu  # File menu
526  _method_command("new_session", "&New Session", "NewSession")  _method_command("new_session", "&New Session", "NewSession")

Legend:
Removed from v.193  
changed lines
  Added in v.222

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26