예제 #1
0
파일: animUtils.py 프로젝트: tiniumv/Pyfa
    def OnPaint(self, event):
        rect = self.GetClientRect()
        dc = wx.BufferedPaintDC(self)
        windowColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)
        dc.SetBackground(wx.Brush(windowColor))
        dc.Clear()

        barColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)
        shadeColor = colorUtils.GetSuitableColor(barColor, 0.75)

        barWidth = (rect.width) / self.bars
        barHeight = rect.height - self.padding * 2

        x = self.padding

        for bar in xrange(self.bars):
            if bar != self.animCount:
                dc.SetPen(wx.Pen(shadeColor))
                dc.SetBrush(wx.Brush(shadeColor))
                bh = barHeight
                y = self.padding
            else:
                barColor = colorUtils.GetSuitableColor(barColor,float(self.animCount/2)/10)
                dc.SetPen(wx.Pen(barColor))
                dc.SetBrush(wx.Brush(barColor))
                bh = rect.height
                y = 0

            dc.DrawRectangle(x, y, barWidth, bh)
            x += barWidth

        textColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)
        dc.SetTextForeground(textColor)
        dc.DrawLabel(self.label,rect,wx.ALIGN_CENTER)
예제 #2
0
파일: fleetBrowser.py 프로젝트: flinz/pyfa
    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)
예제 #3
0
파일: PFSearchBox.py 프로젝트: w9jds/Pyfa
    def OnPaint(self, event):
        dc = wx.BufferedPaintDC(self)

        bkColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)
        sepColor = colorUtils.GetSuitableColor(bkColor, 0.2)
        rect = self.GetRect()

        if self.resized:
            self.bkBitmap = drawUtils.RenderGradientBar(bkColor, rect.width, rect.height, 0.1, 0.1, 0.2, 2)
            self.UpdateElementsPos(dc)
            self.resized = False

        dc.DrawBitmap(self.bkBitmap, 0, 0)

        if self.isSearchButtonVisible:
            if self.searchBitmap:
                if self.searchButtonPressed:
                    spad = 1
                else:
                    spad = 0

                dc.DrawBitmap(self.searchBitmapShadow, self.searchButtonX + 1, self.searchButtonY + 1)
                dc.DrawBitmap(self.searchBitmap, self.searchButtonX + spad, self.searchButtonY + spad)

        if self.isCancelButtonVisible:
            if self.cancelBitmap:
                if self.cancelButtonPressed:
                    cpad = 1
                else:
                    cpad = 0
                dc.DrawBitmap(self.cancelBitmapShadow, self.cancelButtonX + 1, self.cancelButtonY + 1)
                dc.DrawBitmap(self.cancelBitmap, self.cancelButtonX + cpad, self.cancelButtonY + cpad)

        dc.SetPen(wx.Pen(sepColor, 1))
        dc.DrawLine(0, rect.height - 1, rect.width, rect.height - 1)
