AGW Logo

svn SVN Revision 69232 For auibook

This file contains the SVN revision history for auibook, at revision 69232.

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: 07-Apr-2009 11:03:26 UTC
  • Committer: AG
  • File Size: 194522 byte(s)

svn_log Log Messages

The following log message was entered by the committer:

Applied patch from Cody Precord adding a new data container class and some properties to AuiNotebook used to customize some attributes of the TabNavigator window (Ctrl+Tab).


svn_diff Diff To Previous Version (69163)

Version SVN diff:

--- wxPython/3rdParty/AGW/agw/aui/auibook.py        2011/09/20 17:26:19     69163
+++ wxPython/3rdParty/AGW/agw/aui/auibook.py        2011/09/29 19:16:48     69232
@@ -543,6 +543,34 @@


# ---------------------------------------------------------------------------- #
+# Class TabNavigatorProps
+# ---------------------------------------------------------------------------- #
+
+class TabNavigatorProps(object):
+    """
+    Data storage class for managing and providing access to L{TabNavigatorWindow}
+    properties.
+    """
+
+    def __init__(self):
+        """ Default class constructor. """
+
+        super(TabNavigatorProps, self).__init__()
+
+        # Attributes
+        self._icon = wx.NullBitmap
+        self._font = wx.NullFont
+        self._minsize = wx.DefaultSize
+
+    # Accessors
+    Icon = property(lambda self: self._icon,
+                    lambda self, icon: setattr(self, '_icon', icon))
+    Font = property(lambda self: self._font,
+                    lambda self, font: setattr(self, '_font', font))
+    MinSize = property(lambda self: self._minsize,
+                       lambda self, size: setattr(self, '_minsize', size))
+
+# ---------------------------------------------------------------------------- #
# Class TabNavigatorWindow
# ---------------------------------------------------------------------------- #

@@ -552,32 +580,37 @@
similar to what you would get by hitting ``Alt`` + ``Tab`` on Windows.
"""

-    def __init__(self, parent=None, icon=None):
+    def __init__(self, parent, props):
"""
Default class constructor. Used internally.

:param `parent`: the L{TabNavigatorWindow} parent;
-        :param `icon`: the L{TabNavigatorWindow} icon.
+        :param `props`: the L{TabNavigatorProps} object.
"""

-        wx.Dialog.__init__(self, parent, wx.ID_ANY, "", style=0)
+        wx.Dialog.__init__(self, parent, wx.ID_ANY, "", size=props.MinSize, style=0)

self._selectedItem = -1
self._indexMap = []
+        self._props = props

-        if icon is None:
-            self._bmp = Mondrian.GetBitmap()
-        else:
-            self._bmp = icon
+        if not self._props.Icon.IsOk():
+            self._props.Icon = Mondrian.GetBitmap()

-        if self._bmp.GetSize() != (16, 16):
-            img = self._bmp.ConvertToImage()
+        if props.Icon.GetSize() != (16, 16):
+            img = self._props.Icon.ConvertToImage()
img.Rescale(16, 16, wx.IMAGE_QUALITY_HIGH)
-            self._bmp = wx.BitmapFromImage(img)
+            self._props.Icon = wx.BitmapFromImage(img)
+
+        if self._props.Font.IsOk():
+            self.Font = self._props.Font

sz = wx.BoxSizer(wx.VERTICAL)

-        self._listBox = wx.ListBox(self, wx.ID_ANY, wx.DefaultPosition, wx.Size(200, 150), [], wx.LB_SINGLE | wx.NO_BORDER)
+        self._listBox = wx.ListBox(self, wx.ID_ANY,
+                                   wx.DefaultPosition,
+                                   wx.Size(200, 150), [],
+                                   wx.LB_SINGLE | wx.NO_BORDER)

mem_dc = wx.MemoryDC()
mem_dc.SelectObject(wx.EmptyBitmap(1,1))
@@ -592,9 +625,10 @@
if panelHeight < 24:
panelHeight = 24

-        self._panel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.Size(200, panelHeight))
+        self._panel = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition,
+                               wx.Size(-1, panelHeight))

-        sz.Add(self._panel)
+        sz.Add(self._panel, 0, wx.EXPAND)
sz.Add(self._listBox, 1, wx.EXPAND)

self.SetSizer(sz)
@@ -612,9 +646,7 @@
self._listBox.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))
self.PopulateListControl(parent)

-        self.GetSizer().Fit(self)
-        self.GetSizer().SetSizeHints(self)
-        self.GetSizer().Layout()
+        self.SetInitialSize(props.MinSize)
self.Centre()

# Set focus on the list box to avoid having to click on it to change
@@ -746,9 +778,9 @@
# Draw the caption title and place the bitmap
# get the bitmap optimal position, and draw it
bmpPt, txtPt = wx.Point(), wx.Point()
-        bmpPt.y = (rect.height - self._bmp.GetHeight())/2
+        bmpPt.y = (rect.height - self._props.Icon.GetHeight())/2
bmpPt.x = 3
-        mem_dc.DrawBitmap(self._bmp, bmpPt.x, bmpPt.y, True)
+        mem_dc.DrawBitmap(self._props.Icon, bmpPt.x, bmpPt.y, True)

# get the text position, and draw it
font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
@@ -756,7 +788,7 @@
mem_dc.SetFont(font)
fontHeight = mem_dc.GetCharHeight()

-        txtPt.x = bmpPt.x + self._bmp.GetWidth() + 4
+        txtPt.x = bmpPt.x + self._props.Icon.GetWidth() + 4
txtPt.y = (rect.height - fontHeight)/2
mem_dc.SetTextForeground(wx.WHITE)
mem_dc.DrawText("Opened tabs:", txtPt.x, txtPt.y)
@@ -2716,6 +2748,7 @@

self.InitNotebook(agwStyle)

+    NavigatorProps = property(lambda self: self._navProps)

def GetTabContainer(self):
""" Returns the instance of L{AuiTabContainer}. """
@@ -2736,8 +2769,8 @@
self._agwFlags = agwStyle

self._popupWin = None
-        self._naviIcon = None
self._imageList = None
+        self._navProps = TabNavigatorProps()
self._last_drag_x = 0

self._normal_font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
@@ -5095,12 +5128,7 @@
"""

if isinstance(bmp, wx.Bitmap) and bmp.IsOk():
-            # Make sure image is proper size
-            if bmp.GetSize() != (16, 16):
-                img = bmp.ConvertToImage()
-                img.Rescale(16, 16, wx.IMAGE_QUALITY_HIGH)
-                bmp = wx.BitmapFromImage(img)
-            self._naviIcon = bmp
+            self.NavigatorProps.Icon = bmp
else:
raise TypeError, "SetNavigatorIcon requires a valid bitmap"

@@ -5115,7 +5143,7 @@
if event.IsWindowChange():
if self._agwFlags & AUI_NB_SMART_TABS:
if not self._popupWin:
-                    self._popupWin = TabNavigatorWindow(self, self._naviIcon)
+                    self._popupWin = TabNavigatorWindow(self, self.NavigatorProps)
self._popupWin.SetReturnCode(wx.ID_OK)
self._popupWin.ShowModal()
idx = self._popupWin.GetSelectedPage()
Tree

Table Of Contents

Previous topic

SVN Revision 69163 For auibook

Next topic

SVN Revision 69295 For auibook