def DrawItem(self, mdc): rect = self.GetRect() windowColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW) textColor = colorUtils.GetSuitableColor(windowColor, 1) mdc.SetTextForeground(textColor) self.UpdateElementsPos(mdc) self.toolbar.SetPosition((self.toolbarx, self.toolbary)) mdc.DrawBitmap(self.fleetEffBmp, self.fleetBmpx + 3, self.fleetBmpy + 2) mdc.DrawBitmap(self.fleetBmp, self.fleetBmpx,self.fleetBmpy) mdc.SetFont(self.fontNormal) suffix = "%d ships" % self.fleetCount if self.fleetCount >1 else "%d ship" % self.fleetCount if self.fleetCount == 1 else "No ships" fleetCount = "Fleet size: %s" % suffix fleetCount = drawUtils.GetPartialText(mdc, fleetCount, self.toolbarx - self.textStartx - self.padding * 2 - self.thoverw) mdc.DrawText(fleetCount, self.textStartx, self.fleetCounty) mdc.SetFont(self.fontSmall) mdc.DrawText(self.toolbar.hoverLabel, self.thoverx, self.thovery) mdc.SetFont(self.fontBig) pfname = drawUtils.GetPartialText(mdc, self.fleetName, self.toolbarx - self.textStartx - self.padding * 2 - self.thoverw) mdc.DrawText(pfname, self.textStartx, self.fleetNamey) if self.tcFleetName.IsShown(): self.AdjustControlSizePos(self.tcFleetName, self.textStartx, self.toolbarx - self.editWidth - self.padding)
def DrawItem(self, mdc): rect = self.GetRect() windowColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW) textColor = colorUtils.GetSuitableColor(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.EmptyBitmap( (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.GetSuitableColor(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 _Render(self): """Renders the tab, complete with the icon, text, and close button""" if self.tabBitmap: del self.tabBitmap height = self.tabHeight # rect = wx.Rect(0, 0, self.tabWidth, self.tabHeight) canvas = wx.EmptyBitmap(self.tabWidth, self.tabHeight, 24) mdc = wx.MemoryDC() mdc.SelectObject(canvas) # mdc.SetBackground(wx.Brush ((0x12,0x23,0x32))) mdc.Clear() # r = copy.copy(rect) # r.top = r.left = 0 # r.height = height mdc.DrawBitmap(self.tabBackBitmap, 0, 0, True) if self.tabImg: bmp = wx.BitmapFromImage(self.tabImg.ConvertToGreyscale() if self. disabled else self.tabImg) if self.contentWidth > 16: # @todo: is this conditional relevant anymore? # Draw tab icon mdc.DrawBitmap( bmp, self.leftWidth + self.padding - bmp.GetWidth() / 2, (height - bmp.GetHeight()) / 2) textStart = self.leftWidth + self.padding + bmp.GetWidth() / 2 else: textStart = self.leftWidth mdc.SetFont(self.font) maxsize = self.tabWidth - textStart - self.rightWidth - self.padding * 4 color = self.selectedColor if self.selected else self.inactiveColor mdc.SetTextForeground(colorUtils.GetSuitableColor(color, 1)) text = drawUtils.GetPartialText(mdc, self.text, maxsize, "") tx, ty = mdc.GetTextExtent(text) mdc.DrawText(text, textStart + self.padding, height / 2 - ty / 2) if self.closeButton: if self.closeBtnHovering: cbmp = self.ctabCloseBmp else: cimg = self.ctabCloseBmp.ConvertToImage() cimg = cimg.AdjustChannels(0.7, 0.7, 0.7, 0.3) cbmp = wx.BitmapFromImage(cimg) mdc.DrawBitmap( cbmp, self.contentWidth + self.leftWidth - self.ctabCloseBmp.GetWidth() / 2, (height - self.ctabCloseBmp.GetHeight()) / 2, ) mdc.SelectObject(wx.NullBitmap) canvas.SetMaskColour((0x12, 0x23, 0x32)) img = canvas.ConvertToImage() if not img.HasAlpha(): img.InitAlpha() bmp = wx.BitmapFromImage(img) self.tabBitmap = bmp
def _Render(self): if self.tabBitmap: del self.tabBitmap inc = 6 height = self.tabHeight width = self.tabWidth contentWidth = self.contentWidth rect = wx.Rect(0, 0, self.tabWidth, self.tabHeight) canvas = wx.EmptyBitmap(rect.width, rect.height) mdc = wx.MemoryDC() mdc.SelectObject(canvas) mdc.SetBackground(wx.Brush((0x12, 0x23, 0x32))) mdc.Clear() r = copy.copy(rect) r.top = r.left = 0 r.height = height mdc.DrawBitmap(self.tabBackBitmap, 0, 0, True) if self.tabImg: bmp = wx.BitmapFromImage(self.tabImg) if self.contentWidth > 16: mdc.DrawBitmap( bmp, self.leftWidth + self.padding - bmp.GetWidth() / 2, (height - bmp.GetHeight()) / 2) textStart = self.leftWidth + self.padding + bmp.GetWidth() / 2 else: textStart = self.leftWidth mdc.SetFont(self.font) maxsize = self.tabWidth - textStart - self.rightWidth - self.padding * 4 if self.selected: color = self.selectedColor else: color = self.inactiveColor mdc.SetTextForeground(colorUtils.GetSuitableColor(color, 1)) text = drawUtils.GetPartialText(mdc, self.text, maxsize, "") tx, ty = mdc.GetTextExtent(text) mdc.DrawText(text, textStart + self.padding, height / 2 - ty / 2) if self.closeButton: if self.closeBtnHovering: mdc.DrawBitmap( self.ctabCloseBmp, self.contentWidth + self.leftWidth - self.ctabCloseBmp.GetWidth() / 2, (height - self.ctabCloseBmp.GetHeight()) / 2) else: cimg = self.ctabCloseBmp.ConvertToImage() cimg = cimg.AdjustChannels(0.7, 0.7, 0.7, 0.3) cbmp = wx.BitmapFromImage(cimg) mdc.DrawBitmap( cbmp, self.contentWidth + self.leftWidth - self.ctabCloseBmp.GetWidth() / 2, (height - self.ctabCloseBmp.GetHeight()) / 2) mdc.SelectObject(wx.NullBitmap) canvas.SetMaskColour((0x12, 0x23, 0x32)) img = canvas.ConvertToImage() if not img.HasAlpha(): img.InitAlpha() bmp = wx.BitmapFromImage(img) self.tabBitmap = bmp