コード例 #1
0
 def _draw_container(self, event, rect, view_properties):
     box_rect = wx.Rect(rect.X - 2, rect.Y - 2, rect.Width + 4,
                        rect.Height + 4)
     if EXTENDED_CONTAINER_HEIGHT.enabled():
         box_rect = EXTENDED_CONTAINER_HEIGHT.get_vertical_larger_box_rect(
             rect)
     self._draw_box(box_rect, event, view_properties)
コード例 #2
0
    def _draw_text(self, dc, rect, event):

        def center_text():
            width, _ = dc.GetTextExtent(event.get_text())
            if width < rect_copy.width:
                return text_x + (rect_copy.width - width) / 2
            else:
                return text_x

        # Ensure that we can't draw content outside inner rectangle
        rect_copy = wx.Rect(*rect)
        rect_copy.Deflate(INNER_PADDING, INNER_PADDING)
        if rect_copy.Width > 0:
            # Draw the text (if there is room for it)
            text_x = rect.X + INNER_PADDING
            if event.get_fuzzy() or event.get_locked():
                text_x += rect.Height / 2
            text_y = rect.Y + INNER_PADDING
            if text_x < INNER_PADDING:
                text_x = INNER_PADDING
            self._set_text_foreground_color(dc, event)
            if event.is_container() and EXTENDED_CONTAINER_HEIGHT.enabled():
                EXTENDED_CONTAINER_HEIGHT.draw_container_text_top_adjusted(event.get_text(), dc, rect)
            else:
                if self.center_text:
                    text_x = center_text()
                dc.SetClippingRect(rect_copy)
                dc.DrawText(event.get_text(), text_x, text_y)
            dc.DestroyClippingRegion()
コード例 #3
0
 def draw(self, dc, timeline, view_properties, appearance, fast_draw=False):
     self.fast_draw = fast_draw
     view_properties.hide_events_done = appearance.get_hide_events_done()
     view_properties.legend_pos = appearance.get_legend_pos()
     view_properties.set_fuzzy_icon(appearance.get_fuzzy_icon())
     view_properties.set_locked_icon(appearance.get_locked_icon())
     view_properties.set_hyperlink_icon(appearance.get_hyperlink_icon())
     view_properties.set_skip_s_in_decade_text(appearance.get_skip_s_in_decade_text())
     view_properties.set_display_checkmark_on_events_done(appearance.get_display_checkmark_on_events_done())
     self.minor_strip_pen.SetColour(appearance.get_minor_strip_divider_line_colour())
     self.major_strip_pen.SetColour(appearance.get_major_strip_divider_line_colour())
     self.now_pen.SetColour(appearance.get_now_line_colour())
     self.weekend_color = appearance.get_weekend_colour()
     self.bg_color = appearance.get_bg_colour()
     self.colorize_weekends = appearance.get_colorize_weekends()
     self.outer_padding = OUTER_PADDING
     self.outer_padding = appearance.get_vertical_space_between_events()
     if EXTENDED_CONTAINER_HEIGHT.enabled():
         self.outer_padding += EXTENDED_CONTAINER_HEIGHT.get_extra_outer_padding_to_avoid_vertical_overlapping()
     self.appearance = appearance
     self.dc = dc
     self.time_type = timeline.get_time_type()
     self.scene = self._create_scene(dc.GetSizeTuple(), timeline, view_properties, self._get_text_extent)
     if view_properties.use_fixed_event_vertical_pos():
         self._calc_fixed_event_rect_y(dc.GetSizeTuple(), timeline, view_properties, self._get_text_extent)
     else:
         self._fixed_ys = {}
     self._perform_drawing(timeline, view_properties)
     del self.dc  # Program crashes if we don't delete the dc reference.
