Add native checkboxes to drone view

This commit is contained in:
cncfanatics
2010-09-05 11:54:40 +02:00
parent 22f0d35742
commit 2180f2639a
6 changed files with 58 additions and 52 deletions

View File

@@ -1,5 +1,5 @@
__all__ = ["moduleState", "moduleNameOrSlot", "attributeDisplay", "maxRange",
"name", "droneDps", "droneNameAmount"]
"name", "droneDps", "droneNameAmount", "checkbox"]
columns = {}
def registerColumn(column):

View File

@@ -0,0 +1,51 @@
#===============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
#
# pyfa is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyfa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
import gui.mainFrame
import wx
class Checkbox(ViewColumn):
name = "Checkbox"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
self.resizable = False
self.size = 16
self.checked = False
for name, state in (("checked", wx.CONTROL_CHECKED), ("unchecked", 0)):
bitmap = wx.EmptyBitmap(16, 16)
dc = wx.MemoryDC()
dc.SelectObject(bitmap)
dc.SetBackground(wx.TheBrushList.FindOrCreateBrush(fittingView.GetBackgroundColour(), wx.SOLID))
dc.Clear()
wx.RendererNative.Get().DrawCheckBox(fittingView, dc, wx.Rect(0, 0, 16, 16), state)
setattr(self, "%sId" % name, fittingView.imageList.Add(bitmap))
def getText(self, mod):
return ""
def getImageId(self, mod):
if self.checked:
return self.checkedId
else:
return self.uncheckedId
builtinViewColumns.registerColumn(Checkbox)

View File

@@ -20,17 +20,14 @@
import wx
import controller
import gui.mainFrame
from gui import bitmapLoader
import gui.fittingView as fv
import gui.marketBrowser as mb
import gui.builtinViewColumns.display as d
from gui.builtinViewColumns import registerColumn
from gui.viewColumn import ViewColumn
from gui.builtinViewColumns.checkbox import Checkbox
class DroneView(d.Display):
DEFAULT_COLS = ["Activate Drone",
"Deactivate Drone",
DEFAULT_COLS = ["Checkbox",
"Drone Name/Amount",
"Drone DPS",
"Max range",
@@ -61,7 +58,7 @@ class DroneView(d.Display):
row, _ = self.HitTest(event.Position)
if row != -1:
col = self.getColumn(event.Position)
if col not in (self.getColIndex(DroneMore), self.getColIndex(DroneLess)):
if col != self.getColIndex(Checkbox):
fitID = self.mainFrame.getActiveFit()
cFit = controller.Fit.getInstance()
cFit.removeDrone(fitID, self.GetItemData(row))
@@ -71,44 +68,5 @@ class DroneView(d.Display):
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"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
bitmap = bitmapLoader.getBitmap("more_small", "icons")
self.moreId = fittingView.imageList.Add(bitmap)
self.size = 16
self.columnText = ""
def getText(self, drone):
return ""
def getImageId(self, mod):
return self.moreId
class DroneLess(ViewColumn):
name = "Deactivate Drone"
def __init__(self, fittingView, params):
ViewColumn.__init__(self, fittingView)
bitmap = bitmapLoader.getBitmap("less_small", "icons")
self.lessId = fittingView.imageList.Add(bitmap)
self.size = 16
self.columnText = ""
def getText(self, drone):
return ""
def getImageId(self, mod):
return self.lessId
registerColumn(DroneMore)
registerColumn(DroneLess)
if col == self.getColIndex(Checkbox):
pass

View File

@@ -1,3 +0,0 @@
[Dolphin]
ShowPreview=true
Timestamp=2010,8,13,20,51,36

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 B