| 23 | |
| 24 | |
| 25 | class ItemParams(wx.Panel): |
| 26 | def __init__(self, parent, stuff, item, context=None): |
| 27 | # Had to manually set the size here, otherwise column widths couldn't be calculated correctly. See #1878 |
| 28 | wx.Panel.__init__(self, parent, size=(1000, 1000)) |
| 29 | self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)) |
| 30 | |
| 31 | self.mainFrame = gui.mainFrame.MainFrame.getInstance() |
| 32 | |
| 33 | mainSizer = wx.BoxSizer(wx.VERTICAL) |
| 34 | |
| 35 | self.paramList = wx.lib.agw.hypertreelist.HyperTreeList(self, wx.ID_ANY, |
| 36 | agwStyle=wx.TR_HIDE_ROOT | wx.TR_NO_LINES | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_HAS_BUTTONS) |
| 37 | self.paramList.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)) |
| 38 | |
| 39 | mainSizer.Add(self.paramList, 1, wx.ALL | wx.EXPAND, 0) |
| 40 | self.SetSizer(mainSizer) |
| 41 | |
| 42 | self.toggleView = AttributeView.NORMAL |
| 43 | self.stuff = stuff |
| 44 | self.item = item |
| 45 | self.isStuffItem = stuff is not None and item is not None and getattr(stuff, 'item', None) == item |
| 46 | self.isStuffCharge = stuff is not None and item is not None and getattr(stuff, 'charge', None) == item |
| 47 | self.attrInfo = {} |
| 48 | self.attrValues = {} |
| 49 | self._fetchValues() |
| 50 | |
| 51 | self.paramList.AddColumn(_t("Attribute")) |
| 52 | self.paramList.AddColumn(_t("Current Value")) |
| 53 | if self.stuff is not None: |
| 54 | self.paramList.AddColumn(_t("Base Value")) |
| 55 | |
| 56 | self.m_staticline = wx.StaticLine(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL) |
| 57 | mainSizer.Add(self.m_staticline, 0, wx.EXPAND) |
| 58 | bSizer = wx.BoxSizer(wx.HORIZONTAL) |
| 59 | |
| 60 | self.toggleViewBtn = wx.ToggleButton(self, wx.ID_ANY, _t("View Raw Data"), wx.DefaultPosition, wx.DefaultSize, |
| 61 | 0) |
| 62 | bSizer.Add(self.toggleViewBtn, 0, wx.ALIGN_CENTER_VERTICAL) |
| 63 | |
| 64 | self.exportStatsBtn = wx.ToggleButton(self, wx.ID_ANY, _t("Export Item Stats"), wx.DefaultPosition, wx.DefaultSize, |
| 65 | 0) |
| 66 | bSizer.Add(self.exportStatsBtn, 0, wx.ALIGN_CENTER_VERTICAL) |
| 67 | |
| 68 | if stuff is not None: |
| 69 | self.refreshBtn = wx.Button(self, wx.ID_ANY, _t("Refresh"), wx.DefaultPosition, wx.DefaultSize, wx.BU_EXACTFIT) |
| 70 | bSizer.Add(self.refreshBtn, 0, wx.ALIGN_CENTER_VERTICAL) |
| 71 | self.refreshBtn.Bind(wx.EVT_BUTTON, self.RefreshValues) |
| 72 | |
| 73 | mainSizer.Add(bSizer, 0, wx.ALIGN_RIGHT) |
| 74 | |
| 75 | self.imageList = wx.ImageList(16, 16) |
| 76 | |
| 77 | self.PopulateList() |
| 78 | |
| 79 | self.toggleViewBtn.Bind(wx.EVT_TOGGLEBUTTON, self.ToggleViewMode) |
| 80 | self.exportStatsBtn.Bind(wx.EVT_TOGGLEBUTTON, self.ExportItemStats) |
| 81 | self.mainFrame.Bind(GE.ITEM_CHANGED_INPLACE, self.OnUpdateStuff) |
| 82 | |