コード例 #4
0
 def _draw_the_text(self, dc, rect, event):
     self._set_text_foreground_color(dc, event)
     if event.is_container() and EXTENDED_CONTAINER_HEIGHT.enabled():
         EXTENDED_CONTAINER_HEIGHT.draw_container_text_top_adjusted(event.get_text(), dc, rect)
     else:
         self._draw_normal_text(dc, rect, event)
     dc.DestroyClippingRegion()
コード例 #5
0
    def _draw_text(self, dc, rect, event):
        def center_text():
            width, _ = dc.GetTextExtent(event.get_text())
            if width < rect_copy.width:
                return text_x + (rect_copy.width - width) / 2
            else:
                return text_x

        # Ensure that we can't draw content outside inner rectangle
        rect_copy = wx.Rect(*rect)
        rect_copy.Deflate(INNER_PADDING, INNER_PADDING)
        if rect_copy.Width > 0:
            # Draw the text (if there is room for it)
            text_x = rect.X + INNER_PADDING
            if event.get_fuzzy() or event.get_locked():
                text_x += rect.Height / 2
            text_y = rect.Y + INNER_PADDING
            if text_x < INNER_PADDING:
                text_x = INNER_PADDING
            self._set_text_foreground_color(dc, event)
            if event.is_container() and EXTENDED_CONTAINER_HEIGHT.enabled():
                EXTENDED_CONTAINER_HEIGHT.draw_container_text_top_adjusted(
                    event.get_text(), dc, rect)
            else:
                if self.center_text:
                    text_x = center_text()
                dc.SetClippingRect(rect_copy)
                dc.DrawText(event.get_text(), text_x, text_y)
            dc.DestroyClippingRegion()
コード例 #6
0
ファイル: default.py プロジェクト: leonardcj/Time-Line
 def draw(self, dc, timeline, view_properties, config):
     self.outer_padding = OUTER_PADDING
     if EXTENDED_CONTAINER_HEIGHT.enabled():
         self.outer_padding += EXTENDED_CONTAINER_HEIGHT.get_extra_outer_padding_to_avoid_vertical_overlapping()
     self.config = config
     self.dc = dc
     self.time_type = timeline.get_time_type()
     self.scene = self._create_scene(dc.GetSizeTuple(), timeline, view_properties, self._get_text_extent)
     if view_properties.use_fixed_event_vertical_pos():
         self._calc_fixed_event_rect_y(dc.GetSizeTuple(), timeline, view_properties, self._get_text_extent)
     self._perform_drawing(timeline, view_properties)
     del self.dc  # Program crashes if we don't delete the dc reference.
コード例 #7
0
 def draw(self, dc, timeline, view_properties, config):
     self.outer_padding = OUTER_PADDING
     if EXTENDED_CONTAINER_HEIGHT.enabled():
         self.outer_padding += EXTENDED_CONTAINER_HEIGHT.get_extra_outer_padding_to_avoid_vertical_overlapping(
         )
     self.config = config
     self.dc = dc
     self.time_type = timeline.get_time_type()
     self.scene = self._create_scene(dc.GetSizeTuple(), timeline,
                                     view_properties, self._get_text_extent)
     if view_properties.use_fixed_event_vertical_pos():
         self._calc_fixed_event_rect_y(dc.GetSizeTuple(), timeline,
                                       view_properties,
                                       self._get_text_extent)
     self._perform_drawing(timeline, view_properties)
     del self.dc  # Program crashes if we don't delete the dc reference.
コード例 #8
0
ファイル: svg.py プロジェクト: ncqgm/gnumed
 def _draw_event_rect(self, event, rect):
     boxBorderColor = self._get_event_border_color(event)
     if event.is_container() and EXTENDED_CONTAINER_HEIGHT.enabled():
         svg_rect = ShapeBuilder().createRect(rect.X, rect.Y - Y_RECT_OFFSET, rect.GetWidth(),
                                              rect.GetHeight() + Y_RECT_OFFSET,
                                              stroke=boxBorderColor,
                                              fill=self._get_event_box_color(event))
     else:
         svg_rect = ShapeBuilder().createRect(rect.X, rect.Y, rect.GetWidth(), rect.GetHeight(),
                                              stroke=boxBorderColor, fill=self._get_event_box_color(event))
     if self._shadow_flag:
         svg_rect.set_filter("url(#filterShadow)")
     return svg_rect
