def _render_color_box(self, item): color = item.get("color", None) self.dc.SetBrush(wx.Brush(color, wx.SOLID)) self.dc.SetPen(wx.Pen(darken_color(color), 1, wx.SOLID)) (w, h) = (16, 16) self.dc.DrawRectangle( item["x"] + item["width"] - w - self.INNER_PADDING, item["y"] + self.model.ITEM_HEIGHT_PX / 2 - h / 2, w, h)
def draw_frame_around_event(): small_rect = wx.Rect(*rect) small_rect.Deflate(1, 1) border_color = self._get_border_color(event) border_color = darken_color(border_color) pen = wx.Pen(border_color, 1, wx.SOLID) dc.SetBrush(wx.TRANSPARENT_BRUSH) dc.SetPen(pen) dc.DrawRectangleRect(small_rect)
def _draw_legend(self, view_properties, categories): """ Draw legend for the given categories. Box in lower right corner Motivation for positioning in right corner: SVG text cannot be centered since the text width cannot be calculated and the first part of each event text is important. ergo: text needs to be left aligned. But then the probability is high that a lot of text is at the left bottom ergo: put the legend to the right. +----------+ | Name O | | Name O | +----------+ """ if self._legend_should_be_drawn(view_properties, categories): num_categories = len(categories) if num_categories == 0: return font_size = SMALL_FONT_SIZE myStyle = StyleBuilder() myStyle.setFontFamily(fontfamily="Verdana") myStyle.setFontSize(font_size) myStyle.setTextAnchor('left') # reserve 15% for the legend width = int(self.metrics['widthpx'] * 0.15) item_height = font_size + OUTER_PADDING height = num_categories *(item_height+INNER_PADDING)+2*OUTER_PADDING # Draw big box builder = ShapeBuilder() x = self.metrics['widthpx'] - width - OUTER_PADDING svgGroup = g() box_rect = builder.createRect(x, self.metrics['heightpx'] - height - OUTER_PADDING, width, height,fill='white') svgGroup.addElement(box_rect) # Draw text and color boxes cur_y = self.metrics['heightpx'] - height - OUTER_PADDING + INNER_PADDING for cat in categories: base_color = self._map_svg_color(cat.color) border_color = self._map_svg_color(darken_color(cat.color)) color_box_rect = builder.createRect(x + OUTER_PADDING, cur_y, item_height, item_height, fill=base_color, stroke=border_color) svgGroup.addElement(color_box_rect) myText = self._svg_clipped_text(cat.name, (x + OUTER_PADDING + INNER_PADDING+item_height, cur_y, width-OUTER_PADDING-INNER_PADDING-item_height, item_height ), myStyle) svgGroup.addElement(myText) cur_y = cur_y + item_height + INNER_PADDING self.svg.addElement(svgGroup)
def _draw_selection_and_handles(self, rect, event): self.dc.SetClippingRect(rect) small_rect = wx.Rect(*rect) small_rect.Deflate(1, 1) border_color = self._get_border_color(event) border_color = darken_color(border_color) pen = wx.Pen(border_color, 1, wx.SOLID) self.dc.SetBrush(wx.TRANSPARENT_BRUSH) self.dc.SetPen(pen) self.dc.DrawRectangleRect(small_rect) self._draw_handles(rect, event) self.dc.DestroyClippingRegion()
def _draw_legend_items(self, rect, categories): item_height = self._text_height_with_current_font() cur_y = rect.Y + INNER_PADDING for cat in categories: base_color = cat.color border_color = darken_color(base_color) self.dc.SetBrush(wx.Brush(base_color, wx.SOLID)) self.dc.SetPen(wx.Pen(border_color, 1, wx.SOLID)) color_box_rect = (OUTER_PADDING + rect.Width - item_height - INNER_PADDING, cur_y, item_height, item_height) self.dc.DrawRectangleRect(color_box_rect) self.dc.DrawText(cat.name, OUTER_PADDING + INNER_PADDING, cur_y) cur_y = cur_y + item_height + INNER_PADDING
def _get_balloon_indicator_brush(self, event): base_color = self._get_base_color(event) darker_color = darken_color(base_color, 0.6) brush = wx.Brush(darker_color, wx.SOLID) return brush
def _set_colour(self, colour): self.SetBackgroundColour(darken_color(colour)) self._inner_panel.SetBackgroundColour(colour)
def _get_border_color(self, event): return darken_color(self._get_base_color(event))
def _get_box_indicator_color(self, event): base_color = self._get_base_color(event) darker_color = darken_color(base_color, 0.6) sColor = self._map_svg_color(darker_color) return sColor
def _get_border_color(self, event): base_color = self._get_base_color(event) border_color = darken_color(base_color) return border_color
def _get_dark_color(self, event): return darken_color(self._get_base_color(event), factor=0.8)