def _do_draw_bars(self, context, rect, maximum_value, value_label_size, label_size): if self._bars == []: return #draw the bars chart.init_sensitive_areas() for i, bar in enumerate(self._bars): bar.draw(context, rect, len(self._bars), i, self._mode, maximum_value, self._bar_padding, value_label_size, label_size, self._draw_labels)
def draw(self, context): """ Draw the widget. This method is called automatically. Don't call it yourself. If you want to force a redrawing of the widget, call the queue_draw() method. @type context: cairo.Context @param context: The context to draw on. """ label.begin_drawing() chart.init_sensitive_areas() rect = self.get_allocation() rect = gtk.gdk.Rectangle(0, 0, rect.width, rect.height) #transform rect to context coordinates context.set_line_width(1) rect = self.draw_basics(context, rect) maximum_value = max(group.get_maximum_value() for group in self._groups) bar_count = 0 for group in self._groups: bar_count += group.get_bar_count() value_label_size = 0 if self._draw_labels: for group in self._groups: value_label_size = max(value_label_size, group.get_value_label_size(context, rect, self._mode, bar_count, len(self._groups), self._group_padding, self._bar_padding)) label_size = 0 if self._draw_labels: for group in self._groups: label_size = max(label_size, group.get_label_size(context, rect, self._mode, bar_count, len(self._groups), self._group_padding, self._bar_padding, self._label_rotation)) label_size += 10 label_size += group.get_group_label_size(context, rect, self._mode, self._rotate_group_label_in_horizontal_mode) rect = self._do_draw_grid(context, rect, maximum_value, value_label_size, label_size) self._do_draw_groups(context, rect, maximum_value, value_label_size, label_size, bar_count) label.finish_drawing() n = len(self._groups) if self._mode == MODE_VERTICAL: minimum_width = rect.x + self._padding + bar_count * 10 + n * self._group_padding minimum_height = rect.y + self._padding + 200 elif self._mode == MODE_HORIZONTAL: minimum_width = rect.x + self._padding + 200 minimum_height = rect.y + self._padding + bar_count * 10 + n * self._group_padding self.set_size_request(minimum_width, minimum_height)