def _draw_ballon(self, event, event_rect, sticky): """Draw one ballon on a selected event that has 'description' data.""" def max_text_width(iw): padding = 2 * BALLOON_RADIUS if iw > 0: padding += BALLOON_RADIUS max_text_width = (self.scene.width - SLIDER_WIDTH - event_rect.X - event_rect.width / 2 - iw - padding + ARROW_OFFSET) return max(MIN_TEXT_WIDTH, max_text_width) # Constants MIN_TEXT_WIDTH = 200 MIN_WIDTH = 100 SLIDER_WIDTH = 20 inner_rect_w = 0 inner_rect_h = 0 # Icon (iw, ih) = (0, 0) icon = event.get_data("icon") if icon != None: (iw, ih) = icon.Size inner_rect_w = iw inner_rect_h = ih # Text self.dc.SetFont(get_default_font(8)) font_h = self.dc.GetCharHeight() (tw, th) = (0, 0) description = event.get_data("description") lines = None if description != None: max_text_width = max_text_width(iw) lines = break_text(description, self.dc, max_text_width) th = len(lines) * self.dc.GetCharHeight() for line in lines: (lw, lh) = self.dc.GetTextExtent(line) tw = max(lw, tw) if icon != None: inner_rect_w += BALLOON_RADIUS inner_rect_w += min(tw, max_text_width) inner_rect_h = max(inner_rect_h, th) inner_rect_w = max(MIN_WIDTH, inner_rect_w) bounding_rect, x, y = self._draw_balloon_bg( self.dc, (inner_rect_w, inner_rect_h), (event_rect.X + event_rect.Width / 2, event_rect.Y), True, sticky) if icon != None: self.dc.DrawBitmap(icon, x, y, False) x += iw + BALLOON_RADIUS if lines != None: ty = y for line in lines: self.dc.DrawText(line, x, ty) ty += font_h x += tw # Write data so we know where the balloon was drawn # Following two lines can be used when debugging the rectangle #self.dc.SetBrush(wx.TRANSPARENT_BRUSH) #self.dc.DrawRectangleRect(bounding_rect) self.balloon_data.append((event, bounding_rect))
def _draw_bitmap(self): width, height = self.GetVirtualSizeTuple() self.buffer_image = wx.EmptyBitmap(width, height) memdc = wx.BufferedDC(None, self.buffer_image) memdc.SetBackground(wx.Brush(self.GetBackgroundColour(), wx.SOLID)) memdc.Clear() memdc.BeginDrawing() monitoring.timer_start() self.renderer.render(memdc) monitoring.timer_end() if monitoring.IS_ENABLED: (width, height) = self.GetSizeTuple() redraw_time = monitoring.timer_elapsed_ms() monitoring.count_category_redraw() memdc.SetTextForeground((255, 0, 0)) memdc.SetFont(get_default_font(10, bold=True)) memdc.DrawText( "Redraw count: %d" % monitoring.category_redraw_count, 10, height - 35) memdc.DrawText("Last redraw time: %.3f ms" % redraw_time, 10, height - 20) memdc.EndDrawing() del memdc
def get_font(self, time_period): return get_default_font(8)
def get_font(self, time_period): if (time_period.start_time.get_day_of_week() in (5, 6)): return get_default_font(8, True) else: return get_default_font(8)
def _create_fonts(self): self.header_font = get_default_font(12, True) self.small_text_font = get_default_font(self.font_size) self.small_text_font_bold = get_default_font(8, True)
def decrement_font_size(self, step=2): if self.font_size > step: self.font_size -= step self.small_text_font = get_default_font(self.font_size) self._adjust_outer_padding_to_font_size()
def increment_font_size(self, step=2): self.font_size += step self.small_text_font = get_default_font(self.font_size) self._adjust_outer_padding_to_font_size()