Gnumed.timelinelib.wxgui.dialogs.eventeditortabselection.view

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

# Source Code for Module Gnumed.timelinelib.wxgui.dialogs.eventeditortabselection.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 os
     20
     21  import wx
     22
     23  from timelinelib.config.paths import ICONS_DIR
     24  from timelinelib.wxgui.dialogs.eventeditortabselection.controller import EventEditorTabSelectionDialogController
     25  from timelinelib.wxgui.framework import Dialog
     26
     27
     28 -class EventEditorTabSelectionDialog(Dialog):
     29
     30      """
     31      <BoxSizerVertical>
     32          <StaticText label="$(header_text)" border="ALL"/>
     33          <BoxSizerHorizontal border="LEFT|RIGHT" proportion="1">
     34              <ListBox
     35                  name="lst_tab_order"
     36                  width="120"
     37                  height="150"
     38                  proportion="1"
     39                  event_EVT_LISTBOX="on_selection_changed"
     40              />
     41              <Spacer />
     42              <BoxSizerVertical align="ALIGN_CENTER_VERTICAL">
     43                  <BitmapButton
     44                      name="btn_up"
     45                      bitmap="$(up_bitmap)"
     46                      event_EVT_BUTTON="on_up"
     47                  />
     48                  <Spacer />
     49                  <BitmapButton
     50                      name="btn_down"
     51                      bitmap="$(down_bitmap)"
     52                      event_EVT_BUTTON="on_down"
     53                  />
     54              </BoxSizerVertical>
     55          </BoxSizerHorizontal>
     56          <DialogButtonsOkCancelSizer
     57              border="ALL"
     58              event_EVT_BUTTON__ID_OK="on_ok"
     59          />
     60      </BoxSizerVertical>
     61      """
     62
     63 -    def __init__(self, parent, config):
     64          Dialog.__init__(self, EventEditorTabSelectionDialogController, parent, {
     65              "header_text": _("Select Tab Order:"),
     66              "up_bitmap": self._GetBitmap(wx.ART_GO_UP),
     67              "down_bitmap": self._GetBitmap(wx.ART_GO_DOWN)
     68          }, title=_("Event Editor Tab Order"),
     69              style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
     70          self.controller.on_init(config)
     71
     72 -    def FillListbox(self, tab_items):
     73          for text, key in tab_items:
     74              self.lst_tab_order.Append(text, key)
     75          self.lst_tab_order.Select(0)
     76
     77 -    def Close(self):
     78          self.EndModalOk()
     79
     80 -    def GetSelection(self):
     81          return self.lst_tab_order.GetSelection()
     82
     83 -    def GetClientData(self, inx):
     84          return self.lst_tab_order.GetClientData(inx)
     85
     86 -    def DisableBtnDown(self):
     87          self.btn_down.Disable()
     88
     89 -    def EnableBtnDown(self):
     90          self.btn_down.Enable()
     91
     92 -    def DisableBtnUp(self):
     93          self.btn_up.Disable()
     94
     95 -    def EnableBtnUp(self):
     96          self.btn_up.Enable()
     97
     98 -    def MoveSelectionUp(self, inx):
     99          self._MoveSelection(inx, -1)
    100
    101 -    def MoveSelectionDown(self, inx):
    102          self._MoveSelection(inx, 1)
    103
    104 -    def _MoveSelection(self, inx, offset):
    105          text = self.lst_tab_order.GetString(inx)
    106          key = self.lst_tab_order.GetClientData(inx)
    107          self.lst_tab_order.Delete(inx)
    108          self.lst_tab_order.Insert(text, inx + offset, key)
    109          self.lst_tab_order.Select(inx + offset)
    110
    111 -    def _GetBitmap(self, bitmap_id):
    112          if 'wxMSW' in wx.PlatformInfo:
    113              name = {wx.ART_GO_UP: "up.png", wx.ART_GO_DOWN: "down.png"}
    114              return wx.Bitmap(os.path.join(ICONS_DIR, name[bitmap_id]))
    115          else:
    116              size = (24, 24)
    117              return wx.ArtProvider.GetBitmap(bitmap_id, wx.ART_TOOLBAR, size)
    118