23 # along with this program; if not, write to the Free Software |
23 # along with this program; if not, write to the Free Software |
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
25 |
25 |
26 import wx |
26 import wx |
27 |
27 |
28 #------------------------------------------------------------------------------- |
28 # ------------------------------------------------------------------------------- |
29 # Helpers |
29 # Helpers |
30 #------------------------------------------------------------------------------- |
30 # ------------------------------------------------------------------------------- |
31 |
31 |
32 REQUIRED_PARAMS = ["projectName", "productName", "productVersion", "companyName"] |
32 REQUIRED_PARAMS = ["projectName", "productName", "productVersion", "companyName"] |
33 |
33 |
34 [TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, |
34 [ |
35 POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES |
35 TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, |
|
36 POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES |
36 ] = range(10) |
37 ] = range(10) |
37 |
38 |
38 #------------------------------------------------------------------------------- |
39 |
|
40 # ------------------------------------------------------------------------------- |
39 # Project Properties Panel |
41 # Project Properties Panel |
40 #------------------------------------------------------------------------------- |
42 # ------------------------------------------------------------------------------- |
|
43 |
41 |
44 |
42 class ProjectPropertiesPanel(wx.Notebook): |
45 class ProjectPropertiesPanel(wx.Notebook): |
43 |
46 |
44 def AddSizerParams(self, parent, sizer, params): |
47 def AddSizerParams(self, parent, sizer, params): |
45 for idx, (name, label) in enumerate(params): |
48 for idx, (name, label) in enumerate(params): |
46 border = 0 |
49 border = 0 |
47 if idx == 0: |
50 if idx == 0: |
48 border |= wx.TOP |
51 border |= wx.TOP |
49 elif idx == len(params) - 1: |
52 elif idx == len(params) - 1: |
50 border |= wx.BOTTOM |
53 border |= wx.BOTTOM |
51 |
54 |
52 st = wx.StaticText(parent, label=label) |
55 st = wx.StaticText(parent, label=label) |
53 sizer.AddWindow(st, border=10, |
56 sizer.AddWindow(st, border=10, |
54 flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT) |
57 flag=wx.ALIGN_CENTER_VERTICAL | border | wx.LEFT) |
55 |
58 |
56 tc = wx.TextCtrl(parent, style=wx.TE_PROCESS_ENTER) |
59 tc = wx.TextCtrl(parent, style=wx.TE_PROCESS_ENTER) |
57 setattr(self, name, tc) |
60 setattr(self, name, tc) |
58 callback = self.GetTextCtrlChangedFunction(tc, name) |
61 callback = self.GetTextCtrlChangedFunction(tc, name) |
59 self.Bind(wx.EVT_TEXT_ENTER, callback, tc) |
62 self.Bind(wx.EVT_TEXT_ENTER, callback, tc) |
60 tc.Bind(wx.EVT_KILL_FOCUS, callback) |
63 tc.Bind(wx.EVT_KILL_FOCUS, callback) |
61 sizer.AddWindow(tc, border=10, |
64 sizer.AddWindow(tc, border=10, |
62 flag=wx.GROW|border|wx.RIGHT) |
65 flag=wx.GROW | border | wx.RIGHT) |
63 |
66 |
64 def __init__(self, parent, controller=None, window=None, enable_required=True): |
67 def __init__(self, parent, controller=None, window=None, enable_required=True): |
65 wx.Notebook.__init__(self, parent) |
68 wx.Notebook.__init__(self, parent) |
66 |
69 |
67 self.Controller = controller |
70 self.Controller = controller |
68 self.ParentWindow = window |
71 self.ParentWindow = window |
69 self.Values = None |
72 self.Values = None |
70 |
73 |
71 # Project Panel elements |
74 # Project Panel elements |
72 |
75 |
73 self.ProjectPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
76 self.ProjectPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
74 projectpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=5, vgap=15) |
77 projectpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=5, vgap=15) |
75 projectpanel_sizer.AddGrowableCol(1) |
78 projectpanel_sizer.AddGrowableCol(1) |
76 self.ProjectPanel.SetSizer(projectpanel_sizer) |
79 self.ProjectPanel.SetSizer(projectpanel_sizer) |
77 |
80 |
78 self.AddSizerParams(self.ProjectPanel, projectpanel_sizer, |
81 self.AddSizerParams(self.ProjectPanel, projectpanel_sizer, |
79 [("projectName", _('Project Name (required):')), |
82 [("projectName", _('Project Name (required):')), |
80 ("projectVersion", _('Project Version (optional):')), |
83 ("projectVersion", _('Project Version (optional):')), |
81 ("productName", _('Product Name (required):')), |
84 ("productName", _('Product Name (required):')), |
82 ("productVersion", _('Product Version (required):')), |
85 ("productVersion", _('Product Version (required):')), |
83 ("productRelease", _('Product Release (optional):'))]) |
86 ("productRelease", _('Product Release (optional):'))]) |
84 |
87 |
85 self.AddPage(self.ProjectPanel, _("Project")) |
88 self.AddPage(self.ProjectPanel, _("Project")) |
86 |
89 |
87 # Author Panel elements |
90 # Author Panel elements |
88 |
91 |
89 self.AuthorPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
92 self.AuthorPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
90 authorpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=4, vgap=15) |
93 authorpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=4, vgap=15) |
91 authorpanel_sizer.AddGrowableCol(1) |
94 authorpanel_sizer.AddGrowableCol(1) |
92 self.AuthorPanel.SetSizer(authorpanel_sizer) |
95 self.AuthorPanel.SetSizer(authorpanel_sizer) |
93 |
96 |
94 self.AddSizerParams(self.AuthorPanel, authorpanel_sizer, |
97 self.AddSizerParams(self.AuthorPanel, authorpanel_sizer, |
95 [("companyName", _('Company Name (required):')), |
98 [("companyName", _('Company Name (required):')), |
96 ("companyURL", _('Company URL (optional):')), |
99 ("companyURL", _('Company URL (optional):')), |
97 ("authorName", _('Author Name (optional):')), |
100 ("authorName", _('Author Name (optional):')), |
98 ("organization", _('Organization (optional):'))]) |
101 ("organization", _('Organization (optional):'))]) |
99 |
102 |
100 self.AddPage(self.AuthorPanel, _("Author")) |
103 self.AddPage(self.AuthorPanel, _("Author")) |
101 |
104 |
102 # Graphics Panel elements |
105 # Graphics Panel elements |
103 |
106 |
104 self.GraphicsPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
107 self.GraphicsPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
105 graphicpanel_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=4, vgap=5) |
108 graphicpanel_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=4, vgap=5) |
106 graphicpanel_sizer.AddGrowableCol(0) |
109 graphicpanel_sizer.AddGrowableCol(0) |
107 graphicpanel_sizer.AddGrowableRow(3) |
110 graphicpanel_sizer.AddGrowableRow(3) |
108 self.GraphicsPanel.SetSizer(graphicpanel_sizer) |
111 self.GraphicsPanel.SetSizer(graphicpanel_sizer) |
109 |
112 |
110 pageSize_st = wx.StaticText(self.GraphicsPanel, |
113 pageSize_st = wx.StaticText(self.GraphicsPanel, |
111 label=_('Page Size (optional):')) |
114 label=_('Page Size (optional):')) |
112 graphicpanel_sizer.AddWindow(pageSize_st, border=10, |
115 graphicpanel_sizer.AddWindow( |
113 flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT|wx.RIGHT) |
116 pageSize_st, border=10, |
114 |
117 flag=wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.LEFT | wx.RIGHT) |
|
118 |
115 pageSize_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) |
119 pageSize_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) |
116 pageSize_sizer.AddGrowableCol(1) |
120 pageSize_sizer.AddGrowableCol(1) |
117 graphicpanel_sizer.AddSizer(pageSize_sizer, border=10, |
121 graphicpanel_sizer.AddSizer(pageSize_sizer, border=10, |
118 flag=wx.GROW|wx.LEFT|wx.RIGHT) |
122 flag=wx.GROW | wx.LEFT | wx.RIGHT) |
119 |
123 |
120 for name, label in [('PageWidth', _('Width:')), |
124 for name, label in [('PageWidth', _('Width:')), |
121 ('PageHeight', _('Height:'))]: |
125 ('PageHeight', _('Height:'))]: |
122 st = wx.StaticText(self.GraphicsPanel, label=label) |
126 st = wx.StaticText(self.GraphicsPanel, label=label) |
123 pageSize_sizer.AddWindow(st, border=12, |
127 pageSize_sizer.AddWindow(st, border=12, |
124 flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT) |
128 flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT) |
125 |
129 |
126 sp = wx.SpinCtrl(self.GraphicsPanel, |
130 sp = wx.SpinCtrl(self.GraphicsPanel, |
127 min=0, max=2**16, style=wx.TE_PROCESS_ENTER) |
131 min=0, max=2**16, style=wx.TE_PROCESS_ENTER) |
128 setattr(self, name, sp) |
132 setattr(self, name, sp) |
129 callback = self.GetPageSizeChangedFunction(sp, name) |
133 callback = self.GetPageSizeChangedFunction(sp, name) |
130 self.Bind(wx.EVT_TEXT_ENTER, callback, sp) |
134 self.Bind(wx.EVT_TEXT_ENTER, callback, sp) |
131 sp.Bind(wx.EVT_KILL_FOCUS, callback) |
135 sp.Bind(wx.EVT_KILL_FOCUS, callback) |
132 pageSize_sizer.AddWindow(sp, flag=wx.GROW) |
136 pageSize_sizer.AddWindow(sp, flag=wx.GROW) |
133 |
137 |
134 scaling_st = wx.StaticText(self.GraphicsPanel, |
138 scaling_st = wx.StaticText(self.GraphicsPanel, |
135 label=_('Grid Resolution:')) |
139 label=_('Grid Resolution:')) |
136 graphicpanel_sizer.AddWindow(scaling_st, border=10, |
140 graphicpanel_sizer.AddWindow(scaling_st, border=10, |
137 flag=wx.GROW|wx.LEFT|wx.RIGHT) |
141 flag=wx.GROW | wx.LEFT | wx.RIGHT) |
138 |
142 |
139 scaling_nb = wx.Notebook(self.GraphicsPanel) |
143 scaling_nb = wx.Notebook(self.GraphicsPanel) |
140 graphicpanel_sizer.AddWindow(scaling_nb, border=10, |
144 graphicpanel_sizer.AddWindow(scaling_nb, border=10, |
141 flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
145 flag=wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT) |
142 |
146 |
143 self.Scalings = {} |
147 self.Scalings = {} |
144 for language, translation in [("FBD",_("FBD")), ("LD",_("LD")), ("SFC",_("SFC"))]: |
148 for language, translation in [("FBD", _("FBD")), ("LD", _("LD")), ("SFC", _("SFC"))]: |
145 scaling_panel = wx.Panel(scaling_nb, style=wx.TAB_TRAVERSAL) |
149 scaling_panel = wx.Panel(scaling_nb, style=wx.TAB_TRAVERSAL) |
146 scalingpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) |
150 scalingpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) |
147 scalingpanel_sizer.AddGrowableCol(1) |
151 scalingpanel_sizer.AddGrowableCol(1) |
148 scaling_panel.SetSizer(scalingpanel_sizer) |
152 scaling_panel.SetSizer(scalingpanel_sizer) |
149 |
153 |
150 scaling_controls = [] |
154 scaling_controls = [] |
151 for idx, (name, label) in enumerate([('XScale', _('Horizontal:')), |
155 for idx, (name, label) in enumerate([('XScale', _('Horizontal:')), |
152 ('YScale', _('Vertical:'))]): |
156 ('YScale', _('Vertical:'))]): |
153 if idx == 0: |
157 if idx == 0: |
154 border = wx.TOP |
158 border = wx.TOP |
155 else: |
159 else: |
156 border = wx.BOTTOM |
160 border = wx.BOTTOM |
157 |
161 |
158 st = wx.StaticText(scaling_panel, label=label) |
162 st = wx.StaticText(scaling_panel, label=label) |
159 scalingpanel_sizer.AddWindow(st, border=10, |
163 scalingpanel_sizer.AddWindow( |
160 flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT) |
164 st, border=10, |
161 |
165 flag=wx.ALIGN_CENTER_VERTICAL | border | wx.LEFT) |
162 sp = wx.SpinCtrl(scaling_panel, |
166 |
163 min=0, max=2**16, style=wx.TE_PROCESS_ENTER) |
167 sp = wx.SpinCtrl(scaling_panel, |
|
168 min=0, max=2**16, style=wx.TE_PROCESS_ENTER) |
164 scaling_controls.append(sp) |
169 scaling_controls.append(sp) |
165 callback = self.GetScalingChangedFunction(sp, language, name) |
170 callback = self.GetScalingChangedFunction(sp, language, name) |
166 self.Bind(wx.EVT_TEXT_ENTER, callback, sp) |
171 self.Bind(wx.EVT_TEXT_ENTER, callback, sp) |
167 sp.Bind(wx.EVT_KILL_FOCUS, callback) |
172 sp.Bind(wx.EVT_KILL_FOCUS, callback) |
168 scalingpanel_sizer.AddWindow(sp, border=10, |
173 scalingpanel_sizer.AddWindow(sp, border=10, |
169 flag=wx.GROW|border|wx.RIGHT) |
174 flag=wx.GROW | border | wx.RIGHT) |
170 |
175 |
171 self.Scalings[language] = scaling_controls |
176 self.Scalings[language] = scaling_controls |
172 scaling_nb.AddPage(scaling_panel, translation) |
177 scaling_nb.AddPage(scaling_panel, translation) |
173 |
178 |
174 self.AddPage(self.GraphicsPanel, _("Graphics")) |
179 self.AddPage(self.GraphicsPanel, _("Graphics")) |
175 |
180 |
176 # Miscellaneous Panel elements |
181 # Miscellaneous Panel elements |
177 |
182 |
178 self.MiscellaneousPanel = wx.Panel(id=-1, parent=self, |
183 self.MiscellaneousPanel = wx.Panel( |
179 name='MiscellaneousPanel', pos=wx.Point(0, 0), |
184 id=-1, parent=self, name='MiscellaneousPanel', pos=wx.Point(0, 0), |
180 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
185 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
181 miscellaneouspanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=15) |
186 miscellaneouspanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=15) |
182 miscellaneouspanel_sizer.AddGrowableCol(1) |
187 miscellaneouspanel_sizer.AddGrowableCol(1) |
183 miscellaneouspanel_sizer.AddGrowableRow(1) |
188 miscellaneouspanel_sizer.AddGrowableRow(1) |
184 self.MiscellaneousPanel.SetSizer(miscellaneouspanel_sizer) |
189 self.MiscellaneousPanel.SetSizer(miscellaneouspanel_sizer) |
185 |
190 |
186 language_label = wx.StaticText(self.MiscellaneousPanel, |
191 language_label = wx.StaticText(self.MiscellaneousPanel, |
187 label=_('Language (optional):')) |
192 label=_('Language (optional):')) |
188 miscellaneouspanel_sizer.AddWindow(language_label, border=10, |
193 miscellaneouspanel_sizer.AddWindow(language_label, border=10, |
189 flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT) |
194 flag=wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.LEFT) |
190 |
195 |
191 self.Language = wx.ComboBox(self.MiscellaneousPanel, |
196 self.Language = wx.ComboBox(self.MiscellaneousPanel, |
192 style=wx.CB_READONLY) |
197 style=wx.CB_READONLY) |
193 self.Bind(wx.EVT_COMBOBOX, self.OnLanguageChanged, self.Language) |
198 self.Bind(wx.EVT_COMBOBOX, self.OnLanguageChanged, self.Language) |
194 miscellaneouspanel_sizer.AddWindow(self.Language, border=10, |
199 miscellaneouspanel_sizer.AddWindow(self.Language, border=10, |
195 flag=wx.GROW|wx.TOP|wx.RIGHT) |
200 flag=wx.GROW | wx.TOP | wx.RIGHT) |
196 |
201 |
197 description_label = wx.StaticText(self.MiscellaneousPanel, |
202 description_label = wx.StaticText( |
198 label=_('Content Description (optional):')) |
203 self.MiscellaneousPanel, label=_('Content Description (optional):')) |
199 miscellaneouspanel_sizer.AddWindow(description_label, border=10, |
204 miscellaneouspanel_sizer.AddWindow(description_label, border=10, |
200 flag=wx.BOTTOM|wx.LEFT) |
205 flag=wx.BOTTOM | wx.LEFT) |
201 |
206 |
202 self.ContentDescription = wx.TextCtrl(self.MiscellaneousPanel, |
207 self.ContentDescription = wx.TextCtrl( |
203 size=wx.Size(240,150), style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER) |
208 self.MiscellaneousPanel, size=wx.Size(240, 150), |
204 self.Bind(wx.EVT_TEXT_ENTER, self.OnContentDescriptionChanged, |
209 style=wx.TE_MULTILINE | wx.TE_PROCESS_ENTER) |
205 self.ContentDescription) |
210 self.Bind(wx.EVT_TEXT_ENTER, self.OnContentDescriptionChanged, |
206 self.ContentDescription.Bind(wx.EVT_KILL_FOCUS, |
211 self.ContentDescription) |
207 self.OnContentDescriptionChanged) |
212 self.ContentDescription.Bind(wx.EVT_KILL_FOCUS, |
208 miscellaneouspanel_sizer.AddWindow(self.ContentDescription, border=10, |
213 self.OnContentDescriptionChanged) |
209 flag=wx.GROW|wx.BOTTOM|wx.RIGHT) |
214 miscellaneouspanel_sizer.AddWindow(self.ContentDescription, border=10, |
210 |
215 flag=wx.GROW | wx.BOTTOM | wx.RIGHT) |
|
216 |
211 self.AddPage(self.MiscellaneousPanel, _("Miscellaneous")) |
217 self.AddPage(self.MiscellaneousPanel, _("Miscellaneous")) |
212 |
218 |
213 for param in REQUIRED_PARAMS: |
219 for param in REQUIRED_PARAMS: |
214 getattr(self, param).Enable(enable_required) |
220 getattr(self, param).Enable(enable_required) |
215 |
221 |
216 languages = ["", "en-US", "fr-FR", "zh-CN", "ru-RU"] |
222 languages = ["", "en-US", "fr-FR", "zh-CN", "ru-RU"] |
217 |
223 |
218 for language in languages: |
224 for language in languages: |
219 self.Language.Append(language) |
225 self.Language.Append(language) |
220 |
226 |
221 def RefreshView(self): |
227 def RefreshView(self): |
222 if self.Controller is not None: |
228 if self.Controller is not None: |