mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 09:40:07 +01:00
Merge branch 'tianzhuqiao-agw_aui_4.0.x' into wxPy-4.0.x
(cherry picked from commit 4dc42a0bf5)
This commit is contained in:
@@ -57,6 +57,9 @@ Changes in this release include the following:
|
||||
even if a different Python (such as Anaconda, EDM or Homebrew) was used to
|
||||
import wxPython. This, of course, caused runtime errors. (#892)
|
||||
|
||||
* Sort pages by dock_pos when added to automatic (agw.aui) notebook. (#882)
|
||||
|
||||
|
||||
|
||||
|
||||
4.0.2 "Cute as a June bug!"
|
||||
|
||||
@@ -4234,6 +4234,7 @@ class AuiManager(wx.EvtHandler):
|
||||
self.Bind(EVT_AUI_PANE_DOCKED, self.OnPaneDocked)
|
||||
|
||||
self.Bind(auibook.EVT_AUINOTEBOOK_BEGIN_DRAG, self.OnTabBeginDrag)
|
||||
self.Bind(auibook.EVT_AUINOTEBOOK_END_DRAG, self.OnTabEndDrag)
|
||||
self.Bind(auibook.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnTabPageClose)
|
||||
self.Bind(auibook.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnTabSelected)
|
||||
|
||||
@@ -5445,6 +5446,17 @@ class AuiManager(wx.EvtHandler):
|
||||
# mark all panes currently managed as docked and hidden
|
||||
saveCapt = {} # see restorecaption param
|
||||
for pane in self._panes:
|
||||
|
||||
# dock the notebook pages
|
||||
if pane.IsNotebookPage():
|
||||
notebook = self._notebooks[pane.notebook_id]
|
||||
idx = notebook.GetPageIndex(pane.window)
|
||||
notebook.RemovePage(idx)
|
||||
pane.window.Reparent(self._frame)
|
||||
nb = self.GetPane(notebook)
|
||||
pane.notebook_id = -1
|
||||
pane.Direction(nb.dock_direction)
|
||||
|
||||
pane.Dock().Hide()
|
||||
saveCapt[pane.name] = pane.caption
|
||||
|
||||
@@ -5759,6 +5771,9 @@ class AuiManager(wx.EvtHandler):
|
||||
if spacer_only or not pane.window:
|
||||
sizer_item = vert_pane_sizer.Add((1, 1), 1, wx.EXPAND)
|
||||
else:
|
||||
if pane.window.GetContainingSizer():
|
||||
# Make sure that there is only one sizer to this window
|
||||
pane.window.GetContainingSizer().Detach(pane.window);
|
||||
sizer_item = vert_pane_sizer.Add(pane.window, 1, wx.EXPAND)
|
||||
vert_pane_sizer.SetItemMinSize(pane.window, (1, 1))
|
||||
|
||||
@@ -6183,7 +6198,12 @@ class AuiManager(wx.EvtHandler):
|
||||
if not dock.fixed:
|
||||
for jj in range(dock_pane_count):
|
||||
pane = dock.panes[jj]
|
||||
pane.dock_pos = jj
|
||||
if pane.IsNotebookPage() and pane.notebook_id < len(self._notebooks):
|
||||
# update dock_pos to its index in notebook
|
||||
notebook = self._notebooks[pane.notebook_id]
|
||||
pane.dock_pos = notebook.GetPageIndex(pane.window)
|
||||
else:
|
||||
pane.dock_pos = jj
|
||||
|
||||
# if the dock mode is fixed, and none of the panes
|
||||
# are being moved right now, make sure the panes
|
||||
@@ -6603,6 +6623,7 @@ class AuiManager(wx.EvtHandler):
|
||||
notebook.DoSizing()
|
||||
|
||||
# Add notebook pages that aren't there already...
|
||||
pages_and_panes = {}
|
||||
for paneInfo in self._panes:
|
||||
if paneInfo.IsNotebookPage():
|
||||
|
||||
@@ -6613,8 +6634,9 @@ class AuiManager(wx.EvtHandler):
|
||||
|
||||
if page_id < 0:
|
||||
|
||||
paneInfo.window.Reparent(notebook)
|
||||
notebook.AddPage(paneInfo.window, title, True, paneInfo.icon)
|
||||
if paneInfo.notebook_id not in pages_and_panes:
|
||||
pages_and_panes[paneInfo.notebook_id] = []
|
||||
pages_and_panes[paneInfo.notebook_id].append(paneInfo)
|
||||
|
||||
# Update title and icon ...
|
||||
else:
|
||||
@@ -6628,6 +6650,16 @@ class AuiManager(wx.EvtHandler):
|
||||
elif paneInfo.IsNotebookControl() and not paneInfo.window:
|
||||
paneInfo.window = self._notebooks[paneInfo.notebook_id]
|
||||
|
||||
for notebook_id, pnp in six.iteritems(pages_and_panes):
|
||||
# sort the panes with dock_pos
|
||||
sorted_pnp = sorted(pnp, key=lambda pane: pane.dock_pos)
|
||||
notebook = self._notebooks[notebook_id]
|
||||
for pane in sorted_pnp:
|
||||
title = (pane.caption == "" and [pane.name] or [pane.caption])[0]
|
||||
pane.window.Reparent(notebook)
|
||||
notebook.AddPage(pane.window, title, True, pane.icon)
|
||||
notebook.DoSizing()
|
||||
|
||||
# Delete empty notebooks, and convert notebooks with 1 page to
|
||||
# normal panes...
|
||||
remap_ids = [-1]*len(self._notebooks)
|
||||
@@ -6666,46 +6698,7 @@ class AuiManager(wx.EvtHandler):
|
||||
|
||||
else:
|
||||
|
||||
# Correct page ordering. The original wxPython code
|
||||
# for this did not work properly, and would misplace
|
||||
# windows causing errors.
|
||||
self._notebooks[nb_idx] = notebook
|
||||
pages = notebook.GetPageCount()
|
||||
selected = notebook.GetPage(notebook.GetSelection())
|
||||
|
||||
# Take each page out of the notebook, group it with
|
||||
# its current pane, and sort the list by pane.dock_pos
|
||||
# order
|
||||
pages_and_panes = []
|
||||
for idx in list(range(pages)):
|
||||
page = notebook.GetPage(idx)
|
||||
pane = self.GetPane(page)
|
||||
pages_and_panes.append((page, pane))
|
||||
|
||||
sorted_pnp = sorted(pages_and_panes, key=lambda tup: tup[1].dock_pos)
|
||||
if sorted_pnp != pages_and_panes:
|
||||
notebook.Freeze()
|
||||
pages_and_panes = []
|
||||
for idx in reversed(list(range(pages))):
|
||||
page = notebook.GetPage(idx)
|
||||
pane = self.GetPane(page)
|
||||
pages_and_panes.append((page, pane))
|
||||
notebook.RemovePage(idx)
|
||||
|
||||
# Grab the attributes from the panes which are ordered
|
||||
# correctly, and copy those attributes to the original
|
||||
# panes. (This avoids having to change the ordering
|
||||
# of self._panes) Then, add the page back into the notebook
|
||||
sorted_attributes = [self.GetAttributes(tup[1])
|
||||
for tup in sorted_pnp]
|
||||
for attrs, tup in zip(sorted_attributes, pages_and_panes):
|
||||
pane = tup[1]
|
||||
self.SetAttributes(pane, attrs)
|
||||
notebook.AddPage(pane.window, pane.caption)
|
||||
|
||||
notebook.SetSelection(notebook.GetPageIndex(selected), True)
|
||||
notebook.DoSizing()
|
||||
notebook.Thaw()
|
||||
|
||||
# It's a keeper.
|
||||
remap_ids[nb] = nb_idx
|
||||
@@ -7418,6 +7411,18 @@ class AuiManager(wx.EvtHandler):
|
||||
# not our window
|
||||
event.Skip()
|
||||
|
||||
def OnTabEndDrag(self, event):
|
||||
"""
|
||||
Handles the ``EVT_AUINOTEBOOK_END_DRAG`` event.
|
||||
|
||||
:param `event`: a :class:`~wx.lib.agw.aui.auibook.AuiNotebookEvent` event to be processed.
|
||||
"""
|
||||
|
||||
if self._masterManager:
|
||||
self._masterManager.OnTabEndDrag(event)
|
||||
else:
|
||||
self.Update()
|
||||
event.Skip()
|
||||
|
||||
def OnTabPageClose(self, event):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user