Renders the tab, complete with the icon, text, and close button
(self)
| 567 | return self.tab_bitmap |
| 568 | |
| 569 | def _Render(self): |
| 570 | """Renders the tab, complete with the icon, text, and close button""" |
| 571 | if self.tab_bitmap: |
| 572 | del self.tab_bitmap |
| 573 | |
| 574 | height = self.tab_height |
| 575 | |
| 576 | canvas = wx.Bitmap(round(self.tab_width), round(self.tab_height), 24) |
| 577 | |
| 578 | mdc = wx.MemoryDC() |
| 579 | |
| 580 | mdc.SelectObject(canvas) |
| 581 | mdc.Clear() |
| 582 | |
| 583 | mdc.DrawBitmap(self.tab_back_bitmap, 0, 0, True) |
| 584 | |
| 585 | # draw the tab icon |
| 586 | if self.tab_img: |
| 587 | bmp = wx.Bitmap(self.tab_img.ConvertToGreyscale() if self.disabled else self.tab_img) |
| 588 | # @todo: is this conditional relevant anymore? |
| 589 | if self.content_width > 16: |
| 590 | # Draw tab icon |
| 591 | mdc.DrawBitmap( |
| 592 | bmp, |
| 593 | round(self.left_width + self.padding - bmp.GetWidth() / 2), |
| 594 | round((height - bmp.GetHeight()) / 2)) |
| 595 | |
| 596 | # draw close button |
| 597 | if self.closeable: |
| 598 | if self.close_btn_hovering: |
| 599 | cbmp = self.ctab_close_bmp |
| 600 | else: |
| 601 | cimg = self.ctab_close_bmp.ConvertToImage() |
| 602 | cimg = cimg.AdjustChannels(0.7, 0.7, 0.7, 0.3) |
| 603 | cbmp = wx.Bitmap(cimg) |
| 604 | |
| 605 | mdc.DrawBitmap( |
| 606 | cbmp, |
| 607 | round(self.content_width + self.left_width - cbmp.GetWidth() / 2), |
| 608 | round((height - cbmp.GetHeight()) / 2)) |
| 609 | |
| 610 | mdc.SelectObject(wx.NullBitmap) |
| 611 | |
| 612 | canvas.SetMaskColour((0x12, 0x23, 0x32)) |
| 613 | img = canvas.ConvertToImage() |
| 614 | |
| 615 | if not img.HasAlpha(): |
| 616 | img.InitAlpha() |
| 617 | |
| 618 | bmp = wx.Bitmap(img) |
| 619 | self.tab_bitmap = bmp |
| 620 | |
| 621 | # We draw the text separately in order to draw it directly on the native DC, rather than a memory one, because |
| 622 | # drawing text on a memory DC draws it blurry on HD/Retina screens |
no test coverage detected