def DrawItem(self, mdc): rect = self.GetRect() windowColor = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW) textColor = colorUtils.GetSuitable(windowColor, 1) mdc.SetTextForeground(textColor) self.UpdateElementsPos(mdc) self.toolbar.SetPosition((self.toolbarx, self.toolbary)) if self.GetState() & SFItem.SB_ITEM_HIGHLIGHTED: shipEffBk = self.shipEffBkMirrored else: shipEffBk = self.shipEffBk mdc.DrawBitmap(shipEffBk, self.shipEffx, self.shipEffy, 0) mdc.DrawBitmap(self.shipBmp, self.shipBmpx, self.shipBmpy, 0) mdc.SetFont(self.fontNormal) fitDate = self.timestamp.strftime("%m/%d/%Y %H:%M") fitLocalDate = fitDate # "%d/%02d/%02d %02d:%02d" % (fitDate[0], fitDate[1], fitDate[2], fitDate[3], fitDate[4]) pfdate = drawUtils.GetPartialText( mdc, fitLocalDate, self.toolbarx - self.textStartx - self.padding * 2 - self.thoverw) mdc.DrawText(pfdate, self.textStartx, self.timestampy) mdc.SetFont(self.fontSmall) mdc.DrawText(self.toolbar.hoverLabel, self.thoverx, self.thovery) mdc.SetFont(self.fontBig) psname = drawUtils.GetPartialText( mdc, self.fitName, self.toolbarx - self.textStartx - self.padding * 2 - self.thoverw) mdc.DrawText(psname, self.textStartx, self.fitNamey) if self.tcFitName.IsShown(): self.AdjustControlSizePos( self.tcFitName, self.textStartx, self.toolbarx - self.editWidth - self.padding) tdc = wx.MemoryDC() self.dragTLFBmp = wx.Bitmap( (self.toolbarx if self.toolbarx < 200 else 200), rect.height, 24) tdc.SelectObject(self.dragTLFBmp) tdc.Blit(0, 0, (self.toolbarx if self.toolbarx < 200 else 200), rect.height, mdc, 0, 0, wx.COPY) tdc.SelectObject(wx.NullBitmap)
def DrawItem(self, mdc): # rect = self.GetRect() windowColor = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW) textColor = colorUtils.GetSuitable(windowColor, 1) mdc.SetTextForeground(textColor) self.UpdateElementsPos(mdc) self.toolbar.SetPosition((self.toolbarx, self.toolbary)) if self.GetState() & SFItem.SB_ITEM_HIGHLIGHTED: shipEffBk = self.shipEffBkMirrored else: shipEffBk = self.shipEffBk mdc.DrawBitmap(shipEffBk, self.shipEffx, self.shipEffy, 0) mdc.DrawBitmap(self.shipBmp, self.shipBmpx, self.shipBmpy, 0) mdc.DrawBitmap(self.raceDropShadowBmp, self.raceBmpx + 1, self.raceBmpy + 1) mdc.DrawBitmap(self.raceBmp, self.raceBmpx, self.raceBmpy) shipName, shipTrait, fittings = self.shipFittingInfo if fittings < 1: fformat = "No fits" elif fittings == 1: fformat = "%d fit" else: fformat = "%d fits" mdc.SetFont(self.fontNormal) mdc.DrawText(fformat % fittings if fittings > 0 else fformat, self.textStartx, self.fittingsy) mdc.SetFont(self.fontSmall) mdc.DrawText(self.toolbar.hoverLabel, self.thoverx, self.thovery) mdc.SetFont(self.fontBig) psname = drawUtils.GetPartialText( mdc, shipName, self.toolbarx - self.textStartx - self.padding * 2 - self.thoverw) mdc.DrawText(psname, self.textStartx, self.shipNamey) if self.tcFitName.IsShown(): self.AdjustControlSizePos( self.tcFitName, self.textStartx, self.toolbarx - self.editWidth - self.padding)
def DrawText(self, dc): height = self.tab_height dc.SetFont(self.font) if self.tab_bmp: text_start = self.left_width + self.padding + self.tab_bmp.GetWidth() / 2 else: text_start = self.left_width maxsize = self.tab_width \ - text_start \ - self.right_width \ - self.padding * 4 color = self.selected_color if self.selected else self.inactive_color dc.SetTextForeground(color_utils.GetSuitable(color, 1)) # draw text (with no ellipses) text = draw.GetPartialText(dc, self.text, maxsize, "") tx, ty = dc.GetTextExtent(text) dc.DrawText(text, text_start + self.padding, height / 2 - ty / 2)
def _Render(self): """Renders the tab, complete with the icon, text, and close button""" if self.tab_bitmap: del self.tab_bitmap height = self.tab_height canvas = wx.Bitmap(self.tab_width, self.tab_height, 24) mdc = wx.MemoryDC() mdc.SelectObject(canvas) mdc.Clear() mdc.DrawBitmap(self.tab_back_bitmap, 0, 0, True) # draw the tab icon if self.tab_img: bmp = wx.Bitmap(self.tab_img.ConvertToGreyscale() if self. disabled else self.tab_img) # @todo: is this conditional relevant anymore? if self.content_width > 16: # Draw tab icon mdc.DrawBitmap( bmp, self.left_width + self.padding - bmp.GetWidth() / 2, (height - bmp.GetHeight()) / 2) text_start = self.left_width + self.padding + bmp.GetWidth() / 2 else: text_start = self.left_width mdc.SetFont(self.font) maxsize = self.tab_width \ - text_start \ - self.right_width \ - self.padding * 4 color = self.selected_color if self.selected else self.inactive_color mdc.SetTextForeground(color_utils.GetSuitable(color, 1)) # draw text (with no ellipses) text = draw.GetPartialText(mdc, self.text, maxsize, "") tx, ty = mdc.GetTextExtent(text) mdc.DrawText(text, text_start + self.padding, height / 2 - ty / 2) # draw close button if self.closeable: if self.close_btn_hovering: cbmp = self.ctab_close_bmp else: cimg = self.ctab_close_bmp.ConvertToImage() cimg = cimg.AdjustChannels(0.7, 0.7, 0.7, 0.3) cbmp = wx.Bitmap(cimg) mdc.DrawBitmap( cbmp, self.content_width + self.left_width - cbmp.GetWidth() / 2, (height - cbmp.GetHeight()) / 2) mdc.SelectObject(wx.NullBitmap) canvas.SetMaskColour((0x12, 0x23, 0x32)) img = canvas.ConvertToImage() if not img.HasAlpha(): img.InitAlpha() bmp = wx.Bitmap(img) self.tab_bitmap = bmp