Compilation fix for wxCStrData handling.
[wxWidgets.git] / wxPython / wx / lib / flatnotebook.py
index 8d23496088af2604c05f1368dca936acba815f01..a5daebcdeba3c18781ad1809989ab5c13e3e58ec 100644 (file)
@@ -146,6 +146,9 @@ FNB_DROPDOWN_TABS_LIST = 16384
 FNB_ALLOW_FOREIGN_DND = 32768
 """Allows drag 'n' drop operations between different L{FlatNotebook}s"""
 
+FNB_HIDE_ON_SINGLE_TAB = 65536
+"""Hides the Page Container when there is one or fewer tabs"""
+
 VERTICAL_BORDER_PADDING = 4
 
 # Button size is a 16x16 xpm bitmap
@@ -181,7 +184,7 @@ FNB_DROP_DOWN_ARROW = 6 # On the drop down arrow button
 FNB_NOWHERE = 0         # Anywhere else
 """Indicates mouse coordinates not on any tab of the notebook"""
 
-FNB_DEFAULT_STYLE = FNB_MOUSE_MIDDLE_CLOSES_TABS
+FNB_DEFAULT_STYLE = FNB_MOUSE_MIDDLE_CLOSES_TABS | FNB_HIDE_ON_SINGLE_TAB
 """L{FlatNotebook} default style"""
 
 # FlatNotebook Events:
@@ -195,8 +198,8 @@ FNB_DEFAULT_STYLE = FNB_MOUSE_MIDDLE_CLOSES_TABS
 # wxEVT_FLATNOTEBOOK_PAGE_CLOSED: Event Fired When A Page Is Closed.
 # wxEVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU: Event Fired When A Menu Pops-up In A Tab.
 
-wxEVT_FLATNOTEBOOK_PAGE_CHANGED = wx.NewEventType()
-wxEVT_FLATNOTEBOOK_PAGE_CHANGING = wx.NewEventType()
+wxEVT_FLATNOTEBOOK_PAGE_CHANGED = wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED
+wxEVT_FLATNOTEBOOK_PAGE_CHANGING = wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
 wxEVT_FLATNOTEBOOK_PAGE_CLOSING = wx.NewEventType()
 wxEVT_FLATNOTEBOOK_PAGE_CLOSED = wx.NewEventType()
 wxEVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU = wx.NewEventType()
@@ -205,10 +208,10 @@ wxEVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU = wx.NewEventType()
 #        FlatNotebookEvent
 #-----------------------------------#
 
-EVT_FLATNOTEBOOK_PAGE_CHANGED = wx.PyEventBinder(wxEVT_FLATNOTEBOOK_PAGE_CHANGED, 1)
+EVT_FLATNOTEBOOK_PAGE_CHANGED = wx.EVT_NOTEBOOK_PAGE_CHANGED
 """Notify client objects when the active page in L{FlatNotebook} 
 has changed."""
-EVT_FLATNOTEBOOK_PAGE_CHANGING = wx.PyEventBinder(wxEVT_FLATNOTEBOOK_PAGE_CHANGING, 1)
+EVT_FLATNOTEBOOK_PAGE_CHANGING = wx.EVT_NOTEBOOK_PAGE_CHANGING
 """Notify client objects when the active page in L{FlatNotebook} 
 is about to change."""
 EVT_FLATNOTEBOOK_PAGE_CLOSING = wx.PyEventBinder(wxEVT_FLATNOTEBOOK_PAGE_CLOSING, 1)
@@ -2538,8 +2541,8 @@ class FNBRendererVC8(FNBRenderer):
             pc._colorTo   = LightColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE), 0) 
             pc._colorFrom = LightColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE), 60)
         
-        col2 = (pc.HasFlag(FNB_BOTTOM) and [pc._pParent.GetGradientColourTo()] or [pc._pParent.GetGradientColourFrom()])[0]
-        col1 = (pc.HasFlag(FNB_BOTTOM) and [pc._pParent.GetGradientColourFrom()] or [pc._pParent.GetGradientColourTo()])[0]
+        col2 = pc._pParent.GetGradientColourTo()
+        col1 = pc._pParent.GetGradientColourFrom()
 
         # If colorful tabs style is set, override the tab color
         if pc.HasFlag(FNB_COLORFUL_TABS):
@@ -2952,14 +2955,17 @@ class FlatNotebook(wx.Panel):
 
 
     def SetImageList(self, imageList):
-        """
-        Sets the image list for the page control. It does not take ownership
-        of the image list, you must delete it yourself.
-        """
+        """ Sets the image list for the page control. """
 
         self._pages.SetImageList(imageList)
 
 
+    def AssignImageList(self, imageList):
+        """ Assigns the image list for the page control. """
+
+        self._pages.AssignImageList(imageList)
+
+
     def GetImageList(self):
         """ Returns the associated image list. """
         
@@ -3327,6 +3333,10 @@ class FlatNotebook(wx.Panel):
             # refreshing the tab container is not enough
             self.SetSelection(self._pages._iActivePage)
 
+        if not self._pages.HasFlag(FNB_HIDE_ON_SINGLE_TAB):
+            #For Redrawing the Tabs once you remove the Hide tyle
+            self._pages._ReShow()
+
 
     def RemovePage(self, page):
         """ Deletes the specified page, without deleting the associated window. """
@@ -3579,6 +3589,13 @@ class PageContainer(wx.Panel):
         pass
 
     
+    def _ReShow(self):
+        """ Handles the Redraw of the tabs when the FNB_HIDE_ON_SINGLE_TAB has been removed """
+        self.Show()
+        self.GetParent()._mainSizer.Layout()
+        self.Refresh()
+
+
     def OnPaint(self, event):
         """ Handles the wx.EVT_PAINT event for L{PageContainer}."""
 
@@ -3586,6 +3603,11 @@ class PageContainer(wx.Panel):
         renderer = self._mgr.GetRenderer(self.GetParent().GetWindowStyleFlag())
         renderer.DrawTabs(self, dc)
 
+        if self.HasFlag(FNB_HIDE_ON_SINGLE_TAB) and len(self._pagesInfoVec) <= 1:
+            self.Hide()
+            self.GetParent()._mainSizer.Layout()
+            self.Refresh()
+
 
     def AddPage(self, caption, selected=True, imgindex=-1):
         """
@@ -4362,7 +4384,7 @@ class PageContainer(wx.Panel):
                            
         elif self.GetParent().GetWindowStyleFlag() & FNB_ALLOW_FOREIGN_DND:
         
-            if wx.Platform in ["__WXMSW__", "__WXGTK__"]:
+            if wx.Platform in ["__WXMSW__", "__WXGTK__", "__WXMAC__"]:
                 if nTabPage >= 0:
                 
                     window = oldNotebook.GetPage(nTabPage)
@@ -4604,6 +4626,12 @@ class PageContainer(wx.Panel):
         self._ImageList = imglist
 
 
+    def AssignImageList(self, imglist):
+        """ Assigns the image list for the page control. """
+
+        self._ImageList = imglist
+
+
     def GetImageList(self):
         """ Returns the image list for the page control. """