/[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 573 by jonathan, Fri Mar 28 17:07:06 2003 UTC revision 622 by bh, Mon Apr 7 10:54:32 2003 UTC
# Line 101  class MainWindow(DockFrame): Line 101  class MainWindow(DockFrame):
101    
102          self.init_dialogs()          self.init_dialogs()
103    
104          EVT_CLOSE(self, self.OnClose)          EVT_CLOSE(self, self._OnClose)
105    
106      def Subscribe(self, channel, *args):      def Subscribe(self, channel, *args):
107          """Subscribe a function to a message channel.          """Subscribe a function to a message channel.
# Line 387  class MainWindow(DockFrame): Line 387  class MainWindow(DockFrame):
387          dlg.Destroy()          dlg.Destroy()
388    
389      def Exit(self):      def Exit(self):
390          self.Close(false)          self.Close(False)
391    
392      def OnClose(self, event):      def _OnClose(self, event):
393          result = self.save_modified_session(can_veto = event.CanVeto())          result = self.save_modified_session(can_veto = event.CanVeto())
394          if result == wxID_CANCEL:          if result == wxID_CANCEL:
395              event.Veto()              event.Veto()
# Line 398  class MainWindow(DockFrame): Line 398  class MainWindow(DockFrame):
398              # wx's destroy event, but that isn't implemented for wxGTK              # wx's destroy event, but that isn't implemented for wxGTK
399              # yet.              # yet.
400              self.canvas.Unsubscribe(VIEW_POSITION, self.view_position_changed)              self.canvas.Unsubscribe(VIEW_POSITION, self.view_position_changed)
401                DockFrame._OnClose(self, event)
402              self.Destroy()              self.Destroy()
403    
404      def SetMap(self, map):      def SetMap(self, map):
# Line 412  class MainWindow(DockFrame): Line 413  class MainWindow(DockFrame):
413    
414          return self.canvas.Map()          return self.canvas.Map()
415    
416      def ShowSessionTree(self):      def ToggleSessionTree(self):
417            """If the session tree is shown close it otherwise create a new tree"""
418          name = "session_tree"          name = "session_tree"
419          dialog = self.get_open_dialog(name)          dialog = self.get_open_dialog(name)
420          if dialog is None:          if dialog is None:
# Line 420  class MainWindow(DockFrame): Line 422  class MainWindow(DockFrame):
422              self.add_dialog(name, dialog)              self.add_dialog(name, dialog)
423              dialog.Show(True)              dialog.Show(True)
424          else:          else:
425              # FIXME: bring dialog to front here              dialog.Close()
             pass  
426    
427        def SessionTreeShown(self):
428            """Return true iff the session tree is currently shown"""
429            return self.get_open_dialog("session_tree") is not None
430    
431      def About(self):      def About(self):
432          self.RunMessageBox(_("About"),          self.RunMessageBox(_("About"),
# Line 466  class MainWindow(DockFrame): Line 470  class MainWindow(DockFrame):
470      def CanRemoveLayer(self):      def CanRemoveLayer(self):
471          """Return true if the currently selected layer can be deleted.          """Return true if the currently selected layer can be deleted.
472    
473          If no layer is selected return false.          If no layer is selected return False.
474    
475          The return value of this method determines whether the remove          The return value of this method determines whether the remove
476          layer command is sensitive in menu.          layer command is sensitive in menu.
# Line 474  class MainWindow(DockFrame): Line 478  class MainWindow(DockFrame):
478          layer = self.current_layer()          layer = self.current_layer()
479          if layer is not None:          if layer is not None:
480              return self.canvas.Map().CanRemoveLayer(layer)              return self.canvas.Map().CanRemoveLayer(layer)
481          return 0          return False
482    
483      def RaiseLayer(self):      def RaiseLayer(self):
484          layer = self.current_layer()          layer = self.current_layer()
# Line 523  class MainWindow(DockFrame): Line 527  class MainWindow(DockFrame):
527      def LayerTransparentFill(self):      def LayerTransparentFill(self):
528          layer = self.current_layer()          layer = self.current_layer()
529          if layer is not None:          if layer is not None:
530              layer.GetClassification().SetDefaultFill(Color.None)              layer.GetClassification().SetDefaultFill(Color.Transparent)
531    
532      def LayerOutlineColor(self):      def LayerOutlineColor(self):
533          layer = self.current_layer()          layer = self.current_layer()
# Line 535  class MainWindow(DockFrame): Line 539  class MainWindow(DockFrame):
539      def LayerNoOutline(self):      def LayerNoOutline(self):
540          layer = self.current_layer()          layer = self.current_layer()
541          if layer is not None:          if layer is not None:
542              layer.GetClassification().SetDefaultLineColor(Color.None)              layer.GetClassification().SetDefaultLineColor(Color.Transparent)
543    
544      def HideLayer(self):      def HideLayer(self):
545          layer = self.current_layer()          layer = self.current_layer()
# Line 602  class MainWindow(DockFrame): Line 606  class MainWindow(DockFrame):
606          dialog.Raise()          dialog.Raise()
607    
608    
609      def ShowLegend(self, switch = False):      def ShowLegend(self):
610            if not self.LegendShown():
611                self.ToggleLegend()
612    
613        def ToggleLegend(self):
614            """Show the legend if it's not shown otherwise hide it again"""
615          name = "legend"          name = "legend"
616          dialog = self.FindRegisteredDock(name)          dialog = self.FindRegisteredDock(name)
617    
# Line 610  class MainWindow(DockFrame): Line 619  class MainWindow(DockFrame):
619              title = "Legend: %s" % self.Map().Title()              title = "Legend: %s" % self.Map().Title()
620              dialog = self.CreateDock(name, -1, title, wxLAYOUT_LEFT)              dialog = self.CreateDock(name, -1, title, wxLAYOUT_LEFT)
621              legend.LegendPanel(dialog, None, self)              legend.LegendPanel(dialog, None, self)
622                dialog.Dock()
623                dialog.GetPanel().SetMap(self.Map())
624                dialog.Show()
625            else:
626                dialog.Show(not dialog.IsShown())
627    
628          dialog.GetPanel().SetMap(self.Map())      def LegendShown(self):
629          dialog.Show()          """Return true iff the legend is currently open"""
630            dialog = self.FindRegisteredDock("legend")
631            return dialog is not None and dialog.IsShown()
632    
633      def ZoomInTool(self):      def ZoomInTool(self):
634          self.canvas.ZoomInTool()          self.canvas.ZoomInTool()
# Line 658  def call_method(context, methodname, *ar Line 674  def call_method(context, methodname, *ar
674      apply(getattr(context.mainwindow, methodname), args)      apply(getattr(context.mainwindow, methodname), args)
675    
676  def _method_command(name, title, method, helptext = "",  def _method_command(name, title, method, helptext = "",
677                      icon = "", sensitive = None):                      icon = "", sensitive = None, checked = None):
678      """Add a command implemented by a method of the mainwindow object"""      """Add a command implemented by a method of the mainwindow object"""
679      registry.Add(Command(name, title, call_method, args=(method,),      registry.Add(Command(name, title, call_method, args=(method,),
680                           helptext = helptext, icon = icon,                           helptext = helptext, icon = icon,
681                           sensitive = sensitive))                           sensitive = sensitive, checked = checked))
682    
683  def make_check_current_tool(toolname):  def make_check_current_tool(toolname):
684      """Return a function that tests if the currently active tool is toolname      """Return a function that tests if the currently active tool is toolname
# Line 692  def _can_remove_layer(context): Line 708  def _can_remove_layer(context):
708    
709  def _has_tree_window_shown(context):  def _has_tree_window_shown(context):
710      """Return true if the tree window is shown"""      """Return true if the tree window is shown"""
711      return context.mainwindow.get_open_dialog("session_tree") is None      return context.mainwindow.SessionTreeShown()
712    
713  def _has_visible_map(context):  def _has_visible_map(context):
714      """Return true iff theres a visible map in the mainwindow.      """Return true iff theres a visible map in the mainwindow.
# Line 707  def _has_visible_map(context): Line 723  def _has_visible_map(context):
723    
724  def _has_legend_shown(context):  def _has_legend_shown(context):
725      """Return true if the legend window is shown"""      """Return true if the legend window is shown"""
726      return context.mainwindow.FindRegisteredDock("legend") is None      return context.mainwindow.LegendShown()
727    
728    
729  # File menu  # File menu
# Line 715  _method_command("new_session", _("&New S Line 731  _method_command("new_session", _("&New S
731  _method_command("open_session", _("&Open Session"), "OpenSession")  _method_command("open_session", _("&Open Session"), "OpenSession")
732  _method_command("save_session", _("&Save Session"), "SaveSession")  _method_command("save_session", _("&Save Session"), "SaveSession")
733  _method_command("save_session_as", _("Save Session &As"), "SaveSessionAs")  _method_command("save_session_as", _("Save Session &As"), "SaveSessionAs")
734  _method_command("show_session_tree", _("Show Session &Tree"), "ShowSessionTree",  _method_command("toggle_session_tree", _("Session &Tree"), "ToggleSessionTree",
735                  sensitive = _has_tree_window_shown)                  checked = _has_tree_window_shown)
736    _method_command("toggle_legend", _("Legend"), "ToggleLegend",
737                    checked = _has_legend_shown)
738  _method_command("exit", _("E&xit"), "Exit")  _method_command("exit", _("E&xit"), "Exit")
739    
740  # Help menu  # Help menu
# Line 784  _method_command("layer_show_table", _("S Line 802  _method_command("layer_show_table", _("S
802                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
803  _method_command("layer_classifier", _("Classify"), "Classify",  _method_command("layer_classifier", _("Classify"), "Classify",
804                  sensitive = _has_selected_layer)                  sensitive = _has_selected_layer)
 _method_command("show_legend", _("Show Legend"), "ShowLegend",  
                 sensitive = _has_legend_shown)  
805    
806  # the menu structure  # the menu structure
807  main_menu = Menu("<main>", "<main>",  main_menu = Menu("<main>", "<main>",
808                   [Menu("file", _("&File"),                   [Menu("file", _("&File"),
809                         ["new_session", "open_session", None,                         ["new_session", "open_session", None,
810                          "save_session", "save_session_as", None,                          "save_session", "save_session_as", None,
811                          "show_session_tree", None,                          "toggle_session_tree",
812                          "show_legend", None,                          "toggle_legend", None,
813                          "exit"]),                          "exit"]),
814                    Menu("map", _("&Map"),                    Menu("map", _("&Map"),
815                         ["layer_add", "layer_remove",                         ["layer_add", "layer_remove",

Legend:
Removed from v.573  
changed lines
  Added in v.622

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26