예제 #4
0
    def OnPaint(self, event):
        rect = self.GetRect()

        windowColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)
        # bkColor = colorUtils.GetSuitableColor(windowColor, 0.1)
        sepColor = colorUtils.GetSuitableColor(windowColor, 0.2)

        mdc = wx.BufferedPaintDC(self)

        bkBitmap = drawUtils.RenderGradientBar(windowColor, rect.width,
                                               rect.height, 0.1, 0.1, 0.2, 2)
        mdc.DrawBitmap(bkBitmap, 0, 0, True)

        x, y = self.buttonsBarPos

        if self.direction == 1:
            for raceBmp in self.raceBmps:
                dropShadow = drawUtils.CreateDropShadowBitmap(raceBmp, 0.2)

                if self.shipBrowser.GetRaceFilterState(
                        self.raceNames[self.raceBmps.index(raceBmp)]):
                    bmp = raceBmp
                else:
                    img = wx.ImageFromBitmap(raceBmp)
                    if self.hoveredItem == self.raceBmps.index(raceBmp):
                        img = img.AdjustChannels(1, 1, 1, 0.7)
                    else:
                        img = img.AdjustChannels(1, 1, 1, 0.4)
                    bmp = wx.BitmapFromImage(img)

                if self.layout == wx.VERTICAL:
                    mdc.DrawBitmap(
                        dropShadow,
                        rect.width - self.buttonsPadding - bmp.GetWidth() + 1,
                        y + 1)
                    mdc.DrawBitmap(
                        bmp, rect.width - self.buttonsPadding - bmp.GetWidth(),
                        y)
                    y += raceBmp.GetHeight() + self.buttonsPadding
                    mdc.SetPen(wx.Pen(sepColor, 1))
                    mdc.DrawLine(rect.width - 1, 0, rect.width - 1,
                                 rect.height)
                else:
                    mdc.DrawBitmap(dropShadow, x + 1, self.buttonsPadding + 1)
                    mdc.DrawBitmap(bmp, x, self.buttonsPadding)
                    x += raceBmp.GetWidth() + self.buttonsPadding
                    mdc.SetPen(wx.Pen(sepColor, 1))
                    mdc.DrawLine(0, 0, rect.width, 0)

        if self.direction < 1:
            if self.layout == wx.VERTICAL:
                mdc.DrawBitmap(self.bmpArrow, -2,
                               (rect.height - self.bmpArrow.GetHeight()) / 2)
            else:
                mdc.SetPen(wx.Pen(sepColor, 1))
                mdc.DrawLine(0, 0, rect.width, 0)
                mdc.DrawBitmap(self.bmpArrow,
                               (rect.width - self.bmpArrow.GetWidth()) / 2, -2)
예제 #5
0
파일: fitItem.py 프로젝트: w9jds/Pyfa
    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)
예제 #6
0
def RenderGradientBar(windowColor,
                      width,
                      height,
                      sFactor,
                      eFactor,
                      mFactor=None,
                      fillRatio=2):
    if sFactor == 0 and eFactor == 0 and mFactor is None:
        return DrawFilledBitmap(width, height, windowColor)

    gStart = colorUtils.GetSuitableColor(windowColor, sFactor)

    if mFactor:
        gMid = colorUtils.GetSuitableColor(windowColor, mFactor)
    else:
        gMid = colorUtils.GetSuitableColor(windowColor,
                                           sFactor + (eFactor - sFactor) / 2)

    gEnd = colorUtils.GetSuitableColor(windowColor, eFactor)

    return DrawGradientBar(width, height, gStart, gEnd, gMid, fillRatio)
예제 #7
0
    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)
예제 #8
0
    def DrawItem(self, mdc):
        # rect = self.GetRect()
        self.UpdateElementsPos(mdc)

        windowColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)
        textColor = colorUtils.GetSuitableColor(windowColor, 1)

        mdc.SetTextForeground(textColor)
        mdc.DrawBitmap(self.dropShadowBitmap, self.shipBmpx + 1,
                       self.shipBmpy + 1)
        mdc.DrawBitmap(self.shipBmp, self.shipBmpx, self.shipBmpy, 0)

        mdc.SetFont(self.fontBig)

        categoryName, fittings = self.fittingInfo

        mdc.DrawText(categoryName, self.catx, self.caty)
예제 #9
0
    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
예제 #10
0
 def InitColors(self):
     """Determines colors used for tab, based on system settings"""
     self.tabColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE)
     self.inactiveColor = colorUtils.GetSuitableColor(self.tabColor, 0.25)
     self.selectedColor = colorUtils.GetSuitableColor(self.tabColor, 0.10)
예제 #11
0
    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
예제 #12
0
 def InitColors(self):
     self.tabColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE)
     self.inactiveColor = colorUtils.GetSuitableColor(self.tabColor, 0.25)
     self.selectedColor = colorUtils.GetSuitableColor(self.tabColor, 0.10)