AGW Logo

svn SVN Revision 68475 For framemanager

This file contains the SVN revision history for framemanager, at revision 68475.

Available information include commit date, the name of the committer, the file size, the SVN log messages and a diff from the previous version (if available).


file_info File Information

  • Commit Date: 02-Apr-2009 14:32:39 UTC
  • Committer: AG
  • File Size: 364831 byte(s)

svn_log Log Messages

The following log message was entered by the committer:

framemanager.py: Implementation of the AUI_MINIMIZE_POS_TOOLBAR flag, which allows to minimize a pane inside an existing toolbar. Limitation: if the minimized icon in the toolbar ends up in the overflowing items (i.e., a menu is needed to show the icon), this style will not work.


svn_diff Diff To Previous Version (68362)

Version SVN diff:

--- wxPython/3rdParty/AGW/agw/aui/framemanager.py   2011/07/24 21:36:47     68362
+++ wxPython/3rdParty/AGW/agw/aui/framemanager.py   2011/07/31 20:22:23     68475
@@ -13,7 +13,7 @@
# Python Code By:
#
# Andrea Gavana, @ 23 Dec 2005
-# Latest Revision: 22 Jul 2011, 21.00 GMT
+# Latest Revision: 31 Jul 2011, 22.00 GMT
#
# For All Kind Of Problems, Requests Of Enhancements And Bug Reports, Please
# Write To Me At:
@@ -30,7 +30,7 @@
Description
===========

-framemanager is the central module of the AUI class framework.
+`framemanager.py` is the central module of the AUI class framework.

L{AuiManager} manages the panes associated with it for a particular `wx.Frame`, using
a pane's L{AuiPaneInfo} information to determine each pane's docking and floating
@@ -547,6 +547,7 @@
self.previousDockPos = None
self.previousDockSize = 0
self.snapped = 0
+        self.minimize_target = None

self.DefaultPane()

@@ -822,7 +823,8 @@
``AUI_MINIMIZE_POS_LEFT``           0x03 Minimizes the pane on its left tool bar
``AUI_MINIMIZE_POS_RIGHT``          0x04 Minimizes the pane on its right tool bar
``AUI_MINIMIZE_POS_BOTTOM``         0x05 Minimizes the pane on its bottom tool bar
-        ``AUI_MINIMIZE_POS_MASK``           0x07 Mask to filter the position flags
+        ``AUI_MINIMIZE_POS_TOOLBAR``        0x06 Minimizes the pane on a target L{AuiToolBar}
+        ``AUI_MINIMIZE_POS_MASK``           0x17 Mask to filter the position flags
``AUI_MINIMIZE_CAPT_HIDE``           0x0 Hides the caption of the minimized pane
``AUI_MINIMIZE_CAPT_SMART``         0x08 Displays the caption in the best rotation (horizontal or clockwise)
``AUI_MINIMIZE_CAPT_HORZ``          0x10 Displays the caption horizontally
@@ -834,7 +836,7 @@
============================== ========= ==============================
Minimize Mask Flag             Hex Value Description
============================== ========= ==============================
-        ``AUI_MINIMIZE_POS_MASK``           0x07 Filters the position flags
+        ``AUI_MINIMIZE_POS_MASK``           0x17 Filters the position flags
``AUI_MINIMIZE_CAPT_MASK``          0x18 Filters the caption flags
============================== ========= ==============================

@@ -1222,6 +1224,7 @@
``AUI_MINIMIZE_POS_LEFT``           0x03 Minimizes the pane on its left tool bar
``AUI_MINIMIZE_POS_RIGHT``          0x04 Minimizes the pane on its right tool bar
``AUI_MINIMIZE_POS_BOTTOM``         0x05 Minimizes the pane on its bottom tool bar
+        ``AUI_MINIMIZE_POS_TOOLBAR``        0x06 Minimizes the pane on a target L{AuiToolBar}
============================== ========= ==============================

The caption of the minimized pane can be displayed in different modes:
@@ -1240,6 +1243,24 @@
return self


+    def MinimizeTarget(self, toolbarPane):
+        """
+        Minimizes the panes using a L{AuiPaneInfo} as a target. As L{AuiPaneInfo} properties
+        need to be copied back and forth every time the perspective has changed, we
+        only store the toobar **name**.
+
+        :param `toolbarPane`: an instance of L{AuiPaneInfo}, containing a L{AuiToolBar}.
+
+        :note: In order to use this functionality (and with the ``AUI_MINIMIZE_POS_TOOLBAR``
+         flag set), the instance of L{AuiPaneInfo} you pass as an input **must** have a real
+         name and not the randomly generated one. Remember to set the L{Name} property of
+         the toolbar pane before calling this method.
+        """
+
+        self.minimize_target = toolbarPane.name
+        return self
+
+
def Restore(self):
""" Is the reverse of L{Maximize} and L{Minimize}."""

@@ -1678,8 +1699,7 @@
self.optionFloatable | self.optionMovable | self.optionResizable | \
self.optionCaption | self.optionPaneBorder | self.buttonClose

