/[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 1933 by bh, Tue Nov 11 16:37:53 2003 UTC revision 2878 by dpinte, Tue Jun 2 11:06:15 2009 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__()          Publisher.__del__(self)
         Publisher.__del__()  
67    
68      def _subscribe_proj_files(self):      def _subscribe_proj_files(self):
69          """Subscribe to the messages of self.proj_files"""          """Subscribe to the messages of self.proj_files"""
# Line 87  class ProjectionList(wxListCtrl, Publish Line 86  class ProjectionList(wxListCtrl, Publish
86          # an instance of ProjectionList anymore as wxPython replaces          # an instance of ProjectionList anymore as wxPython replaces
87          # self.__class__ with its dead object class          # self.__class__ with its dead object class
88          Publisher.Destroy(self)          Publisher.Destroy(self)
89          wxListCtrl.Destroy(self)          wx.ListCtrl.Destroy(self)
90    
91      def update_on_idle(self):      def update_on_idle(self):
92          self.needs_update = True          self.needs_update = True
# Line 126  class ProjectionList(wxListCtrl, Publish Line 125  class ProjectionList(wxListCtrl, Publish
125          # selected with indices higher than the new count.          # selected with indices higher than the new count.
126          if len(self.projections) < old_length:          if len(self.projections) < old_length:
127              for i in xrange(len(self.projections), old_length):              for i in xrange(len(self.projections), old_length):
128                  self.SetItemState(i, 0, wxLIST_STATE_SELECTED)                  self.SetItemState(i, 0, wx.LIST_STATE_SELECTED)
129    
130          self.SetItemCount(len(self.projections))          self.SetItemCount(len(self.projections))
131    
# Line 136  class ProjectionList(wxListCtrl, Publish Line 135  class ProjectionList(wxListCtrl, Publish
135          for i in xrange(len(self.projections)):          for i in xrange(len(self.projections)):
136              p = self.projections[i][1]              p = self.projections[i][1]
137              if get(id(p)):              if get(id(p)):
138                  state = wxLIST_STATE_SELECTED                  state = wx.LIST_STATE_SELECTED
139                  count += 1                  count += 1
140              else:              else:
141                  state = 0                  state = 0
142              self.SetItemState(i, state, wxLIST_STATE_SELECTED)              self.SetItemState(i, state, wx.LIST_STATE_SELECTED)
143    
144          # If the selection changed send a PROJ_SELECTION_CHANGED message          # If the selection changed send a PROJ_SELECTION_CHANGED message
145          if count != len(selection):          if count != len(selection):
# Line 178  class ProjectionList(wxListCtrl, Publish Line 177  class ProjectionList(wxListCtrl, Publish
177          # wxLIST_STATE_SELECTED is set, some other item is focused and          # wxLIST_STATE_SELECTED is set, some other item is focused and
178          # the first time the focus is moved with the keyboard the          # the first time the focus is moved with the keyboard the
179          # selection moves in unexpected ways.          # selection moves in unexpected ways.
180          state = wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED          state = wx.LIST_STATE_SELECTED|wx.LIST_STATE_FOCUSED
181          for i in range(len(self.projections)):          for i in range(len(self.projections)):
182              p = self.projections[i][1]              p = self.projections[i][1]
183              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 185  class ProjectionList(wxListCtrl, Publish
185      def ClearSelection(self):      def ClearSelection(self):
186          """Deselect all projections."""          """Deselect all projections."""
187          for i in range(len(self.projections)):          for i in range(len(self.projections)):
188              self.SetItemState(i, 0, wxLIST_STATE_SELECTED)              self.SetItemState(i, 0, wx.LIST_STATE_SELECTED)
189    
190      def SetProjFiles(self, proj_files):      def SetProjFiles(self, proj_files):
191          """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 216  class ProjectionList(wxListCtrl, Publish
216          """          """
217          return [self.projections[i][1:]          return [self.projections[i][1:]
218                      for i in range(len(self.projections))                      for i in range(len(self.projections))
219                          if self.GetItemState(i, wxLIST_STATE_SELECTED)]                          if self.GetItemState(i, wx.LIST_STATE_SELECTED)]
220    
221      def _issue_proj_selection_changed(self):      def _issue_proj_selection_changed(self):
222          """Internal: Issue a PROJ_SELECTION_CHANGED message"""          """Internal: Issue a PROJ_SELECTION_CHANGED message"""

Legend:
Removed from v.1933  
changed lines
  Added in v.2878

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26