Example #1
0
    def OnPaint(self, event):
        """
            Standard paints.
        """
        dc = AutoBufferedPaintDC(self)
        rect = RectS(self.Size)

        self.framebg.Draw(dc, rect)
Example #2
0
    def OnPaint(self,event):
        dc   = AutoBufferedPaintDC(self)
        rect = RectS(self.Size)
        self.bg.Draw(dc, rect)

        # Draw service icon
        icon = self.licon if self.account.is_connected else self.licon.Greyed

        dc.DrawBitmapPoint(icon, self.liconpos, True)

        #The right icon can either be the close icon, the state icon, or nothing
        #Shows the state icon if the list is in ShowAll or nothing if state is CONNECTING, AUTHENTICATING,INITIALIZING, or LOADING_CONTACT_LIST
        #   Otherwise it shows the close button
        ricon = self.stateicon if self.Parent.ShowAll else (self.closeicon[self.buttonstate] if self.account.state not in ShowNothingStates else None)
        if ricon:
            rconpos = self.riconpos + Point(8 - ricon.Width // 2, 8 - ricon.Height // 2)
            dc.DrawBitmapPoint(ricon, rconpos, True)
        self.buttonshown = bool(ricon)

        # Draw the account name
        dc.Font = self.majorfont
        dc.TextForeground = self.majorfc
        dc.DrawTruncatedText(self.title, self.titlerect)

        # Draws the offline reason or state
        dc.Font = self.minorfont
        dc.TextForeground = self.statefc
        if callable(self.reason):
            self.wrappedreason = Wrap(self.reason(), self.reasonrect.Width, self.minorfont, dc )
        dc.DrawLabel(self.wrappedreason,self.reasonrect)

        # Draw the link
        dc.Font = self.linkfont
        dc.TextForeground = self.linkfc
        dc.DrawLabel(self.link,self.linkrect)
Example #3
0
    def OnPaint(self, event):
        "Draws the button's background."

        # excape if native
        if self.native:
            event.Skip()
            return

        rect = RectS(self.Size)

        parent, grandparent = self.Parent, self.GrandParent
        if parent.__class__.__name__ == "Tab" and self.side_tabs:
            #Clipping the button for when partualy hidden
            cliptangle = RectS(self.Size)
            sy = self.Rect.y
            sw, sh = self.Size
            py = parent.Position.y
            pph = grandparent.Size.height - 16

            if parent.Position.y + parent.Size.height > grandparent.Size.height-16 and \
               sy + sh + py > pph:
                cliptangle = Rect(0, 0, sw, pph - (sy + py))
                dc = wx.PaintDC(self)
                dc.SetClippingRect(cliptangle)
        else:
            dc = AutoBufferedPaintDC(self)

        # actual drawing of background
        currentstate=5 if self.isdown else \
                     6 if self.state and self.notified else \
                     self.state+(self.hovered*2) if self.state else \
                     0

        if self.rendernative:

            nrect = rect if self.type == 'combo' else rect.Inflate(1, 1)
            #wx.RendererNative.Get().DrawPushButton(self,dc,nrect,self.backgrounds[currentstate])
            part = 1
            state = self.backgrounds[currentstate]
            self.DrawNativeLike(dc, part, state, nrect)
        else:
            background = self.backgrounds[currentstate]
            from cgui import SplitImage4
            if isinstance(background, SplitImage4):
                ApplySmokeAndMirrors(self, background.GetBitmap(self.Size))
            else:
                ApplySmokeAndMirrors(self)
            background.Draw(dc, rect)

        #TODO: Backgroundless icon buttons

        if not (self.type == 'combo' and self.rendernative):
            self.DrawContent(dc)
Example #4
0
    def _on_paint(self, _e):
        scroll = -self.scroll
        text_offset_x = self.text_offset_x

        dc = AutoBufferedPaintDC(self)
        dc.Clear()

        text_shift = -self.half_step

        hl, cur = self._hl, self.current

        for x1, y1, x2, y2 in self.lines:
            dc.DrawLine(x1, y1 + scroll, x2, y2 + scroll)

        br = dc.GetBackground()
        prev_c = br.GetColour()
        revert_color = False

        for c in Commit.graph.iter_commits():
            while True:
                if c is cur:
                    br.SetColour((0, 255, 0, 255))
                elif c is hl:
                    br.SetColour((255, 0, 0, 255))
                else:
                    break
                dc.SetBrush(br)
                revert_color = True
                break

            x = c._x
            y = c._y

            dc.DrawCircle(x, y + scroll, 4)
            dc.DrawText(c.label, x + text_offset_x, y + scroll + text_shift)

            if revert_color:
                br.SetColour(prev_c)
                dc.SetBrush(br)
                revert_color = False
Example #5
0
 def __draw_cross_point(self, dc: wx.AutoBufferedPaintDC, pos: wx.Point):
     size: wx.Size = self.frame.GetSize()
     dc.DrawLine(0, 0, pos.x, pos.y)
     dc.DrawLine(size.x, 0, pos.x, pos.y)
     dc.DrawLine(0, size.y, pos.x, pos.y)
     dc.DrawLine(size.x, size.y, pos.x, pos.y)
Example #6
0
    def OnPaint(self,event):
        'EVT_PAINT handling'
        dc   = AutoBufferedPaintDC(self)
        rect = RectS(self.Size)

        # draw the background
        background = self.Parent.hoverbg if self.hover else self.Parent.normalbg
        background.Draw(dc, rect)

        margins = self.Parent.margins
        padding = self.Parent.padding

        # Font setup
        font = None
        sp  = self.Parent.menu.spine
        sel = sp.Selection
        if sel > len(sp.items): sel = sp.Selection = -1

        if sel != -1 and sel < len(sp.items) and sel >= 0 and sp.items[sel].font:
            font = sp.items[sel].font
            #font.PointSize=self.Font.PointSize
        else:
            font = self.Font

        dc.Font = font
        color = self.Parent.hoverfc if self.hover else self.Parent.normalfc
        dc.TextForeground = color
        fontHeight = font.Height

        # initial cursor setup

        if self.Parent.ForceTextFieldBackground:
            self.Parent.activebg.Draw(dc,rect)

        label = self.DisplayLabel

        # Draw text if value is just a string
        if isinstance(label, basestring):
            cursor =  Point(rect.x+margins.left+padding.x, margins.top+padding.y)
            if not label and self.empty_text:
                text = self.empty_text
                dc.SetTextForeground(self.Parent.hintfc)
            else:
                text = label

            text_rect = Rect(cursor.x, cursor.y, rect.width - cursor.x - margins.right - padding.x, fontHeight)
            text_rect, text = self.music_note_hack(dc, text_rect, text, fontHeight)
            dc.DrawTruncatedText(text.split('\n', 1)[0], text_rect, alignment = wx.ALIGN_LEFT| wx.ALIGN_TOP)

        # or draw each part of the value
        else:
            cursor =  Point(rect.x+margins.left+padding.x, ((rect.height - margins.top - margins.bottom) / 2)+ margins.top)
            if label is not None:
                for i in label.content:
                    if isinstance(i, Bitmap):
                        dc.DrawBitmapPoint(i, (cursor.x, cursor.y - i.Height/2), True)
                        cursor += Point(i.Width + padding.x, 0)

                    elif isinstance(i, basestring):
                        dc.DrawTruncatedText(i.split('\n', 1)[0], wx.Rect(cursor.x, cursor.y-fontHeight/2, rect.width - cursor.x-margins.right - padding.x, fontHeight), alignment =wx.ALIGN_LEFT| wx.ALIGN_CENTRE_VERTICAL)
                        cursor += Point(dc.GetTextExtent(i)[0] + padding.x, 0)

        # Draw a background for the textfield
        if self.txtfld.Shown:# or self.Parent.ForceTextFieldBackground:
#            dc.Brush = wx.Brush(self.Parent.activebg)
#            dc.Pen   = wx.TRANSPARENT_PEN
#
#            dc.DrawRectangleRect(rect)
            self.Parent.activebg.Draw(dc,rect)
Example #7
0
 def Draw(self, dc: wx.AutoBufferedPaintDC):
     size = self.item.size
     if self.cache.GetWidth() != size[0] or self.cache.GetHeight(
     ) != size[1]:
         self.RefreshCache()
     dc.DrawBitmap(self.cache, *self.position)
Example #8
0
    def OnPaint(self, event):
        'EVT_PAINT handling'
        dc = AutoBufferedPaintDC(self)
        rect = RectS(self.Size)

        # draw the background
        background = self.Parent.hoverbg if self.hover else self.Parent.normalbg
        background.Draw(dc, rect)

        margins = self.Parent.margins
        padding = self.Parent.padding

        # Font setup
        font = None
        sp = self.Parent.menu.spine
        sel = sp.Selection
        if sel > len(sp.items): sel = sp.Selection = -1

        if sel != -1 and sel < len(
                sp.items) and sel >= 0 and sp.items[sel].font:
            font = sp.items[sel].font
            #font.PointSize=self.Font.PointSize
        else:
            font = self.Font

        dc.Font = font
        color = self.Parent.hoverfc if self.hover else self.Parent.normalfc
        dc.TextForeground = color
        fontHeight = font.Height

        # initial cursor setup

        if self.Parent.ForceTextFieldBackground:
            self.Parent.activebg.Draw(dc, rect)

        label = self.DisplayLabel

        # Draw text if value is just a string
        if isinstance(label, basestring):
            cursor = Point(rect.x + margins.left + padding.x,
                           margins.top + padding.y)
            if not label and self.empty_text:
                text = self.empty_text
                dc.SetTextForeground(self.Parent.hintfc)
            else:
                text = label

            text_rect = Rect(cursor.x, cursor.y,
                             rect.width - cursor.x - margins.right - padding.x,
                             fontHeight)
            text_rect, text = self.music_note_hack(dc, text_rect, text,
                                                   fontHeight)
            dc.DrawTruncatedText(text.split('\n', 1)[0],
                                 text_rect,
                                 alignment=wx.ALIGN_LEFT | wx.ALIGN_TOP)

        # or draw each part of the value
        else:
            cursor = Point(rect.x + margins.left + padding.x,
                           ((rect.height - margins.top - margins.bottom) / 2) +
                           margins.top)
            if label is not None:
                for i in label.content:
                    if isinstance(i, Bitmap):
                        dc.DrawBitmapPoint(i,
                                           (cursor.x, cursor.y - i.Height / 2),
                                           True)
                        cursor += Point(i.Width + padding.x, 0)

                    elif isinstance(i, basestring):
                        dc.DrawTruncatedText(
                            i.split('\n', 1)[0],
                            wx.Rect(
                                cursor.x, cursor.y - fontHeight / 2,
                                rect.width - cursor.x - margins.right -
                                padding.x, fontHeight),
                            alignment=wx.ALIGN_LEFT | wx.ALIGN_CENTRE_VERTICAL)
                        cursor += Point(dc.GetTextExtent(i)[0] + padding.x, 0)

        # Draw a background for the textfield
        if self.txtfld.Shown:  # or self.Parent.ForceTextFieldBackground:
            #            dc.Brush = wx.Brush(self.Parent.activebg)
            #            dc.Pen   = wx.TRANSPARENT_PEN
            #
            #            dc.DrawRectangleRect(rect)
            self.Parent.activebg.Draw(dc, rect)
Example #9
0
    def OnPaint(self, event):
        'Standard painting stuff.'

        dc = AutoBufferedPaintDC(self)
        self.framebg.Draw(dc, RectS(self.Size))
Example #10
0
    def OnPaint(self, event):
        dc = AutoBufferedPaintDC(self)
        rect = RectS(self.Size)
        self.bg.Draw(dc, rect)

        # Draw service icon
        icon = self.licon if self.account.is_connected else self.licon.Greyed

        dc.DrawBitmapPoint(icon, self.liconpos, True)

        #The right icon can either be the close icon, the state icon, or nothing
        #Shows the state icon if the list is in ShowAll or nothing if state is CONNECTING, AUTHENTICATING,INITIALIZING, or LOADING_CONTACT_LIST
        #   Otherwise it shows the close button
        ricon = self.stateicon if self.Parent.ShowAll else (
            self.closeicon[self.buttonstate]
            if self.account.state not in ShowNothingStates else None)
        if ricon:
            rconpos = self.riconpos + Point(8 - ricon.Width // 2,
                                            8 - ricon.Height // 2)
            dc.DrawBitmapPoint(ricon, rconpos, True)
        self.buttonshown = bool(ricon)

        # Draw the account name
        dc.Font = self.majorfont
        dc.TextForeground = self.majorfc
        dc.DrawTruncatedText(self.title, self.titlerect)

        # Draws the offline reason or state
        dc.Font = self.minorfont
        dc.TextForeground = self.statefc
        if callable(self.reason):
            self.wrappedreason = Wrap(self.reason(), self.reasonrect.Width,
                                      self.minorfont, dc)
        dc.DrawLabel(self.wrappedreason, self.reasonrect)

        # Draw the link
        dc.Font = self.linkfont
        dc.TextForeground = self.linkfc
        dc.DrawLabel(self.link, self.linkrect)
Example #11
0
 def OnPaint(self, event):
     self.bg.Draw(AutoBufferedPaintDC(self), RectS(self.ClientSize))