-        self.state = state
-
+        self.state = state
return self


@@ -1708,7 +1728,7 @@

def ToolbarPane(self):
""" Specifies that the pane should adopt the default toolbar pane settings. """
-
+
self.DefaultPane()
state = self.state

@@ -2891,6 +2911,7 @@
contained_pane.transparent = pane.transparent
contained_pane.snapped = pane.snapped
contained_pane.minimize_mode = pane.minimize_mode
+        contained_pane.minimize_target = pane.minimize_target

return contained_pane

@@ -3425,6 +3446,7 @@
dest_panes[ii].transparent = src_panes[ii].transparent
dest_panes[ii].snapped = src_panes[ii].snapped
dest_panes[ii].minimize_mode = src_panes[ii].minimize_mode
+        dest_panes[ii].minimize_target = src_panes[ii].minimize_target

for ii in xrange(len(dest_docks)):
dock = dest_docks[ii]
@@ -7416,6 +7438,7 @@
drop.transparent = target.transparent
drop.snapped = target.snapped
drop.minimize_mode = target.minimize_mode
+        drop.minimize_target = target.minimize_target

return drop

@@ -8206,7 +8229,7 @@
pane.floating_pos, pane.floating_size, pane.best_size,
pane.min_size, pane.max_size, pane.caption, pane.name,
pane.buttons, pane.rect, pane.icon, pane.notebook_id,
-                      pane.transparent, pane.snapped, pane.minimize_mode])
+                      pane.transparent, pane.snapped, pane.minimize_mode, pane.minimize_target])

return attrs

@@ -8241,6 +8264,7 @@
pane.transparent = attrs[19]
pane.snapped = attrs[20]
pane.minimize_mode = attrs[21]
+        pane.minimize_target = attrs[22]

return pane

@@ -9793,15 +9817,30 @@
#
# 3) Hide the minimizing pane

-
# personalize the toolbar style
+
tbStyle = AUI_TB_DEFAULT_STYLE
posMask = paneInfo.minimize_mode & AUI_MINIMIZE_POS_MASK
captMask = paneInfo.minimize_mode & AUI_MINIMIZE_CAPT_MASK
dockDirection = paneInfo.dock_direction
if captMask != 0:
tbStyle |= AUI_TB_TEXT
-            if posMask == AUI_MINIMIZE_POS_SMART:
+
+            if posMask == AUI_MINIMIZE_POS_TOOLBAR:
+                minimize_toolbar = self.GetPane(paneInfo.minimize_target)
+                if not minimize_toolbar.IsOk():
+                    posMask = AUI_MINIMIZE_POS_SMART
+                    if paneInfo.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_BOTTOM]:
+                        tbStyle |= AUI_TB_HORZ_LAYOUT
+
+                    elif paneInfo.dock_direction in [AUI_DOCK_LEFT, AUI_DOCK_RIGHT, AUI_DOCK_CENTER]:
+                        tbStyle |= AUI_TB_VERTICAL
+                        if captMask == AUI_MINIMIZE_CAPT_SMART:
+                            tbStyle |= AUI_TB_CLOCKWISE
+                else:
+                    minimize_toolbar = minimize_toolbar.window
+
+            elif posMask == AUI_MINIMIZE_POS_SMART:
if paneInfo.dock_direction in [AUI_DOCK_TOP, AUI_DOCK_BOTTOM]:
tbStyle |= AUI_TB_HORZ_LAYOUT

@@ -9832,17 +9871,29 @@
# give it the same name as the minimized pane with _min appended

win_rect = paneInfo.window.GetScreenRect()
-
-            minimize_toolbar = auibar.AuiToolBar(self.GetManagedWindow(), agwStyle=tbStyle)
-            minimize_toolbar.Hide()
-            minimize_toolbar.SetToolBitmapSize(wx.Size(16, 16))
+
+            if posMask != AUI_MINIMIZE_POS_TOOLBAR:
+                minimize_toolbar = auibar.AuiToolBar(self.GetManagedWindow(), agwStyle=tbStyle)
+                minimize_toolbar.Hide()
+                minimize_toolbar.SetToolBitmapSize(wx.Size(16, 16))

if paneInfo.icon and paneInfo.icon.IsOk():
restore_bitmap = paneInfo.icon
else:
restore_bitmap = self._art._restore_bitmap
+
+            if posMask == AUI_MINIMIZE_POS_TOOLBAR:
+                xsize, ysize = minimize_toolbar.GetToolBitmapSize()
+                if xsize != restore_bitmap.GetWidth():
+                    img = restore_bitmap.ConvertToImage()
+                    img.Rescale(xsize, ysize, wx.IMAGE_QUALITY_HIGH)
+                    restore_bitmap = img.ConvertToBitmap()
+
+            target = None
+            if posMask == AUI_MINIMIZE_POS_TOOLBAR:
+                target = paneInfo.name

