Package Gnumed :: Package timelinelib :: Package features :: Package experimental :: Module experimentalfeaturecontainersize |
[frames] | no frames]

# Source Code for Module Gnumed.timelinelib.features.experimental.experimentalfeaturecontainersize

     1  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg
     2  #
     3  # This file is part of Timeline.
     4  #
     5  # Timeline is free software: you can redistribute it and/or modify
     6  # it under the terms of the GNU General Public License as published by
     7  # the Free Software Foundation, either version 3 of the License, or
     8  # (at your option) any later version.
     9  #
    10  # Timeline is distributed in the hope that it will be useful,
    11  # but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13  # GNU General Public License for more details.
    14  #
    15  # You should have received a copy of the GNU General Public License
    16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>.
    17
    18
    19  import wx
    20  from timelinelib.features.experimental.experimentalfeature import ExperimentalFeature
    21  from timelinelib.wxgui.components.font import Font
    22
    23
    24  CONFIG_NAME = "Extend Container height"
    25  DISPLAY_NAME = _("Extend Container height")
    26  DESCRIPTION = _("""
    27                Extend the height of a container so that the container name becomes visible.
    28
    29                This also has the side effect that ordinary events come farther apart in
    30                the vertical direction.
    31
    32                The font for the container name has a fixed size when you zoom vertically (Alt + Mouse wheel)
    33                """)
    34  Y_OFFSET = -16
    35  PADDING = 12
    36  OUTER_PAADING = 4
    37  TEXT_OFFSET = -2
    38  INNER_PADDING = 3
    39  FONT_SIZE = 8
    40
    41
    42 -class ExperimentalFeatureContainerSize(ExperimentalFeature):
    43
    44 -    def __init__(self):
    45          ExperimentalFeature.__init__(self, DISPLAY_NAME, DESCRIPTION, CONFIG_NAME)
    46
    47 -    def get_extra_outer_padding_to_avoid_vertical_overlapping(self):
    48          return OUTER_PAADING
    49
    50 -    def get_vertical_larger_box_rect(self, rect):
    51          return wx.Rect(rect.X - 2, rect.Y - 2 - PADDING, rect.Width + 4, rect.Height + 4 + PADDING)
    52
    53 -    def draw_container_text_top_adjusted(self, text, dc, rect):
    54          old_font = dc.GetFont()
    55          dc.SetFont(Font(FONT_SIZE))
    56          dc.SetClippingRect(wx.Rect(rect.X, rect.Y + Y_OFFSET, rect.Width, rect.Height))
    57          text_x = rect.X + INNER_PADDING
    58          text_y = rect.Y + INNER_PADDING + TEXT_OFFSET
    59          dc.DrawText(text, text_x, text_y)
    60          dc.SetFont(old_font)
    61