+#------------------------------------------
+# Firefox2 renderer
+#------------------------------------------
+class FNBRendererFirefox2(FNBRenderer):
+ """
+ This class handles the drawing of tabs using the I{Firefox 2} renderer.
+ """
+
+ def __init__(self):
+ """ Default class constructor. """
+
+ FNBRenderer.__init__(self)
+
+
+ def DrawTab(self, pageContainer, dc, posx, tabIdx, tabWidth, tabHeight, btnStatus):
+ """ Draws a tab using the I{Firefox 2} style. """
+
+ borderPen = wx.Pen(wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNSHADOW))
+ pc = pageContainer
+
+ tabPoints = [wx.Point() for indx in xrange(7)]
+ tabPoints[0].x = posx + 2
+ tabPoints[0].y = (pc.HasFlag(FNB_BOTTOM) and [2] or [tabHeight - 2])[0]
+
+ tabPoints[1].x = tabPoints[0].x
+ tabPoints[1].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - (VERTICAL_BORDER_PADDING+2)] or [(VERTICAL_BORDER_PADDING+2)])[0]
+
+ tabPoints[2].x = tabPoints[1].x+2
+ tabPoints[2].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - VERTICAL_BORDER_PADDING] or [VERTICAL_BORDER_PADDING])[0]
+
+ tabPoints[3].x = posx + tabWidth - 2
+ tabPoints[3].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - VERTICAL_BORDER_PADDING] or [VERTICAL_BORDER_PADDING])[0]
+
+ tabPoints[4].x = tabPoints[3].x + 2
+ tabPoints[4].y = (pc.HasFlag(FNB_BOTTOM) and [tabHeight - (VERTICAL_BORDER_PADDING+2)] or [(VERTICAL_BORDER_PADDING+2)])[0]
+
+ tabPoints[5].x = tabPoints[4].x
+ tabPoints[5].y = (pc.HasFlag(FNB_BOTTOM) and [2] or [tabHeight - 2])[0]
+
+ tabPoints[6].x = tabPoints[0].x
+ tabPoints[6].y = tabPoints[0].y
+
+ #------------------------------------
+ # Paint the tab with gradient
+ #------------------------------------
+ rr = wx.RectPP(tabPoints[2], tabPoints[5])
+ DrawButton(dc, rr, pc.GetSelection() == tabIdx , not pc.HasFlag(FNB_BOTTOM))
+
+ dc.SetBrush(wx.TRANSPARENT_BRUSH)
+ dc.SetPen(borderPen)
+
+ # Draw the tab as rounded rectangle
+ dc.DrawPolygon(tabPoints)
+
+ # -----------------------------------
+ # Text and image drawing
+ # -----------------------------------
+
+ # The width of the images are 16 pixels
+ padding = pc.GetParent().GetPadding()
+ shapePoints = int(tabHeight*math.tan(float(pc._pagesInfoVec[tabIdx].GetTabAngle())/180.0*math.pi))
+ hasImage = pc._pagesInfoVec[tabIdx].GetImageIndex() != -1
+ imageYCoord = (pc.HasFlag(FNB_BOTTOM) and [6] or [8])[0]
+
+ if hasImage:
+ textOffset = 2*padding + 16 + shapePoints/2
+ else:
+ textOffset = padding + shapePoints/2
+
+ textOffset += 2
+
+ if tabIdx != pc.GetSelection():
+
+ # Set the text background to be like the vertical lines
+ dc.SetTextForeground(pc._pParent.GetNonActiveTabTextColour())
+
+ if hasImage:
+ imageXOffset = textOffset - 16 - padding
+ pc._ImageList.Draw(pc._pagesInfoVec[tabIdx].GetImageIndex(), dc,
+ posx + imageXOffset, imageYCoord,
+ wx.IMAGELIST_DRAW_TRANSPARENT, True)
+
+ dc.DrawText(pc.GetPageText(tabIdx), posx + textOffset, imageYCoord)
+
+ # draw 'x' on tab (if enabled)
+ if pc.HasFlag(FNB_X_ON_TAB) and tabIdx == pc.GetSelection():
+
+ textWidth, textHeight = dc.GetTextExtent(pc.GetPageText(tabIdx))
+ tabCloseButtonXCoord = posx + textOffset + textWidth + 1
+
+ # take a bitmap from the position of the 'x' button (the x on tab button)
+ # this bitmap will be used later to delete old buttons
+ tabCloseButtonYCoord = imageYCoord
+ x_rect = wx.Rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16)
+ self._tabXBgBmp = self._GetBitmap(dc, x_rect, self._tabXBgBmp)
+
+ # Draw the tab
+ self.DrawTabX(pc, dc, x_rect, tabIdx, btnStatus)
+
+