Python wx.Brush() Examples

The following are 30 code examples of wx.Brush(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: mining.py    From nuxhash with GNU General Public License v3.0 7 votes vote down vote up
def Render(self, cell, dc, state):
        position = cell.GetPosition()
        for device in self._Devices:
            box = self.GetTextExtent(device['name'])
            RADIUS = DeviceListRenderer.CORNER_RADIUS

            if device['vendor'] == 'nvidia':
                color = self._ColorDb.Find('LIME GREEN')
            else:
                color = self._ColorDb.Find('LIGHT GREY')
            dc.SetBrush(wx.Brush(color))
            dc.SetPen(wx.TRANSPARENT_PEN)
            shadeRect = wx.Rect(
                    position,
                    wx.Size(box.GetWidth() + RADIUS*2, box.GetHeight() + RADIUS*2))
            dc.DrawRoundedRectangle(shadeRect, RADIUS)

            textRect = wx.Rect(
                    wx.Point(position.x + RADIUS, position.y + RADIUS), box)
            self.RenderText(device['name'], 0, textRect, dc, state)

            position = wx.Point(
                    position.x, (position.y + box.GetHeight() + RADIUS*2 + RADIUS))
        return True 
Example #2
Source File: chronolapsegui.py    From chronolapse with MIT License 6 votes vote down vote up
def OnPaint(self, evt):
        # this doesnt appear to work at all...

        width,height = self.GetSizeTuple()

        # get drawing shit
        dc = wx.PaintDC(self)

        dc.SetPen(wx.Pen(wx.Colour(0,0,255,255)))
        dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220)))

        # build rect
        size = max(2, (width-10)*self.progress)
        rect = wx.Rect(5,8, size ,5)

        # draw rect
        dc.Clear()
        dc.BeginDrawing()
        dc.DrawRoundedRectangleRect(rect, 2)
        dc.EndDrawing()
# end wxGlade 
Example #3
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def SetUpDraw(self, dc, WorldToPixel, ScaleWorldToPixel, HTdc):
        """
        Setup for draw
        
        :param `dc`: the dc to draw ???
        :param `WorldToPixel`: ???
        :param `ScaleWorldToPixel`: ???
        :param `HTdc`: ???
        
        """
        dc.SetPen(self.Pen)
        dc.SetBrush(self.Brush)
        if HTdc and self.HitAble:
            HTdc.SetPen(self.HitPen)
            HTdc.SetBrush(self.HitBrush)
        return ( WorldToPixel(self.XY),
                 ScaleWorldToPixel(self.WH) ) 
Example #4
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def _Draw(self, dc, WorldToPixel, ScaleWorldToPixel, HTdc=None):
        dc.SetPen(self.Pen)
        xy = WorldToPixel(self.XY)
        if self.Diameter <= 1:
            dc.DrawPoint(xy[0], xy[1])
        else:
            dc.SetBrush(self.Brush)
            radius = int(round(self.Diameter/2))
            dc.DrawCircle(xy[0],xy[1], radius)
        if HTdc and self.HitAble:
            HTdc.SetPen(self.HitPen)
            if self.Diameter <= 1:
                HTdc.DrawPoint(xy[0], xy[1])
            else:
                HTdc.SetBrush(self.HitBrush)
                HTdc.DrawCircle(xy[0],xy[1], radius) 
Example #5
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def Draw(
        self,
        dc,
        foregroundColour,
        backgroundColour,
        coverage,
        aspectRatio=0,
        display=0, # deprecated
    ):
        dc.SetBackground(wx.Brush(backgroundColour))
        dc.Clear()
        dc.SetPen(wx.Pen(foregroundColour, 1))
        dc.SetBrush(wx.Brush(foregroundColour))
        dc.SetPen(wx.Pen(foregroundColour, 1))
        dc.SetBrush(wx.Brush(foregroundColour))
        w, h = dc.GetSizeTuple()
        area = (w * h) * coverage / 100
        width = height = sqrt(area)
        dc.DrawRectangle((w - width) / 2, (h - height) / 2, width, height) 
