2 # -*- coding: UTF-8 -*-
5 # graphical user interface for pdf2swf
7 # Part of the swftools package.
9 # Copyright (c) 2008,2009 Matthias Kramm <kramm@quiss.org>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
26 from choicetext import ChoiceInt
29 def __init__(self, name, label, data, selection):
33 self.selection = selection
36 self.value = self.ctrl.GetValue()
38 def _SetControlValue(self, value):
40 self.ctrl.SetValue(value)
42 def _OnUpdate(self, event):
46 def SetValue(self, value):
47 self._SetControlValue(value)
50 def __init__(self, name, value):
54 def draw(self, parent):
57 def SetValue(self, value):
62 def __init__(self, name, label, data, selection):
63 Option.__init__(self, name, label, data, selection)
64 self.choices = data[0::2]
65 self.data = data[1::2]
67 def draw(self, parent):
68 label = wx.StaticText(parent, label=self.label)
69 self.ctrl = ctrl = self.klass(parent, choices=self.choices)
70 ctrl.Bind(wx.EVT_CHOICE, self._OnUpdate)
71 self._SetControlValue(self.selection)
75 n = self.ctrl.GetSelection()
76 self.value = self.data[n]
78 def _SetControlValue(self, n):
79 self.ctrl.SetSelection(n)
80 self.value = self.data[n]
82 def SetValue(self, value):
83 # in python < 2.6 tuples doesnt have the index method
84 # be sure that we are using a list
90 self._SetControlValue(n)
92 class ChooseAndInt(Choose):
94 def __init__(self, name, label, data, selection, editselection, editvalue):
95 Choose.__init__(self, name, label, data, selection)
96 self.editselection = editselection
97 self.editvalue = editvalue
99 def draw(self, parent):
100 label = wx.StaticText(parent, label=self.label)
101 self.ctrl = ctrl = self.klass(parent, choices=self.choices,
102 editselection=self.editselection)
103 ctrl.choice.Bind(wx.EVT_CHOICE, self._OnUpdate)
104 ctrl.text.Bind(wx.EVT_TEXT, self._OnUpdate)
105 self._SetControlValue(self.selection)
109 n = self.ctrl.GetSelection()
110 if self.ctrl.IsEditableSelection(n):
111 self.value = self.ctrl.GetValue()
113 self.value = self.data[n]
115 def _SetControlValue(self, n):
116 self.ctrl.SetSelectionAndValue(n, self.editvalue)
117 self.value = self.data[n]
119 def SetValue(self, value):
120 # in python < 2.6 tuples doesnt have the index method
121 # be sure that we are using a list
122 tmp = list(self.data)
126 n = self.editselection
127 self.editvalue = value
128 self._SetControlValue(n)
132 def __init__(self, name, label, data, selection):
133 Option.__init__(self, name, label, data, selection)
134 self.choices = data[0::2]
135 self.data = data[1::2]
136 self.selection = selection
138 def draw(self, parent):
139 self.ctrl = ctrl = self.klass(parent, label=self.label,
140 choices=self.choices,
142 style=wx.RA_SPECIFY_COLS)
143 ctrl.Bind(wx.EVT_RADIOBOX, self._OnUpdate)
144 self._SetControlValue(self.selection)
148 n = self.ctrl.GetSelection()
149 self.value = self.data[n]
151 def _SetControlValue(self, n):
152 self.ctrl.SetSelection(n)
153 self.value = self.data[n]
155 def SetValue(self, value):
156 # in python < 2.6 tuples doesnt have the index method
157 # be sure that we are using a list
158 tmp = list(self.data)
163 self._SetControlValue(n)
165 class Spinner(Option):
167 def __init__(self, name, label, data, selection):
168 Option.__init__(self, name, label, data, selection)
172 def draw(self, parent):
173 label = wx.StaticText(parent, label=self.label)
174 self.ctrl = ctrl = self.klass(parent, min=self.min, max=self.max,
175 initial=self.selection)
176 ctrl.Bind(wx.EVT_SPINCTRL, self._OnUpdate)
177 self._SetControlValue(self.selection)
180 class Slider(Option):
182 def __init__(self, name, label, data, selection):
183 Option.__init__(self, name, label, data, selection)
187 def draw(self, parent):
188 label = wx.StaticText(parent, label=self.label)
189 self.ctrl = ctrl = self.klass(parent, minValue=self.min,
191 value=self.selection,
193 ctrl.Bind(wx.EVT_SCROLL, self._OnUpdate)
194 self._SetControlValue(self.selection)