예제 #1
0
    def testAdjustColour(self):
        """Test that a valid colour results are returned"""
        c = wx.Colour(125, 125, 125)

        # Check that the color was brightened
        c2 = util.AdjustColour(c, 50)
        self.assertTrue(sum(c.Get()) < sum(c2.Get()),
                        "Failed to lighten colour")

        # Check that the color was darkened
        c2 = util.AdjustColour(c, -50)
        self.assertTrue(sum(c.Get()) > sum(c2.Get()),
                        "Failed to darken colour")
예제 #2
0
    def OnPaint(self, evt):
        """Paints the background of the menubar"""
        dc = wx.PaintDC(self)
        gc = wx.GraphicsContext.Create(dc)
        col1 = util.AdjustColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE), -15)
        col2 = util.AdjustColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE), 40)
        rect = self.GetRect()
        grad = gc.CreateLinearGradientBrush(0, 1, 0, rect.height, col2, col1)

        # Create the background path
        path = gc.CreatePath()
        path.AddRectangle(0, 0, rect.width - 0.5, rect.height - 0.5)

        gc.SetPen(wx.Pen(util.AdjustColour(col1, -20), 1))
        gc.SetBrush(grad)
        gc.DrawPath(path)

        evt.Skip()
예제 #3
0
파일: cfgdlg.py 프로젝트: wangdyna/wxPython
    def ColorRow(self, index):
        """Color the given index
        @param index: list index

        """
        if index % 2:
            color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT)
            color = util.AdjustColour(color, 15)
            self.SetItemBackgroundColour(index, color)
예제 #4
0
    def OnPaint(self, evt):
        """Paints the background of the bar with a nice gradient.
        @param evt: Event that called this handler
        @type evt: wx.PaintEvent

        """
        dc = wx.PaintDC(self)
        gc = wx.GraphicsContext.Create(dc)
        col1 = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE)
        col2 = util.AdjustColour(col1, 40)
        col1 = util.AdjustColour(col1, -15)
        grad = gc.CreateLinearGradientBrush(0, 1, 0, 29, col2, col1)
        rect = self.GetClientRect()

        pen_col = tuple([min(190, x) for x in util.AdjustColour(col1, 20)])
        gc.SetPen(gc.CreatePen(wx.Pen(pen_col, 1)))
        gc.SetBrush(grad)
        gc.DrawRectangle(0, 1, rect.width - 0.5, rect.height - 0.5)

        evt.Skip()
예제 #5
0
    def OnPaint(self, evt):
        """Paints the background of the panel"""
        dc = wx.PaintDC(self)
        gc = wx.GraphicsContext.Create(dc)
        col1 = util.AdjustColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE), -15)
        col2 = util.AdjustColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE), 40)
        rect = self.GetRect()
        x = 0
        y = rect.height - (self._showh_cb.GetSize()[1] + 6)
        grad = gc.CreateLinearGradientBrush(x, y, x, 
                                            y + self._showh_cb.GetSize()[1] + 6,
                                            col2, col1)

        # Create the background path
        path = gc.CreatePath()
        path.AddRectangle(x, y, rect.width - 0.5, 
                          self._showh_cb.GetSize()[1] + 6)

        gc.SetPen(wx.Pen(util.AdjustColour(col1, -20), 1))
        gc.SetBrush(grad)
        gc.DrawPath(path)

        evt.Skip()
예제 #6
0
파일: calc.py 프로젝트: CrownBonded/editra
    def OnPaint(self, evt):
        """Paint the display and its values"""
        dc = wx.PaintDC(self)
        gc = wx.GraphicsContext.Create(dc)

        rect = self.GetRect()
        w = rect.width
        h = rect.height

        gc.SetBrush(wx.Brush(DISP_COLOR))
        gc.SetPen(wx.TRANSPARENT_PEN)
        gc.DrawRoundedRectangle(0, 0, w - 3, h - 3, 5)

        gc.SetBrush(wx.TRANSPARENT_BRUSH)
        color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_ACTIVEBORDER)
        color = util.AdjustColour(color, -70)
        gc.SetPen(wx.Pen(color, 2))
        gc.DrawRoundedRectangle(1, 1, w - 2, h - 2, 5)

        font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        gc.SetPen(wx.BLACK_PEN)
        self._DrawText(gc, rect, font)

        evt.Skip()