Example #6
Source File: LD_Objects.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def DrawHighlightment(self, dc):
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)
        dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
        dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
        dc.SetLogicalFunction(wx.AND)
        # Draw two rectangles for representing the contact
        left_left = (self.Pos.x - 1) * scalex - 2
        right_left = (self.Pos.x + self.Size[0] - 2) * scalex - 2
        top = (self.Pos.y - 1) * scaley - 2
        width = 4 * scalex + 5
        height = (self.Size[1] + 3) * scaley + 5

        dc.DrawRectangle(left_left, top, width, height)
        dc.DrawRectangle(right_left, top, width, height)
        dc.SetLogicalFunction(wx.COPY)
        dc.SetUserScale(scalex, scaley)

    # Adds an highlight to the connection 
Example #7
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def SetBrush(self, FillColor, FillStyle):
        """
        Set the brush for this DrawObject
        
        :param `FillColor`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetColor`
         for valid entries
        :param `FillStyle`: see :meth:`~lib.floatcanvas.FloatCanvas.DrawObject.SetFillStyle`
         for valid entries
        """
        if FillColor is None or FillStyle is None:
            self.Brush = wx.TRANSPARENT_BRUSH
            ##fixme: should I really re-set the style?
            self.FillStyle = "Transparent"
        else:
            self.Brush = self.BrushList.setdefault(
                (FillColor, FillStyle),
                wx.Brush(FillColor, self.FillStyleList[FillStyle]))
            #print("Setting Brush, BrushList length:", len(self.BrushList)) 
Example #8
Source File: GraphicCommons.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def DrawHighlightedText(dc, text, highlights, x, y):
    current_pen = dc.GetPen()
    dc.SetPen(wx.TRANSPARENT_PEN)
    for start, end, highlight_type in highlights:
        dc.SetBrush(wx.Brush(highlight_type[0]))
        offset_width, _offset_height = dc.GetTextExtent(text[:start[1]])
        part = text[start[1]:end[1] + 1]
        part_width, part_height = dc.GetTextExtent(part)
        dc.DrawRectangle(x + offset_width, y, part_width, part_height)
        dc.SetTextForeground(highlight_type[1])
        dc.DrawText(part, x + offset_width, y)
    dc.SetPen(current_pen)
    dc.SetTextForeground(wx.BLACK)


# -------------------------------------------------------------------------------
#                           Graphic element base class
# ------------------------------------------------------------------------------- 
Example #9
Source File: GraphicCommons.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def DrawHighlightment(self, dc):
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)
        pen = MiterPen(HIGHLIGHTCOLOR, 2 * scalex + 5)
        pen.SetCap(wx.CAP_BUTT)
        dc.SetPen(pen)
        dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
        dc.SetLogicalFunction(wx.AND)
        parent_pos = self.ParentBlock.GetPosition()
        xstart = parent_pos[0] + self.Pos.x
        ystart = parent_pos[1] + self.Pos.y
        if self.Direction[0] < 0:
            xstart += 1
        if self.Direction[1] < 0:
            ystart += 1
        xend = xstart + CONNECTOR_SIZE * self.Direction[0]
        yend = ystart + CONNECTOR_SIZE * self.Direction[1]
        dc.DrawLine(round((xstart + self.Direction[0]) * scalex), round((ystart + self.Direction[1]) * scaley),
                    round(xend * scalex), round(yend * scaley))
        dc.SetLogicalFunction(wx.COPY)
        dc.SetUserScale(scalex, scaley)

    # Adds an highlight to the connector 
Example #10
Source File: Widget.py    From meerk40t with MIT License 6 votes vote down vote up
def process_draw(self, gc):
        if self.scene.device.draw_mode & DRAW_MODE_GRID != 0:
            return
        device = self.scene.device
        if device is not None:
            wmils = device.bed_width * MILS_IN_MM
            hmils = device.bed_height * MILS_IN_MM
        else:
            wmils = 320 * MILS_IN_MM
            hmils = 220 * MILS_IN_MM
        background = self.background
        if background is None:
            gc.SetBrush(wx.WHITE_BRUSH)
            gc.DrawRectangle(0, 0, wmils, hmils)
        elif isinstance(background, int):
            gc.SetBrush(wx.Brush(wx.Colour(swizzlecolor(background))))
            gc.DrawRectangle(0, 0, wmils, hmils)
        else:
            gc.DrawBitmap(background, 0, 0, wmils, hmils)

        if self.grid is None:
            self.calculate_grid()
        starts, ends = self.grid
        gc.SetPen(wx.BLACK_PEN)
        gc.StrokeLineSegments(starts, ends) 
