Package Gnumed :: Package timelinelib :: Package wxgui :: Package dialogs :: Package editcategory :: Module view |
[frames] | no frames]

# Source Code for Module Gnumed.timelinelib.wxgui.dialogs.editcategory.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  from timelinelib.wxgui.dialogs.editcategory.controller import EditCategoryDialogController
     20  from timelinelib.wxgui.framework import Dialog
     21  from timelinelib.wxgui.utils import display_error_message
     22  from timelinelib.wxgui.utils import _set_focus_and_select
     23
     24
     25 -class EditCategoryDialog(Dialog):
     26
     27      """
     28      <BoxSizerVertical>
     29          <FlexGridSizer rows="6" columns="2" growableColumns="1" proportion="1" border="ALL">
     30              <StaticText align="ALIGN_CENTER_VERTICAL" label="$(name_text)" />
     31              <TextCtrl name="txt_name" width="150" />
     32              <StaticText align="ALIGN_CENTER_VERTICAL" label="$(color_text)" />
     33              <ColourSelect name="colorpicker" align="ALIGN_CENTER_VERTICAL" width="60" height="30" />
     34              <StaticText align="ALIGN_CENTER_VERTICAL" label="$(progress_color_text)" />
     35              <ColourSelect name="progresscolorpicker" align="ALIGN_CENTER_VERTICAL" width="60" height="30" />
     36              <StaticText align="ALIGN_CENTER_VERTICAL" label="$(done_color_text)" />
     37              <ColourSelect name="donecolorpicker" align="ALIGN_CENTER_VERTICAL" width="60" height="30" />
     38              <StaticText align="ALIGN_CENTER_VERTICAL" label="$(font_color_text)" />
     39              <ColourSelect name="fontcolorpicker" align="ALIGN_CENTER_VERTICAL" width="60" height="30" />
     40              <StaticText align="ALIGN_CENTER_VERTICAL" label="$(parent_text)" />
     41              <CategoryChoice name="category_choice" allow_add="True" timeline="$(db)" align="ALIGN_CENTER_VERTICAL" />
     42          </FlexGridSizer>
     43          <DialogButtonsOkCancelSizer
     44              border="LEFT|BOTTOM|RIGHT"
     45              event_EVT_BUTTON__ID_OK="on_ok_clicked"
     46          />
     47      </BoxSizerVertical>
     48      """
     49
     50 -    def __init__(self, parent, title, db, category):
     51          Dialog.__init__(self, EditCategoryDialogController, parent, {
     52              "db": db,
     53              "name_text": _("Name:"),
     54              "color_text": _("Color:"),
     55              "progress_color_text": _("Progress Color:"),
     56              "done_color_text": _("Done Color:"),
     57              "font_color_text": _("Font Color:"),
     58              "parent_text": _("Parent:"),
     59          }, title=title)
     60          self.controller.on_init(db, category)
     61
     62 -    def PopulateCategories(self, exclude):
     63          self.category_choice.Populate(exclude=exclude)
     64          self.Fit()
     65
     66 -    def GetName(self):
     67          return self.txt_name.GetValue().strip()
     68
     69 -    def SetName(self, new_name):
     70          self.txt_name.SetValue(new_name)
     71
     72 -    def GetColor(self):
     73          return self.colorpicker.GetValueAsRgbTuple()
     74
     75 -    def SetColor(self, new_color):
     76          self.colorpicker.SetValue(new_color)
     77
     78 -    def GetProgressColor(self):
     79          return self.progresscolorpicker.GetValueAsRgbTuple()
     80
     81 -    def SetProgressColor(self, new_color):
     82          self.progresscolorpicker.SetValue(new_color)
     83
     84 -    def GetDoneColor(self):
     85          return self.donecolorpicker.GetValueAsRgbTuple()
     86
     87 -    def SetDoneColor(self, new_color):
     88          self.donecolorpicker.SetValue(new_color)
     89
     90 -    def GetFontColor(self):
     91          return self.fontcolorpicker.GetValueAsRgbTuple()
     92
     93 -    def SetFontColor(self, new_color):
     94          self.fontcolorpicker.SetValue(new_color)
     95
     96 -    def GetParent(self):
     97          return self.category_choice.GetSelectedCategory()
     98
     99 -    def SetParent(self, parent):
    100          return self.category_choice.SetSelectedCategory(parent)
    101
    102 -    def HandleInvalidName(self, name):
    103          msg = _("Category name '%s' not valid. Must be non-empty.")
    104          display_error_message(msg % name, self)
    105          _set_focus_and_select(self.txt_name)
    106
    107 -    def HandleUsedName(self, name):
    108          msg = _("Category name '%s' already in use.")
    109          display_error_message(msg % name, self)
    110          _set_focus_and_select(self.txt_name)
    111
    112 -    def GetEditedCategory(self):
    113          return self.controller.get_edited_category()
    114