Package Gnumed :: Package timelinelib :: Package wxgui :: Package components :: Package textpatterncontrol :: Module view |
[frames] | no frames]

# Source Code for Module Gnumed.timelinelib.wxgui.components.textpatterncontrol.view

     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.textctrl import TextCtrl
    22  from timelinelib.wxgui.components.textpatterncontrol.controller import TextPatternControlController
    23
    24
    25 -class TextPatternControl(TextCtrl):
    26
    27 -    def __init__(self, parent, name=None, fit_text=None):
    28          TextCtrl.__init__(
    29              self,
    30              parent,
    31              style=wx.TE_PROCESS_TAB,
    32              fit_text=fit_text
    33          )
    34          self.controller = TextPatternControlController(self)
    35          self._bind_events()
    36          self.controller.on_init()
    37
    38 -    def GetParts(self):
    39          return self.controller.get_parts()
    40
    41 -    def GetSelectedGroup(self):
    42          return self.controller.get_selected_group()
    43
    44 -    def SetSeparators(self, separators):
    45          self.controller.set_separators(separators)
    46
    47 -    def SetParts(self, parts):
    48          self.controller.set_parts(parts)
    49
    50 -    def SetValidator(self, validator):
    51          self.controller.set_validator(validator)
    52
    53 -    def SetUpHandler(self, group, up_handler):
    54          self.controller.set_up_handler(group, up_handler)
    55
    56 -    def SetDownHandler(self, group, down_handler):
    57          self.controller.set_down_handler(group, down_handler)
    58
    59 -    def Validate(self):
    60          self.controller.validate()
    61
    62 -    def _bind_events(self):
    63          self.Bind(wx.EVT_CHAR, self.controller.on_char)
    64          self.Bind(wx.EVT_TEXT, self.controller.on_text)
    65          self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus)
    66          self.Bind(wx.EVT_KILL_FOCUS, self.controller.on_kill_focus)
    67
    68 -    def _on_set_focus(self, event):
    69          wx.CallAfter(self.controller.on_after_set_focus)
    70          event.Skip()
    71