示例#1
0
 def OnPaint(self, event):
     dc = PaintDC(self)
     self.SetCurrent()
     if not self.init:
         self.InitGL()
         self.init = True
     self.OnDraw()
     return
示例#2
0
 def draw_tile(self, canvas: wx.PaintDC, x: int, y: int,
               shape: Tetrominoes) -> None:
     """On canvas dc, at pixel coordinate (x,y), draw shape. Color depends on shape.
     """
     colors = [
         "#000000", "#CC6666", "#66CC66", "#6666CC", "#CCCC66", "#CC66CC",
         "#66CCCC", "#DAAA00"
     ]
     light = [
         "#000000", "#F89FAB", "#79FC79", "#7979FC", "#FCFC79", "#FC79FC",
         "#79FCFC", "#FCC600"
     ]
     dark = [
         "#000000", "#803C3B", "#3B803B", "#3B3B80", "#80803B", "#803B80",
         "#3B8080", "#806200"
     ]
     W, H = self.tile_width, self.tile_height
     # draw left and bottom edge, with light color
     pen = wx.Pen(light[shape])
     pen.SetCap(wx.CAP_PROJECTING)
     canvas.SetPen(pen)
     canvas.DrawLine(x, y + H - 1, x, y)
     canvas.DrawLine(x, y, x + W - 1, y)
     # draw top and right edge, with dark color
     darkpen = wx.Pen(dark[shape])
     darkpen.SetCap(wx.CAP_PROJECTING)
     canvas.SetPen(darkpen)
     canvas.DrawLine(x + 1, y + H - 1, x + W - 1, y + H - 1)
     canvas.DrawLine(x + W - 1, y + H - 1, x + W - 1, y + 1)
     # fill square
     canvas.SetPen(wx.TRANSPARENT_PEN)
     canvas.SetBrush(wx.Brush(colors[shape]))
     canvas.DrawRectangle(x + 1, y + 1, W - 2, H - 2)
示例#3
0
    def OnPaint(self, event: PaintEvent):
        """
        Callback.
        Refresh the screen when a paint event is issued by the system.

        @param event
        """
        dc = PaintDC(self)
        w, h = self.GetSize()
        mem = self.CreateDC(False, w, h)
        mem.SetBackground(Brush(self.GetBackgroundColour()))
        mem.Clear()
        self.Redraw(mem)

        if __version__ > "2.3.2":
            x, y = self.CalcUnscrolledPosition(0, 0)
            dc.Blit(0, 0, w, h, mem, x, y)
        else:
            dc.Blit(0, 0, w, h, mem, 0, 0)
示例#4
0
    def OnPaint(self, event, pdc=None):
        #If this is in reponse to a paint event, wx requires a PaintDC for the anchor
        if event: dc2 = PaintDC(self.anchor)
        dc = pdc or ClientDC(self.parent)

        dc.Font = self.font
        dc.TextForeground = self.fontcolor

        dc.DrawLabel(self.flabel,
                     RectPS(self.anchor.Position, self.Size),
                     alignment=self.alignment)
示例#5
0
    def OnPaint(self, event: PaintEvent):
        """
        Refresh the screen when a paint event is issued by the system.

        Args:
            event:
        """
        dc = PaintDC(self)
        w, h = self.GetSize()
        mem = self.CreateDC(False, w, h)
        mem.SetBackground(Brush(self.GetBackgroundColour()))
        mem.Clear()

        x, y = self.CalcUnscrolledPosition(0, 0)
        #
        # self.clsLogger.warning(f'OnPaint - {w=}, {h=} {x=} {y=}')
        # Paint events don't seem to be generated when Pyut is built for deployment;  So code duplicated in .Redraw()
        #
        if self._prefs.backgroundGridEnabled is True:
            self._drawGrid(memDC=mem, width=w, height=h, startX=x, startY=y)
        self.Redraw(mem)

        dc.Blit(0, 0, w, h, mem, x, y)
示例#6
0
    def OnRefreshPanel(self, event):
        """
        Refresh dialog box

        """
        import time
        # constants
        backRed: int = 230
        backGreen: int = 255
        backBlue: int = 230  # Background color

        frontRed: int = 64
        frontGreen: int = 0
        frontBlue: int = 64  # Foreground color

        FADE_IN_LENGTH: int = 63
        self.logger.debug(f'Enter OnRefreshPanel')
        # Init memory buffer
        tdc: MemoryDC = MemoryDC()
        tdc.SelectObject(Bitmap(FrameWidth, FrameHeight))
        while not tdc.IsOk():
            time.sleep(0.05)
            tdc = MemoryDC()
            tdc.SelectObject(Bitmap(FrameWidth, FrameHeight))

        tdc.SetTextForeground(Colour(frontRed, frontGreen, frontBlue))
        tdc.SetBackground(
            Brush(Colour(backRed, backGreen, backBlue), BRUSHSTYLE_SOLID))
        tdc.Clear()
        font = tdc.GetFont()
        font.SetFamily(FONTFAMILY_MODERN)
        font.SetPointSize(12)
        tdc.SetFont(font)

        # Fade-in
        position = self.textPosition
        if position < FADE_IN_LENGTH:
            n = float(position) / float(FADE_IN_LENGTH)
            r = backRed - n * (backRed - frontRed)
            g = backGreen - n * (backGreen - frontGreen)
            b = backBlue - n * (backBlue - frontBlue)
            r = int(r)
            g = int(g)
            b = int(b)
            tdc.SetTextForeground(Colour(r, g, b))

        # Display text
        for j in range(1, len(self._textToShow)):
            # Draw text ?
            if position > FADE_IN_LENGTH:
                y = y0 + j * dy - (position - FADE_IN_LENGTH)
                if -dy < y < FrameHeight:
                    tdc.DrawText(self._textToShow[j], x0, y)
            else:  # Draw initial screen with fade in
                y = y0 + j * dy
                if -dy < y < FrameHeight:
                    tdc.DrawText(self._textToShow[j], x0, y)

        # Show memory dc to current dc (blit)
        dc = PaintDC(self._panel)
        dc.Blit(0, 0, FrameWidth, FrameHeight, tdc, 0, 0)
        tdc.SelectObject(NullBitmap)
        self.logger.debug(f'Exit OnRefreshPanel')
示例#7
0
 def _OnPaint(self, event):
     # redraw if BackgroundBitmap is defined
     if self.BackgroundBitmap:
         dc = PaintDC(self)  #1
         dc.DrawBitmap(self.BackgroundBitmap, 0, 0)
     return