def DrawCaption(self, dc, window, text, rect, pane): """ Draws the text in the pane caption. :param `dc`: a `wx.DC` device context; :param `window`: an instance of `wx.Window`; :param `text`: the text to be displayed; :param `rect`: the pane caption rectangle; :param `pane`: the pane for which the text is drawn. """ dc.SetPen(wx.TRANSPARENT_PEN) self.DrawCaptionBackground(dc, rect, pane) active = ((pane.state & optionActive) and [True] or [False])[0] self._caption_font.SetWeight(wx.FONTWEIGHT_BOLD) dc.SetFont(self._caption_font) if active: dc.SetTextForeground(self._active_caption_text_colour) else: dc.SetTextForeground(self._inactive_caption_text_colour) w, h = dc.GetTextExtent("ABCDEFHXfgkj") clip_rect = wx.Rect(*rect) btns = pane.CountButtons() captionLeft = pane.HasCaptionLeft() variable = (captionLeft and [rect.height] or [rect.width])[0] variable -= 3 # text offset variable -= 2 # button padding caption_offset = 0 if pane.icon: if captionLeft: caption_offset += pane.icon.GetHeight() + 3 else: caption_offset += pane.icon.GetWidth() + 3 self.DrawIcon(dc, rect, pane) diff = -2 if self.usingTheme: diff = -1 variable -= caption_offset variable -= btns * (self._button_size + self._button_border_size) draw_text = ChopText(dc, text, variable) if captionLeft: dc.DrawRotatedText(draw_text, rect.x + (rect.width / 2) - (h / 2) - diff, rect.y + rect.height - 3 - caption_offset, 90) else: dc.DrawText(draw_text, rect.x + 3 + caption_offset, rect.y + (rect.height / 2) - (h / 2) - diff)
def DrawCaption(self, dc, window, text, rect, pane): """ Draws the text in the pane caption. :param `dc`: a wx.DC device context; :param `window`: an instance of wx.Window; :param `text`: the text to be displayed; :param `rect`: the pane caption rectangle; :param `pane`: the pane for which the text is drawn. """ dc.SetPen(wx.TRANSPARENT_PEN) active = ((pane.state & optionActive) and [True] or [False])[0] self.DrawCaptionBackground(dc, rect, active) self._caption_font.SetWeight(wx.FONTWEIGHT_BOLD) dc.SetFont(self._caption_font) if active: dc.SetTextForeground(self._active_caption_text_colour) else: dc.SetTextForeground(self._inactive_caption_text_colour) w, h = dc.GetTextExtent("ABCDEFHXfgkj") caption_offset = 0 if pane.icon: caption_offset += pane.icon.GetWidth() + 3 self.DrawIcon(dc, rect, pane) diff = -2 if self.usingTheme: diff = -1 clip_rect = wx.Rect(*rect) clip_rect.width -= caption_offset btns = pane.CountButtons() clip_rect.width -= btns * (self._button_size + self._button_border_size) draw_text = ChopText(dc, text, clip_rect.width) dc.SetClippingRect(clip_rect) dc.DrawText(draw_text, rect.x + 3 + caption_offset, rect.y + (rect.height / 2) - (h / 2) + diff) dc.DestroyClippingRegion()