Merge branch 'master' of evefit.org:pyfa

This commit is contained in:
HomeWorld
2010-09-05 13:27:47 +03:00
4 changed files with 88 additions and 5 deletions

View File

@@ -64,6 +64,13 @@ class Display(wx.ListCtrl):
col.resized = False
self.SetColumnWidth(i, wx.LIST_AUTOSIZE_USEHEADER if col.size is wx.LIST_AUTOSIZE else col.size)
def getColIndex(self, colClass):
for i, col in enumerate(self.activeColumns):
if col.__class__ == colClass:
return i
return None
def resizeChecker(self, event):
if self.activeColumns[event.Column].resizable is False:
event.Veto()
@@ -100,3 +107,11 @@ class Display(wx.ListCtrl):
for sel in selection:
self.Select(sel)
def getColumn(self, point):
x = point[0]
total = 0
for col in xrange(self.GetColumnCount()):
total += self.GetColumnWidth(col)
if total >= x:
return col

View File

@@ -42,6 +42,7 @@ class DroneView(d.Display):
self.mainFrame.Bind(fv.FIT_CHANGED, self.fitChanged)
self.mainFrame.Bind(mb.ITEM_SELECTED, self.addItem)
self.Bind(wx.EVT_LEFT_DCLICK, self.removeItem)
self.Bind(wx.EVT_LEFT_DOWN, self.click)
def fitChanged(self, event):
cFit = controller.Fit.getInstance()
@@ -59,11 +60,25 @@ class DroneView(d.Display):
def removeItem(self, event):
row, _ = self.HitTest(event.Position)
if row != -1:
fitID = self.mainFrame.getActiveFit()
cFit = controller.Fit.getInstance()
cFit.removeDrone(fitID, self.GetItemData(row))
col = self.getColumn(event.Position)
if col not in (self.getColIndex(DroneMore), self.getColIndex(DroneLess)):
fitID = self.mainFrame.getActiveFit()
cFit = controller.Fit.getInstance()
cFit.removeDrone(fitID, self.GetItemData(row))
wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID))
wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID))
def click(self, event):
row, _ = self.HitTest(event.Position)
if row != -1:
col = self.getColumn(event.Position)
cFit = controller.Fit.getInstance()
fitID = self.mainFrame.getActiveFit()
if col == self.getColIndex(DroneMore):
cFit.activateDrone(fitID, row)
wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID))
elif col == self.getColIndex(DroneLess):
cFit.deactivateDrone(fitID, row)
wx.PostEvent(self.mainFrame, fv.FitChanged(fitID=fitID))
class DroneMore(ViewColumn):
name = "Activate Drone"