# Python Code By:
#
# Andrea Gavana, @ 02 Oct 2006
-# Latest Revision: 04 Oct 2006, 20.00 GMT
+# Latest Revision: 05 Oct 2006, 20.00 GMT
#
#
# For All Kind Of Problems, Requests Of Enhancements And Bug Reports, Please
FlatNotebook Is Freeware And Distributed Under The wxPython License.
-Latest Revision: Andrea Gavana @ 04 Oct 2006, 20.00 GMT
-Version 0.3.
+Latest Revision: Andrea Gavana @ 05 Oct 2006, 20.00 GMT
+Version 0.4.
"""
self.Bind(wx.EVT_NAVIGATION_KEY, self.OnNavigationKey)
- self._pages._colorBorder = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)
+ self._pages._colorBorder = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW)
self._mainSizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(self._mainSizer)
- self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_APPWORKSPACE))
+ # The child panels will inherit this bg color, so leave it at the default value
+ #self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_APPWORKSPACE))
# Add the tab container to the sizer
self._mainSizer.Insert(0, self._pages, 0, wx.EXPAND)
# Set default page height
dc = wx.ClientDC(self)
-
- if "__WXGTK__" in wx.PlatformInfo:
- # For GTK it seems that we must do this steps in order
- # for the tabs will get the proper height on initialization
- # on MSW, preforming these steps yields wierd results
- normalFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- boldFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- boldFont.SetWeight(wx.FONTWEIGHT_BOLD)
- dc.SetFont(boldFont)
-
- width, height = dc.GetTextExtent("Tp")
+ font = self.GetFont()
+ font.SetWeight(wx.FONTWEIGHT_BOLD)
+ dc.SetFont(font)
+ height = dc.GetCharHeight()
+ ##print height, font.Ok()
tabHeight = height + FNB_HEIGHT_SPACER # We use 8 pixels as padding
self._pages.SetSizeHints(-1, tabHeight)
return self._pages._activeTextColor
- def SetPageImageIndex(self, page, imgindex):
+ def SetPageImage(self, page, imgindex):
"""
Sets the image index for the given page. Image is an index into the
image list which was set with SetImageList.
"""
- self._pages.SetPageImageIndex(page, imgindex)
+ self._pages.SetPageImage(page, imgindex)
def GetPageImageIndex(self, page):
self._pagesInfoVec = []
- self._colorTo = wx.SystemSettings_GetColour(wx.SYS_COLOUR_ACTIVECAPTION)
+ self._colorTo = wx.SystemSettings.GetColour(wx.SYS_COLOUR_ACTIVECAPTION)
self._colorFrom = wx.WHITE
self._activeTabColor = wx.WHITE
- self._activeTextColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNTEXT)
- self._nonActiveTextColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)
- self._tabAreaColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE)
+ self._activeTextColor = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT)
+ self._nonActiveTextColor = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW)
+ self._tabAreaColor = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
self._nFrom = 0
self._isdragging = False
- wx.Panel.__init__(self, parent, id, pos, size, style)
+ wx.Panel.__init__(self, parent, id, pos, size, style|wx.TAB_TRAVERSAL)
self._pDropTarget = FNBDropTarget(self)
self.SetDropTarget(self._pDropTarget)
# For GTK it seems that we must do this steps in order
# for the tabs will get the proper height on initialization
# on MSW, preforming these steps yields wierd results
- normalFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- boldFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
+ normalFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
+ boldFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
boldFont.SetWeight(wx.FONTWEIGHT_BOLD)
if "__WXGTK__" in wx.PlatformInfo:
dc.SetFont(boldFont)
# Set the maximum client size
self.SetSizeHints(self.GetButtonsAreaLength(), tabHeight)
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
+ borderPen = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW))
if style & FNB_VC71:
backBrush = wx.Brush(wx.Colour(247, 243, 233))
else:
backBrush = wx.Brush(self._tabAreaColor)
- noselBrush = wx.Brush(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE))
+ noselBrush = wx.Brush(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
selBrush = wx.Brush(self._activeTabColor)
size = self.GetSize()
greyLineYVal = self.HasFlag((FNB_BOTTOM and [0] or [size.y - 2])[0])
whiteLineYVal = self.HasFlag((FNB_BOTTOM and [3] or [size.y - 3])[0])
- pen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))
+ pen = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE))
dc.SetPen(pen)
# Draw thik grey line between the windows area and
- The Selected tab is colored with gradient color
"""
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
+ borderPen = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW))
pen = (tabIdx==self.GetSelection() and [wx.Pen(self._colorBorder)] \
- or [wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))])[0]
+ or [wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE))])[0]
fnb_bottom = self.HasFlag(FNB_BOTTOM)
fnb_bottom = self.HasFlag(FNB_BOTTOM)
# Visual studio 7.1 style
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
- dc.SetPen((tabIdx==self.GetSelection() and [wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))] or [borderPen])[0])
- dc.SetBrush((tabIdx==self.GetSelection() and [wx.Brush(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))] or \
+ borderPen = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW))
+ dc.SetPen((tabIdx==self.GetSelection() and [wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE))] or [borderPen])[0])
+ dc.SetBrush((tabIdx==self.GetSelection() and [wx.Brush(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE))] or \
[wx.Brush(wx.Colour(247, 243, 233))])[0])
if tabIdx == self.GetSelection():
fnb_bottom = self.HasFlag(FNB_BOTTOM)
# Default style
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
+ borderPen = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW))
tabPoints = [wx.Point() for ii in xrange(7)]
tabPoints[0].x = posx
return
# We draw the 'x' on the active tab only
- if tabIdx != self.GetSelection() or tabIdx < 0 or not self.CanFitToScreen(tabIdx):
+ if tabIdx != self.GetSelection() or tabIdx < 0:
return
# Set the bitmap according to the button status
for ii in xrange(self._nFrom, -1, -1):
- boldFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
+ boldFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
boldFont.SetWeight(wx.FONTWEIGHT_BOLD)
dc.SetFont(boldFont)
self.DrawRightArrow(dc)
selection = self.GetSelection()
+
+ if selection == -1:
+ event.Skip()
+ return
- if selection != -1:
- self.DrawTabX(dc, self._pagesInfoVec[selection].GetXRect(), selection)
+ if not self.IsTabVisible(selection):
+ if selection == len(self._pagesInfoVec) - 1:
+ if not self.CanFitToScreen(selection):
+ event.Skip()
+ return
+ else:
+ event.Skip()
+ return
+
+ self.DrawTabX(dc, self._pagesInfoVec[selection].GetXRect(), selection)
event.Skip()
bf += bstep
- def SetPageImageIndex(self, page, imgindex):
+ def SetPageImage(self, page, imgindex):
""" Sets the image index associated to a page. """
if page < len(self._pagesInfoVec):
dc.DrawRectangleRect(clientRect2)
dc.DrawRectangleRect(clientRect3)
- dc.SetPen(wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)))
+ dc.SetPen(wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW)))
dc.DrawRectangleRect(clientRect)
if not self.HasFlag(FNB_TABS_BORDER_SIMPLE):
# Custom initialization of the tab area
if style & FNB_VC8:
# Initialise the default style colors
- self.SetNonActiveTabTextColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNTEXT))
+ self.SetNonActiveTabTextColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT))
def CreatePageContainer(self):
self._factor = 1
- self._colorTo = LightColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE), 0)
- self._colorFrom = LightColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE), 60)
+ self._colorTo = LightColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE), 0)
+ self._colorFrom = LightColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE), 60)
PageContainerBase.__init__(self, parent, id, pos, size, style)
# We take the maxmimum font size, this is
# achieved by setting the font to be bold
- font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
+ font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
font.SetWeight(wx.FONTWEIGHT_BOLD)
dc.SetFont(font)
for i in xrange(self._nFrom, -1, -1):
- boldFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
+ boldFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
boldFont.SetWeight(wx.FONTWEIGHT_BOLD)
dc.SetFont(boldFont)
return
# Set the font for measuring the tab height
- normalFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
- boldFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
+ normalFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
+ boldFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
boldFont.SetWeight(wx.FONTWEIGHT_BOLD)
if "__WXGTK__" in wx.PlatformInfo:
# Set the maximum client size
self.SetSizeHints(self.GetButtonsAreaLength(), tabHeight)
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
+ borderPen = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW))
# Create brushes
backBrush = wx.Brush(self._tabAreaColor)
- noselBrush = wx.Brush(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE))
+ noselBrush = wx.Brush(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
selBrush = wx.Brush(self._activeTabColor)
size = self.GetSize()
# Draw the polygon
br = dc.GetBrush()
dc.SetBrush(wx.Brush((tabIdx == self.GetSelection() and [self._activeTabColor] or [self._colorTo])[0]))
- dc.SetPen(wx.Pen((tabIdx == self.GetSelection() and [wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)] or [self._colorBorder])[0]))
+ dc.SetPen(wx.Pen((tabIdx == self.GetSelection() and [wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW)] or [self._colorBorder])[0]))
dc.DrawPolygon(tabPoints)
# Restore the brush
# but without the bottom (upper line incase of wxBOTTOM)
if tabIdx == self.GetSelection():
- borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
+ borderPen = wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW))
brush = wx.TRANSPARENT_BRUSH
dc.SetPen(borderPen)
dc.SetBrush(brush)
# Draw a thin line to the right of the non-selected tab
if tabIdx != self.GetSelection():
- dc.SetPen(wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE)))
+ dc.SetPen(wx.Pen(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE)))
dc.DrawLine(tabPoints[4].x-1, tabPoints[4].y, tabPoints[5].x-1, tabPoints[5].y)
dc.DrawLine(tabPoints[5].x-1, tabPoints[5].y, tabPoints[6].x-1, tabPoints[6].y)
dc.DrawLine(startX, y, endX, y)
# Draw the border using the 'edge' point
- dc.SetPen(wx.Pen((bSelectedTab and [wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW)] or [self._colorBorder])[0]))
+ dc.SetPen(wx.Pen((bSelectedTab and [wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW)] or [self._colorBorder])[0]))
dc.DrawPoint(startX, y)
dc.DrawPoint(endX, y)