コード例 #9
0
 def _draw_event_rect(self, event, rect):
     boxBorderColor = self._get_event_border_color(event)
     if event.is_container() and EXTENDED_CONTAINER_HEIGHT.enabled():
         svg_rect = ShapeBuilder().createRect(rect.X, rect.Y - Y_RECT_OFFSET, rect.GetWidth(),
                                              rect.GetHeight() + Y_RECT_OFFSET,
                                              stroke=boxBorderColor,
                                              fill=self._get_event_box_color(event))
     else:
         svg_rect = ShapeBuilder().createRect(rect.X, rect.Y, rect.GetWidth(), rect.GetHeight(),
                                              stroke=boxBorderColor, fill=self._get_event_box_color(event))
     if self._shadow_flag:
         svg_rect.set_filter("url(#filterShadow)")
     return svg_rect
コード例 #10
0
ファイル: svg.py プロジェクト: ncqgm/gnumed
 def _draw_event(self, event, rect):
     if self._scene.center_text():
         style = self._small_centered_font_style
     else:
         style = self._small_font_style
     group = g()
     group.addElement(self._draw_event_rect(event, rect))
     text_rect = rect.Get()
     if event.is_container() and EXTENDED_CONTAINER_HEIGHT.enabled():
         text_rect = rect.Get()
         text_rect = (text_rect[0], text_rect[1] - Y_TEXT_OFFSET, text_rect[2], text_rect[3])
     group.addElement(self._svg_clipped_text(event.text, text_rect, style,
                                             self._scene.center_text()))
     if event.has_data():
         group.addElement(self._draw_contents_indicator(event, rect))
     return group
コード例 #11
0
 def _draw_event(self, event, rect):
     if self._scene.center_text():
         style = self._small_centered_font_style
     else:
         style = self._small_font_style
     group = G()
     group.addElement(self._draw_event_rect(event, rect))
     text_rect = rect.Get()
     if event.is_container() and EXTENDED_CONTAINER_HEIGHT.enabled():
         text_rect = rect.Get()
         text_rect = (text_rect[0], text_rect[1] - Y_TEXT_OFFSET, text_rect[2], text_rect[3])
     group.addElement(self._svg_clipped_text(event.text, text_rect, style,
                                             self._scene.center_text()))
     if event.has_data():
         group.addElement(self._draw_contents_indicator(event, rect))
     return group
コード例 #12
0
ファイル: default.py プロジェクト: leonardcj/Time-Line
 def _draw_container(self, event, rect, view_properties):
     box_rect = wx.Rect(rect.X - 2, rect.Y - 2, rect.Width + 4, rect.Height + 4)
     if EXTENDED_CONTAINER_HEIGHT.enabled():
         box_rect = EXTENDED_CONTAINER_HEIGHT.get_vertical_larger_box_rect(rect)
     self._draw_box(box_rect, event, view_properties)
コード例 #13
0
ファイル: default.py プロジェクト: weeksjm/gnumed
 def _adjust_container_rect_for_hittest(self, rect):
     if EXTENDED_CONTAINER_HEIGHT.enabled():
         return EXTENDED_CONTAINER_HEIGHT.get_vertical_larger_box_rect(rect)
     else:
         return rect
コード例 #14
0
ファイル: default.py プロジェクト: ncqgm/gnumed
 def _adjust_container_rect_for_hittest(self, rect):
     if EXTENDED_CONTAINER_HEIGHT.enabled():
         return EXTENDED_CONTAINER_HEIGHT.get_vertical_larger_box_rect(rect)
     else:
         return rect