-            minimize_toolbar.AddSimpleTool(ID_RESTORE_FRAME, paneInfo.caption, restore_bitmap, "Restore " + paneInfo.caption)
+            minimize_toolbar.AddSimpleTool(ID_RESTORE_FRAME, paneInfo.caption, restore_bitmap, "Restore " + paneInfo.caption, target=target)
minimize_toolbar.SetAuiManager(self)
minimize_toolbar.Realize()
toolpanelname = paneInfo.name + "_min"
@@ -9850,29 +9901,31 @@
if paneInfo.IsMaximized():
paneInfo.SetFlag(paneInfo.wasMaximized, True)

-            if dockDirection == AUI_DOCK_TOP:
-                self.AddPane(minimize_toolbar, AuiPaneInfo(). \
-                    Name(toolpanelname).Caption(paneInfo.caption). \
-                    ToolbarPane().Top().BottomDockable(False). \
-                    LeftDockable(False).RightDockable(False).DestroyOnClose())
-
-            elif dockDirection == AUI_DOCK_BOTTOM:
-                self.AddPane(minimize_toolbar, AuiPaneInfo(). \
-                    Name(toolpanelname).Caption(paneInfo.caption). \
-                    ToolbarPane().Bottom().TopDockable(False). \
-                    LeftDockable(False).RightDockable(False).DestroyOnClose())
-
-            elif dockDirection == AUI_DOCK_LEFT:
-                self.AddPane(minimize_toolbar, AuiPaneInfo(). \
-                    Name(toolpanelname).Caption(paneInfo.caption). \
-                    ToolbarPane().Left().TopDockable(False). \
-                    BottomDockable(False).RightDockable(False).DestroyOnClose())
-
-            elif dockDirection in [AUI_DOCK_RIGHT, AUI_DOCK_CENTER]:
-                self.AddPane(minimize_toolbar, AuiPaneInfo(). \
-                    Name(toolpanelname).Caption(paneInfo.caption). \
-                    ToolbarPane().Right().TopDockable(False). \
-                    LeftDockable(False).BottomDockable(False).DestroyOnClose())
+            if posMask != AUI_MINIMIZE_POS_TOOLBAR:
+
+                if dockDirection == AUI_DOCK_TOP:
+                    self.AddPane(minimize_toolbar, AuiPaneInfo(). \
+                        Name(toolpanelname).Caption(paneInfo.caption). \
+                        ToolbarPane().Top().BottomDockable(False). \
+                        LeftDockable(False).RightDockable(False).DestroyOnClose())
+
+                elif dockDirection == AUI_DOCK_BOTTOM:
+                    self.AddPane(minimize_toolbar, AuiPaneInfo(). \
+                        Name(toolpanelname).Caption(paneInfo.caption). \
+                        ToolbarPane().Bottom().TopDockable(False). \
+                        LeftDockable(False).RightDockable(False).DestroyOnClose())
+
+                elif dockDirection == AUI_DOCK_LEFT:
+                    self.AddPane(minimize_toolbar, AuiPaneInfo(). \
+                        Name(toolpanelname).Caption(paneInfo.caption). \
+                        ToolbarPane().Left().TopDockable(False). \
+                        BottomDockable(False).RightDockable(False).DestroyOnClose())
+
+                elif dockDirection in [AUI_DOCK_RIGHT, AUI_DOCK_CENTER]:
+                    self.AddPane(minimize_toolbar, AuiPaneInfo(). \
+                        Name(toolpanelname).Caption(paneInfo.caption). \
+                        ToolbarPane().Right().TopDockable(False). \
+                        LeftDockable(False).BottomDockable(False).DestroyOnClose())

arr = FindDocks(self._docks, paneInfo.dock_direction, paneInfo.dock_layer, paneInfo.dock_row)

@@ -9970,11 +10023,17 @@
"""

panename = paneInfo.name
-        panename = panename[0:-4]
-        pane = self.GetPane(panename)

+        if paneInfo.minimize_mode & AUI_MINIMIZE_POS_TOOLBAR:
+            pane = self.GetPane(panename)
+            hasTarget = True
+        else:
+            panename = panename[0:-4]
+            hasTarget = False
+
+        pane = self.GetPane(panename)
pane.SetFlag(pane.needsRestore, True)
-
+
if not pane.IsOk():
panename = paneInfo.name
pane = self.GetPane(panename)
@@ -9989,18 +10048,24 @@


if pane.HasFlag(pane.wasMaximized):
-
self.SavePreviousDockSizes(pane)

-
self.ShowPane(pane.window, True)
pane.Show(True)
self._has_minimized = False
pane.SetFlag(pane.optionMinimized, False)
-            paneInfo.window.Show(False)
-            self.DetachPane(paneInfo.window)
-            paneInfo.Show(False)
-            paneInfo.Hide()
+
+            if hasTarget:
+                targetName = pane.minimize_target
+                toolbarPane = self.GetPane(targetName)
+                toolbar = toolbarPane.window
+                item = toolbar.FindToolByLabel(pane.caption)
+                toolbar.DeleteTool(item.id)
+            else:
+                paneInfo.window.Show(False)
+                self.DetachPane(paneInfo.window)
+                paneInfo.Show(False)
+                paneInfo.Hide()

self.Update()
Tree