Example #1
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)