Tweaks and bugfixes related to tab spawning

This commit is contained in:
cncfanatics
2010-11-25 16:20:44 +01:00
parent bb827fdb54
commit fb6fd8662e
2 changed files with 20 additions and 9 deletions

View File

@@ -25,11 +25,10 @@ import gui.marketBrowser
import gui.display as d
from gui.contextMenu import ContextMenu
import gui.shipBrowser
import gui.multiSwitch
from eos.types import Slot
from gui.builtinViewColumns.state import State
import gui.multiSwitch
from gui import bitmapLoader
import gui.shipBrowser
FitChanged, FIT_CHANGED = wx.lib.newevent.NewEvent()
@@ -59,8 +58,19 @@ class FitSpawner(gui.multiSwitch.TabSpawner):
def handleDrag(self, type, fitID):
if type == "fit":
for page in self.multiSwitch.pages:
if isinstance(page, FittingView) and page.activeFitID == fitID:
index = self.multiSwitch.GetPageIndex(page)
self.multiSwitch.SetSelection(index)
return
elif isinstance(page, gui.multiSwitch.BlankPage):
view = FittingView(self.multiSwitch)
self.multiSwitch.ReplaceActivePage(view)
view.handleDrag(type, fitID)
return
view = FittingView(self.multiSwitch)
self.multiSwitch.ReplaceActivePage(view)
self.multiSwitch.AddPage(view)
view.handleDrag(type, fitID)
FitSpawner.register()

View File

@@ -29,10 +29,7 @@ class MultiSwitch(gui.chromeTabs.PFNotebook):
for type in TabSpawner.tabTypes:
handlers.append(type(self))
def handleDrag(self, type, info, spawnTab=True):
if spawnTab:
self.AddPage()
def handleDrag(self, type, info):
for handler in self.handlers:
h = getattr(handler, "handleDrag", None)
if h:
@@ -40,8 +37,8 @@ class MultiSwitch(gui.chromeTabs.PFNotebook):
def AddPage(self, tabWnd=None, tabTitle="Empty Tab", tabImage=None):
if tabWnd is None:
tabWnd = wx.Panel(self, size=(0, 0))
tabWnd.handleDrag = lambda type, info: self.handleDrag(type, info, False)
tabWnd = BlankPage(self)
tabWnd.handleDrag = lambda type, info: self.handleDrag(type, info)
gui.chromeTabs.PFNotebook.AddPage(self, tabWnd, tabTitle, tabImage, True)
@@ -52,6 +49,10 @@ class MultiSwitch(gui.chromeTabs.PFNotebook):
else:
gui.mainFrame.MainFrame.getInstance().Close()
class BlankPage(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, size=(0, 0))
class TabSpawner(object):
tabTypes = []
@classmethod