| 60 | return menuItem |
| 61 | |
| 62 | def getSubMenu(self, callingWindow, context, rootMenu, i, pitem): |
| 63 | msw = True if "wxMSW" in wx.PlatformInfo else False |
| 64 | self.context = context |
| 65 | self.fitMenuItemIds = {} |
| 66 | |
| 67 | sub = wx.Menu() |
| 68 | |
| 69 | if len(self.__class__.commandFits) < 15: |
| 70 | for fit in sorted(self.__class__.commandFits, key=lambda x: x.name): |
| 71 | menuItem = self.addFit(rootMenu if msw else sub, fit, True) |
| 72 | sub.Append(menuItem) |
| 73 | else: |
| 74 | typeDict = {} |
| 75 | |
| 76 | for fit in self.__class__.commandFits: |
| 77 | shipName = fit.ship.item.name |
| 78 | if shipName not in typeDict: |
| 79 | typeDict[shipName] = [] |
| 80 | typeDict[shipName].append(fit) |
| 81 | |
| 82 | for ship in sorted(typeDict.keys()): |
| 83 | shipItem = wx.MenuItem(sub, ContextMenuUnconditional.nextID(), ship) |
| 84 | grandSub = wx.Menu() |
| 85 | shipItem.SetSubMenu(grandSub) |
| 86 | |
| 87 | for fit in sorted(typeDict[ship], key=lambda x: x.name): |
| 88 | fitItem = self.addFit(rootMenu if msw else grandSub, fit, False) |
| 89 | grandSub.Append(fitItem) |
| 90 | |
| 91 | sub.Append(shipItem) |
| 92 | |
| 93 | return sub |
| 94 | |
| 95 | def handleSelection(self, event): |
| 96 | fit = self.fitMenuItemIds[event.Id] |