merged in Ricardo Pedroso's new pdf2swf gui
[swftools.git] / wx / gui / dialogs.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 from __future__ import division
26 import os
27
28 import wx
29 from wx.lib.wordwrap import wordwrap
30
31 from gui.options import Quality, ViewerBook
32
33
34 class ProgressDialog(wx.ProgressDialog):
35     def __init__(self, title, message, maximum=100, parent=None,
36                  style=wx.PD_AUTO_HIDE|wx.PD_APP_MODAL):
37         wx.ProgressDialog.__init__(self, title, message, maximum=maximum,
38                                    parent=parent, style=style)
39
40 class OptionsDialog(wx.Dialog):
41     def __init__(self, parent):
42         wx.Dialog.__init__(self, parent)
43
44         app_name = wx.GetApp().GetAppName()
45         self.SetTitle(u"%s options" % app_name)
46
47         p = wx.Notebook(self)
48         self.__quality = Quality(p)
49         self.__viewers = ViewerBook(p)
50         p.AddPage(self.__quality, u"Quality")
51         p.AddPage(self.__viewers, u"Viewer")
52
53         sizer = wx.BoxSizer(wx.VERTICAL)
54         btnsizer = wx.BoxSizer(wx.HORIZONTAL)
55
56         btn = wx.Button(self, wx.ID_CLOSE)
57         self.SetAffirmativeId(wx.ID_CLOSE)
58         btnsizer.Add(btn)
59
60         sizer.Add(p, 0, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
61         sizer.Add(btnsizer, 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
62
63         self.SetSizer(sizer)
64         sizer.Fit(self)
65
66     def __get_quality(self):
67         return self.__quality
68     quality_panel = property(__get_quality)
69
70     def __get_viewers(self):
71         return self.__viewers
72     viewers_panel = property(__get_viewers)
73
74     def __get_quality_options(self):
75         return self.__quality.options
76     quality = property(__get_quality_options)
77
78     def __get_viewers_options(self):
79         return self.__viewers.options
80     viewers = property(__get_viewers_options)
81
82
83 class AboutDialog:
84     def __init__(self, parent):
85         info = wx.AboutDialogInfo()
86         # no need to get app name
87         #info.Name = wx.GetApp().GetAppName()
88         info.Version = u"0.9.0"
89         info.Copyright = (u"Copyright (c) 2008,2009 "
90                           u"Matthias Kramm <kramm@quiss.org>")
91         info.Description = u"graphical user interface for pdf2swf"
92         info.Developers = [
93                            u"Matthias Kramm <kramm@quiss.org>",
94                            u"Ricardo Pedroso <rmdpedroso@gmail.com>",
95                           ]
96
97         if 'wxGTK' in wx.PlatformInfo:
98             info.WebSite = (u"http://www.swftools.org/", u"swftools home page")
99             licenseText = [
100                 u"%(name)s is free software; you can redistribute "
101                 u"it and/or modify it under the terms of the GNU General "
102                 u"Public License as published by the Free Software "
103                 u"Foundation; either version 2 of the License, or (at "
104                 u"your option) any later version."
105             ]
106             licenseText.append(
107                 u"%(name)s is distributed in the hope that it will "
108                 u"be useful, but WITHOUT ANY WARRANTY; without even the "
109                 u"implied warranty of MERCHANTABILITY or FITNESS FOR A "
110                 u"PARTICULAR PURPOSE. See the GNU General Public License "
111                 u"for more details."
112             )
113             licenseText.append(
114                 u"You should have received a copy of the GNU General "
115                 u"Public License along with %(name)s; if not, "
116                 u"write to the Free Software Foundation, Inc., 51 "
117                 u"Franklin St, Fifth Floor, Boston, MA  02110-1301 USA"
118             )
119             lic = (os.linesep*2).join(licenseText) % {'name': info.Name}
120             info.License = wordwrap(lic, 350, wx.ClientDC(parent))
121
122         wx.AboutBox(info)
123