small cosmetic improvements
[swftools.git] / wx / gui / options / quality.py
1 #!/usr/bin/env python
2 # -*- coding: UTF-8 -*-
3 #
4 # gpdf2swf.py
5 # graphical user interface for pdf2swf
6 #
7 # Part of the swftools package.
8
9 # Copyright (c) 2008,2009 Matthias Kramm <kramm@quiss.org> 
10 #
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.
15 #
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.
20 #
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 */
24
25 import wx
26 from gui import fields
27
28 class Quality(wx.Panel):
29     def __init__(self, parent):
30         wx.Panel.__init__(self, parent)
31         self.__options = []
32
33         sizer = wx.BoxSizer(wx.VERTICAL)
34         obj = fields.Radio(
35                         ("bitmap", "poly2bitmap", "bitmapfonts"),
36                          u"Rendering mode",
37                         [u"Convert polygons to polygons and fonts to fonts", (0, 0, 0),
38                          u"Convert fonts to fonts, everything else to bitmaps", (0, 1, 0),
39                          u"Convert everthing to bitmaps", (1, 0, 1),
40                         ], 0)
41
42         ra = obj.draw(self)
43         self.__options.append(obj)
44         sizer.Add(ra, 0, wx.EXPAND|wx.ALL, 5)
45
46         quality = [
47             ('Spinner', 'zoom', u'Resolution (in dpi):', (0, 100), 72),
48             ('Slider', 'fontquality', u'Font quality:', (0, 100), 20),
49             ('Choose', 'storeallcharacters', u'Insert full fonts in SWF file:',
50                        (u'no', 0, u'yes', 1), 0),
51             ('Slider', 'splinequality', u'Polygon quality:', (0, 100), 100),
52             ('Slider', 'jpegquality', u'JPEG quality:', (0, 100), 75),
53             ('Choose', 'jpegsubpixels', u'JPEG image resolution:',
54                        (u'same as in PDF', 0, u'1x', 1, u'2x', 2, u'4x', 4), 0),
55             ('Choose', 'ppmsubpixels', u'non-JPEG image resolution:',
56                        (u'same as in PDF', 0, u'1x', 1, u'2x', 2, u'4x', 4), 0),
57         ]
58
59         box = wx.StaticBox(self, label=u"Quality")
60         bsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
61
62         flex = wx.FlexGridSizer(rows=1, cols=2, hgap=0, vgap=0)
63         flex.AddGrowableCol(0)
64         flex.AddGrowableCol(1)
65         for ctrl, opt, label, range, value in quality:
66             wxobj = getattr(fields, ctrl)
67             optobj = wxobj(opt, label, range, value)
68             lb, sp = optobj.draw(self)
69             flex.Add(lb, 0, wx.TOP|wx.ALIGN_CENTER_VERTICAL, 5)
70             flex.Add(sp, 0, wx.TOP|wx.EXPAND, 5)
71             self.__options.append(optobj)
72
73         bsizer.Add(flex, 0, wx.EXPAND)
74         sizer.Add(bsizer, 0, wx.EXPAND|wx.ALL, 5)
75
76         self.SetSizer(sizer)
77
78     def __get_options(self):
79         return self.__options
80     options = property(__get_options)
81
82     def pickle(self):
83         data = {}
84         for opt in self.__options:
85             data[opt.name] = opt.value
86         return data
87
88     def unpickle(self, data):
89         fields = {}
90         for opt in self.__options:
91             fields[opt.name] = opt
92
93         for k, v in data.items():
94             fields[k].SetValue(v)