Example #11
Source File: FCObjects.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def _Draw(self, dc , WorldToPixel, ScaleWorldToPixel, HTdc=None):
        Size = self.Size
        dc.SetPen(self.Pen)
        xc,yc = WorldToPixel(self.XY)

        if self.Size <= 1:
            dc.DrawPoint(xc, yc)
        else:
            x = xc - Size/2.0
            y = yc - Size/2.0
            dc.SetBrush(self.Brush)
            dc.DrawRectangle(x, y, Size, Size)
        if HTdc and self.HitAble:
            HTdc.SetPen(self.HitPen)
            if self.Size <= 1:
                HTdc.DrawPoint(xc, xc)
            else:
                HTdc.SetBrush(self.HitBrush)
                HTdc.DrawRectangle(x, y, Size, Size) 
Example #12
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def Draw(
        self,
        dc,
        firstColour,
        secondColour,
        numBeams,
    ):
        dc.SetBackground(wx.Brush("black"))
        dc.Clear()
        w, h = dc.GetSizeTuple()
        numBars = numBeams
        r1, g1, b1 = firstColour
        r2, g2, b2 = secondColour
        k = numBars * math.pi / w
        rgbTuples = zip(firstColour, secondColour)
        for x in range(w):
            factor = 0.5 + cos(x * k) / 2
            rgb = [c1 * factor + c2 * (1.0 - factor) for c1, c2 in rgbTuples]
            dc.SetPen(wx.Pen(rgb, 1))
            dc.DrawLine(x, 0, x, h) 
Example #13
Source File: core.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def _makeBitmap(self):
                width = height = 22
                bg = self.GetColour()
                if self.HasFlag(CLRP_SHOW_LABEL):
                    w, h = self.GetTextExtent(bg.GetAsString(wx.C2S_HTML_SYNTAX))
                    width += w
                bmp = wx.Bitmap(width, height)
                dc = wx.MemoryDC(bmp)
                dc.SetBackground(wx.Brush(self.colour))
                dc.Clear()
                if self.HasFlag(CLRP_SHOW_LABEL):
                    from wx.lib.colourutils import BestLabelColour
                    fg = BestLabelColour(bg)
                    dc.SetTextForeground(fg)
                    dc.DrawText(bg.GetAsString(wx.C2S_HTML_SYNTAX),
                                (width - w)/2, (height - h)/2)
                return bmp
        
        #-------------------------------------------------- 
Example #14
Source File: wm_legend.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def draw_background(self):
        """
        Draw the background box.

        If I don't do this, then the background is black.

        Could I change wx.EmptyBitmap() so that it defaults to white rather
        than black?
        """
        # TODO: change the bitmap background to be transparent
        c = wx.Colour(200, 230, 230, 0)
        c = wx.Colour(255, 255, 255, 0)
        pen = wx.Pen(c)
        brush = wx.Brush(c)
        self.mdc.SetPen(pen)
        self.mdc.SetBrush(brush)
        self.mdc.DrawRectangle(0, 0, self.dc_w, self.dc_h) 
Example #15
Source File: chronolapse.py    From chronolapse with MIT License 6 votes vote down vote up
def OnPaint(self, evt):
        # this doesnt appear to work at all...
        width,height = self.GetSizeTuple()

        # get drawing canvas
        dc = wx.PaintDC(self)

        dc.SetPen(wx.Pen(wx.Colour(0,0,255,255)))
        dc.SetBrush(wx.Brush(wx.Colour(0,0,255,220)))

        # build rect
        size = max(2, (width-10)*self.progress)
        rect = wx.Rect(5,8, size ,5)

        # draw rect
        dc.Clear()
        dc.BeginDrawing()
        dc.DrawRoundedRectangleRect(rect, 2)
        dc.EndDrawing() 
