/[thuban]/trunk/thuban/Thuban/UI/projlist.py
ViewVC logotype

Diff of /trunk/thuban/Thuban/UI/projlist.py

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

revision 2699 by bh, Tue Nov 11 16:37:53 2003 UTC revision 2700 by dpinte, Mon Sep 18 14:27:02 2006 UTC
# Line 11  __version__ = "$Revision$" Line 11  __version__ = "$Revision$"
11  # $Source$  # $Source$
12  # $Id$  # $Id$
13    
14  from wxPython.wx import *  import wx
15    
16  from Thuban import _  from Thuban import _
17    
# Line 24  from Thuban.Model.messages import PROJEC Line 24  from Thuban.Model.messages import PROJEC
24  PROJ_SELECTION_CHANGED = "PROJ_SELECTION_CHANGED"  PROJ_SELECTION_CHANGED = "PROJ_SELECTION_CHANGED"
25    
26    
27  class ProjectionList(wxListCtrl, Publisher):  class ProjectionList(wx.ListCtrl, Publisher):
28    
29      """A ListCtrl that shows a list of projections      """A ListCtrl that shows a list of projections
30    
# Line 46  class ProjectionList(wxListCtrl, Publish Line 46  class ProjectionList(wxListCtrl, Publish
46          proj_files -- a sequence of ProjFile objects          proj_files -- a sequence of ProjFile objects
47          orig_proj -- The projection originally selected in the map/layer          orig_proj -- The projection originally selected in the map/layer
48          """          """
49          wxListCtrl.__init__(self, parent, ID, style=wxLC_REPORT|wxLC_VIRTUAL)          wx.ListCtrl.__init__(self, parent, ID, style=wx.LC_REPORT|wx.LC_VIRTUAL)
50    
51          self.InsertColumn(0, _("Available Projections"))          self.InsertColumn(0, _("Available Projections"))
52          self.proj_files = proj_files          self.proj_files = proj_files
# Line 56  class ProjectionList(wxListCtrl, Publish Line 56  class ProjectionList(wxListCtrl, Publish
56          self.proj_map = {}          self.proj_map = {}
57          self.needs_update = False          self.needs_update = False
58          self.update_projections()          self.update_projections()
59          EVT_SIZE(self, self.OnSize)          self.Bind(wx.EVT_SIZE, self.OnSize)
60          EVT_LEFT_UP(self, self.mouse_left_up)          self.Bind(wx.EVT_LEFT_UP, self.mouse_left_up)
61          EVT_LIST_ITEM_SELECTED(self, self.GetId(), self.item_selected)          self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.item_selected, id=self.GetId())
62          EVT_LIST_ITEM_DESELECTED(self, self.GetId(), self.item_deselected)          self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.item_deselected, id=self.GetId())
63          EVT_IDLE(self, self.OnIdle)          self.Bind(wx.EVT_IDLE, self.OnIdle)
64    
65      def __del__(self):      def __del__(self):
66          wxListCtrl.__del__()          wx.ListCtrl.__del__()
67          Publisher.__del__()          Publisher.__del__()
68    
69      def _subscribe_proj_files(self):      def _subscribe_proj_files(self):
# Line 87  class ProjectionList(wxListCtrl, Publish Line 87  class ProjectionList(wxListCtrl, Publish
87          # an instance of ProjectionList anymore as wxPython replaces          # an instance of ProjectionList anymore as wxPython replaces
88          # self.__class__ with its dead object class          # self.__class__ with its dead object class
89          Publisher.Destroy(self)          Publisher.Destroy(self)
90          wxListCtrl.Destroy(self)          wx.ListCtrl.Destroy(self)
91    
92      def update_on_idle(self):      def update_on_idle(self):
93          self.needs_update = True          self.needs_update = True
# Line 126  class ProjectionList(wxListCtrl, Publish Line 126  class ProjectionList(wxListCtrl, Publish
126          # selected with indices higher than the new count.          # selected with indices higher than the new count.
127          if len(self.projections) < old_length:          if len(self.projections) < old_length:
128              for i in xrange(len(self.projections), old_length):              for i in xrange(len(self.projections), old_length):
129                  self.SetItemState(i, 0, wxLIST_STATE_SELECTED)                  self.SetItemState(i, 0, wx.LIST_STATE_SELECTED)
130    
131          self.SetItemCount(len(self.projections))          self.SetItemCount(len(self.projections))
132    
# Line 136  class ProjectionList(wxListCtrl, Publish Line 136  class ProjectionList(wxListCtrl, Publish
136          for i in xrange(len(self.projections)):          for i in xrange(len(self.projections)):
137              p = self.projections[i][1]              p = self.projections[i][1]
138              if get(id(p)):              if get(id(p)):
139                  state = wxLIST_STATE_SELECTED                  state = wx.LIST_STATE_SELECTED
140                  count += 1                  count += 1
141              else:              else:
142                  state = 0                  state = 0
143              self.SetItemState(i, state, wxLIST_STATE_SELECTED)              self.SetItemState(i, state, wx.LIST_STATE_SELECTED)
144    
145          # If the selection changed send a PROJ_SELECTION_CHANGED message          # If the selection changed send a PROJ_SELECTION_CHANGED message
146          if count != len(selection):          if count != len(selection):
# Line 178  class ProjectionList(wxListCtrl, Publish Line 178  class ProjectionList(wxListCtrl, Publish
178          # wxLIST_STATE_SELECTED is set, some other item is focused and          # wxLIST_STATE_SELECTED is set, some other item is focused and
179          # the first time the focus is moved with the keyboard the          # the first time the focus is moved with the keyboard the
180          # selection moves in unexpected ways.          # selection moves in unexpected ways.
181          state = wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED          state = wx.LIST_STATE_SELECTED|wx.LIST_STATE_FOCUSED
182          for i in range(len(self.projections)):          for i in range(len(self.projections)):
183              p = self.projections[i][1]              p = self.projections[i][1]
184              self.SetItemState(i, p is proj and state or 0, state)              self.SetItemState(i, p is proj and state or 0, state)
# Line 186  class ProjectionList(wxListCtrl, Publish Line 186  class ProjectionList(wxListCtrl, Publish
186      def ClearSelection(self):      def ClearSelection(self):
187          """Deselect all projections."""          """Deselect all projections."""
188          for i in range(len(self.projections)):          for i in range(len(self.projections)):
189              self.SetItemState(i, 0, wxLIST_STATE_SELECTED)              self.SetItemState(i, 0, wx.LIST_STATE_SELECTED)
190    
191      def SetProjFiles(self, proj_files):      def SetProjFiles(self, proj_files):
192          """Set the projfile objects whose projections are shown in the list"""          """Set the projfile objects whose projections are shown in the list"""
# Line 217  class ProjectionList(wxListCtrl, Publish Line 217  class ProjectionList(wxListCtrl, Publish
217          """          """
218          return [self.projections[i][1:]          return [self.projections[i][1:]
219                      for i in range(len(self.projections))                      for i in range(len(self.projections))
220                          if self.GetItemState(i, wxLIST_STATE_SELECTED)]                          if self.GetItemState(i, wx.LIST_STATE_SELECTED)]
221    
222      def _issue_proj_selection_changed(self):      def _issue_proj_selection_changed(self):
223          """Internal: Issue a PROJ_SELECTION_CHANGED message"""          """Internal: Issue a PROJ_SELECTION_CHANGED message"""

Legend:
Removed from v.2699  
changed lines
  Added in v.2700

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26