Pass calling window to context menu
This commit is contained in:
@@ -212,7 +212,7 @@ class BoosterView(d.Display):
|
||||
mainBooster = booster
|
||||
sourceContext = "boosterItem"
|
||||
itemContext = None if mainBooster is None else "Booster"
|
||||
menu = ContextMenu.getMenu(mainBooster, selection, (sourceContext, itemContext))
|
||||
menu = ContextMenu.getMenu(self, mainBooster, selection, (sourceContext, itemContext))
|
||||
if menu:
|
||||
self.PopupMenu(menu)
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ class CargoView(d.Display):
|
||||
mainCargo = cargo
|
||||
sourceContext = "cargoItem"
|
||||
itemContext = None if mainCargo is None else Market.getInstance().getCategoryByItem(mainCargo.item).name
|
||||
menu = ContextMenu.getMenu(mainCargo, selection, (sourceContext, itemContext))
|
||||
menu = ContextMenu.getMenu(self, mainCargo, selection, (sourceContext, itemContext))
|
||||
if menu:
|
||||
self.PopupMenu(menu)
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ class CommandView(d.Display):
|
||||
if mainCommandFit is not None:
|
||||
contexts.append(('commandFit', 'Command Fit'))
|
||||
contexts.append(('commandView',))
|
||||
menu = ContextMenu.getMenu(mainCommandFit, selection, *contexts)
|
||||
menu = ContextMenu.getMenu(self, mainCommandFit, selection, *contexts)
|
||||
if menu:
|
||||
self.PopupMenu(menu)
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ class DroneView(Display):
|
||||
selection = self.getSelectedDrones()
|
||||
sourceContext = "droneItem"
|
||||
itemContext = None if mainDrone is None else Market.getInstance().getCategoryByItem(mainDrone.item).name
|
||||
menu = ContextMenu.getMenu(mainDrone, selection, (sourceContext, itemContext))
|
||||
menu = ContextMenu.getMenu(self, mainDrone, selection, (sourceContext, itemContext))
|
||||
if menu:
|
||||
self.PopupMenu(menu)
|
||||
|
||||
|
||||
@@ -361,7 +361,7 @@ class FighterDisplay(d.Display):
|
||||
mainFighter = fighter
|
||||
sourceContext = "fighterItem"
|
||||
itemContext = None if mainFighter is None else Market.getInstance().getCategoryByItem(mainFighter.item).name
|
||||
menu = ContextMenu.getMenu(mainFighter, selection, (sourceContext, itemContext))
|
||||
menu = ContextMenu.getMenu(self, mainFighter, selection, (sourceContext, itemContext))
|
||||
if menu:
|
||||
self.PopupMenu(menu)
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ class ImplantDisplay(d.Display):
|
||||
sourceContext1 = "implantItem" if fit.implantSource == ImplantLocation.FIT else "implantItemChar"
|
||||
sourceContext2 = "implantView" if fit.implantSource == ImplantLocation.FIT else "implantViewChar"
|
||||
itemContext = None if mainImplant is None else Market.getInstance().getCategoryByItem(mainImplant.item).name
|
||||
menu = ContextMenu.getMenu(mainImplant, selection, (sourceContext1, itemContext), (sourceContext2, itemContext))
|
||||
menu = ContextMenu.getMenu(self, mainImplant, selection, (sourceContext1, itemContext), (sourceContext2, itemContext))
|
||||
if menu:
|
||||
self.PopupMenu(menu)
|
||||
|
||||
|
||||
@@ -325,7 +325,7 @@ class ProjectedView(d.Display):
|
||||
contexts.append(('projected',))
|
||||
|
||||
selection = self.getSelectedProjectors()
|
||||
menu = ContextMenu.getMenu(mainItem, selection, *contexts)
|
||||
menu = ContextMenu.getMenu(self, mainItem, selection, *contexts)
|
||||
if menu is not None:
|
||||
self.PopupMenu(menu)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class AmmoToDmgPattern(ContextMenuSingle):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if not self.settings.get('ammoPattern'):
|
||||
return False
|
||||
|
||||
@@ -30,15 +30,15 @@ class AmmoToDmgPattern(ContextMenuSingle):
|
||||
|
||||
return False
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Set {} as Damage Pattern".format(itmContext if itmContext is not None else "Item")
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
Fit.getInstance().setAsPattern(fitID, mainItem)
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,)))
|
||||
|
||||
def getBitmap(self, context, mainItem):
|
||||
def getBitmap(self, callingWindow, context, mainItem):
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class BoosterSideEffects(ContextMenuSingle):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if self.mainFrame.getActiveFit() is None or srcContext not in "boosterItem":
|
||||
return False
|
||||
|
||||
@@ -27,7 +27,7 @@ class BoosterSideEffects(ContextMenuSingle):
|
||||
|
||||
return False
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Side Effects"
|
||||
|
||||
def addEffect(self, menu, ability):
|
||||
@@ -39,7 +39,7 @@ class BoosterSideEffects(ContextMenuSingle):
|
||||
menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
|
||||
return menuItem
|
||||
|
||||
def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, mainItem, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
self.context = context
|
||||
self.effectIds = {}
|
||||
|
||||
@@ -9,7 +9,7 @@ class AddToCargo(ContextMenuSingle):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if srcContext not in ("marketItemGroup", "marketItemMisc"):
|
||||
return False
|
||||
|
||||
@@ -25,10 +25,10 @@ class AddToCargo(ContextMenuSingle):
|
||||
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Add {} to Cargo".format(itmContext)
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
typeID = int(mainItem.ID)
|
||||
command = cmd.GuiAddCargoCommand(fitID=fitID, itemID=typeID, amount=1)
|
||||
|
||||
@@ -8,7 +8,7 @@ class AddToCargoAmmo(ContextMenuSingle):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if srcContext not in ("marketItemGroup", "marketItemMisc") or self.mainFrame.getActiveFit() is None:
|
||||
return False
|
||||
|
||||
@@ -20,10 +20,10 @@ class AddToCargoAmmo(ContextMenuSingle):
|
||||
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Add {0} to Cargo (x1000)".format(itmContext)
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
typeID = int(mainItem.ID)
|
||||
command = cmd.GuiAddCargoCommand(fitID=fitID, itemID=typeID, amount=1000)
|
||||
|
||||
@@ -40,13 +40,13 @@ class AddCommandFit(ContextMenuUnconditional):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
if self.mainFrame.getActiveFit() is None or len(self.__class__.commandFits) == 0 or srcContext != "commandView":
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
return "Command Fits"
|
||||
|
||||
def addFit(self, menu, fit, includeShip=False):
|
||||
@@ -57,7 +57,7 @@ class AddCommandFit(ContextMenuUnconditional):
|
||||
menu.Bind(wx.EVT_MENU, self.handleSelection, menuItem)
|
||||
return menuItem
|
||||
|
||||
def getSubMenu(self, context, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
self.context = context
|
||||
self.fitMenuItemIds = {}
|
||||
|
||||
@@ -16,14 +16,14 @@ class ChangeDamagePattern(ContextMenuUnconditional):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
return srcContext == "resistancesViewFull"
|
||||
|
||||
@property
|
||||
def enabled(self):
|
||||
return self.mainFrame.getActiveFit() is not None
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
sDP = import_DamagePattern.getInstance()
|
||||
sFit = Fit.getInstance()
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
@@ -75,7 +75,7 @@ class ChangeDamagePattern(ContextMenuUnconditional):
|
||||
menuItem.SetBitmap(bitmap)
|
||||
return menuItem
|
||||
|
||||
def getSubMenu(self, context, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
|
||||
if self.m[i] not in self.subMenus:
|
||||
|
||||
@@ -10,7 +10,7 @@ class DroneAddStack(ContextMenuSingle):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if srcContext not in ('marketItemGroup', 'marketItemMisc'):
|
||||
return False
|
||||
|
||||
@@ -32,11 +32,11 @@ class DroneAddStack(ContextMenuSingle):
|
||||
self.amount = amount
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return 'Add {} to Drone Bay{}'.format(
|
||||
itmContext, '' if self.amount == 1 else ' (x{})'.format(self.amount))
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
command = cmd.GuiAddLocalDroneCommand(
|
||||
fitID=self.mainFrame.getActiveFit(),
|
||||
itemID=int(mainItem.ID),
|
||||
|
||||
@@ -14,7 +14,7 @@ class DroneSplitStack(ContextMenuSingle):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if srcContext != "droneItem":
|
||||
return False
|
||||
|
||||
@@ -23,10 +23,10 @@ class DroneSplitStack(ContextMenuSingle):
|
||||
|
||||
return mainItem.amount > 1
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Split {} Stack".format(itmContext)
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
dlg = DroneStackSplit(self.mainFrame, mainItem.amount)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
|
||||
@@ -26,13 +26,13 @@ class AddEnvironmentEffect(ContextMenuUnconditional):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
return srcContext == "projected"
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
return "Add Environmental Effect"
|
||||
|
||||
def getSubMenu(self, context, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
|
||||
# Wormholes
|
||||
|
||||
@@ -12,17 +12,17 @@ class FactorReload(ContextMenuUnconditional):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
return srcContext == "firepowerViewFull"
|
||||
|
||||
@property
|
||||
def enabled(self):
|
||||
return self.mainFrame.getActiveFit() is not None
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
return "Factor in Reload Time"
|
||||
|
||||
def activate(self, fullContext, i):
|
||||
def activate(self, callingWindow, fullContext, i):
|
||||
fitIDs = Fit.getInstance().toggleFactorReload()
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=tuple(fitIDs)))
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class FighterAbilities(ContextMenuCombined):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.isProjected = None
|
||||
|
||||
def display(self, srcContext, mainItem, selection):
|
||||
def display(self, callingWindow, srcContext, mainItem, selection):
|
||||
if self.mainFrame.getActiveFit() is None or srcContext not in ("fighterItem", "projectedFighter"):
|
||||
return False
|
||||
|
||||
@@ -26,7 +26,7 @@ class FighterAbilities(ContextMenuCombined):
|
||||
self.isProjected = True if srcContext == "projectedFighter" else False
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem, selection):
|
||||
def getText(self, callingWindow, itmContext, mainItem, selection):
|
||||
return "Abilities"
|
||||
|
||||
def addAbility(self, menu, ability):
|
||||
@@ -37,7 +37,7 @@ class FighterAbilities(ContextMenuCombined):
|
||||
menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
|
||||
return menuItem
|
||||
|
||||
def getSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, mainItem, selection, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
self.context = context
|
||||
self.abilityIds = {}
|
||||
|
||||
@@ -13,17 +13,17 @@ class AddCurrentlyOpenFit(ContextMenuUnconditional):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
|
||||
if self.mainFrame.getActiveFit() is None or srcContext not in ('projected', 'commandView'):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
return 'Add Currently Open Fit'
|
||||
|
||||
def getSubMenu(self, context, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
|
||||
self.fitLookup = {}
|
||||
self.context = context
|
||||
sFit = Fit.getInstance()
|
||||
|
||||
@@ -11,7 +11,7 @@ class OpenFitInNewTab(ContextMenuSingle):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if srcContext not in ("projectedFit", "commandFit"):
|
||||
return False
|
||||
|
||||
@@ -24,10 +24,10 @@ class OpenFitInNewTab(ContextMenuSingle):
|
||||
return False
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Open Fit in New Tab"
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
wx.PostEvent(self.mainFrame, FitSelected(fitID=mainItem.ID, startup=2))
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class FitSystemSecurityMenu(ContextMenuUnconditional):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
if srcContext != "fittingShip":
|
||||
return False
|
||||
|
||||
@@ -33,7 +33,7 @@ class FitSystemSecurityMenu(ContextMenuUnconditional):
|
||||
|
||||
return True
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
return "Citadel System Security"
|
||||
|
||||
def addOption(self, menu, optionLabel):
|
||||
@@ -43,7 +43,7 @@ class FitSystemSecurityMenu(ContextMenuUnconditional):
|
||||
menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
|
||||
return menuItem
|
||||
|
||||
def getSubMenu(self, context, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
fit = Fit.getInstance().getFit(fitID)
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
|
||||
@@ -13,13 +13,13 @@ class GraphDmgApplyProjectedMenu(ContextMenuUnconditional):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = GraphSettings.getInstance()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
return srcContext == 'dmgStatsGraph'
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
return 'Apply Attacker Webs and TPs'
|
||||
|
||||
def activate(self, fullContext, i):
|
||||
def activate(self, callingWindow, fullContext, i):
|
||||
self.settings.set('applyProjected', not self.settings.get('applyProjected'))
|
||||
wx.PostEvent(self.mainFrame, GE.GraphOptionChanged())
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ class GraphDmgDroneModeMenu(ContextMenuUnconditional):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = GraphSettings.getInstance()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
return srcContext == 'dmgStatsGraph'
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
return 'Drone Mode'
|
||||
|
||||
def handleModeSwitch(self, event):
|
||||
@@ -29,7 +29,7 @@ class GraphDmgDroneModeMenu(ContextMenuUnconditional):
|
||||
self.settings.set('mobileDroneMode', option)
|
||||
wx.PostEvent(self.mainFrame, GE.GraphOptionChanged())
|
||||
|
||||
def getSubMenu(self, context, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
|
||||
m = wx.Menu()
|
||||
if "wxMSW" in wx.PlatformInfo:
|
||||
bindmenu = rootMenu
|
||||
|
||||
@@ -13,13 +13,13 @@ class GraphDmgIgnoreResistsMenu(ContextMenuUnconditional):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = GraphSettings.getInstance()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
return srcContext == 'dmgStatsGraph'
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
return 'Ignore Target Resists'
|
||||
|
||||
def activate(self, fullContext, i):
|
||||
def activate(self, callingWindow, fullContext, i):
|
||||
self.settings.set('ignoreResists', not self.settings.get('ignoreResists'))
|
||||
wx.PostEvent(self.mainFrame, GE.GraphOptionChanged())
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class AddImplantSet(ContextMenuSingle):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
|
||||
sIS = s_ImplantSets.getInstance()
|
||||
implantSets = sIS.getImplantSetList()
|
||||
@@ -23,10 +23,10 @@ class AddImplantSet(ContextMenuSingle):
|
||||
return False
|
||||
return srcContext in ("implantView", "implantEditor")
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Add Implant Set"
|
||||
|
||||
def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, mainItem, rootMenu, i, pitem):
|
||||
"""
|
||||
A note on the mainItem here: Most context menus act on a fit, so it's easy enough to get the active fit from
|
||||
the MainFrame instance. There's never been a reason to get info from another window, so there's not common
|
||||
|
||||
@@ -18,7 +18,7 @@ class ChangeItemAmount(ContextMenuSingle):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if srcContext not in ("droneItem", "projectedDrone", "cargoItem", "projectedFit", "fighterItem", "projectedFighter"):
|
||||
return False
|
||||
|
||||
@@ -27,10 +27,10 @@ class ChangeItemAmount(ContextMenuSingle):
|
||||
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Change {0} Quantity".format(itmContext)
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
srcContext = fullContext[0]
|
||||
if isinstance(mainItem, es_Fit):
|
||||
|
||||
@@ -10,7 +10,7 @@ class FillWithItem(ContextMenuSingle):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if not self.settings.get('moduleFill'):
|
||||
return False
|
||||
|
||||
@@ -28,10 +28,10 @@ class FillWithItem(ContextMenuSingle):
|
||||
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Fill With Module"
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
self.mainFrame.command.Submit(cmd.GuiFillWithNewLocalModulesCommand(
|
||||
fitID=self.mainFrame.getActiveFit(),
|
||||
itemID=int(mainItem.ID)))
|
||||
|
||||
@@ -7,7 +7,7 @@ class JumpToMarketItem(ContextMenuSingle):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
validContexts = ("marketItemMisc", "fittingModule",
|
||||
"fittingCharge", "droneItem",
|
||||
"implantItem", "boosterItem",
|
||||
@@ -36,10 +36,10 @@ class JumpToMarketItem(ContextMenuSingle):
|
||||
doit = not mainItem.isEmpty if srcContext == "fittingModule" else True
|
||||
return doit
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "{0} Market Group".format(itmContext if itmContext is not None else "Item")
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
srcContext = fullContext[0]
|
||||
if srcContext in ("fittingCharge", "projectedCharge"):
|
||||
item = mainItem.charge
|
||||
|
||||
@@ -11,7 +11,7 @@ class ProjectItem(ContextMenuSingle):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if not self.settings.get('project'):
|
||||
return False
|
||||
|
||||
@@ -30,10 +30,10 @@ class ProjectItem(ContextMenuSingle):
|
||||
|
||||
return mainItem.isType("projected")
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Project {0} onto Fit".format(itmContext)
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
if mainItem.isModule:
|
||||
success = self.mainFrame.command.Submit(cmd.GuiAddProjectedModuleCommand(fitID=fitID, itemID=mainItem.ID))
|
||||
|
||||
@@ -18,7 +18,7 @@ class RemoveItem(ContextMenuCombined):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem, selection):
|
||||
def display(self, callingWindow, srcContext, mainItem, selection):
|
||||
if srcContext not in (
|
||||
"fittingModule", "droneItem",
|
||||
"implantItem", "boosterItem",
|
||||
@@ -35,12 +35,12 @@ class RemoveItem(ContextMenuCombined):
|
||||
self.srcContext = srcContext
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem, selection):
|
||||
def getText(self, callingWindow, itmContext, mainItem, selection):
|
||||
return 'Remove {}{}'.format(
|
||||
itmContext if itmContext is not None else 'Item',
|
||||
' Stack' if self.srcContext in ('droneItem', 'projectedDrone', 'cargoItem', 'projectedFit') else '')
|
||||
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, selection, i):
|
||||
handlerMap = {
|
||||
'fittingModule': self.__handleModule,
|
||||
'droneItem': self.__handleDrone,
|
||||
|
||||
@@ -11,7 +11,7 @@ class ItemStats(ContextMenuSingle):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if srcContext not in (
|
||||
"marketItemGroup", "marketItemMisc",
|
||||
"fittingModule", "fittingCharge",
|
||||
@@ -31,10 +31,10 @@ class ItemStats(ContextMenuSingle):
|
||||
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "{} Stats".format(itmContext if itmContext is not None else "Item")
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
srcContext = fullContext[0]
|
||||
if srcContext == "fittingShip":
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
@@ -16,7 +16,7 @@ class ChangeItemToVariation(ContextMenuCombined):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem, selection):
|
||||
def display(self, callingWindow, srcContext, mainItem, selection):
|
||||
if not self.settings.get('metaSwap'):
|
||||
return False
|
||||
|
||||
@@ -45,10 +45,10 @@ class ChangeItemToVariation(ContextMenuCombined):
|
||||
self.selection = selection
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem, selection):
|
||||
def getText(self, callingWindow, itmContext, mainItem, selection):
|
||||
return 'Variations'
|
||||
|
||||
def getSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, mainItem, selection, rootMenu, i, pitem):
|
||||
self.moduleLookup = {}
|
||||
sFit = Fit.getInstance()
|
||||
fit = sFit.getFit(self.mainFrame.getActiveFit())
|
||||
|
||||
@@ -22,7 +22,7 @@ class ChangeModuleAmmo(ContextMenuCombined):
|
||||
# Format: {type ID: set(loadable, charges)}
|
||||
self.loadableCharges = {}
|
||||
|
||||
def display(self, srcContext, mainItem, selection):
|
||||
def display(self, callingWindow, srcContext, mainItem, selection):
|
||||
if srcContext not in ("fittingModule", "projectedModule"):
|
||||
return False
|
||||
|
||||
@@ -38,7 +38,7 @@ class ChangeModuleAmmo(ContextMenuCombined):
|
||||
self.srcContext = srcContext
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem, selection):
|
||||
def getText(self, callingWindow, itmContext, mainItem, selection):
|
||||
return "Charge"
|
||||
|
||||
def getChargesForMod(self, mod):
|
||||
@@ -130,7 +130,7 @@ class ChangeModuleAmmo(ContextMenuCombined):
|
||||
m.Append(id_, '─ %s ─' % text)
|
||||
m.Enable(id_, False)
|
||||
|
||||
def getSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, mainItem, selection, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
m = wx.Menu()
|
||||
self.chargeIds = {}
|
||||
|
||||
@@ -11,7 +11,7 @@ class FillWithModule(ContextMenuSingle):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
|
||||
if not self.settings.get('moduleFill'):
|
||||
return False
|
||||
@@ -21,10 +21,10 @@ class FillWithModule(ContextMenuSingle):
|
||||
|
||||
return srcContext == "fittingModule"
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Fill With {0}".format(itmContext if itmContext is not None else "Module")
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
|
||||
srcContext = fullContext[0]
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
@@ -13,7 +13,7 @@ class ChangeModuleMutation(ContextMenuSingle):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.eventIDs = {}
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
|
||||
if srcContext != "fittingModule" or self.mainFrame.getActiveFit() is None:
|
||||
return False
|
||||
@@ -26,10 +26,10 @@ class ChangeModuleMutation(ContextMenuSingle):
|
||||
|
||||
return True
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Apply Mutaplasmid" if not mainItem.isMutated else "Revert to {}".format(mainItem.baseItem.name)
|
||||
|
||||
def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, mainItem, rootMenu, i, pitem):
|
||||
if mainItem.isMutated:
|
||||
return None
|
||||
|
||||
@@ -58,7 +58,7 @@ class ChangeModuleMutation(ContextMenuSingle):
|
||||
self.mainFrame.command.Submit(GuiConvertMutatedLocalModuleCommand(
|
||||
fitID=fitID, position=position, mutaplasmid=mutaplasmid))
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
fit = Fit.getInstance().getFit(fitID)
|
||||
if mainItem in fit.modules:
|
||||
@@ -66,7 +66,7 @@ class ChangeModuleMutation(ContextMenuSingle):
|
||||
self.mainFrame.command.Submit(GuiRevertMutatedLocalModuleCommand(
|
||||
fitID=fitID, position=position))
|
||||
|
||||
def getBitmap(self, context, mainItem):
|
||||
def getBitmap(self, callingWindow, context, mainItem):
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class ChangeModuleSpool(ContextMenuSingle):
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
self.resetId = None
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if not self.settings.get('spoolup'):
|
||||
return False
|
||||
|
||||
@@ -34,10 +34,10 @@ class ChangeModuleSpool(ContextMenuSingle):
|
||||
|
||||
return self.mod.item.group.name in ("Precursor Weapon", "Mutadaptive Remote Armor Repairer")
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Spoolup Cycles"
|
||||
|
||||
def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, mainItem, rootMenu, i, pitem):
|
||||
m = wx.Menu()
|
||||
if "wxMSW" in wx.PlatformInfo:
|
||||
bindmenu = rootMenu
|
||||
|
||||
@@ -24,13 +24,13 @@ class ItemGroupPrice(ContextMenuUnconditional, metaclass=ABCMeta):
|
||||
def optionName(self):
|
||||
raise NotImplementedError()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
return srcContext in ("priceViewFull", "priceViewMinimal")
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
return self.label
|
||||
|
||||
def activate(self, fullContext, i):
|
||||
def activate(self, callingWindow, fullContext, i):
|
||||
self.settings.set(self.optionName, not self.settings.get(self.optionName))
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(fitID,)))
|
||||
|
||||
@@ -12,7 +12,7 @@ class JumpToShip(ContextMenuUnconditional):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
if srcContext != "fittingShip":
|
||||
return False
|
||||
fitTabSelected = self.mainFrame.notebookBrowsers.GetSelection() == 1
|
||||
@@ -28,10 +28,10 @@ class JumpToShip(ContextMenuUnconditional):
|
||||
return True
|
||||
return False
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
return "Open in Fitting Browser"
|
||||
|
||||
def activate(self, fullContext, i):
|
||||
def activate(self, callingWindow, fullContext, i):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
ship = Fit.getInstance().getFit(fitID).ship
|
||||
self.mainFrame.notebookBrowsers.SetSelection(1)
|
||||
|
||||
@@ -12,7 +12,7 @@ class ChangeShipTacticalMode(ContextMenuUnconditional):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
if self.mainFrame.getActiveFit() is None or srcContext != "fittingShip":
|
||||
return False
|
||||
|
||||
@@ -25,7 +25,7 @@ class ChangeShipTacticalMode(ContextMenuUnconditional):
|
||||
|
||||
return srcContext == "fittingShip" and self.modes is not None
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
return "Tactical Mode"
|
||||
|
||||
def addMode(self, menu, mode):
|
||||
@@ -36,7 +36,7 @@ class ChangeShipTacticalMode(ContextMenuUnconditional):
|
||||
menu.Bind(wx.EVT_MENU, self.handleMode, menuItem)
|
||||
return menuItem
|
||||
|
||||
def getSubMenu(self, context, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
self.context = context
|
||||
self.modeIds = {}
|
||||
|
||||
@@ -17,7 +17,7 @@ class ChangeAffectingSkills(ContextMenuSingle):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.settings = ContextMenuSettings.getInstance()
|
||||
|
||||
def display(self, srcContext, mainItem):
|
||||
def display(self, callingWindow, srcContext, mainItem):
|
||||
if not self.settings.get('changeAffectingSkills'):
|
||||
return False
|
||||
|
||||
@@ -70,7 +70,7 @@ class ChangeAffectingSkills(ContextMenuSingle):
|
||||
self.skills = sorted(skills, key=lambda x: x.item.name)
|
||||
return len(self.skills) > 0
|
||||
|
||||
def getText(self, itmContext, mainItem):
|
||||
def getText(self, callingWindow, itmContext, mainItem):
|
||||
return "Change %s Skills" % itmContext
|
||||
|
||||
def addSkill(self, rootMenu, skill, i):
|
||||
@@ -85,7 +85,7 @@ class ChangeAffectingSkills(ContextMenuSingle):
|
||||
rootMenu.Bind(wx.EVT_MENU, self.handleSkillChange, menuItem)
|
||||
return menuItem
|
||||
|
||||
def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, mainItem, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
self.skillIds = {}
|
||||
sub = wx.Menu()
|
||||
|
||||
@@ -16,7 +16,7 @@ class TargetProfile(ContextMenuUnconditional):
|
||||
def __init__(self):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
|
||||
def display(self, srcContext):
|
||||
def display(self, callingWindow, srcContext):
|
||||
if self.mainFrame.getActiveFit() is None or srcContext != "firepowerViewFull":
|
||||
return False
|
||||
|
||||
@@ -26,7 +26,7 @@ class TargetProfile(ContextMenuUnconditional):
|
||||
|
||||
return len(self.patterns) > 0
|
||||
|
||||
def getText(self, itmContext):
|
||||
def getText(self, callingWindow, itmContext):
|
||||
# We take into consideration just target resists, so call menu item accordingly
|
||||
return "Target Resists"
|
||||
|
||||
@@ -63,7 +63,7 @@ class TargetProfile(ContextMenuUnconditional):
|
||||
item.SetBitmap(bitmap)
|
||||
return item
|
||||
|
||||
def getSubMenu(self, context, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
|
||||
msw = True if "wxMSW" in wx.PlatformInfo else False
|
||||
self.patternIds = {}
|
||||
self.subMenus = OrderedDict()
|
||||
|
||||
@@ -83,7 +83,7 @@ class ItemAffectedBy(wx.Panel):
|
||||
type_ = stuff.__class__.__name__
|
||||
contexts.append(("itemStats", type_))
|
||||
stuff = stuff if type_ != "Skill" else stuff.item
|
||||
menu = ContextMenu.getMenu(stuff, (stuff,), *contexts)
|
||||
menu = ContextMenu.getMenu(self, stuff, (stuff,), *contexts)
|
||||
self.PopupMenu(menu)
|
||||
|
||||
def ExpandCollapseTree(self):
|
||||
|
||||
@@ -248,7 +248,7 @@ class ItemView(Display):
|
||||
sourceContext = "marketItemMisc" if self.marketBrowser.mode in ("search", "recent") else "marketItemGroup"
|
||||
itemContext = sMkt.getCategoryByItem(item).name
|
||||
|
||||
menu = ContextMenu.getMenu(item, (item,), (sourceContext, itemContext))
|
||||
menu = ContextMenu.getMenu(self, item, (item,), (sourceContext, itemContext))
|
||||
self.PopupMenu(menu)
|
||||
|
||||
def populate(self, items):
|
||||
|
||||
@@ -108,7 +108,7 @@ class ShipItem(SFItem.SFBrowserItem):
|
||||
pos = event.GetPosition()
|
||||
pos = self.ScreenToClient(pos)
|
||||
contexts = [("baseShip", "Ship Basic")]
|
||||
menu = ContextMenu.getMenu(self.baseItem, (self.baseItem,), *contexts)
|
||||
menu = ContextMenu.getMenu(self, self.baseItem, (self.baseItem,), *contexts)
|
||||
self.PopupMenu(menu, pos)
|
||||
|
||||
def OnTimer(self, event):
|
||||
|
||||
@@ -669,7 +669,7 @@ class FittingView(d.Display):
|
||||
contexts.append(fullContext)
|
||||
contexts.append(("fittingShip", "Ship" if not fit.isStructure else "Citadel"))
|
||||
|
||||
menu = ContextMenu.getMenu(mainMod, selection, *contexts)
|
||||
menu = ContextMenu.getMenu(self, mainMod, selection, *contexts)
|
||||
self.PopupMenu(menu)
|
||||
|
||||
def click(self, event):
|
||||
|
||||
@@ -603,18 +603,13 @@ class SkillTreeView(wx.Panel):
|
||||
srcContext = "skillItem"
|
||||
itemContext = "Skill"
|
||||
context = (srcContext, itemContext)
|
||||
menu = ContextMenu.getMenu(eveItem, [eveItem], context)
|
||||
menu = ContextMenu.getMenu(self, eveItem, [eveItem], context)
|
||||
char = self.charEditor.entityEditor.getActiveEntity()
|
||||
if char.name not in ("All 0", "All 5"):
|
||||
menu.AppendSeparator()
|
||||
menu.Append(self.idUnlearned, "Unlearn")
|
||||
for level in range(6):
|
||||
menu.Append(self.idLevels[level], "Level %d" % level)
|
||||
# Doesn't make sense to have these menu items here, as they do not revert skill changes
|
||||
# done in an editor - because these changes are persisted anyway
|
||||
# menu.AppendSeparator()
|
||||
# menu.Append(self.revertID, "Revert")
|
||||
# menu.Append(self.saveID, "Save")
|
||||
menu.Bind(wx.EVT_MENU, self.changeLevel)
|
||||
|
||||
self.PopupMenu(menu)
|
||||
@@ -718,7 +713,7 @@ class ImplantEditorView(BaseImplantEditorView):
|
||||
# fuck good coding practices, passing a pointer to the character editor here for [reasons] =D
|
||||
# (see implantSets context class for info)
|
||||
item = self.Parent.Parent
|
||||
menu = ContextMenu.getMenu(item, (item,), *context)
|
||||
menu = ContextMenu.getMenu(self, item, (item,), *context)
|
||||
|
||||
if menu:
|
||||
self.PopupMenu(menu)
|
||||
|
||||
@@ -38,20 +38,21 @@ class ContextMenu(metaclass=ABCMeta):
|
||||
ContextMenu.menus.append(cls)
|
||||
|
||||
@classmethod
|
||||
def hasMenu(cls, mainItem, selection, *fullContexts):
|
||||
def hasMenu(cls, callingWindow, mainItem, selection, *fullContexts):
|
||||
for i, fullContext in enumerate(fullContexts):
|
||||
srcContext = fullContext[0]
|
||||
for menuHandler in cls.menus:
|
||||
m = menuHandler()
|
||||
if m._baseDisplay(srcContext, mainItem, selection):
|
||||
if m._baseDisplay(callingWindow, srcContext, mainItem, selection):
|
||||
return True
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def getMenu(cls, mainItem, selection, *fullContexts):
|
||||
def getMenu(cls, callingWindow, mainItem, selection, *fullContexts):
|
||||
"""
|
||||
getMenu returns a menu that is used with wx.PopupMenu.
|
||||
|
||||
callingWindow: window (in wx' sense) which requested menu
|
||||
mainItem: usually, provides item which was clicked. Useful for single-
|
||||
item actions when user has multiple items selected
|
||||
selection: provides a list of what was selected. If only 1 item was
|
||||
@@ -85,22 +86,22 @@ class ContextMenu(metaclass=ABCMeta):
|
||||
for menuHandler in cls.menus:
|
||||
# loop through registered menus
|
||||
m = menuHandler()
|
||||
if m._baseDisplay(srcContext, mainItem, selection):
|
||||
if m._baseDisplay(callingWindow, srcContext, mainItem, selection):
|
||||
display_amount += 1
|
||||
texts = m._baseGetText(itemContext, mainItem, selection)
|
||||
texts = m._baseGetText(callingWindow, itemContext, mainItem, selection)
|
||||
|
||||
if isinstance(texts, str):
|
||||
texts = (texts,)
|
||||
|
||||
bitmap = m._baseGetBitmap(srcContext, mainItem, selection)
|
||||
bitmap = m._baseGetBitmap(callingWindow, srcContext, mainItem, selection)
|
||||
multiple = not isinstance(bitmap, wx.Bitmap)
|
||||
for it, text in enumerate(texts):
|
||||
id = ContextMenu.nextID()
|
||||
check = m.checked
|
||||
rootItem = wx.MenuItem(rootMenu, id, text, kind=wx.ITEM_NORMAL if m.checked is None else wx.ITEM_CHECK)
|
||||
rootMenu.info[id] = (m, fullContext, it)
|
||||
rootMenu.info[id] = (m, callingWindow, fullContext, it)
|
||||
|
||||
sub = m._baseGetSubMenu(srcContext, mainItem, selection, rootMenu, it, rootItem)
|
||||
sub = m._baseGetSubMenu(callingWindow, srcContext, mainItem, selection, rootMenu, it, rootItem)
|
||||
|
||||
if sub is None:
|
||||
# if there is no sub menu, bind the handler to the rootItem
|
||||
@@ -152,13 +153,13 @@ class ContextMenu(metaclass=ABCMeta):
|
||||
menu = event.EventObject
|
||||
stuff = menu.info.get(event.Id)
|
||||
if stuff is not None:
|
||||
menuHandler, context, i = stuff
|
||||
menuHandler, callingWindow, context, i = stuff
|
||||
selection = menu.selection
|
||||
mainItem = menu.mainItem
|
||||
if not hasattr(selection, "__iter__"):
|
||||
selection = (selection,)
|
||||
|
||||
menuHandler._baseActivate(context, mainItem, selection, i)
|
||||
menuHandler._baseActivate(callingWindow, context, mainItem, selection, i)
|
||||
else:
|
||||
event.Skip()
|
||||
|
||||
@@ -190,15 +191,15 @@ class ContextMenu(metaclass=ABCMeta):
|
||||
return True
|
||||
|
||||
@abstractmethod
|
||||
def _baseDisplay(self, context, mainItem, selection):
|
||||
def _baseDisplay(self, callingWindow, context, mainItem, selection):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def _baseGetBitmap(self, context, mainItem, selection):
|
||||
def _baseGetBitmap(self, callingWindow, context, mainItem, selection):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def _baseGetText(self, context, mainItem, selection):
|
||||
def _baseGetText(self, callingWindow, context, mainItem, selection):
|
||||
"""
|
||||
getText should be implemented in child classes, and should return either
|
||||
a string that will make up a menu item label or a list of strings which
|
||||
@@ -209,11 +210,11 @@ class ContextMenu(metaclass=ABCMeta):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def _baseGetSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
def _baseGetSubMenu(self, callingWindow, context, mainItem, selection, rootMenu, i, pitem):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def _baseActivate(self, fullContext, mainItem, selection, i):
|
||||
def _baseActivate(self, callingWindow, fullContext, mainItem, selection, i):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@@ -224,36 +225,36 @@ class ContextMenuUnconditional(ContextMenu, metaclass=ABCMeta):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def display(self, context):
|
||||
def display(self, callingWindow, context):
|
||||
raise NotImplementedError
|
||||
|
||||
def getBitmap(self, context):
|
||||
def getBitmap(self, callingWindow, context):
|
||||
return
|
||||
|
||||
@abstractmethod
|
||||
def getText(self, context):
|
||||
def getText(self, callingWindow, context):
|
||||
raise NotImplementedError
|
||||
|
||||
def getSubMenu(self, context, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
|
||||
return
|
||||
|
||||
def activate(self, fullContext, i):
|
||||
def activate(self, callingWindow, fullContext, i):
|
||||
return
|
||||
|
||||
def _baseDisplay(self, context, mainItem, selection):
|
||||
return self.display(context)
|
||||
def _baseDisplay(self, callingWindow, context, mainItem, selection):
|
||||
return self.display(callingWindow, context)
|
||||
|
||||
def _baseGetBitmap(self, context, mainItem, selection):
|
||||
return self.getBitmap(context)
|
||||
def _baseGetBitmap(self, callingWindow, context, mainItem, selection):
|
||||
return self.getBitmap(callingWindow, context)
|
||||
|
||||
def _baseGetText(self, context, mainItem, selection):
|
||||
return self.getText(context)
|
||||
def _baseGetText(self, callingWindow, context, mainItem, selection):
|
||||
return self.getText(callingWindow, context)
|
||||
|
||||
def _baseGetSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
return self.getSubMenu(context, rootMenu, i, pitem)
|
||||
def _baseGetSubMenu(self, callingWindow, context, mainItem, selection, rootMenu, i, pitem):
|
||||
return self.getSubMenu(callingWindow, context, rootMenu, i, pitem)
|
||||
|
||||
def _baseActivate(self, fullContext, mainItem, selection, i):
|
||||
return self.activate(fullContext, i)
|
||||
def _baseActivate(self, callingWindow, fullContext, mainItem, selection, i):
|
||||
return self.activate(callingWindow, fullContext, i)
|
||||
|
||||
|
||||
class ContextMenuSingle(ContextMenu, metaclass=ABCMeta):
|
||||
@@ -263,36 +264,36 @@ class ContextMenuSingle(ContextMenu, metaclass=ABCMeta):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def display(self, context, mainItem):
|
||||
def display(self, callingWindow, context, mainItem):
|
||||
raise NotImplementedError
|
||||
|
||||
def getBitmap(self, context, mainItem):
|
||||
def getBitmap(self, callingWindow, context, mainItem):
|
||||
return
|
||||
|
||||
@abstractmethod
|
||||
def getText(self, context, mainItem):
|
||||
def getText(self, callingWindow, context, mainItem):
|
||||
raise NotImplementedError
|
||||
|
||||
def getSubMenu(self, context, mainItem, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, mainItem, rootMenu, i, pitem):
|
||||
return
|
||||
|
||||
def activate(self, fullContext, mainItem, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, i):
|
||||
return
|
||||
|
||||
def _baseDisplay(self, context, mainItem, selection):
|
||||
return self.display(context, mainItem)
|
||||
def _baseDisplay(self, callingWindow, context, mainItem, selection):
|
||||
return self.display(callingWindow, context, mainItem)
|
||||
|
||||
def _baseGetBitmap(self, context, mainItem, selection):
|
||||
return self.getBitmap(context, mainItem)
|
||||
def _baseGetBitmap(self, callingWindow, context, mainItem, selection):
|
||||
return self.getBitmap(callingWindow, context, mainItem)
|
||||
|
||||
def _baseGetText(self, context, mainItem, selection):
|
||||
return self.getText(context, mainItem)
|
||||
def _baseGetText(self, callingWindow, context, mainItem, selection):
|
||||
return self.getText(callingWindow, context, mainItem)
|
||||
|
||||
def _baseGetSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
return self.getSubMenu(context, mainItem, rootMenu, i, pitem)
|
||||
def _baseGetSubMenu(self, callingWindow, context, mainItem, selection, rootMenu, i, pitem):
|
||||
return self.getSubMenu(callingWindow, context, mainItem, rootMenu, i, pitem)
|
||||
|
||||
def _baseActivate(self, fullContext, mainItem, selection, i):
|
||||
return self.activate(fullContext, mainItem, i)
|
||||
def _baseActivate(self, callingWindow, fullContext, mainItem, selection, i):
|
||||
return self.activate(callingWindow, fullContext, mainItem, i)
|
||||
|
||||
|
||||
class ContextMenuSelection(ContextMenu, metaclass=ABCMeta):
|
||||
@@ -302,41 +303,41 @@ class ContextMenuSelection(ContextMenu, metaclass=ABCMeta):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def display(self, context, selection):
|
||||
def display(self, callingWindow, context, selection):
|
||||
raise NotImplementedError
|
||||
|
||||
def getBitmap(self, context, selection):
|
||||
def getBitmap(self, callingWindow, context, selection):
|
||||
return
|
||||
|
||||
@abstractmethod
|
||||
def getText(self, context, selection):
|
||||
def getText(self, callingWindow, context, selection):
|
||||
raise NotImplementedError
|
||||
|
||||
def getSubMenu(self, context, selection, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, selection, rootMenu, i, pitem):
|
||||
return
|
||||
|
||||
def activate(self, fullContext, selection, i):
|
||||
def activate(self, callingWindow, fullContext, selection, i):
|
||||
return
|
||||
|
||||
def _baseDisplay(self, context, mainItem, selection):
|
||||
def _baseDisplay(self, callingWindow, context, mainItem, selection):
|
||||
selection = self.__getSelection(selection, mainItem)
|
||||
return self.display(context, selection)
|
||||
return self.display(callingWindow, context, selection)
|
||||
|
||||
def _baseGetBitmap(self, context, mainItem, selection):
|
||||
def _baseGetBitmap(self, callingWindow, context, mainItem, selection):
|
||||
selection = self.__getSelection(selection, mainItem)
|
||||
return self.getBitmap(context, selection)
|
||||
return self.getBitmap(callingWindow, context, selection)
|
||||
|
||||
def _baseGetText(self, context, mainItem, selection):
|
||||
def _baseGetText(self, callingWindow, context, mainItem, selection):
|
||||
selection = self.__getSelection(selection, mainItem)
|
||||
return self.getText(context, selection)
|
||||
return self.getText(callingWindow, context, selection)
|
||||
|
||||
def _baseGetSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
def _baseGetSubMenu(self, callingWindow, context, mainItem, selection, rootMenu, i, pitem):
|
||||
selection = self.__getSelection(selection, mainItem)
|
||||
return self.getSubMenu(context, selection, rootMenu, i, pitem)
|
||||
return self.getSubMenu(callingWindow, context, selection, rootMenu, i, pitem)
|
||||
|
||||
def _baseActivate(self, fullContext, mainItem, selection, i):
|
||||
def _baseActivate(self, callingWindow, fullContext, mainItem, selection, i):
|
||||
selection = self.__getSelection(selection, mainItem)
|
||||
return self.activate(fullContext, selection, i)
|
||||
return self.activate(callingWindow, fullContext, selection, i)
|
||||
|
||||
def __getSelection(self, selection, mainItem):
|
||||
if mainItem is not None and mainItem not in selection:
|
||||
@@ -351,41 +352,41 @@ class ContextMenuCombined(ContextMenu, metaclass=ABCMeta):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def display(self, context, mainItem, selection):
|
||||
def display(self, callingWindow, context, mainItem, selection):
|
||||
raise NotImplementedError
|
||||
|
||||
def getBitmap(self, context, mainItem, selection):
|
||||
def getBitmap(self, callingWindow, context, mainItem, selection):
|
||||
return
|
||||
|
||||
@abstractmethod
|
||||
def getText(self, context, mainItem, selection):
|
||||
def getText(self, callingWindow, context, mainItem, selection):
|
||||
raise NotImplementedError
|
||||
|
||||
def getSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
def getSubMenu(self, callingWindow, context, mainItem, selection, rootMenu, i, pitem):
|
||||
return
|
||||
|
||||
def activate(self, fullContext, mainItem, selection, i):
|
||||
def activate(self, callingWindow, fullContext, mainItem, selection, i):
|
||||
return
|
||||
|
||||
def _baseDisplay(self, context, mainItem, selection):
|
||||
def _baseDisplay(self, callingWindow, context, mainItem, selection):
|
||||
selection = self.__getSelection(selection, mainItem)
|
||||
return self.display(context, mainItem, selection)
|
||||
return self.display(callingWindow, context, mainItem, selection)
|
||||
|
||||
def _baseGetBitmap(self, context, mainItem, selection):
|
||||
def _baseGetBitmap(self, callingWindow, context, mainItem, selection):
|
||||
selection = self.__getSelection(selection, mainItem)
|
||||
return self.getBitmap(context, mainItem, selection)
|
||||
return self.getBitmap(callingWindow, context, mainItem, selection)
|
||||
|
||||
def _baseGetText(self, context, mainItem, selection):
|
||||
def _baseGetText(self, callingWindow, context, mainItem, selection):
|
||||
selection = self.__getSelection(selection, mainItem)
|
||||
return self.getText(context, mainItem, selection)
|
||||
return self.getText(callingWindow, context, mainItem, selection)
|
||||
|
||||
def _baseGetSubMenu(self, context, mainItem, selection, rootMenu, i, pitem):
|
||||
def _baseGetSubMenu(self, callingWindow, context, mainItem, selection, rootMenu, i, pitem):
|
||||
selection = self.__getSelection(selection, mainItem)
|
||||
return self.getSubMenu(context, mainItem, selection, rootMenu, i, pitem)
|
||||
return self.getSubMenu(callingWindow, context, mainItem, selection, rootMenu, i, pitem)
|
||||
|
||||
def _baseActivate(self, fullContext, mainItem, selection, i):
|
||||
def _baseActivate(self, callingWindow, fullContext, mainItem, selection, i):
|
||||
selection = self.__getSelection(selection, mainItem)
|
||||
return self.activate(fullContext, mainItem, selection, i)
|
||||
return self.activate(callingWindow, fullContext, mainItem, selection, i)
|
||||
|
||||
def __getSelection(self, selection, mainItem):
|
||||
if mainItem is not None and mainItem not in selection:
|
||||
|
||||
@@ -163,7 +163,7 @@ class GraphControlPanel(wx.Panel):
|
||||
self._updateInputs(storeInputs=False)
|
||||
|
||||
# Context icon
|
||||
self.contextIcon.Show(ContextMenu.hasMenu(None, None, (view.internalName,)))
|
||||
self.contextIcon.Show(ContextMenu.hasMenu(self, None, None, (view.internalName,)))
|
||||
|
||||
if layout:
|
||||
self.graphFrame.Layout()
|
||||
@@ -346,7 +346,7 @@ class GraphControlPanel(wx.Panel):
|
||||
|
||||
def contextMenuHandler(self, event):
|
||||
viewName = self.graphFrame.getView().internalName
|
||||
menu = ContextMenu.getMenu(None, None, (viewName,))
|
||||
menu = ContextMenu.getMenu(self, None, None, (viewName,))
|
||||
if menu is not None:
|
||||
self.PopupMenu(menu)
|
||||
event.Skip()
|
||||
|
||||
@@ -132,19 +132,18 @@ class StatsPane(wx.Panel):
|
||||
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
|
||||
self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged)
|
||||
|
||||
@staticmethod
|
||||
def contextHandler(contentPanel, tp):
|
||||
def contextHandler(self, contentPanel, tp):
|
||||
viewName = contentPanel.viewName
|
||||
|
||||
def handler(event):
|
||||
menu = ContextMenu.getMenu(None, None, (viewName,))
|
||||
menu = ContextMenu.getMenu(self, None, None, (viewName,))
|
||||
|
||||
if menu is not None:
|
||||
contentPanel.PopupMenu(menu)
|
||||
|
||||
event.Skip()
|
||||
|
||||
if ContextMenu.hasMenu(None, None, (viewName,)):
|
||||
if ContextMenu.hasMenu(self, None, None, (viewName,)):
|
||||
sizer = tp.GetHeaderContentSizer()
|
||||
sizer.AddStretchSpacer()
|
||||
# Add menu
|
||||
|
||||
Reference in New Issue
Block a user