controls/ProjectPropertiesPanel.py
author Laurent Bessard
Fri, 13 Jul 2012 12:42:38 +0200
changeset 725 7c44fc339889
parent 714 131ea7f237b9
permissions -rw-r--r--
Fix bug with FBDBlockDialog on Beremiz
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     1
#!/usr/bin/env python
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     3
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     4
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     5
#based on the plcopen standard. 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     6
#
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     7
#Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     8
#
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
     9
#See COPYING file for copyrights details.
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    10
#
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    11
#This library is free software; you can redistribute it and/or
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    12
#modify it under the terms of the GNU General Public
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    13
#License as published by the Free Software Foundation; either
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    14
#version 2.1 of the License, or (at your option) any later version.
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    15
#
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    16
#This library is distributed in the hope that it will be useful,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    17
#but WITHOUT ANY WARRANTY; without even the implied warranty of
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    18
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    19
#General Public License for more details.
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    20
#
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    21
#You should have received a copy of the GNU General Public
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    22
#License along with this library; if not, write to the Free Software
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    23
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    24
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    25
import wx
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    26
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    27
#-------------------------------------------------------------------------------
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    28
#                                 Helpers
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    29
#-------------------------------------------------------------------------------
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    30
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    31
REQUIRED_PARAMS = ["projectName", "productName", "productVersion", "companyName"]
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    32
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    33
[TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    34
 POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    35
] = range(10)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    36
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    37
#-------------------------------------------------------------------------------
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    38
#                       Project Properties Panel
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    39
#-------------------------------------------------------------------------------
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    40
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    41
class ProjectPropertiesPanel(wx.Notebook):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    42
    
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    43
    def AddSizerParams(self, parent, sizer, params):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    44
        for idx, (name, label) in enumerate(params):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    45
            border = 0
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    46
            if idx == 0:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    47
                border |= wx.TOP
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    48
            elif idx == len(params) - 1:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    49
                border |= wx.BOTTOM
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    50
            
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    51
            st = wx.StaticText(parent, label=label)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    52
            sizer.AddWindow(st, border=10, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    53
                  flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    54
            
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    55
            tc = wx.TextCtrl(parent, style=wx.TE_PROCESS_ENTER)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    56
            setattr(self, name, tc)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    57
            callback = self.GetTextCtrlChangedFunction(tc, name)
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    58
            self.Bind(wx.EVT_TEXT_ENTER, callback, tc)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    59
            tc.Bind(wx.EVT_KILL_FOCUS, callback)
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    60
            sizer.AddWindow(tc, border=10, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    61
                  flag=wx.GROW|border|wx.RIGHT)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    62
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    63
    def __init__(self, parent, controller=None, window=None, enable_required=True):
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    64
        wx.Notebook.__init__(self, parent, size=wx.Size(500, 300))
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    65
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    66
        self.Controller = controller
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    67
        self.ParentWindow = window
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    68
        self.Values = None
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    69
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    70
        # Project Panel elements
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    71
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    72
        self.ProjectPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    73
        projectpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=5, vgap=15)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    74
        projectpanel_sizer.AddGrowableCol(1)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    75
        self.ProjectPanel.SetSizer(projectpanel_sizer)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    76
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    77
        self.AddSizerParams(self.ProjectPanel, projectpanel_sizer,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    78
              [("projectName", _('Project Name (required):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    79
               ("projectVersion", _('Project Version (optional):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    80
               ("productName", _('Product Name (required):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    81
               ("productVersion", _('Product Version (required):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    82
               ("productRelease", _('Product Release (optional):'))])
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    83
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    84
        self.AddPage(self.ProjectPanel, _("Project"))
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    85
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    86
        # Author Panel elements
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    87
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
    88
        self.AuthorPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    89
        authorpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=4, vgap=15)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    90
        authorpanel_sizer.AddGrowableCol(1)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    91
        self.AuthorPanel.SetSizer(authorpanel_sizer)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    92
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    93
        self.AddSizerParams(self.AuthorPanel, authorpanel_sizer,
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    94
              [("companyName", _('Company Name (required):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    95
               ("companyURL", _('Company URL (optional):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    96
               ("authorName", _('Author Name (optional):')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    97
               ("organization", _('Organization (optional):'))])
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    98
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
    99
        self.AddPage(self.AuthorPanel, _("Author"))
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   100
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   101
        # Graphics Panel elements
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   102
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   103
        self.GraphicsPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   104
        graphicpanel_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=4, vgap=5)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   105
        graphicpanel_sizer.AddGrowableCol(0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   106
        graphicpanel_sizer.AddGrowableRow(3)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   107
        self.GraphicsPanel.SetSizer(graphicpanel_sizer)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   108
        
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   109
        pageSize_st = wx.StaticText(self.GraphicsPanel,
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   110
              label=_('Page Size (optional):'))
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   111
        graphicpanel_sizer.AddWindow(pageSize_st, border=10, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   112
              flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT|wx.RIGHT)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   113
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   114
        pageSize_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   115
        pageSize_sizer.AddGrowableCol(1)
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   116
        graphicpanel_sizer.AddSizer(pageSize_sizer, border=10, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   117
              flag=wx.GROW|wx.LEFT|wx.RIGHT)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   118
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   119
        for name, label in [('PageWidth', _('Width:')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   120
                            ('PageHeight', _('Height:'))]:
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   121
            st = wx.StaticText(self.GraphicsPanel, label=label)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   122
            pageSize_sizer.AddWindow(st, border=12, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   123
                  flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   124
            
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   125
            sp = wx.SpinCtrl(self.GraphicsPanel, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   126
                  min=0, max=2**16, style=wx.TE_PROCESS_ENTER)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   127
            setattr(self, name, sp)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   128
            callback = self.GetPageSizeChangedFunction(sp, name)
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   129
            self.Bind(wx.EVT_TEXT_ENTER, callback, sp)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   130
            sp.Bind(wx.EVT_KILL_FOCUS, callback)
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   131
            pageSize_sizer.AddWindow(sp, flag=wx.GROW)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   132
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   133
        scaling_st = wx.StaticText(self.GraphicsPanel,
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   134
              label=_('Grid Resolution:'))
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   135
        graphicpanel_sizer.AddWindow(scaling_st, border=10, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   136
              flag=wx.GROW|wx.LEFT|wx.RIGHT)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   137
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   138
        scaling_nb = wx.Notebook(self.GraphicsPanel)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   139
        graphicpanel_sizer.AddWindow(scaling_nb, border=10, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   140
              flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   141
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   142
        self.Scalings = {}
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   143
        for language, translation in [("FBD",_("FBD")), ("LD",_("LD")), ("SFC",_("SFC"))]:
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   144
            scaling_panel = wx.Panel(scaling_nb, style=wx.TAB_TRAVERSAL)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   145
            scalingpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   146
            scalingpanel_sizer.AddGrowableCol(1)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   147
            scaling_panel.SetSizer(scalingpanel_sizer)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   148
            
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   149
            scaling_controls = []
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   150
            for idx, (name, label) in enumerate([('XScale', _('Horizontal:')),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   151
                                                 ('YScale', _('Vertical:'))]):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   152
                if idx == 0:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   153
                    border = wx.TOP
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   154
                else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   155
                    border = wx.BOTTOM
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   156
                
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   157
                st = wx.StaticText(scaling_panel, label=label)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   158
                scalingpanel_sizer.AddWindow(st, border=10, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   159
                      flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   160
                
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   161
                sp = wx.SpinCtrl(scaling_panel, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   162
                      min=0, max=2**16, style=wx.TE_PROCESS_ENTER)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   163
                scaling_controls.append(sp)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   164
                callback = self.GetScalingChangedFunction(sp, language, name)
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   165
                self.Bind(wx.EVT_TEXT_ENTER, callback, sp)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   166
                sp.Bind(wx.EVT_KILL_FOCUS, callback)
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   167
                scalingpanel_sizer.AddWindow(sp, border=10, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   168
                      flag=wx.GROW|border|wx.RIGHT)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   169
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   170
            self.Scalings[language] = scaling_controls
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   171
            scaling_nb.AddPage(scaling_panel, translation)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   172
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   173
        self.AddPage(self.GraphicsPanel, _("Graphics"))
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   174
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   175
        # Miscellaneous Panel elements
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   176
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   177
        self.MiscellaneousPanel = wx.Panel(id=-1, parent=self, 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   178
              name='MiscellaneousPanel', pos=wx.Point(0, 0),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   179
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   180
        miscellaneouspanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=15)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   181
        miscellaneouspanel_sizer.AddGrowableCol(1)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   182
        miscellaneouspanel_sizer.AddGrowableRow(1)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   183
        self.MiscellaneousPanel.SetSizer(miscellaneouspanel_sizer)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   184
        
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   185
        language_label = wx.StaticText(self.MiscellaneousPanel,
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   186
              label=_('Language (optional):'))
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   187
        miscellaneouspanel_sizer.AddWindow(language_label, border=10, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   188
              flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   189
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   190
        self.Language = wx.ComboBox(self.MiscellaneousPanel, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   191
              style=wx.CB_READONLY)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   192
        self.Bind(wx.EVT_COMBOBOX, self.OnLanguageChanged, self.Language)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   193
        miscellaneouspanel_sizer.AddWindow(self.Language, border=10, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   194
              flag=wx.GROW|wx.TOP|wx.RIGHT)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   195
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   196
        description_label = wx.StaticText(self.MiscellaneousPanel,
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   197
              label=_('Content Description (optional):'))
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   198
        miscellaneouspanel_sizer.AddWindow(description_label, border=10, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   199
              flag=wx.BOTTOM|wx.LEFT)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   200
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   201
        self.ContentDescription = wx.TextCtrl(self.MiscellaneousPanel, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   202
              style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   203
        self.Bind(wx.EVT_TEXT_ENTER, self.OnContentDescriptionChanged, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   204
              self.ContentDescription)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   205
        self.ContentDescription.Bind(wx.EVT_KILL_FOCUS, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   206
              self.OnContentDescriptionChanged)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   207
        miscellaneouspanel_sizer.AddWindow(self.ContentDescription, border=10, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   208
              flag=wx.GROW|wx.BOTTOM|wx.RIGHT)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   209
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   210
        self.AddPage(self.MiscellaneousPanel, _("Miscellaneous"))
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   211
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   212
        for param in REQUIRED_PARAMS:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   213
            getattr(self, param).Enable(enable_required)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   214
           
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   215
        languages = ["", "en-US", "fr-FR", "zh-CN"]
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   216
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   217
        for language in languages:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   218
            self.Language.Append(language)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   219
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   220
    def RefreshView(self):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   221
        if self.Controller is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   222
            self.SetValues(self.Controller.GetProjectProperties())
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   223
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   224
    def SetValues(self, values):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   225
        self.Values = values
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   226
        for item, value in values.items():
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   227
            if item == "language":
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   228
                self.Language.SetStringSelection(value)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   229
            elif item == "contentDescription":
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   230
                self.ContentDescription.SetValue(value)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   231
            elif item == "pageSize":
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   232
                self.PageWidth.SetValue(value[0])
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   233
                self.PageHeight.SetValue(value[1])
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   234
            elif item == "scaling":
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   235
                for language, (x, y) in value.items():
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   236
                    if language in self.Scalings:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   237
                        self.Scalings[language][0].SetValue(x)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   238
                        self.Scalings[language][1].SetValue(y)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   239
            else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   240
                tc = getattr(self, item, None)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   241
                if tc is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   242
                    tc.SetValue(value)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   243
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   244
    def GetValues(self):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   245
        values = {}
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   246
        for param in ["projectName", "projectVersion",
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   247
                      "productName", "productVersion",
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   248
                      "productRelease", "companyName",
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   249
                      "companyURL", "authorName", 
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   250
                      "organization"]:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   251
            value = getattr(self, param).GetValue()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   252
            if param in REQUIRED_PARAMS or value != "":
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   253
                values[param] = value
702
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   254
            else:
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   255
                values[param] = None
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   256
        language = self.Language.GetStringSelection()
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   257
        if language != "":
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   258
            values["language"] = language
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   259
        else:
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   260
            values["language"] = None
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   261
        content_description = self.ContentDescription.GetValue()
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   262
        if content_description != "":
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   263
            values["contentDescription"] = content_description
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   264
        else:
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   265
            values["contentDescription"] = None
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   266
        values["pageSize"] = (self.PageWidth.GetValue(), self.PageHeight.GetValue())
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   267
        values["scaling"] = {}
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   268
        for language in ["FBD", "LD", "SFC"]:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   269
            values["scaling"][language] = (self.Scalings[language][0].GetValue(),
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   270
                                           self.Scalings[language][1].GetValue())
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   271
        return values
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   272
    
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   273
    def GetTextCtrlChangedFunction(self, textctrl, name):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   274
        def TextCtrlChangedFunction(event):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   275
            if self.Controller is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   276
                if self.Values is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   277
                    old_value = self.Values.get(name)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   278
                else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   279
                    old_value = None
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   280
                new_value = textctrl.GetValue()
702
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   281
                if name not in REQUIRED_PARAMS and new_value == "":
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   282
                    new_value = None
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   283
                if old_value != new_value:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   284
                    self.Controller.SetProjectProperties(properties={name: new_value})
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   285
                    self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU,
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   286
                            PROJECTTREE, PAGETITLES)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   287
                    wx.CallAfter(self.RefreshView)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   288
            event.Skip()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   289
        return TextCtrlChangedFunction
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   290
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   291
    def GetPageSizeChangedFunction(self, spinctrl, name):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   292
        def PageSizeChangedFunction(event):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   293
            if self.Controller is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   294
                if self.Values is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   295
                    old_value = self.Values.get("pageSize")
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   296
                else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   297
                    old_value = (0, 0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   298
                if name == 'PageWidth':
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   299
                    new_value = (spinctrl.GetValue(), old_value[1])
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   300
                else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   301
                    new_value = (old_value[0], spinctrl.GetValue())
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   302
                if old_value != new_value:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   303
                    self.Controller.SetProjectProperties(properties={"pageSize": new_value})
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   304
                    self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU,
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   305
                          PAGETITLES, SCALING)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   306
                    wx.CallAfter(self.RefreshView)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   307
            event.Skip()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   308
        return PageSizeChangedFunction
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   309
    
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   310
    def GetScalingChangedFunction(self, spinctrl, language, name):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   311
        def ScalingChangedFunction(event):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   312
            if self.Controller is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   313
                old_value = (0, 0)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   314
                if self.Values is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   315
                    scaling = self.Values.get("scaling")
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   316
                    if scaling is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   317
                        old_value = scaling.get(language)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   318
                if name == 'XScale':
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   319
                    new_value = (spinctrl.GetValue(), old_value[1])
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   320
                else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   321
                    new_value = (old_value[0], spinctrl.GetValue())
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   322
                if old_value != new_value:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   323
                    self.Controller.SetProjectProperties(properties={"scaling": {language: new_value}})
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   324
                    self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU,
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   325
                          PAGETITLES, SCALING)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   326
                    wx.CallAfter(self.RefreshView)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   327
            event.Skip()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   328
        return ScalingChangedFunction
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   329
    
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   330
    def OnLanguageChanged(self, event):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   331
        if self.Controller is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   332
            if self.Values is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   333
                old_value = self.Values.get("language")
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   334
            else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   335
                old_value = None
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   336
            new_value = self.Language.GetStringSelection()
702
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   337
            if new_value == "":
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   338
                new_value = None
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   339
            if old_value != new_value:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   340
                self.Controller.SetProjectProperties(properties={"language": new_value})
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   341
                self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   342
                wx.CallAfter(self.RefreshView)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   343
        event.Skip()
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   344
        
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   345
    def OnContentDescriptionChanged(self, event):
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   346
        if self.Controller is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   347
            if self.Values is not None:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   348
                old_value = self.Values.get("contentDescription")
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   349
            else:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   350
                old_value = None
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   351
            new_value = self.ContentDescription.GetValue()
702
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   352
            if new_value == "":
ece862b07321 Fixing bugs with properties panel when resetting optional value and saving project
Laurent Bessard
parents: 700
diff changeset
   353
                new_value = None
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   354
            if old_value != new_value:
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   355
                self.Controller.SetProjectProperties(properties={"contentDescription": new_value})
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 711
diff changeset
   356
                self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES)
700
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   357
                wx.CallAfter(self.RefreshView)
cf3db1775105 Separating ProjectDialog from PLCOpenEditor for integration of panel into Beremiz project window
Laurent Bessard
parents:
diff changeset
   358
        event.Skip()