Revert "Rework the stats pane to be modular, add a short sample on how it works too"
This reverts commit c0bc0c6fe7.
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
__all__ = ["exampleView"]
|
||||
|
||||
columns = {}
|
||||
def registerView(column):
|
||||
columns[column.name] = column
|
||||
|
||||
def getView(name):
|
||||
return columns[name]
|
||||
@@ -1,43 +0,0 @@
|
||||
#===============================================================================
|
||||
# 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/>.
|
||||
#===============================================================================
|
||||
|
||||
import wx
|
||||
from gui.statsView import StatsView
|
||||
from gui import builtinStatsViews
|
||||
|
||||
class ExampleView(StatsView):
|
||||
name = "exampleView"
|
||||
def __init__(self):
|
||||
StatsView.__init__(self)
|
||||
|
||||
def populatePanel(self, panel):
|
||||
self.panel = panel
|
||||
self.mainSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
panel.SetSizer(self.mainSizer)
|
||||
|
||||
self.mainSizer.Add(wx.StaticText(panel, wx.ID_ANY, "Hello world!"))
|
||||
|
||||
def getHeaderText(self, fit):
|
||||
return "MOO"
|
||||
|
||||
def refreshPanel(self, fit):
|
||||
#If we did anything intresting, we'd update our labels to reflect the new fit's stats here
|
||||
pass
|
||||
|
||||
builtinStatsViews.registerView(ExampleView)
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
###########################################################################
|
||||
## pyfatogllepanel.py
|
||||
@@ -6,7 +6,7 @@
|
||||
## Author: Darriele - HomeWorld
|
||||
## Serial: 2010090702 (YYYYMMDDII)
|
||||
## Project home: http://www.evefit.org - pyfa project
|
||||
## http://www.evefit.org is the home for pyfa / eos / aurora
|
||||
## http://www.evefit.org is the home for pyfa / eos / aurora
|
||||
## Some portions of code are based on
|
||||
## AGW:pycollapsiblepane generic implementation of wx.CollapsiblePane
|
||||
## AGW:pycollapsiblepane credits ( from the original source file used ):
|
||||
@@ -30,7 +30,7 @@ from gui import bitmapLoader
|
||||
###########################################################################
|
||||
|
||||
class TogglePanel ( wx.Panel ):
|
||||
|
||||
|
||||
def __init__( self, parent ):
|
||||
wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.TAB_TRAVERSAL )
|
||||
|
||||
@@ -47,7 +47,7 @@ class TogglePanel ( wx.Panel ):
|
||||
self.mainSizer = wx.BoxSizer( wx.VERTICAL )
|
||||
self.SetSizer( self.mainSizer )
|
||||
parentSize = parent.GetMinSize()
|
||||
|
||||
|
||||
# Create the header panel
|
||||
|
||||
self.headerPanel = wx.Panel(self)
|
||||
@@ -56,7 +56,7 @@ class TogglePanel ( wx.Panel ):
|
||||
|
||||
self.mainSizer.Add(self.headerPanel,0,wx.EXPAND,5)
|
||||
|
||||
# Attempt to use native treeitembitmaps - fails on some linux distros / w.mangers
|
||||
# Attempt to use native treeitembitmaps - fails on some linux distros / w.mangers
|
||||
# self.bmpExpanded = self.GetNativeTreeItemBitmap("expanded")
|
||||
# self.bmpCollapsed = self.GetNativeTreeItemBitmap("")
|
||||
#
|
||||
@@ -73,27 +73,27 @@ class TogglePanel ( wx.Panel ):
|
||||
img = self.bmpExpanded.ConvertToImage()
|
||||
img.Replace(0, 0, 0, sysTextColour[0], sysTextColour[1], sysTextColour[2])
|
||||
self.bmpExpanded = wx.BitmapFromImage(img)
|
||||
|
||||
|
||||
img = self.bmpCollapsed.ConvertToImage()
|
||||
img.Replace(0, 0, 0, sysTextColour[0], sysTextColour[1], sysTextColour[2])
|
||||
self.bmpCollapsed = wx.BitmapFromImage(img)
|
||||
|
||||
|
||||
# Assign the bitmaps to the header static bitmap control
|
||||
|
||||
self.headerBmp = wx.StaticBitmap(self.headerPanel )
|
||||
self.headerBmp.SetBitmap( self.bmpExpanded)
|
||||
|
||||
# Create the header sizer and append the static bitmap and static text controls
|
||||
|
||||
# Create the header sizer and append the static bitmap and static text controls
|
||||
|
||||
headerSizer = wx.BoxSizer( wx.HORIZONTAL )
|
||||
self.headerPanel.SetSizer( headerSizer)
|
||||
|
||||
|
||||
hbmpSizer = wx.BoxSizer( wx.HORIZONTAL )
|
||||
hlblSizer = wx.BoxSizer( wx.HORIZONTAL )
|
||||
self.hcntSizer = wx.BoxSizer( wx.HORIZONTAL)
|
||||
|
||||
|
||||
hbmpSizer.Add( self.headerBmp, 0,0, 5 )
|
||||
|
||||
|
||||
self.headerLabel = wx.StaticText( self.headerPanel, wx.ID_ANY, u"PYFA", wx.DefaultPosition, wx.DefaultSize, 0 )
|
||||
hlblSizer.Add( self.headerLabel, 0, wx.EXPAND , 5 )
|
||||
|
||||
@@ -107,18 +107,18 @@ class TogglePanel ( wx.Panel ):
|
||||
headerFont.SetWeight(wx.BOLD)
|
||||
self.headerLabel.SetFont(headerFont)
|
||||
|
||||
# Create the content panel and its main sizer
|
||||
# Create the content panel and its main sizer
|
||||
|
||||
self.contentSizer = wx.BoxSizer( wx.VERTICAL )
|
||||
self.contentPanel = wx.Panel(self)
|
||||
self.contentPanel.SetSizer(self.contentSizer)
|
||||
|
||||
|
||||
self.mainSizer.Add( self.contentPanel, 1, wx.EXPAND, 5)
|
||||
|
||||
|
||||
self.Layout()
|
||||
|
||||
|
||||
|
||||
|
||||
# Connect Events
|
||||
self.headerLabel.Bind( wx.EVT_LEFT_UP, self.toggleContent )
|
||||
@@ -127,15 +127,15 @@ class TogglePanel ( wx.Panel ):
|
||||
self.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||
self.headerPanel.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||
self.contentPanel.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||
|
||||
|
||||
|
||||
|
||||
def __del__( self ):
|
||||
pass
|
||||
|
||||
def OnPaint(self, event):
|
||||
self.contentPanel.Layout()
|
||||
self.headerPanel.Layout()
|
||||
event.Skip()
|
||||
event.Skip()
|
||||
|
||||
def GetHeaderContentSizer(self):
|
||||
return self.hcntSizer
|
||||
@@ -148,15 +148,15 @@ class TogglePanel ( wx.Panel ):
|
||||
def AddSizer(self, sizer):
|
||||
self.contentSizer.Add(sizer, 0, wx.EXPAND | wx.ALL, 0)
|
||||
self.Layout()
|
||||
|
||||
|
||||
def GetContentPane(self):
|
||||
return self.contentPanel
|
||||
|
||||
|
||||
def SetLabel(self, label):
|
||||
self.headerLabel.SetLabel(label)
|
||||
|
||||
|
||||
def GetNativeTreeItemBitmap(self, mode):
|
||||
|
||||
|
||||
bitmap = wx.EmptyBitmap(24, 24)
|
||||
dc = wx.MemoryDC()
|
||||
dc.SelectObject(bitmap)
|
||||
@@ -166,9 +166,9 @@ class TogglePanel ( wx.Panel ):
|
||||
wx.RendererNative.Get().DrawTreeItemButton(self, dc, wx.Rect(0, 0, 24, 24), wx.CONTROL_EXPANDED if mode == "expanded" else 0)
|
||||
|
||||
dc.Destroy()
|
||||
|
||||
return bitmap
|
||||
|
||||
|
||||
return bitmap
|
||||
|
||||
# Virtual event handlers, overide them in your derived class
|
||||
|
||||
def IsCollapsed(self):
|
||||
@@ -200,7 +200,7 @@ class TogglePanel ( wx.Panel ):
|
||||
|
||||
self.parent.GetSizer().SetSizeHints(self.parent)
|
||||
|
||||
|
||||
|
||||
if self.IsCollapsed():
|
||||
# expanded . collapsed transition
|
||||
if self.parent.GetSizer():
|
||||
@@ -210,26 +210,26 @@ class TogglePanel ( wx.Panel ):
|
||||
# use SetClientSize() and not SetSize() otherwise the size for
|
||||
# e.g. a wxFrame with a menubar wouldn't be correctly set
|
||||
self.parent.SetClientSize(sz)
|
||||
|
||||
|
||||
else:
|
||||
self.parent.Layout()
|
||||
|
||||
|
||||
else:
|
||||
|
||||
|
||||
# collapsed . expanded transition
|
||||
|
||||
# force our parent to "fit", i.e. expand so that it can honour
|
||||
# our minimal size
|
||||
self.parent.Fit()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Toggle the content panel (hide/show)
|
||||
|
||||
def toggleContent( self, event ):
|
||||
self.Freeze()
|
||||
self.Freeze()
|
||||
if self._toggle == 1:
|
||||
# self.contentPanel.Hide()
|
||||
self.contentMinSize = self.contentPanel.GetSize()
|
||||
@@ -243,7 +243,7 @@ class TogglePanel ( wx.Panel ):
|
||||
|
||||
self.headerBmp.SetBitmap( self.bmpExpanded)
|
||||
|
||||
|
||||
|
||||
self._toggle *=-1
|
||||
|
||||
self.Thaw()
|
||||
@@ -260,11 +260,11 @@ class TogglePanel ( wx.Panel ):
|
||||
self.headerPanel.Refresh()
|
||||
|
||||
event.Skip()
|
||||
|
||||
|
||||
def leaveWindow( self, event ):
|
||||
|
||||
self.headerPanel.SetBackgroundColour( self.bkColour )
|
||||
self.headerPanel.Refresh()
|
||||
self.headerPanel.Refresh()
|
||||
|
||||
event.Skip()
|
||||
|
||||
|
||||
|
||||
1617
gui/statsPane.py
1617
gui/statsPane.py
File diff suppressed because it is too large
Load Diff
@@ -1,31 +0,0 @@
|
||||
#===============================================================================
|
||||
# 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/>.
|
||||
#===============================================================================
|
||||
|
||||
class StatsView(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def populatePanel(self, panel):
|
||||
raise NotImplementedError()
|
||||
|
||||
def getHeaderText(self, fit):
|
||||
raise NotImplementedError()
|
||||
|
||||
def refreshPanel(self, fit):
|
||||
raise NotImplementedError()
|
||||
Reference in New Issue
Block a user