Example #16
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def Draw(
        self,
        dc,
        foregroundColour=(255, 255, 255),
        backgroundColour=(0, 0, 0),
        hCount=4,
        vCount=4,
        display=0, # deprecated
    ):
        dc.SetBackground(wx.Brush(backgroundColour))
        dc.Clear()
        dc.SetPen(wx.Pen(foregroundColour, 1))
        dc.SetBrush(wx.Brush(foregroundColour))
        w, h = dc.GetSizeTuple()
        width = 1.0 * w / hCount
        height = 1.0 * h / vCount
        for i in range(1, hCount):
            x = int(round(width * i))
            dc.DrawLine(x, 0, x, h)
        for i in range(1, vCount):
            y = int(round(height * i))
            dc.DrawLine(0, y, w, y)
        w -= 1
        h -= 1
        dc.DrawLine(0, 0, 0, h)
        dc.DrawLine(w, 0, w, h)
        dc.DrawLine(0, 0, w, 0)
        dc.DrawLine(0, h, w, h) 
Example #17
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def Draw(
        self,
        dc,
        foregroundColour=(255, 255, 255),
        backgroundColour=(0, 0, 0),
        hCount=4,
        vCount=4,
        diameter=1,
        antialiasing=False
    ):
        diameter *= 1.0
        dc.SetBackground(wx.Brush(backgroundColour))
        dc.Clear()
        if antialiasing and diameter > 1:
            gc = wx.GraphicsContext.Create(dc)
            gc.Translate(0, 0)
            gc.Scale(1.0, 1.0)
            d = diameter + 1
        else:
            gc = dc
            d = diameter + 2
        gc.SetPen(wx.Pen(backgroundColour, 0))
        gc.SetBrush(wx.Brush(foregroundColour))
        w, h = dc.GetSizeTuple()
        if hCount == 1:
            xOffset = (w - diameter) / 2.0  - 1
            width = 0
        else:
            xOffset = -1
            width = (w - diameter) / (hCount - 1)
        if vCount == 1:
            yOffset = (h - diameter) / 2.0 - 1
            height = 0
        else:
            yOffset = -1
            height = (h - diameter) / (vCount - 1)

        for y in range(vCount):
            for x in range(hCount):
                gc.DrawEllipse(x * width + xOffset, y * height + yOffset, d, d) 
Example #18
Source File: CustomWidgets.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def draw_bar(self, dc, rect):
        if self.percent == None:
            return 0
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.SetBrush(wx.Brush(self.remaining_color))
        dc.DrawRectangle(rect.x, rect.y,
                         rect.width, rect.height)
        dc.SetBrush(wx.Brush(self.completed_color))
        dc.DrawRectangle(rect.x, rect.y,
                         rect.width * self.percent, rect.height)
        return 0 
Example #19
Source File: CustomWidgets.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def init_buffer(self):
        size = self._calc_size()
        if ((self.buffer_size.width < size.width) or
            (self.buffer_size.height < size.height)):
            self.buffer = wx.EmptyBitmap(size.width, size.height)
            dc = wx.MemoryDC()
            dc.SelectObject(self.buffer)
            dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
            dc.Clear()
            dc.SelectObject(wx.NullBitmap)
            self.buffer_size = size
            return True
        return False 
Example #20
Source File: __init__.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def OnPaint(self, event):
        dc = wx.PaintDC(self)
        dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
        if self.bitmap:
            dc.DrawBitmap(self.bitmap, 0, 0, True) 
Example #21
Source File: LaserRender.py    From meerk40t with MIT License 5 votes vote down vote up
def __init__(self, device):
        self.device = device
        self.cache = None
        self.pen = wx.Pen()
        self.brush = wx.Brush()
        self.color = wx.Colour() 
Example #22
Source File: PDFLinkMaint.py    From PyMuPDF-Utilities with GNU General Public License v3.0 5 votes vote down vote up
def draw_rect(self, x, y, w, h, c):
        dc = wx.ClientDC(self.PDFimage)
        dc.SetPen(wx.Pen(c, width=1))
        dc.SetBrush(wx.Brush(c, style=wx.BRUSHSTYLE_TRANSPARENT))
        dc.DrawRectangle(x, y, w, h)
        return 
