OSDN Git Service

Merge branch 'hotfix/singleton_with_db_accessor_generator_problem'
[amulettoolsmh4/main.git] / view / notebooksettingview.py
1 # -*- coding: utf-8 -*-
2
3 # GUIのメインフレームにおける設定Notebookのview
4 # 2013/12/15 written by kei9
5
6 import wx
7 from wx import xrc
8
9 import constnumbers
10
11 class NoteBookSettingView():
12     u""" メインフレームの流れ説明タブ """
13     def __init__(self, frame):
14         self.frame = frame
15         self._init_view()
16
17     def _init_view(self):
18         # initialize view
19         self.spin_ctrl_highlight1 = xrc.XRCCTRL(self.frame, "SpinCtrlHighlightThreshold1")
20         self.spin_ctrl_highlight2 = xrc.XRCCTRL(self.frame, "SpinCtrlHighlightThreshold2")
21         self.check_list_box_highlight_skill =  xrc.XRCCTRL(self.frame, "CheckListBoxHighlight")
22         self.ID_CHECK_LIST_BOX_HIGHLIGHT_SKILL = xrc.XRCID("CheckListBoxHighlight")
23
24         self.button_ok = xrc.XRCCTRL(self.frame, "ButtonSettingOK")
25         self.button_clear = xrc.XRCCTRL(self.frame, "ButtonSettingClear")
26         self.ID_BUTTON_OK = xrc.XRCID("ButtonSettingOK")
27         self.ID_BUTTON_CLEAR = xrc.XRCID("ButtonSettingClear")
28
29         # set min & max
30         self.set_minmax(constnumbers.THRESHOLD1_MIN, constnumbers.THRESHOLD1_MAX,
31                 constnumbers.THRESHOLD2_MIN, constnumbers.THRESHOLD2_MAX)
32         self.set_threshold(constnumbers.HIGHLIGHT_THRESHOLD1, constnumbers.HIGHLIGHT_THRESHOLD2)
33
34     def set_minmax(self, threshold1_min, threshold1_max, threshold2_min, threshold2_max):
35         u"""ハイライトする判定値のSpinCtrlの最大、最小値をセットする
36             arg: (threshold1_min, threshold1_max, threshold2_min, threshold2_max)
37         """
38         self.spin_ctrl_highlight1.SetRange(threshold1_min, threshold1_max)
39         self.spin_ctrl_highlight2.SetRange(threshold2_min, threshold2_max)
40
41     def set_threshold(self, threshold1, threshold2):
42         u"""ハイライトする判定値のSpinCtrlの値をセットする
43             arg (threshold1, threshold2)
44         """
45         self.spin_ctrl_highlight1.SetValue(threshold1)
46         self.spin_ctrl_highlight2.SetValue(threshold2)
47
48     def get_threshold(self):
49         u"""ハイライトする判定値のSpinCtrlの値を得る
50             return (threshold1, threshold2)
51         """
52         threshold1 = self.spin_ctrl_highlight1.GetValue()
53         threshold2 = self.spin_ctrl_highlight2.GetValue()
54         return (threshold1, threshold2)
55
56     def get_minmax(self):
57         u"""ハイライトする判定値のSpinCtrlの最大、最小値を得る
58             return (threshold1_min, threshold1_max, threshold2_min, threshold2_max)
59         """
60         threshold1_min = self.spin_ctrl_highlight1.GetMin()
61         threshold1_max = self.spin_ctrl_highlight1.GetMax()
62         threshold2_min = self.spin_ctrl_highlight2.GetMin()
63         threshold2_max = self.spin_ctrl_highlight2.GetMax()
64         return (threshold1_min, threshold1_max, threshold2_min, threshold2_max)
65
66     def set_skill_strings(self, string_list):
67         u""" CheckBoxListにスキル名をセットする """
68         self.check_list_box_highlight_skill.SetItems(string_list)
69
70     def get_checked_strings(self):
71         u""" CheckBoxListでチェックの入った文字列のリストを返す """
72         return [x for x in self.check_list_box_highlight_skill.GetCheckedStrings()]
73
74     def set_checked_strings(self, string_list):
75         u""" CheckBoxListで与えられた文字列に一致する名称のスキルにチェックを入れる """
76         self.check_list_box_highlight_skill.SetCheckedStrings(string_list)
77
78     def clear_checked_strings(self):
79         u""" CheckBoxListのチェックを全て外す """
80         for idx in self.check_list_box_highlight_skill.GetChecked():
81             self.check_list_box_highlight_skill.Check(idx, False)
82
83     def bind_button_ok(self, event_func, evt=wx.EVT_BUTTON):
84         u""" OKボタンが押された時のイベントをセットする """
85         self.button_ok.Bind(evt, event_func)
86
87     def bind_button_clear(self, event_func, evt=wx.EVT_BUTTON):
88         u""" クリアボタンが押された時のイベントをセットする """
89         self.button_clear.Bind(evt, event_func)