Package Gnumed :: Package timelinelib :: Package wxgui :: Package components :: Package propertyeditors :: Module coloreditor |
[frames] | no frames]

# Source Code for Module Gnumed.timelinelib.wxgui.components.propertyeditors.coloreditor

     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
    21  from timelinelib.wxgui.components.propertyeditors.baseeditor import BaseEditor
    22  from timelinelib.wxgui.components.colourselect import ColourSelect
    23
    24
    25 -class ColorEditorGuiCreator(wx.Panel):
    26
    27 -    def __init__(self, parent):
    28          wx.Panel.__init__(self, parent)
    29
    30 -    def create_sizer(self):
    31          return wx.GridBagSizer(vgap=10, hgap=10)
    32
    33 -    def create_controls(self):
    34          description = wx.StaticText(self, label=_("Color used when the Event has no category associated with it."))
    35          self.data = self._create_color_chooser_control()
    36          return (description, self.data)
    37
    38 -    def put_controls_in_sizer(self, sizer, controls):
    39          description, spin_ctrl = controls
    40          span = wx.GBSpan(rowspan=1, colspan=1)
    41          sizer.Add(description, wx.GBPosition(row=1, col=1), span)
    42          sizer.Add(spin_ctrl, wx.GBPosition(row=2, col=1), span)
    43
    44 -    def _create_color_chooser_control(self):
    45          return ColourSelect(self)
    46
    47
    48 -class ColorEditor(BaseEditor, ColorEditorGuiCreator):
    49
    50 -    def __init__(self, parent, editor, name=""):
    51          BaseEditor.__init__(self, parent, editor)
    52          ColorEditorGuiCreator.__init__(self, parent)
    53          self.create_gui()
    54          self.clear_data()
    55
    56 -    def focus(self):
    57          super(ColorEditor, self).focus()
    58
    59 -    def clear_data(self):
    60          self.data.SetValue(wx.LIGHT_GREY)
    61
    62 -    def get_data(self):
    63          color = self.data.GetValue()
    64          return color.Get()
    65