Example #23
Source File: PDFLinkMaint.py    From PyMuPDF-Utilities with GNU General Public License v3.0 5 votes vote down vote up
def draw_links(self):
        dc = wx.ClientDC(self.PDFimage)
        dc.SetPen(wx.Pen("BLUE", width=1))
        dc.SetBrush(wx.Brush("BLUE", style=wx.BRUSHSTYLE_TRANSPARENT))
        self.link_rects = []
        self.link_bottom_rects = []
        self.link_texts = []
        for lnk in self.page_links:
            if lnk.get("update", False):
                self.enable_update()
            wxr = self.Rect_to_wxRect(lnk["from"])
            dc.DrawRectangle(wxr[0], wxr[1], wxr[2], wxr[3])
            self.link_rects.append(wxr)
            p = wxr.BottomRight
            br = wx.Rect(p.x - self.sense, p.y - self.sense,
                         2*self.sense, 2*self.sense)
            self.link_bottom_rects.append(br)
            if lnk["kind"] == fitz.LINK_GOTO:
                if lnk["page"] >= 0:
                    txt = "page " + str(lnk["page"] + 1)
                else:
                    txt = "name " + str(lnk["to"])
            elif lnk["kind"] == fitz.LINK_GOTOR:
                txt = lnk["file"]
                if lnk["page"] >= 0:
                    txt += " p. " + str(lnk["page"] + 1)
                else:
                    txt += "(" + str(lnk["to"]) + ")"
            elif lnk["kind"] == fitz.LINK_URI:
                txt = lnk["uri"]
            elif lnk["kind"] == fitz.LINK_LAUNCH:
                txt = "open " + lnk["file"]
            elif lnk["kind"] == fitz.LINK_NONE:
                txt = "none"
            else:
                txt = "unkown destination"
            self.link_texts.append(txt)
        return 
Example #24
Source File: wxTableExtract.py    From PyMuPDF-Utilities with GNU General Public License v3.0 5 votes vote down vote up
def DrawRect(self, x, y, w, h):
        # Draw a rectangle (red border, transparent interior)
        dc = wx.ClientDC(self.PDFimage)     # make a device control out of img
        dc.SetPen(wx.Pen("RED"))
        dc.SetBrush(wx.Brush("RED", style=wx.BRUSHSTYLE_TRANSPARENT))
        self.redraw_bitmap()
        dc.DrawRectangle(x, y, w, h) 
Example #25
Source File: PDFdisplay.py    From PyMuPDF-Utilities with GNU General Public License v3.0 5 votes vote down vote up
def draw_links(self, bmp, pno):
        dc = wx.MemoryDC()
        dc.SelectObject(bmp)
        dc.SetPen(wx.Pen("BLUE", width=1))
        dc.SetBrush(wx.Brush("BLUE", style=wx.BRUSHSTYLE_TRANSPARENT))
        pg_w = self.pg_ir.x1 - self.pg_ir.x0
        pg_h = self.pg_ir.y1 - self.pg_ir.y0
        zoom_w = float(bmp.Size[0]) / float(pg_w)
        zoom_h = float(bmp.Size[1]) / float(pg_h)
        for lnk in self.current_lnks:
            r = lnk["from"].irect
            wx_r = wx.Rect(int(r.x0 * zoom_w),
                           int(r.y0 * zoom_h),
                           int(r.width * zoom_w),
                           int(r.height * zoom_h))
            dc.DrawRectangle(wx_r[0], wx_r[1], wx_r[2]+1, wx_r[3]+1)
            if lnk["kind"] == fitz.LINK_GOTO:
                txt = "page " + str(lnk["page"] + 1)
            elif lnk["kind"] == fitz.LINK_GOTOR:
                txt = lnk["file"]
            elif lnk["kind"] == fitz.LINK_URI:
                txt = lnk["uri"]
            else:
                txt = "unkown destination"
            self.link_texts.append(txt)
        dc.SelectObject(wx.NullBitmap)
        dc = None
        return 
Example #26
Source File: viewer.py    From GraphLayout with MIT License 5 votes vote down vote up
def on_paint(self, event):
        dc = wx.AutoBufferedPaintDC(self)
        dc.SetBackground(wx.Brush(render.BACKGROUND))
        dc.Clear()
        if self.bitmap is None:
            return
        cw, ch = self.GetClientSize()
        bw, bh = self.bitmap.GetSize()
        x = cw / 2 - bw / 2
        y = ch / 2 - bh / 2
        dc.DrawBitmap(self.bitmap, x, y)
        dc.DrawText(str(self.index), 10, 10) 
