File: appearance.py

package info (click to toggle)
gnumed-client 1.8.9%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 35,164 kB
  • sloc: python: 126,791; javascript: 6,113; sh: 1,192; xml: 36; makefile: 33
file content (73 lines) | stat: -rw-r--r-- 3,307 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg
#
# This file is part of Timeline.
#
# Timeline is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Timeline is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Timeline.  If not, see <http://www.gnu.org/licenses/>.


import wx

from timelinelib.general.observer import Observable
from timelinelib.wxgui.components.font import Font


class Appearance(Observable):

    def __init__(self):
        Observable.__init__(self)
        self._build_property("legend_visible", True)
        self._build_property("balloons_visible", True)
        self._build_property("hide_events_done", False)
        self._build_property("minor_strip_divider_line_colour", (200, 200, 200))
        self._build_property("major_strip_divider_line_colour", (200, 200, 200))
        self._build_property("now_line_colour", (200, 0, 0))
        self._build_property("weekend_colour", (255, 255, 255))
        self._build_property("bg_colour", (255, 255, 255))
        self._build_property("colorize_weekends", False)
        self._build_property("draw_period_events_to_right", False)
        self._build_property("text_below_icon", False)
        self._build_property("minor_strip_font", Font(8).serialize())
        self._build_property("major_strip_font", Font(12, weight=wx.FONTWEIGHT_BOLD).serialize())
        self._build_property("legend_font", Font(8).serialize())
        self._build_property("balloon_font", Font(8).serialize())
        self._build_property("center_event_texts", False)
        self._build_property("never_show_period_events_as_point_events", False)
        self._build_property("week_start", "monday")
        self._build_property("use_inertial_scrolling", False)
        self._build_property("fuzzy_icon", "fuzzy.png")
        self._build_property("locked_icon", "locked.png")
        self._build_property("hyperlink_icon", "hyperlink.png")
        self._build_property("vertical_space_between_events", 5)
        self._build_property("skip_s_in_decade_text", False)
        self._build_property("display_checkmark_on_events_done", False)
        self._build_property("never_use_time", False)
        self._build_property("use_second", False)
        self._build_property("legend_pos", 0)
        self._build_property("time_scale_pos", 1)
        self._build_property("use_bold_nowline", False)

    def _build_property(self, name, initial_value):

        def getter():
            return getattr(self, "_%s" % name)

        def setter(new_value):
            old_value = getter()
            if new_value != old_value:
                setattr(self, "_%s" % name, new_value)
                self._notify()

        setattr(self, "get_%s" % name, getter)
        setattr(self, "set_%s" % name, setter)
        setattr(self, "_%s" % name, initial_value)