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)
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)