Example #27
Source File: backend_wx.py    From ImageFusion with MIT License 5 votes vote down vote up
def draw_rubberband(self, event, x0, y0, x1, y1):
        # Use an Overlay to draw a rubberband-like bounding box.

        dc = wx.ClientDC(self.canvas)
        odc = wx.DCOverlay(self.wxoverlay, dc)
        odc.Clear()

        # Mac's DC is already the same as a GCDC, and it causes
        # problems with the overlay if we try to use an actual
        # wx.GCDC so don't try it.
        if 'wxMac' not in wx.PlatformInfo:
            dc = wx.GCDC(dc)

        height = self.canvas.figure.bbox.height
        y1 = height - y1
        y0 = height - y0

        if y1<y0: y0, y1 = y1, y0
        if x1<y0: x0, x1 = x1, x0

        w = x1 - x0
        h = y1 - y0
        rect = wx.Rect(x0, y0, w, h)

        rubberBandColor = '#C0C0FF' # or load from config?

        # Set a pen for the border
        color = wx.NamedColour(rubberBandColor)
        dc.SetPen(wx.Pen(color, 1))

        # use the same color, plus alpha for the brush
        r, g, b = color.Get()
        color.Set(r,g,b, 0x60)
        dc.SetBrush(wx.Brush(color))
        dc.DrawRectangleRect(rect) 
Example #28
Source File: GraphicCommons.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def DrawHighlightment(self, dc):
        scalex, scaley = dc.GetUserScale()
        dc.SetUserScale(1, 1)
        dc.SetPen(MiterPen(HIGHLIGHTCOLOR))
        dc.SetBrush(wx.Brush(HIGHLIGHTCOLOR))
        dc.SetLogicalFunction(wx.AND)
        dc.DrawRectangle(int(round((self.Pos.x - 1) * scalex)) - 2,
                         int(round((self.Pos.y - 1) * scaley)) - 2,
                         int(round((self.Size.width + 3) * scalex)) + 5,
                         int(round((self.Size.height + 3) * scaley)) + 5)
        dc.SetLogicalFunction(wx.COPY)
        dc.SetUserScale(scalex, scaley)

    # Draws the handles of this element if it is selected 
Example #29
Source File: backend_wx.py    From ImageFusion with MIT License 5 votes vote down vote up
def draw_path(self, gc, path, transform, rgbFace=None):
        gc.select()
        self.handle_clip_rectangle(gc)
        gfx_ctx = gc.gfx_ctx
        transform = transform + Affine2D().scale(1.0, -1.0).translate(0.0, self.height)
        wxpath = self.convert_path(gfx_ctx, path, transform)
        if rgbFace is not None:
            gfx_ctx.SetBrush(wx.Brush(gc.get_wxcolour(rgbFace)))
            gfx_ctx.DrawPath(wxpath)
        else:
            gfx_ctx.StrokePath(wxpath)
        gc.unselect() 
Example #30
Source File: edit_base.py    From wxGlade with MIT License 5 votes vote down vote up
def _draw_background(self, dc, clear=True):
        "draw the hatches on device context dc (red if selected)"
        size = self.widget.GetSize()
        small = size[0]<10 or size[1]<10
        focused = misc.focused_widget is self
        if clear:
            if small and focused:
                dc.SetBackground(wx.Brush(wx.BLUE))
            else:
                dc.SetBackground(wx.Brush(wx.LIGHT_GREY))
            dc.Clear()
        if small and focused:
            color = wx.WHITE
        elif small or not focused:
            color = wx.BLACK
        else:
            color = wx.BLUE

        if focused:
            hatch = compat.BRUSHSTYLE_CROSSDIAG_HATCH
        elif not self.parent.IS_SIZER:
            hatch = compat.BRUSHSTYLE_FDIAGONAL_HATCH
        else:
            if not "cols" in self.parent.PROPERTIES:  # horizontal/vertical sizer or grid sizer?
                pos = self.index
            else:
                pos = sum( self.sizer._get_row_col(self.index) )
            hatch = compat.BRUSHSTYLE_FDIAGONAL_HATCH  if pos%2 else  compat.BRUSHSTYLE_BDIAGONAL_HATCH
        brush = wx.Brush(color, hatch)
        # draw hatched lines in foreground
        dc.SetBrush(brush)
        size = self.widget.GetClientSize()
        dc.DrawRectangle(0, 0, size.width, size.height)

    # context menu #####################################################################################################