# HG changeset patch # User Laurent Bessard # Date 1340647433 -7200 # Node ID 131ea7f237b9bf22af6ddf858e49ccc665fb6a15 # Parent 95a0a427f3ef335ee8ec3b2cca19fed7cb9989f4 Replacing buttons with text by buttons with icons Adding support for bitmap library to have a common API for icon request handling Simplify wx controls and sizers creation in dialogs and custom controls and panels diff -r 95a0a427f3ef -r 131ea7f237b9 DataTypeEditor.py --- a/DataTypeEditor.py Fri Jun 15 18:03:25 2012 +0200 +++ b/DataTypeEditor.py Mon Jun 25 20:03:53 2012 +0200 @@ -22,31 +22,39 @@ #License along with this library; if not, write to the Free Software #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +import re + import wx import wx.grid +import wx.lib.buttons from plcopen.structures import IEC_KEYWORDS, TestIdentifier from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD from controls import CustomEditableListBox, CustomGrid, CustomTable, EditorPanel - -import re +from utils.BitmapLibrary import GetBitmap + +#------------------------------------------------------------------------------- +# Helpers +#------------------------------------------------------------------------------- DIMENSION_MODEL = re.compile("([0-9]+)\.\.([0-9]+)$") def AppendMenu(parent, help, id, kind, text): - if wx.VERSION >= (2, 6, 0): - parent.Append(help=help, id=id, kind=kind, text=text) - else: - parent.Append(helpString=help, id=id, kind=kind, item=text) + parent.Append(help=help, id=id, kind=kind, text=text) + +def GetElementsTableColnames(): + _ = lambda x : x + return ["#", _("Name"), _("Type"), _("Initial Value")] + +def GetDatatypeTypes(): + _ = lambda x : x + return [_("Directly"), _("Subrange"), _("Enumerated"), _("Array"), _("Structure")] +DATATYPE_TYPES_DICT = dict([(_(datatype), datatype) for datatype in GetDatatypeTypes()]) #------------------------------------------------------------------------------- # Structure Elements Table #------------------------------------------------------------------------------- -def GetElementsTableColnames(): - _ = lambda x : x - return ["#", _("Name"), _("Type"), _("Initial Value")] - class ElementsTable(CustomTable): """ @@ -121,329 +129,240 @@ # Datatype Editor class #------------------------------------------------------------------------------- -[ID_DATATYPEEDITOR, ID_DATATYPEEDITORPANEL, ID_DATATYPEEDITORSTATICBOX, - ID_DATATYPEEDITORDERIVATIONTYPE, ID_DATATYPEEDITORDIRECTLYPANEL, - ID_DATATYPEEDITORSUBRANGEPANEL, ID_DATATYPEEDITORDIRECTLYBASETYPE, - ID_DATATYPEEDITORSUBRANGEBASETYPE, ID_DATATYPEEDITORSUBRANGEMINIMUM, - ID_DATATYPEEDITORSUBRANGEMAXIMUM, ID_DATATYPEEDITORDIRECTLYINITIALVALUE, - ID_DATATYPEEDITORSUBRANGEINITIALVALUE, ID_DATATYPEEDITORENUMERATEDPANEL, - ID_DATATYPEEDITORENUMERATEDVALUES, ID_DATATYPEEDITORENUMERATEDINITIALVALUE, - ID_DATATYPEEDITORARRAYPANEL, ID_DATATYPEEDITORARRAYBASETYPE, - ID_DATATYPEEDITORARRAYDIMENSIONS, ID_DATATYPEEDITORARRAYINITIALVALUE, - ID_DATATYPEEDITORSTRUCTUREPANEL, ID_DATATYPEEDITORSTRUCTUREELEMENTSGRID, - ID_DATATYPEEDITORSTRUCTUREADDBUTTON, ID_DATATYPEEDITORSTRUCTUREDELETEBUTTON, - ID_DATATYPEEDITORSTRUCTUREUPBUTTON, ID_DATATYPEEDITORSTRUCTUREDOWNBUTTON, - ID_DATATYPEEDITORSTATICTEXT1, ID_DATATYPEEDITORSTATICTEXT2, - ID_DATATYPEEDITORSTATICTEXT3, ID_DATATYPEEDITORSTATICTEXT4, - ID_DATATYPEEDITORSTATICTEXT5, ID_DATATYPEEDITORSTATICTEXT6, - ID_DATATYPEEDITORSTATICTEXT7, ID_DATATYPEEDITORSTATICTEXT8, - ID_DATATYPEEDITORSTATICTEXT9, ID_DATATYPEEDITORSTATICTEXT10, - ID_DATATYPEEDITORSTATICTEXT11, -] = [wx.NewId() for _init_ctrls in range(36)] - -def GetDatatypeTypes(): - _ = lambda x : x - return [_("Directly"), _("Subrange"), _("Enumerated"), _("Array"), _("Structure")] -DATATYPE_TYPES_DICT = dict([(_(datatype), datatype) for datatype in GetDatatypeTypes()]) - class DataTypeEditor(EditorPanel): - ID = ID_DATATYPEEDITOR - - def _init_coll_MainSizer_Items(self, parent): - parent.AddSizer(self.TopSizer, 0, border=5, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.TypeInfosSizer, 0, border=5, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT) - - def _init_coll_MainSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_coll_TopSizer_Items(self, parent): - parent.AddWindow(self.staticText1, 0, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT) - parent.AddWindow(self.DerivationType, 0, border=5, flag=wx.GROW|wx.RIGHT) - - def _init_coll_TypeInfosSizer_Items(self, parent): - parent.AddWindow(self.DirectlyPanel, 1, border=0, flag=wx.ALL) - parent.AddWindow(self.SubrangePanel, 1, border=0, flag=wx.ALL) - parent.AddWindow(self.EnumeratedPanel, 1, border=0, flag=wx.GROW|wx.ALL) - parent.AddWindow(self.ArrayPanel, 1, border=0, flag=wx.ALL) - parent.AddWindow(self.StructurePanel, 1, border=0, flag=wx.GROW|wx.ALL) - - def _init_coll_DirectlyPanelSizer_Items(self, parent): - parent.AddWindow(self.staticText2, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) - parent.AddWindow(self.DirectlyBaseType, 1, border=5, flag=wx.GROW|wx.ALL) - parent.AddWindow(self.staticText3, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) - parent.AddWindow(self.DirectlyInitialValue, 1, border=5, flag=wx.ALL) - - def _init_coll_SubrangePanelSizer_Items(self, parent): - parent.AddWindow(self.staticText4, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) - parent.AddWindow(self.SubrangeBaseType, 1, border=5, flag=wx.GROW|wx.ALL) - parent.AddWindow(self.staticText5, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) - parent.AddWindow(self.SubrangeInitialValue, 1, border=5, flag=wx.GROW|wx.ALL) - parent.AddWindow(self.staticText6, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) - parent.AddWindow(self.SubrangeMinimum, 1, border=5, flag=wx.GROW|wx.ALL) - parent.AddWindow(wx.Size(0, 0), 1, border=5, flag=wx.GROW|wx.ALL) - parent.AddWindow(wx.Size(0, 0), 1, border=5, flag=wx.GROW|wx.ALL) - parent.AddWindow(self.staticText7, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) - parent.AddWindow(self.SubrangeMaximum, 1, border=5, flag=wx.GROW|wx.ALL) - - def _init_coll_EnumeratedPanelSizer_Items(self, parent): - parent.AddWindow(self.EnumeratedValues, 1, border=5, flag=wx.GROW|wx.ALL) - parent.AddSizer(self.EnumeratedPanelRightSizer, 1, border=0, flag=0) - - def _init_coll_EnumeratedPanelRightSizer_Items(self, parent): - parent.AddWindow(self.staticText8, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) - parent.AddWindow(self.EnumeratedInitialValue, 1, border=5, flag=wx.ALL) - - def _init_coll_ArrayPanelSizer_Items(self, parent): - parent.AddSizer(self.ArrayPanelLeftSizer, 0, border=0, flag=wx.GROW) - parent.AddSizer(self.ArrayPanelRightSizer, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.ArrayDimensions, 0, border=5, flag=wx.GROW|wx.ALL) - - def _init_coll_ArrayPanelSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableCol(1) - parent.AddGrowableRow(1) - - def _init_coll_ArrayPanelLeftSizer_Items(self, parent): - parent.AddWindow(self.staticText9, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) - parent.AddWindow(self.ArrayBaseType, 1, border=5, flag=wx.GROW|wx.ALL) - - def _init_coll_ArrayPanelRightSizer_Items(self, parent): - parent.AddWindow(self.staticText10, 1, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) - parent.AddWindow(self.ArrayInitialValue, 1, border=5, flag=wx.ALL) - - def _init_coll_StructurePanelSizer_Items(self, parent): - parent.AddSizer(self.StructurePanelButtonSizer, 0, border=5, flag=wx.ALL|wx.GROW) - parent.AddWindow(self.StructureElementsGrid, 0, border=0, flag=wx.GROW) - - def _init_coll_StructurePanelSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_coll_StructurePanelButtonSizer_Items(self, parent): - parent.AddWindow(self.staticText11, 0, border=0, flag=wx.ALIGN_BOTTOM) - parent.AddWindow(self.StructureAddButton, 0, border=0, flag=0) - parent.AddWindow(self.StructureDeleteButton, 0, border=0, flag=0) - parent.AddWindow(self.StructureUpButton, 0, border=0, flag=0) - parent.AddWindow(self.StructureDownButton, 0, border=0, flag=0) - - def _init_coll_StructurePanelButtonSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_sizers(self): + def _init_Editor(self, parent): + self.Editor = wx.Panel(parent, style=wx.SUNKEN_BORDER) + self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.TopSizer = wx.BoxSizer(wx.HORIZONTAL) - self.TypeInfosSizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL) - self.DirectlyPanelSizer = wx.BoxSizer(wx.HORIZONTAL) - self.SubrangePanelSizer = wx.GridSizer(cols=4, hgap=5, rows=3, vgap=0) - self.EnumeratedPanelSizer = wx.BoxSizer(wx.HORIZONTAL) - self.EnumeratedPanelRightSizer = wx.BoxSizer(wx.HORIZONTAL) - self.ArrayPanelSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=0) - self.ArrayPanelLeftSizer = wx.BoxSizer(wx.HORIZONTAL) - self.ArrayPanelRightSizer = wx.BoxSizer(wx.HORIZONTAL) - self.StructurePanelSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) - self.StructurePanelButtonSizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) - - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_MainSizer_Growables(self.MainSizer) - self._init_coll_TopSizer_Items(self.TopSizer) - self._init_coll_TypeInfosSizer_Items(self.TypeInfosSizer) - self._init_coll_DirectlyPanelSizer_Items(self.DirectlyPanelSizer) - self._init_coll_SubrangePanelSizer_Items(self.SubrangePanelSizer) - self._init_coll_EnumeratedPanelSizer_Items(self.EnumeratedPanelSizer) - self._init_coll_EnumeratedPanelRightSizer_Items(self.EnumeratedPanelRightSizer) - self._init_coll_ArrayPanelSizer_Items(self.ArrayPanelSizer) - self._init_coll_ArrayPanelSizer_Growables(self.ArrayPanelSizer) - self._init_coll_ArrayPanelLeftSizer_Items(self.ArrayPanelLeftSizer) - self._init_coll_ArrayPanelRightSizer_Items(self.ArrayPanelRightSizer) - self._init_coll_StructurePanelSizer_Items(self.StructurePanelSizer) - self._init_coll_StructurePanelSizer_Growables(self.StructurePanelSizer) - self._init_coll_StructurePanelButtonSizer_Items(self.StructurePanelButtonSizer) - self._init_coll_StructurePanelButtonSizer_Growables(self.StructurePanelButtonSizer) - - self.Editor.SetSizer(self.MainSizer) - self.DirectlyPanel.SetSizer(self.DirectlyPanelSizer) - self.SubrangePanel.SetSizer(self.SubrangePanelSizer) - self.EnumeratedPanel.SetSizer(self.EnumeratedPanelSizer) - self.ArrayPanel.SetSizer(self.ArrayPanelSizer) - self.StructurePanel.SetSizer(self.StructurePanelSizer) - - def _init_Editor(self, prnt): - self.Editor = wx.Panel(id=ID_DATATYPEEDITORPANEL, name='', parent=prnt, - size=wx.Size(0, 0), style=wx.SUNKEN_BORDER) - - self.staticbox = wx.StaticBox(id=ID_DATATYPEEDITORSTATICBOX, - label=_('Type infos:'), name='staticBox1', parent=self.Editor, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.staticText1 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT1, - label=_('Derivation Type:'), name='staticText1', parent=self.Editor, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.DerivationType = wx.ComboBox(id=ID_DATATYPEEDITORDERIVATIONTYPE, - name='DerivationType', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.Size(200, 28), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnDerivationTypeChanged, id=ID_DATATYPEEDITORDERIVATIONTYPE) - + self.MainSizer.AddGrowableCol(0) + self.MainSizer.AddGrowableRow(1) + + top_sizer = wx.BoxSizer(wx.HORIZONTAL) + self.MainSizer.AddSizer(top_sizer, border=5, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + + derivation_type_label = wx.StaticText(self.Editor, label=_('Derivation Type:')) + top_sizer.AddWindow(derivation_type_label, border=5, + flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT) + + self.DerivationType = wx.ComboBox(self.Editor, + size=wx.Size(200, -1), style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnDerivationTypeChanged, self.DerivationType) + top_sizer.AddWindow(self.DerivationType, border=5, flag=wx.GROW|wx.RIGHT) + + typeinfos_staticbox = wx.StaticBox(self.Editor, label=_('Type infos:')) + typeinfos_sizer = wx.StaticBoxSizer(typeinfos_staticbox, wx.HORIZONTAL) + self.MainSizer.AddSizer(typeinfos_sizer, border=5, + flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT) + # Panel for Directly derived data types - self.DirectlyPanel = wx.Panel(id=ID_DATATYPEEDITORDIRECTLYPANEL, - name='DirectlyPanel', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.staticText2 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT2, - label=_('Base Type:'), name='staticText2', parent=self.DirectlyPanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.DirectlyBaseType = wx.ComboBox(id=ID_DATATYPEEDITORDIRECTLYBASETYPE, - name='DirectlyBaseType', parent=self.DirectlyPanel, pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, id=ID_DATATYPEEDITORDIRECTLYBASETYPE) - - self.staticText3 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT3, - label=_('Initial Value:'), name='staticText3', parent=self.DirectlyPanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.DirectlyInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE, - name='DirectlyInitialValue', parent=self.DirectlyPanel, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_MULTILINE|wx.TE_RICH) - self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE) - + self.DirectlyPanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL) + typeinfos_sizer.AddWindow(self.DirectlyPanel, 1) + + directly_panel_sizer = wx.BoxSizer(wx.HORIZONTAL) + + directly_basetype_label = wx.StaticText(self.DirectlyPanel, + label=_('Base Type:')) + directly_panel_sizer.AddWindow(directly_basetype_label, 1, border=5, + flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) + + self.DirectlyBaseType = wx.ComboBox(self.DirectlyPanel, style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, self.DirectlyPanel) + directly_panel_sizer.AddWindow(self.DirectlyBaseType, 1, border=5, + flag=wx.GROW|wx.ALL) + + directly_initialvalue_label = wx.StaticText(self.DirectlyPanel, + label=_('Initial Value:')) + directly_panel_sizer.AddWindow(directly_initialvalue_label, 1, border=5, + flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) + + self.DirectlyInitialValue = wx.TextCtrl(self.DirectlyPanel, + style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_RICH) + self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, self.DirectlyInitialValue) + directly_panel_sizer.AddWindow(self.DirectlyInitialValue, 1, border=5, + flag=wx.ALL) + + self.DirectlyPanel.SetSizer(directly_panel_sizer) + # Panel for Subrange data types - self.SubrangePanel = wx.Panel(id=ID_DATATYPEEDITORSUBRANGEPANEL, - name='SubrangePanel', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.staticText4 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT4, - label=_('Base Type:'), name='staticText4', parent=self.SubrangePanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.SubrangeBaseType = wx.ComboBox(id=ID_DATATYPEEDITORSUBRANGEBASETYPE, - name='SubrangeBaseType', parent=self.SubrangePanel, pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) - self.SubrangeBaseType.SetBackgroundColour(wx.BLUE) - self.Bind(wx.EVT_COMBOBOX, self.OnSubrangeBaseTypeChanged, id=ID_DATATYPEEDITORSUBRANGEBASETYPE) - - self.staticText5 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT5, - label=_('Initial Value:'), name='staticText5', parent=self.SubrangePanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.SubrangeInitialValue = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEINITIALVALUE, - name='SubrangeInitialValue', parent=self.SubrangePanel, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL) - self.Bind(wx.EVT_SPINCTRL, self.OnInfosChanged, id=ID_DATATYPEEDITORSUBRANGEINITIALVALUE) - - self.staticText6 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT6, - label=_('Minimum:'), name='staticText6', parent=self.SubrangePanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.SubrangeMinimum = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEMINIMUM, - name='SubrangeMinimum', parent=self.SubrangePanel, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL) - self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMinimumChanged, id=ID_DATATYPEEDITORSUBRANGEMINIMUM) - - self.staticText7 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT7, - label=_('Maximum:'), name='staticText7', parent=self.SubrangePanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.SubrangeMaximum = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEMAXIMUM, - name='SubrangeMaximum', parent=self.SubrangePanel, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL) - self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMaximumChanged, id=ID_DATATYPEEDITORSUBRANGEMAXIMUM) - + self.SubrangePanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL) + typeinfos_sizer.AddWindow(self.SubrangePanel, 1) + + subrange_panel_sizer = wx.GridSizer(cols=4, hgap=5, rows=3, vgap=0) + + subrange_basetype_label = wx.StaticText(self.SubrangePanel, + label=_('Base Type:')) + subrange_panel_sizer.AddWindow(subrange_basetype_label, 1, border=5, + flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) + + self.SubrangeBaseType = wx.ComboBox(self.SubrangePanel, style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnSubrangeBaseTypeChanged, + self.SubrangeBaseType) + subrange_panel_sizer.AddWindow(self.SubrangeBaseType, 1, border=5, + flag=wx.GROW|wx.ALL) + + subrange_initialvalue_label = wx.StaticText(self.SubrangePanel, + label=_('Initial Value:')) + subrange_panel_sizer.AddWindow(subrange_initialvalue_label, 1, border=5, + flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) + + self.SubrangeInitialValue = wx.SpinCtrl(self.SubrangePanel, + style=wx.TAB_TRAVERSAL) + self.Bind(wx.EVT_SPINCTRL, self.OnInfosChanged, self.SubrangeInitialValue) + subrange_panel_sizer.AddWindow(self.SubrangeInitialValue, 1, border=5, + flag=wx.GROW|wx.ALL) + + subrange_minimum_label = wx.StaticText(self.SubrangePanel, label=_('Minimum:')) + subrange_panel_sizer.AddWindow(subrange_minimum_label, 1, border=5, + flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) + + self.SubrangeMinimum = wx.SpinCtrl(self.SubrangePanel, style=wx.TAB_TRAVERSAL) + self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMinimumChanged, self.SubrangeMinimum) + subrange_panel_sizer.AddWindow(self.SubrangeMinimum, 1, border=5, + flag=wx.GROW|wx.ALL) + + for i in xrange(2): + subrange_panel_sizer.AddWindow(wx.Size(0, 0), 1) + + subrange_maximum_label = wx.StaticText(self.SubrangePanel, + label=_('Maximum:')) + subrange_panel_sizer.AddWindow(subrange_maximum_label, 1, border=5, + flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) + + self.SubrangeMaximum = wx.SpinCtrl(self.SubrangePanel, style=wx.TAB_TRAVERSAL) + self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMaximumChanged, self.SubrangeMaximum) + + subrange_panel_sizer.AddWindow(self.SubrangeMaximum, 1, border=5, + flag=wx.GROW|wx.ALL) + + self.SubrangePanel.SetSizer(subrange_panel_sizer) + # Panel for Enumerated data types - - self.EnumeratedPanel = wx.Panel(id=ID_DATATYPEEDITORENUMERATEDPANEL, - name='EnumeratedPanel', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.EnumeratedValues = CustomEditableListBox(id=ID_DATATYPEEDITORENUMERATEDVALUES, - name='EnumeratedValues', parent=self.EnumeratedPanel, label=_("Values:"), pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.gizmos.EL_ALLOW_NEW | wx.gizmos.EL_ALLOW_EDIT | wx.gizmos.EL_ALLOW_DELETE) + + self.EnumeratedPanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL) + typeinfos_sizer.AddWindow(self.EnumeratedPanel, 1) + + enumerated_panel_sizer = wx.BoxSizer(wx.HORIZONTAL) + + self.EnumeratedValues = CustomEditableListBox(self.EnumeratedPanel, + label=_("Values:"), style=wx.gizmos.EL_ALLOW_NEW| + wx.gizmos.EL_ALLOW_EDIT| + wx.gizmos.EL_ALLOW_DELETE) setattr(self.EnumeratedValues, "_OnLabelEndEdit", self.OnEnumeratedValueEndEdit) for func in ["_OnAddButton", "_OnDelButton", "_OnUpButton", "_OnDownButton"]: setattr(self.EnumeratedValues, func, self.OnEnumeratedValuesChanged) - - self.staticText8 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT8, - label=_('Initial Value:'), name='staticText8', parent=self.EnumeratedPanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.EnumeratedInitialValue = wx.ComboBox(id=ID_DATATYPEEDITORENUMERATEDINITIALVALUE, - name='EnumeratedInitialValue', parent=self.EnumeratedPanel, pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, id=ID_DATATYPEEDITORENUMERATEDINITIALVALUE) + enumerated_panel_sizer.AddWindow(self.EnumeratedValues, 1, border=5, + flag=wx.GROW|wx.ALL) + + enumerated_panel_rightsizer = wx.BoxSizer(wx.HORIZONTAL) + enumerated_panel_sizer.AddSizer(enumerated_panel_rightsizer, 1) + + enumerated_initialvalue_label = wx.StaticText(self.EnumeratedPanel, + label=_('Initial Value:')) + enumerated_panel_rightsizer.AddWindow(enumerated_initialvalue_label, 1, + border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) + + self.EnumeratedInitialValue = wx.ComboBox(self.EnumeratedPanel, + style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, self.EnumeratedInitialValue) + enumerated_panel_rightsizer.AddWindow(self.EnumeratedInitialValue, 1, + border=5, flag=wx.ALL) + + self.EnumeratedPanel.SetSizer(enumerated_panel_sizer) # Panel for Array data types - self.ArrayPanel = wx.Panel(id=ID_DATATYPEEDITORARRAYPANEL, - name='ArrayPanel', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.staticText9 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT9, - label=_('Base Type:'), name='staticText9', parent=self.ArrayPanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.ArrayBaseType = wx.ComboBox(id=ID_DATATYPEEDITORARRAYBASETYPE, - name='ArrayBaseType', parent=self.ArrayPanel, pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, id=ID_DATATYPEEDITORARRAYBASETYPE) - - self.ArrayDimensions = CustomEditableListBox(id=ID_DATATYPEEDITORARRAYDIMENSIONS, - name='ArrayDimensions', parent=self.ArrayPanel, label=_("Dimensions:"), pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.gizmos.EL_ALLOW_NEW | wx.gizmos.EL_ALLOW_EDIT | wx.gizmos.EL_ALLOW_DELETE) - for func in ["_OnLabelEndEdit", "_OnAddButton", "_OnDelButton", "_OnUpButton", "_OnDownButton"]: + self.ArrayPanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL) + typeinfos_sizer.AddWindow(self.ArrayPanel, 1) + + array_panel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=0) + array_panel_sizer.AddGrowableCol(0) + array_panel_sizer.AddGrowableCol(1) + array_panel_sizer.AddGrowableRow(1) + + array_panel_leftSizer = wx.BoxSizer(wx.HORIZONTAL) + array_panel_sizer.AddSizer(array_panel_leftSizer, flag=wx.GROW) + + array_basetype_label = wx.StaticText(self.ArrayPanel, label=_('Base Type:')) + array_panel_leftSizer.AddWindow(array_basetype_label, 1, border=5, + flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) + + self.ArrayBaseType = wx.ComboBox(self.ArrayPanel, style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnInfosChanged, self.ArrayBaseType) + array_panel_leftSizer.AddWindow(self.ArrayBaseType, 1, border=5, + flag=wx.GROW|wx.ALL) + + array_panel_rightsizer = wx.BoxSizer(wx.HORIZONTAL) + array_panel_sizer.AddSizer(array_panel_rightsizer, flag=wx.GROW) + + array_initialvalue_label = wx.StaticText(self.ArrayPanel, + label=_('Initial Value:')) + array_panel_rightsizer.AddWindow(array_initialvalue_label, 1, border=5, + flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL) + + self.ArrayInitialValue = wx.TextCtrl(self.ArrayPanel, + style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_RICH) + self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, self.ArrayInitialValue) + array_panel_rightsizer.AddWindow(self.ArrayInitialValue, 1, border=5, + flag=wx.ALL) + + self.ArrayDimensions = CustomEditableListBox(self.ArrayPanel, + label=_("Dimensions:"), style=wx.gizmos.EL_ALLOW_NEW| + wx.gizmos.EL_ALLOW_EDIT| + wx.gizmos.EL_ALLOW_DELETE) + for func in ["_OnLabelEndEdit", "_OnAddButton", "_OnDelButton", + "_OnUpButton", "_OnDownButton"]: setattr(self.EnumeratedValues, func, self.OnDimensionsChanged) - - self.staticText10 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT10, - label=_('Initial Value:'), name='staticText10', parent=self.ArrayPanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.ArrayInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORARRAYINITIALVALUE, - name='ArrayInitialValue', parent=self.ArrayPanel, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_MULTILINE|wx.TE_RICH) - self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, id=ID_DATATYPEEDITORARRAYINITIALVALUE) + array_panel_sizer.AddWindow(self.ArrayDimensions, 0, border=5, + flag=wx.GROW|wx.ALL) + + self.ArrayPanel.SetSizer(array_panel_sizer) # Panel for Structure data types - self.StructurePanel = wx.Panel(id=ID_DATATYPEEDITORSTRUCTUREPANEL, - name='StructurePanel', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.staticText11 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT11, - label=_('Elements :'), name='staticText11', parent=self.StructurePanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.StructureElementsGrid = CustomGrid(id=ID_DATATYPEEDITORSTRUCTUREELEMENTSGRID, - name='StructureElementsGrid', parent=self.StructurePanel, pos=wx.Point(0, 0), + self.StructurePanel = wx.Panel(self.Editor, style=wx.TAB_TRAVERSAL) + typeinfos_sizer.AddWindow(self.StructurePanel, 1) + + structure_panel_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) + structure_panel_sizer.AddGrowableCol(0) + structure_panel_sizer.AddGrowableRow(1) + + structure_button_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) + structure_button_sizer.AddGrowableCol(0) + structure_button_sizer.AddGrowableRow(0) + structure_panel_sizer.AddSizer(structure_button_sizer, 0, border=5, + flag=wx.ALL|wx.GROW) + + structure_elements_label = wx.StaticText(self.StructurePanel, + label=_('Elements :')) + structure_button_sizer.AddWindow(structure_elements_label, flag=wx.ALIGN_BOTTOM) + + for name, bitmap, help in [ + ("StructureAddButton", "add_element", _("Add element")), + ("StructureDeleteButton", "remove_element", _("Remove element")), + ("StructureUpButton", "up", _("Move element up")), + ("StructureDownButton", "down", _("Move element down"))]: + button = wx.lib.buttons.GenBitmapButton(self.StructurePanel, + bitmap=GetBitmap(bitmap), size=wx.Size(28, 28), style=wx.NO_BORDER) + button.SetToolTipString(help) + setattr(self, name, button) + structure_button_sizer.AddWindow(button) + + self.StructureElementsGrid = CustomGrid(self.StructurePanel, size=wx.Size(0, 150), style=wx.VSCROLL) - if wx.VERSION >= (2, 6, 0): - self.StructureElementsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnStructureElementsGridCellChange) - self.StructureElementsGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnStructureElementsGridEditorShown) - else: - wx.grid.EVT_GRID_CELL_CHANGE(self.StructureElementsGrid, self.OnStructureElementsGridCellChange) - wx.grid.EVT_GRID_EDITOR_SHOWN(self.StructureElementsGrid, self.OnStructureElementsGridEditorShown) - - self.StructureAddButton = wx.Button(id=ID_DATATYPEEDITORSTRUCTUREADDBUTTON, label=_('Add'), - name='StructureAddButton', parent=self.StructurePanel, pos=wx.Point(0, 0), - size=wx.DefaultSize, style=0) - - self.StructureDeleteButton = wx.Button(id=ID_DATATYPEEDITORSTRUCTUREDELETEBUTTON, label=_('Delete'), - name='StructureDeleteButton', parent=self.StructurePanel, pos=wx.Point(0, 0), - size=wx.DefaultSize, style=0) - - self.StructureUpButton = wx.Button(id=ID_DATATYPEEDITORSTRUCTUREUPBUTTON, label='^', - name='StructureUpButton', parent=self.StructurePanel, pos=wx.Point(0, 0), - size=wx.Size(32, 32), style=0) - - self.StructureDownButton = wx.Button(id=ID_DATATYPEEDITORSTRUCTUREDOWNBUTTON, label='v', - name='StructureDownButton', parent=self.StructurePanel, pos=wx.Point(0, 0), - size=wx.Size(32, 32), style=0) - - self._init_sizers() - + self.StructureElementsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, + self.OnStructureElementsGridCellChange) + self.StructureElementsGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, + self.OnStructureElementsGridEditorShown) + structure_panel_sizer.AddWindow(self.StructureElementsGrid, flag=wx.GROW) + + self.StructurePanel.SetSizer(structure_panel_sizer) + + self.Editor.SetSizer(self.MainSizer) + def __init__(self, parent, tagname, window, controler): EditorPanel.__init__(self, parent, tagname, window, controler) diff -r 95a0a427f3ef -r 131ea7f237b9 GraphicViewer.py --- a/GraphicViewer.py Fri Jun 15 18:03:25 2012 +0200 +++ b/GraphicViewer.py Mon Jun 25 20:03:53 2012 +0200 @@ -31,6 +31,7 @@ from graphics.GraphicCommons import DebugViewer, MODE_SELECTION, MODE_MOTION from controls import EditorPanel +from utils.BitmapLibrary import GetBitmap colours = ['blue', 'red', 'green', 'yellow', 'orange', 'purple', 'brown', 'cyan', 'pink', 'grey'] @@ -90,7 +91,7 @@ self.CanvasRange = wx.ComboBox(self.Editor, size=wx.Size(100, 28), style=wx.CB_READONLY) self.Bind(wx.EVT_COMBOBOX, self.OnRangeChanged, self.CanvasRange) - range_sizer.AddWindow(self.CanvasRange, 0, border=0, flag=0) + range_sizer.AddWindow(self.CanvasRange, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) zoom_label = wx.StaticText(self.Editor, label=_('Zoom:')) range_sizer.AddWindow(zoom_label, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) @@ -98,7 +99,7 @@ self.CanvasZoom = wx.ComboBox(self.Editor, size=wx.Size(70, 28), style=wx.CB_READONLY) self.Bind(wx.EVT_COMBOBOX, self.OnZoomChanged, self.CanvasZoom) - range_sizer.AddWindow(self.CanvasZoom, 0, border=0, flag=0) + range_sizer.AddWindow(self.CanvasZoom, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) position_label = wx.StaticText(self.Editor, label=_('Position:')) range_sizer.AddWindow(position_label, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) @@ -118,17 +119,21 @@ self.OnPositionChanging, self.CanvasPosition) range_sizer.AddWindow(self.CanvasPosition, 0, border=5, flag=wx.GROW|wx.ALL) - self.ResetButton = wx.Button(self.Editor, label='Reset', size=wx.Size(72, 24)) + self.ResetButton = wx.lib.buttons.GenBitmapButton(self.Editor, + bitmap=GetBitmap("reset"), size=wx.Size(28, 28), style=wx.NO_BORDER) + self.ResetButton.SetToolTipString(_("Clear the graph values")) self.Bind(wx.EVT_BUTTON, self.OnResetButton, self.ResetButton) range_sizer.AddWindow(self.ResetButton, 0, border=0, flag=0) - self.CurrentButton = wx.Button(self.Editor, label='Current', size=wx.Size(72, 24)) + self.CurrentButton = wx.lib.buttons.GenBitmapButton(self.Editor, + bitmap=GetBitmap("current"), size=wx.Size(28, 28), style=wx.NO_BORDER) + self.CurrentButton.SetToolTipString(_("Go to current value")) self.Bind(wx.EVT_BUTTON, self.OnCurrentButton, self.CurrentButton) range_sizer.AddWindow(self.CurrentButton, 0, border=0, flag=0) self.ExportGraphButton = wx.lib.buttons.GenBitmapButton(self.Editor, - bitmap=self.ParentWindow.GenerateBitmap("export_graph"), - size=wx.Size(28, 28), style=wx.NO_BORDER) + bitmap=GetBitmap("export_graph"), size=wx.Size(28, 28), style=wx.NO_BORDER) + self.ExportGraphButton.SetToolTipString(_("Export graph values to clipboard")) self.Bind(wx.EVT_BUTTON, self.OnExportGraphButtonClick, self.ExportGraphButton) range_sizer.AddWindow(self.ExportGraphButton, 0, border=0, flag=0) diff -r 95a0a427f3ef -r 131ea7f237b9 Images/add_element.png Binary file Images/add_element.png has changed diff -r 95a0a427f3ef -r 131ea7f237b9 Images/current.png Binary file Images/current.png has changed diff -r 95a0a427f3ef -r 131ea7f237b9 Images/debug.png Binary file Images/debug.png has changed diff -r 95a0a427f3ef -r 131ea7f237b9 Images/debug_instance.png Binary file Images/debug_instance.png has changed diff -r 95a0a427f3ef -r 131ea7f237b9 Images/down.png Binary file Images/down.png has changed diff -r 95a0a427f3ef -r 131ea7f237b9 Images/graph.png Binary file Images/graph.png has changed diff -r 95a0a427f3ef -r 131ea7f237b9 Images/icons.svg --- a/Images/icons.svg Fri Jun 15 18:03:25 2012 +0200 +++ b/Images/icons.svg Mon Jun 25 20:03:53 2012 +0200 @@ -6523,7 +6523,7 @@ xlink:href="#linearGradient2264" gradientUnits="userSpaceOnUse" x2="12" - gradientTransform="matrix(0.66667,0,0,0.6,186.09982,116.85104)" + gradientTransform="matrix(0.66667,0,0,0.6,185.74627,11.9117)" y1="2" x1="12" /> <linearGradient @@ -6543,7 +6543,7 @@ xlink:href="#linearGradient2264" gradientUnits="userSpaceOnUse" x2="12" - gradientTransform="matrix(0.94444,0,0,0.8,-123.88437,181.49982)" + gradientTransform="matrix(0.94444,0,0,0.8,-18.945029,181.14627)" y1="2" x1="12" /> <linearGradient @@ -6562,7 +6562,7 @@ y2="47.013" gradientUnits="userSpaceOnUse" x2="25.132" - gradientTransform="matrix(0.54288,0,0,0.46564,-125.58014,181.44814)" + gradientTransform="matrix(0.54288,0,0,0.46564,-20.640799,181.09459)" y1="6.7287002" x1="25.132"> <stop @@ -6579,7 +6579,7 @@ y2="2.9061999" gradientUnits="userSpaceOnUse" x2="-51.785999" - gradientTransform="matrix(0.43837,0,0,0.43577,-93.32704,180.9292)" + gradientTransform="matrix(0.43837,0,0,0.43577,11.61231,180.57565)" y1="50.785999" x1="-51.785999"> <stop @@ -6610,7 +6610,7 @@ r="11" cy="25.749001" cx="12" - gradientTransform="matrix(1.0909,0,0,0.18181693,-125.64194,197.91823)" + gradientTransform="matrix(1.0909,0,0,0.18181693,-20.702599,197.56468)" gradientUnits="userSpaceOnUse" id="radialGradient3137" xlink:href="#radialGradient4208" @@ -7196,6 +7196,1752 @@ id="linearGradient3081" xlink:href="#linearGradient3803" inkscape:collect="always" /> + <linearGradient + x1="-31.523001" + y1="190.50999" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + x2="-55.188999" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient3390-178-986-453-4-5-0-7" + y2="182.48" + id="linearGradient3044-1" /> + <linearGradient + id="linearGradient3390-178-986-453-4-5-0-7"> + <stop + offset="0" + style="stop-color:#bb2b12" + id="stop3624-8-6-0-3" /> + <stop + offset="1" + style="stop-color:#cd7233" + id="stop3626-1-1-2-5" /> + </linearGradient> + <linearGradient + x1="-31.523001" + y1="191.52" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + x2="-55.188999" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient3390-178-986-453-4-5-0-7" + y2="182.48" + id="linearGradient3046-2" /> + <linearGradient + id="linearGradient4942"> + <stop + offset="0" + style="stop-color:#bb2b12" + id="stop4944" /> + <stop + offset="1" + style="stop-color:#cd7233" + id="stop4946" /> + </linearGradient> + <linearGradient + x1="-55.188999" + y1="182.48" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + x2="-31.523001" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-8-1" + y2="191.52" + id="linearGradient3048-0" /> + <linearGradient + id="linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-8-1"> + <stop + offset="0" + style="stop-color:#f0c178" + id="stop3618-1-9-14-1" /> + <stop + offset=".5" + style="stop-color:#e18941" + id="stop3270-5-6-8-1" /> + <stop + offset="1" + style="stop-color:#ec4f18" + id="stop3620-9-3-4-1" /> + </linearGradient> + <linearGradient + x1="-55.188999" + y1="183.48" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + x2="-31.523001" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-8-1" + y2="191.52" + id="linearGradient3050-0" /> + <linearGradient + id="linearGradient4954"> + <stop + offset="0" + style="stop-color:#f0c178" + id="stop4956" /> + <stop + offset=".5" + style="stop-color:#e18941" + id="stop4958" /> + <stop + offset="1" + style="stop-color:#ec4f18" + id="stop4960" /> + </linearGradient> + <linearGradient + id="linearGradient4456-4-4"> + <stop + offset="0" + style="stop-color:#f6daae" + id="stop4458-9-5" /> + <stop + offset="1" + style="stop-color:#f0c178;stop-opacity:0" + id="stop4460-7-5" /> + </linearGradient> + <linearGradient + y1="-8.8818001e-16" + x2="22" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient4456-4-4" + y2="9" + id="linearGradient3052-42" /> + <linearGradient + id="linearGradient4967"> + <stop + offset="0" + style="stop-color:#f6daae" + id="stop4969" /> + <stop + offset="1" + style="stop-color:#f0c178;stop-opacity:0" + id="stop4971" /> + </linearGradient> + <linearGradient + id="linearGradient3732-7" + y2="182.48" + xlink:href="#linearGradient3390-178-986-453-4-5-8" + gradientUnits="userSpaceOnUse" + x2="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + y1="191.52" + x1="-55.188999" /> + <linearGradient + id="linearGradient3390-178-986-453-4-5-8"> + <stop + id="stop3624-8-6-6" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop3626-1-1-0" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3017" + y2="182.48" + xlink:href="#linearGradient3390-178-986-453-4-5-8" + gradientUnits="userSpaceOnUse" + x2="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + y1="191.52" + x1="-55.188999" /> + <linearGradient + id="linearGradient3019-9"> + <stop + id="stop3021" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop3023" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4322-57" + y2="191.52" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-1" + gradientUnits="userSpaceOnUse" + x2="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + y1="182.48" + x1="-31.523001" /> + <linearGradient + id="linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-1"> + <stop + id="stop3618-1-9-9" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop3270-5-6-0" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop3620-9-3-50" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3030" + y2="191.52" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-1" + gradientUnits="userSpaceOnUse" + x2="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + y1="182.48" + x1="-31.523001" /> + <linearGradient + id="linearGradient3032"> + <stop + id="stop3034" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop3036" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop3038" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4462-7" + y2="9" + xlink:href="#linearGradient4456-0" + gradientUnits="userSpaceOnUse" + x2="0" + y1="-8.8818001e-16" + x1="22" /> + <linearGradient + id="linearGradient4456-0"> + <stop + id="stop4458-4" + style="stop-color:#f6daae" + offset="0" /> + <stop + id="stop4460-0" + style="stop-color:#f0c178;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3044-10" + y2="9" + xlink:href="#linearGradient4456-0" + gradientUnits="userSpaceOnUse" + x2="0" + y1="-8.8818001e-16" + x1="22" /> + <linearGradient + id="linearGradient3046-97"> + <stop + id="stop3048-9" + style="stop-color:#f6daae" + offset="0" /> + <stop + id="stop3050-1" + style="stop-color:#f0c178;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + y2="182.48" + x2="-31.523001" + y1="191.52" + x1="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + gradientUnits="userSpaceOnUse" + id="linearGradient3060-7" + xlink:href="#linearGradient3390-178-986-453-4-5-8-9" + inkscape:collect="always" /> + <linearGradient + id="linearGradient3390-178-986-453-4-5-8-9"> + <stop + id="stop3624-8-6-6-1" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop3626-1-1-0-2" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3732-7-1" + y2="182.48" + xlink:href="#linearGradient3390-178-986-453-4-5-8-9" + gradientUnits="userSpaceOnUse" + x2="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + y1="191.52" + x1="-55.188999" /> + <linearGradient + id="linearGradient5305"> + <stop + id="stop5307" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop5309" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + y2="191.52" + x2="-55.188999" + y1="182.48" + x1="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + gradientUnits="userSpaceOnUse" + id="linearGradient3062-1" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-1-2" + inkscape:collect="always" /> + <linearGradient + id="linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-1-2"> + <stop + id="stop3618-1-9-9-3" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop3270-5-6-0-5" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop3620-9-3-50-2" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4322-57-2" + y2="191.52" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-1-2" + gradientUnits="userSpaceOnUse" + x2="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + y1="182.48" + x1="-31.523001" /> + <linearGradient + id="linearGradient5317"> + <stop + id="stop5319" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop5321" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop5323" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + y2="9" + x2="0" + y1="-8.8818001e-16" + x1="22" + gradientUnits="userSpaceOnUse" + id="linearGradient3064-0" + xlink:href="#linearGradient4456-0-0" + inkscape:collect="always" /> + <linearGradient + id="linearGradient4456-0-0"> + <stop + id="stop4458-4-9" + style="stop-color:#f6daae" + offset="0" /> + <stop + id="stop4460-0-2" + style="stop-color:#f0c178;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4462-7-4" + y2="9" + xlink:href="#linearGradient4456-0-0" + gradientUnits="userSpaceOnUse" + x2="0" + y1="-8.8818001e-16" + x1="22" /> + <linearGradient + id="linearGradient5330"> + <stop + id="stop5332" + style="stop-color:#f6daae" + offset="0" /> + <stop + id="stop5334" + style="stop-color:#f0c178;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3732-6" + y2="182.48" + xlink:href="#linearGradient3390-178-986-453-4-5-7" + gradientUnits="userSpaceOnUse" + x2="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,52.302,-181.74)" + y1="190.50999" + x1="-31.523001" /> + <linearGradient + id="linearGradient3390-178-986-453-4-5-7"> + <stop + id="stop3624-8-6-3" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop3626-1-1-8" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4452" + y2="182.48" + xlink:href="#linearGradient3390-178-986-453-4-5-7" + gradientUnits="userSpaceOnUse" + x2="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,52.302,-181.74)" + y1="191.52" + x1="-31.523001" /> + <linearGradient + id="linearGradient3034"> + <stop + id="stop3036-6" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop3038-0" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3795" + y2="167" + xlink:href="#linearGradient3390-178-986-453-4-5-7" + gradientUnits="userSpaceOnUse" + x2="-55.577" + y1="162" + x1="-33.577" /> + <linearGradient + id="linearGradient3041"> + <stop + id="stop3043" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop3045" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3047" + y2="167" + xlink:href="#linearGradient3390-178-986-453-4-5-7" + gradientUnits="userSpaceOnUse" + x2="-55.577" + y1="162" + x1="-33.577" /> + <linearGradient + id="linearGradient3049"> + <stop + id="stop3051" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop3053-1" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4040-8-9-7" + y2="197.31" + gradientUnits="userSpaceOnUse" + x2="-83.371002" + gradientTransform="matrix(0,-1,1,0,-272,102)" + y1="185.44" + x1="-86.552002"> + <stop + id="stop4036-9-1-5" + style="stop-color:#eeeeec" + offset="0" /> + <stop + id="stop4038-0-5-5" + style="stop-color:#babdb6" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3965" + y2="197.31" + gradientUnits="userSpaceOnUse" + x2="-83.371002" + gradientTransform="matrix(0,-1,1,0,-272.58,80)" + y1="178" + x1="-89"> + <stop + id="stop3618-1-9-8" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop3270-5-6-3-3" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop3620-9-3-0" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4322-9" + y2="191.52" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-12" + gradientUnits="userSpaceOnUse" + x2="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,52.302,-181.74)" + y1="182.48" + x1="-55.188999" /> + <linearGradient + id="linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-12"> + <stop + id="stop3618-1-9-89" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop3270-5-6-6" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop3620-9-3-1" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4324-6" + y2="191.52" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-12" + gradientUnits="userSpaceOnUse" + x2="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,52.302,-181.74)" + y1="183.48" + x1="-55.188999" /> + <linearGradient + id="linearGradient3068"> + <stop + id="stop3070" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop3072" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop3074" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4462-4" + y2="9" + xlink:href="#linearGradient4456-1" + gradientUnits="userSpaceOnUse" + x2="22" + gradientTransform="translate(1,0)" + y1="-8.8818001e-16" /> + <linearGradient + id="linearGradient4456-1"> + <stop + id="stop4458-5" + style="stop-color:#f6daae" + offset="0" /> + <stop + id="stop4460-2" + style="stop-color:#f0c178;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3080" + y2="9" + xlink:href="#linearGradient4456-1" + gradientUnits="userSpaceOnUse" + x2="22" + gradientTransform="translate(1,0)" + y1="-8.8818001e-16" /> + <linearGradient + id="linearGradient3082"> + <stop + id="stop3084" + style="stop-color:#f6daae" + offset="0" /> + <stop + id="stop3086" + style="stop-color:#f0c178;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + y2="167" + x2="-55.577" + y1="162" + x1="-33.577" + gradientUnits="userSpaceOnUse" + id="linearGradient3102" + xlink:href="#linearGradient3390-178-986-453-4-5-7" + inkscape:collect="always" /> + <linearGradient + y2="9" + x2="22" + y1="-8.8818001e-16" + gradientTransform="translate(1,0)" + gradientUnits="userSpaceOnUse" + id="linearGradient3104-9" + xlink:href="#linearGradient4456-1" + inkscape:collect="always" /> + <linearGradient + id="linearGradient3732-6-6" + y2="182.48" + xlink:href="#linearGradient3390-178-986-453-4-5-7-6" + gradientUnits="userSpaceOnUse" + x2="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,52.302,-181.74)" + y1="190.50999" + x1="-31.523001" /> + <linearGradient + id="linearGradient3390-178-986-453-4-5-7-6"> + <stop + id="stop3624-8-6-3-0" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop3626-1-1-8-5" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4452-2" + y2="182.48" + xlink:href="#linearGradient3390-178-986-453-4-5-7-6" + gradientUnits="userSpaceOnUse" + x2="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,52.302,-181.74)" + y1="191.52" + x1="-31.523001" /> + <linearGradient + id="linearGradient5604"> + <stop + id="stop5606" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop5608" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3795-3" + y2="167" + xlink:href="#linearGradient3390-178-986-453-4-5-7-6" + gradientUnits="userSpaceOnUse" + x2="-55.577" + y1="162" + x1="-33.577" /> + <linearGradient + id="linearGradient5611"> + <stop + id="stop5613" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop5615" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + y2="167" + x2="-55.577" + y1="162" + x1="-33.577" + gradientUnits="userSpaceOnUse" + id="linearGradient3102-2" + xlink:href="#linearGradient3390-178-986-453-4-5-7-6" + inkscape:collect="always" /> + <linearGradient + id="linearGradient5618"> + <stop + id="stop5620" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop5622" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4040-8-9-7-6" + y2="197.31" + gradientUnits="userSpaceOnUse" + x2="-83.371002" + gradientTransform="matrix(0,-1,1,0,-272,102)" + y1="185.44" + x1="-86.552002"> + <stop + id="stop4036-9-1-5-8" + style="stop-color:#eeeeec" + offset="0" /> + <stop + id="stop4038-0-5-5-8" + style="stop-color:#babdb6" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3965-3" + y2="197.31" + gradientUnits="userSpaceOnUse" + x2="-83.371002" + gradientTransform="matrix(0,-1,1,0,-272.58,80)" + y1="178" + x1="-89"> + <stop + id="stop3618-1-9-8-7" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop3270-5-6-3-3-6" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop3620-9-3-0-8" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4322-9-9" + y2="191.52" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-12-3" + gradientUnits="userSpaceOnUse" + x2="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,52.302,-181.74)" + y1="182.48" + x1="-55.188999" /> + <linearGradient + id="linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-12-3"> + <stop + id="stop3618-1-9-89-9" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop3270-5-6-6-5" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop3620-9-3-1-2" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4324-6-7" + y2="191.52" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-12-3" + gradientUnits="userSpaceOnUse" + x2="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,52.302,-181.74)" + y1="183.48" + x1="-55.188999" /> + <linearGradient + id="linearGradient5637"> + <stop + id="stop5639" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop5641" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop5643" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + y2="9" + x2="22" + y1="-8.8818001e-16" + gradientTransform="translate(1,0)" + gradientUnits="userSpaceOnUse" + id="linearGradient3104-9-4" + xlink:href="#linearGradient4456-1-5" + inkscape:collect="always" /> + <linearGradient + id="linearGradient4456-1-5"> + <stop + id="stop4458-5-7" + style="stop-color:#f6daae" + offset="0" /> + <stop + id="stop4460-2-6" + style="stop-color:#f0c178;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4462-4-9" + y2="9" + xlink:href="#linearGradient4456-1-5" + gradientUnits="userSpaceOnUse" + x2="22" + gradientTransform="translate(1,0)" + y1="-8.8818001e-16" /> + <linearGradient + id="linearGradient5650"> + <stop + id="stop5652" + style="stop-color:#f6daae" + offset="0" /> + <stop + id="stop5654" + style="stop-color:#f0c178;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3732-6-7" + y2="182.48" + xlink:href="#linearGradient3390-178-986-453-4-5-7-3" + gradientUnits="userSpaceOnUse" + x2="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,52.302,-181.74)" + y1="190.50999" + x1="-31.523001" /> + <linearGradient + id="linearGradient3390-178-986-453-4-5-7-3"> + <stop + id="stop3624-8-6-3-7" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop3626-1-1-8-2" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4452-23" + y2="182.48" + xlink:href="#linearGradient3390-178-986-453-4-5-7-3" + gradientUnits="userSpaceOnUse" + x2="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,52.302,-181.74)" + y1="191.52" + x1="-31.523001" /> + <linearGradient + id="linearGradient5604-7"> + <stop + id="stop5606-9" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop5608-9" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3795-7" + y2="167" + xlink:href="#linearGradient3390-178-986-453-4-5-7-3" + gradientUnits="userSpaceOnUse" + x2="-55.577" + y1="162" + x1="-33.577" /> + <linearGradient + id="linearGradient5611-3"> + <stop + id="stop5613-0" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop5615-2" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + y2="167" + x2="-55.577" + y1="162" + x1="-33.577" + gradientUnits="userSpaceOnUse" + id="linearGradient3102-5" + xlink:href="#linearGradient3390-178-986-453-4-5-7-3" + inkscape:collect="always" /> + <linearGradient + id="linearGradient5618-3"> + <stop + id="stop5620-9" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop5622-3" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4040-8-9-7-2" + y2="197.31" + gradientUnits="userSpaceOnUse" + x2="-83.371002" + gradientTransform="matrix(0,-1,1,0,-272,102)" + y1="185.44" + x1="-86.552002"> + <stop + id="stop4036-9-1-5-9" + style="stop-color:#eeeeec" + offset="0" /> + <stop + id="stop4038-0-5-5-6" + style="stop-color:#babdb6" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3965-34" + y2="197.31" + gradientUnits="userSpaceOnUse" + x2="-83.371002" + gradientTransform="matrix(0,-1,1,0,-272.58,80)" + y1="178" + x1="-89"> + <stop + id="stop3618-1-9-8-1" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop3270-5-6-3-3-3" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop3620-9-3-0-7" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4322-9-8" + y2="191.52" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-12-6" + gradientUnits="userSpaceOnUse" + x2="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,52.302,-181.74)" + y1="182.48" + x1="-55.188999" /> + <linearGradient + id="linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-12-6"> + <stop + id="stop3618-1-9-89-7" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop3270-5-6-6-0" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop3620-9-3-1-0" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4324-6-1" + y2="191.52" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-12-6" + gradientUnits="userSpaceOnUse" + x2="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,52.302,-181.74)" + y1="183.48" + x1="-55.188999" /> + <linearGradient + id="linearGradient5637-0"> + <stop + id="stop5639-5" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop5641-8" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop5643-2" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + y2="9" + x2="22" + y1="-8.8818001e-16" + gradientTransform="translate(1,0)" + gradientUnits="userSpaceOnUse" + id="linearGradient3104-9-7" + xlink:href="#linearGradient4456-1-3" + inkscape:collect="always" /> + <linearGradient + id="linearGradient4456-1-3"> + <stop + id="stop4458-5-1" + style="stop-color:#f6daae" + offset="0" /> + <stop + id="stop4460-2-8" + style="stop-color:#f0c178;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4462-4-2" + y2="9" + xlink:href="#linearGradient4456-1-3" + gradientUnits="userSpaceOnUse" + x2="22" + gradientTransform="translate(1,0)" + y1="-8.8818001e-16" /> + <linearGradient + id="linearGradient5650-8"> + <stop + id="stop5652-3" + style="stop-color:#f6daae" + offset="0" /> + <stop + id="stop5654-4" + style="stop-color:#f0c178;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3390-178-986-453-4-5-7-3" + id="linearGradient6036" + gradientUnits="userSpaceOnUse" + x1="-33.577" + y1="162" + x2="-55.577" + y2="167" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient4040-8-9-7-2" + id="linearGradient6038" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0,-1,1,0,-272,102)" + x1="-86.552002" + y1="185.44" + x2="-83.371002" + y2="197.31" /> + <radialGradient + id="radialGradient2403" + gradientUnits="userSpaceOnUse" + cy="19.031" + cx="11.25" + gradientTransform="matrix(1.4062,0,0,0.3867,-3.8197,13.523)" + r="8.0625"> + <stop + id="stop2487" + style="stop-color:#0d0d0d" + offset="0" /> + <stop + id="stop2489" + style="stop-color:#0d0d0d;stop-opacity:0" + offset="1" /> + </radialGradient> + <linearGradient + id="linearGradient2400" + y2="34.224998" + gradientUnits="userSpaceOnUse" + x2="24.104" + gradientTransform="matrix(0.89889,0,0,0.89347,-9.4637,-8.566)" + y1="15.181" + x1="24.104"> + <stop + id="stop2266-3" + style="stop-color:#d7e866" + offset="0" /> + <stop + id="stop2268-0" + style="stop-color:#8cab2a" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient2397" + y2="45.689999" + gradientUnits="userSpaceOnUse" + x2="24.139" + gradientTransform="matrix(0.53994,0,0,0.53668,-0.84892,-0.5062)" + y1="6.5317001" + x1="24.139"> + <stop + id="stop4224-5" + style="stop-color:#fff" + offset="0" /> + <stop + id="stop4226-6" + style="stop-color:#fff;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + y2="45.689999" + x2="24.139" + y1="6.5317001" + x1="24.139" + gradientTransform="matrix(0.53994,0,0,0.53668,-0.84892,-0.5062)" + gradientUnits="userSpaceOnUse" + id="linearGradient3019-5" + xlink:href="#linearGradient2397" + inkscape:collect="always" /> + <radialGradient + id="radialGradient2478" + gradientUnits="userSpaceOnUse" + cy="4.625" + cx="62.625" + gradientTransform="matrix(1.1294,0,0,0.28235,-58.729,19.694)" + r="10.625"> + <stop + id="stop8840-3" + offset="0" /> + <stop + id="stop8842-0" + style="stop-opacity:0" + offset="1" /> + </radialGradient> + <radialGradient + id="radialGradient2500" + gradientUnits="userSpaceOnUse" + cy="3.99" + cx="23.896" + gradientTransform="matrix(0,1.2316,-1.6257,0,18.487,-28.721)" + r="20.396999"> + <stop + id="stop3244" + style="stop-color:#f8b17e" + offset="0" /> + <stop + id="stop3246" + style="stop-color:#e35d4f" + offset=".26238" /> + <stop + id="stop3248" + style="stop-color:#c6262e" + offset=".66094" /> + <stop + id="stop3250" + style="stop-color:#690b54" + offset="1" /> + </radialGradient> + <linearGradient + id="linearGradient2502" + y2="3.0816" + gradientUnits="userSpaceOnUse" + x2="18.379" + gradientTransform="matrix(0.51604,0,0,0.51604,-0.38499,-0.38499)" + y1="44.98" + x1="18.379"> + <stop + id="stop2492" + style="stop-color:#791235" + offset="0" /> + <stop + id="stop2494" + style="stop-color:#dd3b27" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient2497" + y2="5.4675999" + gradientUnits="userSpaceOnUse" + x2="63.396999" + gradientTransform="matrix(1.0863,0,0,1.0862,-55.567,15.814)" + y1="-12.489" + x1="63.396999"> + <stop + id="stop4875-9" + style="stop-color:#fff" + offset="0" /> + <stop + id="stop4877-2" + style="stop-color:#fff;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient2494" + y2="45.074001" + gradientUnits="userSpaceOnUse" + x2="24.481001" + gradientTransform="matrix(0.53842,0,0,0.53842,-0.92208,-1.4605)" + y1="5.0809002" + x1="24.481001"> + <stop + id="stop3783" + style="stop-color:#fff" + offset="0" /> + <stop + id="stop3785" + style="stop-color:#fff;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + y2="45.074001" + x2="24.481001" + y1="5.0809002" + x1="24.481001" + gradientTransform="matrix(0.53842,0,0,0.53842,-0.92208,-1.4605)" + gradientUnits="userSpaceOnUse" + id="linearGradient3037" + xlink:href="#linearGradient2494" + inkscape:collect="always" /> + <linearGradient + id="linearGradient3732-2" + y2="182.48" + xlink:href="#linearGradient3390-178-986-453-4-5-74" + gradientUnits="userSpaceOnUse" + x2="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + y1="191.52" + x1="-55.188999" /> + <linearGradient + id="linearGradient3390-178-986-453-4-5-74"> + <stop + id="stop3624-8-6-33" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop3626-1-1-23" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3017-1" + y2="182.48" + xlink:href="#linearGradient3390-178-986-453-4-5-74" + gradientUnits="userSpaceOnUse" + x2="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + y1="191.52" + x1="-55.188999" /> + <linearGradient + id="linearGradient3019-2"> + <stop + id="stop3021-4" + style="stop-color:#bb2b12" + offset="0" /> + <stop + id="stop3023-3" + style="stop-color:#cd7233" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4322-2" + y2="191.52" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-3" + gradientUnits="userSpaceOnUse" + x2="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + y1="182.48" + x1="-31.523001" /> + <linearGradient + id="linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-3"> + <stop + id="stop3618-1-9-6" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop3270-5-6-4" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop3620-9-3-8" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3030-7" + y2="191.52" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-3" + gradientUnits="userSpaceOnUse" + x2="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + y1="182.48" + x1="-31.523001" /> + <linearGradient + id="linearGradient3032-2"> + <stop + id="stop3034-8" + style="stop-color:#f0c178" + offset="0" /> + <stop + id="stop3036-1" + style="stop-color:#e18941" + offset=".5" /> + <stop + id="stop3038-4" + style="stop-color:#ec4f18" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient4462-5" + y2="9" + xlink:href="#linearGradient4456-16" + gradientUnits="userSpaceOnUse" + x2="0" + y1="-8.8818001e-16" + x1="22" /> + <linearGradient + id="linearGradient4456-16"> + <stop + id="stop4458-8" + style="stop-color:#f6daae" + offset="0" /> + <stop + id="stop4460-52" + style="stop-color:#f0c178;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3044-5" + y2="9" + xlink:href="#linearGradient4456-16" + gradientUnits="userSpaceOnUse" + x2="0" + y1="-8.8818001e-16" + x1="22" /> + <linearGradient + id="linearGradient3046-8"> + <stop + id="stop3048-0" + style="stop-color:#f6daae" + offset="0" /> + <stop + id="stop3050-12" + style="stop-color:#f0c178;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + y2="182.48" + x2="-31.523001" + y1="191.52" + x1="-55.188999" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + gradientUnits="userSpaceOnUse" + id="linearGradient3060" + xlink:href="#linearGradient3390-178-986-453-4-5-74" + inkscape:collect="always" /> + <linearGradient + y2="191.52" + x2="-55.188999" + y1="182.48" + x1="-31.523001" + gradientTransform="matrix(0.92957,0,0,0.99594,51.302,-181.74)" + gradientUnits="userSpaceOnUse" + id="linearGradient3062" + xlink:href="#linearGradient7012-661-145-733-759-865-745-661-970-94-1-0-3" + inkscape:collect="always" /> + <linearGradient + y2="9" + x2="0" + y1="-8.8818001e-16" + x1="22" + gradientUnits="userSpaceOnUse" + id="linearGradient3064" + xlink:href="#linearGradient4456-16" + inkscape:collect="always" /> + <linearGradient + gradientTransform="matrix(0.2149522,0,0,0.2369714,30.871779,266.01932)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient3989-9" + id="linearGradient9477-4" + y2="332.36218" + x2="152.87143" + y1="585.21936" + x1="460.01428" /> + <linearGradient + id="linearGradient3989-9"> + <stop + offset="0" + style="stop-color:#000000;stop-opacity:1" + id="stop3991-3" /> + <stop + offset="1" + style="stop-color:#000000;stop-opacity:0" + id="stop3993-0" /> + </linearGradient> + <linearGradient + gradientTransform="matrix(0.3505596,0,0,0.3701598,22.984703,226.27699)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient2190-2" + id="linearGradient9474-9" + y2="322.8829" + x2="131.99297" + y1="451.83481" + x1="225.2822" /> + <linearGradient + id="linearGradient2190-2"> + <stop + offset="0" + style="stop-color:#acbbff;stop-opacity:1" + id="stop2192-2" /> + <stop + offset="1" + style="stop-color:#acbbff;stop-opacity:0" + id="stop2194-7" /> + </linearGradient> + <linearGradient + x1="23.878078" + y1="18.541262" + x2="23.878078" + y2="27.495163" + id="linearGradient2836" + xlink:href="#linearGradient3725-8" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.8988874,0,0,0.8934652,-9.4637044,-8.565972)" /> + <linearGradient + id="linearGradient3725-8"> + <stop + id="stop3729-1" + style="stop-color:#e35d4f;stop-opacity:1" + offset="0" /> + <stop + id="stop3731" + style="stop-color:#c6262e;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + y2="27.495163" + x2="23.878078" + y1="18.541262" + x1="23.878078" + gradientTransform="matrix(0.8988874,0,0,0.8934652,-241.4637,171.43403)" + gradientUnits="userSpaceOnUse" + id="linearGradient3013" + xlink:href="#linearGradient3725-8" + inkscape:collect="always" /> + <linearGradient + x1="24.138529" + y1="6.5316639" + x2="24.138529" + y2="45.690399" + id="linearGradient2833" + xlink:href="#linearGradient4222" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.5399382,0,0,0.5366811,-214.55602,180.4938)" /> + <linearGradient + id="linearGradient4222"> + <stop + id="stop4224-0" + style="stop-color:#ffffff;stop-opacity:1" + offset="0" /> + <stop + id="stop4226-3" + style="stop-color:#ffffff;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + x1="23.878078" + y1="18.541262" + x2="23.878078" + y2="27.495163" + id="linearGradient2836-7" + xlink:href="#linearGradient3725-5" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.8988874,0,0,0.8934652,-9.4637044,-8.565972)" /> + <linearGradient + id="linearGradient3725-5"> + <stop + id="stop3729-2" + style="stop-color:#e35d4f;stop-opacity:1" + offset="0" /> + <stop + id="stop3731-0" + style="stop-color:#c6262e;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + y2="27.495163" + x2="23.878078" + y1="18.541262" + x1="23.878078" + gradientTransform="matrix(0.8988874,0,0,0.8934652,-11.463704,-16.560791)" + gradientUnits="userSpaceOnUse" + id="linearGradient3062-6" + xlink:href="#linearGradient3725-5" + inkscape:collect="always" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3725-5" + id="linearGradient7189" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.8988874,0,0,0.8934652,-223.1708,172.43403)" + x1="23.878078" + y1="18.541262" + x2="23.878078" + y2="27.495163" /> + <radialGradient + id="radialGradient2541" + fx="28.603001" + gradientUnits="userSpaceOnUse" + cy="69" + cx="38" + gradientTransform="matrix(1,0,0,0.45,0,37.95)" + r="20"> + <stop + id="stop6021" + offset="0" /> + <stop + id="stop6023" + style="stop-opacity:0" + offset="1" /> + </radialGradient> + <linearGradient + id="linearGradient2543" + y2="8" + gradientUnits="userSpaceOnUse" + x2="26" + gradientTransform="matrix(0.52499,0,0,0.5277,-1.1749,-0.77947)" + y1="16" + x1="28"> + <stop + id="stop5960" + style="stop-color:#c17d11" + offset="0" /> + <stop + id="stop5962" + style="stop-color:#e9b96e" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient2545" + y2="18" + gradientUnits="userSpaceOnUse" + x2="34" + gradientTransform="matrix(0.52499,0,0,0.5277,-1.1749,-0.77947)" + y1="9.2407999" + x1="30.325001"> + <stop + id="stop5998" + style="stop-color:#8f5902" + offset="0" /> + <stop + id="stop6000" + style="stop-color:#73521e" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient2547" + y2="16.686001" + gradientUnits="userSpaceOnUse" + x2="33.446999" + y1="8" + x1="28"> + <stop + id="stop5986" + style="stop-color:#fff" + offset="0" /> + <stop + id="stop5988" + style="stop-color:#fff;stop-opacity:.13439" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient2549" + y2="30.743" + gradientUnits="userSpaceOnUse" + x2="30.208" + gradientTransform="matrix(0.52499,0,0,0.5277,-1.1749,-0.77947)" + y1="25.061001" + x1="20.934"> + <stop + id="stop5968" + style="stop-color:#fdef72" + offset="0" /> + <stop + id="stop5970" + style="stop-color:#e2cb0b" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient2551" + y2="37.846001" + gradientUnits="userSpaceOnUse" + x2="29.493999" + gradientTransform="matrix(0.52499,0,0,0.5277,-1.1749,-0.77947)" + y1="27.447001" + x1="17.032"> + <stop + id="stop5989" + style="stop-color:#b3a10b" + offset="0" /> + <stop + id="stop5991" + style="stop-color:#91780a" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient2553" + y2="37.028999" + gradientUnits="userSpaceOnUse" + x2="18.986" + gradientTransform="matrix(0.52499,0,0,0.5277,-1.1749,-0.77947)" + y1="41.956001" + x1="22.32"> + <stop + id="stop5983" + style="stop-color:#fff" + offset="0" /> + <stop + id="stop5985" + style="stop-color:#fff;stop-opacity:.69412" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient2555" + y2="34.728001" + gradientUnits="userSpaceOnUse" + x2="23.489" + gradientTransform="matrix(0.52499,0,0,0.5277,-1.1749,-0.77947)" + y1="36.217999" + x1="27.355"> + <stop + id="stop6001" + style="stop-color:#c4a000" + offset="0" /> + <stop + id="stop6003" + style="stop-color:#c4a000;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient2557" + y2="20.618999" + gradientUnits="userSpaceOnUse" + x2="21.591" + gradientTransform="matrix(0.51282,0,0,0.5277,-0.84657,-0.77947)" + y1="23.146" + x1="27.652"> + <stop + id="stop2473" + style="stop-color:#919191" + offset="0" /> + <stop + id="stop2475" + style="stop-color:#cecece" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3328" + y2="11.543" + gradientUnits="userSpaceOnUse" + x2="15.289" + gradientTransform="matrix(0.51378,0,0,-0.52177,-1.8456,25.023)" + y1="36.458" + x1="15.289"> + <stop + id="stop3924" + style="stop-color:#eeeeec" + offset="0" /> + <stop + id="stop3926" + style="stop-color:#babdb6" + offset=".69692" /> + <stop + id="stop3928" + style="stop-color:#a1a59b" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3203" + y2="44.056" + xlink:href="#linearGradient4222-5" + gradientUnits="userSpaceOnUse" + x2="20.622" + gradientTransform="matrix(-0.51406,0,0,0.52227,24.325,-0.034536)" + y1="5.2263999" + x1="20.622" /> + <linearGradient + id="linearGradient4222-5"> + <stop + id="stop4224-45" + style="stop-color:#fff" + offset="0" /> + <stop + id="stop4226-8" + style="stop-color:#fff;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3199" + y2="34.889" + xlink:href="#linearGradient4222-5" + gradientUnits="userSpaceOnUse" + x2="20.622" + gradientTransform="matrix(-0.51406,0,0,0.52227,24.325,-0.034536)" + y1="15.425" + x1="20.622" /> + <linearGradient + id="linearGradient3017-2"> + <stop + id="stop3019" + style="stop-color:#fff" + offset="0" /> + <stop + id="stop3021-3" + style="stop-color:#fff;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3201" + y2="44.056" + xlink:href="#linearGradient4222-5" + gradientUnits="userSpaceOnUse" + x2="20.622" + gradientTransform="matrix(-0.47993,0,0,0.52395,24.153,-0.074909)" + y1="5.2263999" + x1="20.622" /> + <linearGradient + id="linearGradient3024"> + <stop + id="stop3026" + style="stop-color:#fff" + offset="0" /> + <stop + id="stop3028" + style="stop-color:#fff;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + y2="44.056" + x2="20.622" + y1="5.2263999" + x1="20.622" + gradientTransform="matrix(-0.47993,0,0,0.52395,24.153,-0.074909)" + gradientUnits="userSpaceOnUse" + id="linearGradient3035" + xlink:href="#linearGradient4222-5" + inkscape:collect="always" /> + <linearGradient + gradientTransform="matrix(0.2149522,0,0,0.2369714,30.871779,266.01932)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient3989-8" + id="linearGradient9477-2" + y2="332.36218" + x2="152.87143" + y1="585.21936" + x1="460.01428" /> + <linearGradient + id="linearGradient3989-8"> + <stop + offset="0" + style="stop-color:#000000;stop-opacity:1" + id="stop3991-9" /> + <stop + offset="1" + style="stop-color:#000000;stop-opacity:0" + id="stop3993-6" /> + </linearGradient> + <linearGradient + gradientTransform="matrix(0.3505596,0,0,0.3701598,22.984703,226.27699)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient2190-1" + id="linearGradient9474-98" + y2="322.8829" + x2="131.99297" + y1="451.83481" + x1="225.2822" /> + <linearGradient + id="linearGradient2190-1"> + <stop + offset="0" + style="stop-color:#acbbff;stop-opacity:1" + id="stop2192-9" /> + <stop + offset="1" + style="stop-color:#acbbff;stop-opacity:0" + id="stop2194-4" /> + </linearGradient> </defs> <sodipodi:namedview id="base" @@ -7204,9 +8950,9 @@ borderopacity="1.0" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:zoom="11.313708" - inkscape:cx="-103.23578" - inkscape:cy="-187.95775" + inkscape:zoom="7.9999996" + inkscape:cx="-132.22424" + inkscape:cy="-178.90149" inkscape:document-units="px" inkscape:current-layer="layer1" width="16px" @@ -7431,14 +9177,14 @@ id="rect2486" /> <text xml:space="preserve" - style="font-size:5px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" + style="font-size:5px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" x="8" y="-14" id="text2432"><tspan sodipodi:role="line" id="tspan2434" x="8" - y="-14">%% ST IL FBD LD SFC FUNCTION FUNCTIONBLOCK PROJECT TRANSITION ACTION CONFIGURATION RESOURCE DATATYPE DATATYPES PROGRAM TRANSITIONS ACTIONS CONFIGURATIONS RESOURCES PROPERTIES%%</tspan></text> + y="-14">%% ST IL FBD LD SFC FUNCTION FUNCTIONBLOCK PROJECT TRANSITION ACTION CONFIGURATION RESOURCE DATATYPE DATATYPES PROGRAM TRANSITIONS ACTIONS CONFIGURATIONS RESOURCES GRAPH%%</tspan></text> <text sodipodi:linespacing="100%" id="text2443" @@ -8466,8 +10212,8 @@ x="0" y="0" xlink:href="#g3824" - id="PROPERTIES" - transform="translate(560,0)" + id="GRAPH" + transform="translate(544.5,0)" width="16" height="16" inkscape:label="#use3839" /> @@ -8717,99 +10463,6 @@ style="opacity:1;fill:url(#linearGradient4307);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10.43299961;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> </g> </g> - <rect - style="opacity:0.89263802;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" - id="rect4372" - width="1" - height="1" - x="527" - y="7" /> - <rect - y="10" - x="527" - height="1" - width="1" - id="rect4382" - style="opacity:0.89263802;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> - <rect - y="10" - x="530" - height="1" - width="1" - id="rect4384" - style="opacity:0.89263802;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> - <rect - y="10" - x="533" - height="1" - width="1" - id="rect4386" - style="opacity:0.89263802;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> - <rect - y="7" - x="533" - height="1" - width="1" - id="rect4388" - style="opacity:0.89263802;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> - <rect - y="7" - x="530" - height="1" - width="1" - id="rect4390" - style="opacity:0.89263802;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> - <rect - y="13" - x="533" - height="1" - width="1" - id="rect4392" - style="opacity:0.89263802;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> - <rect - y="13" - x="530" - height="1" - width="1" - id="rect4394" - style="opacity:0.89263802;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> - <rect - y="13" - x="527" - height="1" - width="1" - id="rect4396" - style="opacity:0.89263802;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> - <rect - style="opacity:0.89263802;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" - id="rect4398" - width="4.9999681" - height="1" - x="528" - y="2" /> - <rect - style="opacity:0.89263802;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" - id="rect4400" - width="6.0000882" - height="1" - x="528" - y="4" /> - <path - sodipodi:type="arc" - style="opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" - id="path4402" - sodipodi:cx="523.5" - sodipodi:cy="4" - sodipodi:rx="2.5" - sodipodi:ry="2" - d="M 526,4.0014802 A 2.5,2 0 0 1 526,4.0023454" - sodipodi:start="0.00074007753" - sodipodi:end="0.0011727141" - sodipodi:open="true" /> - <path - style="opacity:1;fill:#5f5f5f;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:square;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" - d="M 522.5 2.40625 C 521.60459 2.9254866 521 3.8911133 521 5 C 521 6.1088867 521.60459 7.0745134 522.5 7.59375 L 522.5 14 C 522.5 14.545344 522.93453 15 523.46875 15 L 524.5625 15 C 525.09671 15 525.5 14.545344 525.5 14 L 525.5 7.59375 C 526.39541 7.0745134 527 6.1088867 527 5 C 527 3.8911133 526.39541 2.9254866 525.5 2.40625 C 525.50057 2.4263878 525.5 2.4484431 525.5 2.46875 L 525.5 4.21875 C 525.49999 5.2002515 524.83871 6 524 6 C 523.16129 6.0000002 522.5 5.2002515 522.5 4.21875 L 522.5 2.46875 C 522.5 2.4484431 522.49943 2.4263878 522.5 2.40625 z " - id="path4408" /> <g id="g4430"> <rect @@ -10362,7 +12015,7 @@ x="175" y="131">%%custom_tree_background%%</tspan></text> <g - transform="matrix(0,1,1,0,-257.9999,182.5)" + transform="matrix(0,1,1,0,-125.9999,182.5)" id="layer1-5"> <path d="M 8.475,-1.4875 2.5,4.9999 8.475,11.488" @@ -10403,7 +12056,7 @@ <rect inkscape:label="#rect3636" y="181" - x="-265" + x="-133" height="24" width="24" id="up" @@ -10411,16 +12064,16 @@ <text xml:space="preserve" style="font-size:4.49727678px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" - x="-265" + x="-133" y="177" id="text3638-3-3"><tspan sodipodi:role="line" id="tspan3640-1-8" - x="-265" + x="-133" y="177">%%up%%</tspan></text> <g id="layer1-57" - transform="translate(-231.09946,181.05807)"> + transform="translate(-233.09946,219.05807)"> <g transform="matrix(0.50043,0,0,0.51685,0.11475,-0.57818)" style="stroke-width:1.88259995" @@ -10830,8 +12483,8 @@ </g> <rect inkscape:label="#rect3636" - y="181" - x="-231" + y="219" + x="-233" height="24" width="24" id="edit" @@ -10839,17 +12492,17 @@ <text xml:space="preserve" style="font-size:4.49727678px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" - x="-231.67409" - y="177.06073" + x="-233.67409" + y="215.06073" id="text3638-3-3-2"><tspan sodipodi:role="line" id="tspan3640-1-8-0" - x="-231.67409" - y="177.06073">%%edit%%</tspan></text> + x="-233.67409" + y="215.06073">%%edit%%</tspan></text> <g style="fill-rule:evenodd" id="g652" - transform="matrix(0.36763942,0,0,0.36763942,-270.23385,166.36126)"> + transform="matrix(0.36763942,0,0,0.36763942,-262.23385,204.36126)"> <path id="_70839568" class="fil5" @@ -10909,26 +12562,26 @@ </g> <rect inkscape:label="#rect3636" - y="181" - x="-198" + y="219" + x="-190" height="24" width="24" - id="debug" + id="debug_instance" style="opacity:0;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> <text xml:space="preserve" style="font-size:4.49727678px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" - x="-202" - y="177" + x="-204" + y="215" id="text3638-3-3-2-0"><tspan sodipodi:role="line" id="tspan3640-1-8-0-6" - x="-202" - y="177">%%debug%%</tspan></text> + x="-204" + y="215">%%debug_instance%%</tspan></text> <g style="display:inline" id="layer1-8" - transform="matrix(0.23162724,0,0,0.23162724,-186.03954,107.99446)"> + transform="matrix(0.23162724,0,0,0.23162724,-154.66454,145.99446)"> <rect style="opacity:0.74621211;fill:url(#linearGradient9477);fill-opacity:1;fill-rule:evenodd;stroke:none" id="rect3108" @@ -11081,63 +12734,63 @@ </g> <rect inkscape:label="#rect3636" - y="181" - x="-166" + y="219" + x="-134.625" height="24" width="24" - id="graph" + id="instance_graph" style="opacity:0;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> <text xml:space="preserve" style="font-size:4.49727678px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" - x="-168" - y="177" + x="-148" + y="215" id="text3638-3-3-2-0-9"><tspan sodipodi:role="line" id="tspan3640-1-8-0-6-8" - x="-168" - y="177">%%graph%%</tspan></text> + x="-148" + y="215">%%instance_graph%%</tspan></text> <path inkscape:connector-curvature="0" id="path4200" style="opacity:0.5;fill:url(#radialGradient3137)" - d="m -100.55124,202.60006 a 11.999901,2.0000048 0 0 1 -23.9998,0 11.999901,2.0000048 0 1 1 23.9998,0 z" /> + d="m 4.38811,202.24651 a 11.999905,2.0000054 0 0 1 -23.999809,0 11.999905,2.0000054 0 1 1 23.999809,0 z" /> <path inkscape:connector-curvature="0" id="rect2594-05" style="fill:url(#linearGradient3246);stroke:url(#linearGradient3248);stroke-width:0.99914002;stroke-linejoin:round" - d="m -121.05104,183.09982 h 17 v 17 h -17 v -17 z" /> + d="M -16.111699,182.74627 H 0.88831 v 17 h -17.000009 v -17 z" /> <rect id="rect2875" style="fill:url(#linearGradient4174);stroke:#699536;stroke-linejoin:round" height="4" width="17" - y="183.09979" - x="-121.05104" /> + y="182.74625" + x="-16.111702" /> <rect id="rect4194" style="fill:#bebebe" height="1" width="16" - y="189.59979" - x="-120.55104" /> + y="189.24625" + x="-15.611702" /> <rect id="rect4192" style="fill:#bebebe" height="1" width="16" - y="192.59979" - x="-120.55104" /> + y="192.24625" + x="-15.611702" /> <rect id="rect4196" style="fill:url(#linearGradient4198);stroke:#699536;stroke-linejoin:round" transform="matrix(0,1,-1,0,0,0)" height="3" width="12" - y="118.05104" - x="188.09979" /> + y="13.111702" + x="187.74625" /> <g - transform="translate(-130.83162,180.70712)" + transform="translate(-25.892279,180.35357)" id="layer1-0"> <g id="g3490-1" @@ -11162,8 +12815,8 @@ </g> <rect inkscape:label="#rect3636" - y="181" - x="-124.52512" + y="180.64645" + x="-19.585785" height="24" width="24" id="export_graph" @@ -11171,12 +12824,515 @@ <text xml:space="preserve" style="font-size:4.49727678px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" - x="-134.97713" - y="177.46968" + x="-30.037788" + y="177.11613" id="text3638-3-3-2-0-9-8-5-5"><tspan sodipodi:role="line" id="tspan3640-1-8-0-6-8-4-3-9" - x="-134.97713" - y="177.46968">%%export_graph%%</tspan></text> + x="-30.037788" + y="177.11613">%%export_graph%%</tspan></text> + <rect + inkscape:label="#rect3636" + y="181" + x="-165" + height="24" + width="24" + id="down" + style="opacity:0;color:#000000;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> + <text + xml:space="preserve" + style="font-size:4.49727678px;font-style:normal;font-weight:normal;color:#000000;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Bitstream Vera Sans" + x="-167" + y="177" + id="text3638-3-3-29"><tspan + sodipodi:role="line" + id="tspan3640-1-8-3" + x="-167" + y="177">%%down%%</tspan></text> + <rect + inkscape:label="#rect3636" + y="219" + x="-265.58582" + height="24" + width="24" + id="top" + style="opacity:0;color:#000000;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> + <text + xml:space="preserve" + style="font-size:4.49727678px;font-style:normal;font-weight:normal;color:#000000;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Bitstream Vera Sans" + x="-265.58582" + y="215" + id="text3638-3-3-29-8"><tspan + sodipodi:role="line" + id="tspan3640-1-8-3-4" + x="-265.58582" + y="215">%%top%%</tspan></text> + <g + id="layer1-06" + transform="matrix(0,1,1,0,-258.5827,219.99205)"> + <path + inkscape:connector-curvature="0" + id="path3169-2-3-9" + style="fill:none;stroke:url(#linearGradient3732-6);stroke-width:5;stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="M 8.65,-0.525 3.5,4.9999 8.65,10.525" /> + <path + inkscape:connector-curvature="0" + id="path3765-1" + style="fill:none;stroke:url(#linearGradient4452);stroke-width:6;stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="M 19,5 7.5,4.9999" /> + <g + id="g6115-7" + style="enable-background:new" + transform="matrix(1,0,0,-1,56.577,170)"> + <g + id="g4018-8" + style="stroke:url(#linearGradient3795)" + transform="translate(-1,0)"> + <path + inkscape:connector-curvature="0" + id="path3395-1" + style="fill:none;stroke:url(#linearGradient3102);stroke-width:4;stroke-linecap:round;enable-background:new" + d="m -53.577,158 v 14" /> + </g> + <g + id="g4030-5" + style="stroke:url(#linearGradient4040-8-9-7);enable-background:new" + transform="translate(39,0)"> + <path + inkscape:connector-curvature="0" + id="path3397-3" + style="fill:none;stroke:url(#linearGradient3965);stroke-width:2;stroke-linecap:round;enable-background:new" + d="m -93.577,158 v 14" /> + </g> + <path + inkscape:connector-curvature="0" + id="path3397-6-7" + style="text-indent:0;text-transform:none;block-progression:tb;opacity:0.6;color:#000000;fill:none;stroke:#f6daae;stroke-linecap:round;enable-background:new" + d="m -54.671,172.5 c -0.2292,-0.0437 -0.41011,-0.2667 -0.406,-0.5 v -14" /> + </g> + <path + inkscape:connector-curvature="0" + id="path4277-4" + style="fill:none;stroke:url(#linearGradient4322-9);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="M 8.7501,-0.62517 3.5,4.99993 l 5.2502,5.6251" /> + <path + inkscape:connector-curvature="0" + id="path4279-2" + style="fill:none;stroke:url(#linearGradient4324-6);stroke-width:4;stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="M 19,5 7.5,4.9999" /> + <path + inkscape:connector-curvature="0" + id="path4454-69" + style="opacity:0.4;fill:none;stroke:url(#linearGradient3104-9);stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="m 3.6544,6.704 4.1268,4.44 c 1,1 3.059,-0.06138 1.5,-1.5 L 7.5,8 C 6.4607,7.0409 7.5,6.5 9,6.5 h 9.5 c 3,0 2.5,-3 0,-3 h -9 C 8,3.5 6.5,3.5 7.5,2 L 9.1438,0.7688 c 1.5,-2 -0.5,-2.5 -1.5,-1.5 L 3.6752,3.3121" /> + <path + inkscape:connector-curvature="0" + id="path4464-9" + style="opacity:0.4;fill:none;stroke:url(#linearGradient4462-4);stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="M 7.5,2 9.35,0.4938 c 1.5,-2 -0.5,-2.5 -1.5,-1.5 L 3.6043,3.3762 m 0.0076,3.3096 4.1006,4.5952 c 1,1 2.9702,0.02922 1.5,-1.5 L 7.5,8" /> + <path + inkscape:connector-curvature="0" + id="path4466-57" + style="opacity:0.51000001;fill:none;stroke:#f6daae;stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="M 8.2625,-1.35 3.8123,3.1742" /> + </g> + <rect + inkscape:label="#rect3636" + y="181" + x="-265.58582" + height="24" + width="24" + id="add_element" + style="opacity:0;color:#000000;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> + <text + xml:space="preserve" + style="font-size:4.49727678px;font-style:normal;font-weight:normal;color:#000000;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Bitstream Vera Sans" + x="-276.58582" + y="177" + id="text3638-3-3-29-8-1"><tspan + sodipodi:role="line" + id="tspan3640-1-8-3-4-3" + x="-276.58582" + y="177">%%add_element%%</tspan></text> + <rect + inkscape:label="#rect3636" + y="181" + x="-213.58582" + height="24" + width="24" + id="remove_element" + style="opacity:0;color:#000000;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> + <text + xml:space="preserve" + style="font-size:4.49727678px;font-style:normal;font-weight:normal;color:#000000;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Bitstream Vera Sans" + x="-227.08582" + y="177" + id="text3638-3-3-29-8-8"><tspan + sodipodi:role="line" + id="tspan3640-1-8-3-4-7" + x="-227.08582" + y="177">%%remove_element%%</tspan></text> + <g + transform="translate(-265.9142,180.9194)" + id="layer1-2"> + <path + inkscape:connector-curvature="0" + id="path2262-4" + style="fill:url(#linearGradient2400);fill-rule:evenodd;stroke:#699536;stroke-linejoin:round" + d="M 8.5664,8.4948 V 2.5 H 15.5 v 5.9948 h 6 V 15.5 h -6 v 6 H 8.5603 l -0.027869,-6 h -6.0324 V 8.4948 h 6.0664 z" /> + <path + inkscape:connector-curvature="0" + id="path2272-4" + style="opacity:0.4;fill:none;stroke:url(#linearGradient3019-5)" + d="M 9.5,9.4948 V 3.5 h 5 v 5.9948 h 6 V 14.5 h -6 v 6 h -5 v -6 h -6 V 9.4948 h 6 z" /> + </g> + <g + id="layer1-07" + transform="matrix(0,-1,1,0,-158.12521,204.00001)"> + <path + inkscape:connector-curvature="0" + id="path3169-2-3-8" + style="fill:none;stroke:url(#linearGradient3060);stroke-width:5;stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="M 8.4802,-1.4936 2.5,4.9999 8.4802,11.494" /> + <path + inkscape:connector-curvature="0" + id="path3765-51" + style="fill:none;stroke:url(#linearGradient3732-2);stroke-width:6;stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="M 19,5 6.5,4.9999" /> + <path + inkscape:connector-curvature="0" + id="path4277-1" + style="fill:none;stroke:url(#linearGradient3062);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="M 8.5111,-1.4554 2.5,4.9999 8.5112,11.455" /> + <path + inkscape:connector-curvature="0" + id="path4279-6" + style="fill:none;stroke:url(#linearGradient4322-2);stroke-width:4;stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="M 19,5 6.5,4.9999" /> + <path + inkscape:connector-curvature="0" + id="path4454-5" + style="opacity:0.4;fill:none;stroke:url(#linearGradient3064);stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="M 8.9731,10.405 6.5,8 C 5.4861,7.0141 6.5,6.5 8,6.5 h 10.5 c 3,0 2.5,-3 0,-3 h -10 c -1.5,0 -3,0 -2,-1.5 l 2.4048,-2.3382 c 1.5,-2 -0.5,-2.5 -1.5,-1.5 L 2,4 C 1.5,4.5 1.4724,5.3333 2,6 l 5.4731,5.9048 c 1,1 3.0209,-0.02115 1.5,-1.5 z" /> + <path + inkscape:connector-curvature="0" + id="path4464-7" + style="opacity:0.4;fill:none;stroke:url(#linearGradient4462-5);stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="m 6.5,2 2.3343,-2.3364 c 1.5,-2 -0.5,-2.5 -1.5,-1.5 L 2,4 C 1.5,4.5 1.4724,5.3333 2,6 l 5.4735,5.9731 c 1,1 3.0001,-1.32e-4 1.5,-1.5 L 6.5,8.0001" /> + <path + inkscape:connector-curvature="0" + id="path4466-9" + style="opacity:0.51000001;fill:none;stroke:#f6daae;stroke-linecap:round;stroke-linejoin:round;enable-background:new" + d="M 9.1415,-0.64683 6.3064,2.36687" /> + </g> + <rect + inkscape:label="#rect3636" + y="181" + x="-100" + height="24" + width="24" + id="reset" + style="opacity:0;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> + <text + xml:space="preserve" + style="font-size:4.49727678px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" + x="-102" + y="177" + id="text3638-3-3-2-0-9-8"><tspan + sodipodi:role="line" + id="tspan3640-1-8-0-6-8-4" + x="-102" + y="177">%%reset%%</tspan></text> + <rect + inkscape:label="#rect3636" + y="181" + x="-62.818016" + height="24" + width="24" + id="current" + style="opacity:0;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> + <text + xml:space="preserve" + style="font-size:4.49727678px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" + x="-67.292892" + y="177" + id="text3638-3-3-2-0-9-8-0"><tspan + sodipodi:role="line" + id="tspan3640-1-8-0-6-8-4-7" + x="-67.292892" + y="177">%%current%%</tspan></text> + <path + inkscape:connector-curvature="0" + d="m -192.2071,189.49482 0,7.00518 -19,0 0,-7.00518 19,0 z" + id="path2262-0" + style="fill:url(#linearGradient7189);fill-opacity:1;fill-rule:evenodd;stroke:#a53738;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline" /> + <path + inkscape:connector-curvature="0" + d="m -193.2071,190.49482 0,5.00518 -17,0 0,-5.00518 17,0 z" + id="path2272-3" + style="opacity:0.4;fill:none;stroke:url(#linearGradient2833);stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline" /> + <g + transform="translate(-99.945143,180.87525)" + id="layer1-33"> + <g + id="g2524" + transform="translate(-0.47496,0)"> + <path + inkscape:connector-curvature="0" + id="path6017-8" + style="opacity:0.25;fill:url(#radialGradient2541)" + d="m 58,69 a 20,9 0 1 1 -40,0 20,9 0 1 1 40,0 z" + transform="matrix(0.52499,0,0,0.3518,-7.4748,-3.418)" /> + <path + inkscape:connector-curvature="0" + id="path5371" + style="fill:url(#linearGradient2543);fill-rule:evenodd;stroke:url(#linearGradient2545);stroke-width:1px" + d="m 18.037,0.52328 c -4.307,0.05575 -4.934,8.5737 -6.169,10.109 l 2.1,0.75856 C 15.35,9.08294 22.24,1.41264 18.463,0.53984 18.316,0.52327 18.176,0.52132 18.037,0.52312 z m -0.542,1.0884 c 0.10162,-0.00989 0.19319,0.00302 0.2789,0.049472 0.34285,0.18581 0.37991,0.78884 0.08203,1.3357 -0.29788,0.54689 -0.82198,0.84543 -1.1648,0.65962 -0.343,-0.1858 -0.38,-0.7889 -0.082,-1.3358 0.224,-0.4101 0.581,-0.6794 0.886,-0.709 z" /> + <path + inkscape:connector-curvature="0" + id="path5992" + style="opacity:0.26667002;fill:none;stroke:url(#linearGradient2547);stroke-width:1.89989996px" + d="m 36.625,4.4375 c -1.4036,0.018077 -2.4077,0.62407 -3.4688,1.9062 -1.0611,1.2822 -2.0112,3.2438 -2.7812,5.3438 -0.77003,2.0999 -1.388,4.3243 -1.9688,6.2812 -0.27707,0.9336 -0.50201,1.7858 -0.78125,2.5625 l 0.46875,0.1875 c 1.8051,-2.666 4.7391,-6.2904 7.0312,-10 1.297,-2.1008 2.232,-4.1053 2.406,-5.22 0.087,-0.5574 -0.01,-0.8073 -0.031,-0.8438 -0.018,-0.032 -0.113,-0.0896 -0.469,-0.1874 -0.125,-0.0079 -0.24,-0.0334 -0.406,-0.0313 z" + transform="matrix(0.52499,0,0,0.5277,-1.1749,-0.77947)" /> + <path + inkscape:connector-curvature="0" + id="path5367" + style="fill:url(#linearGradient2549);fill-rule:evenodd;stroke:url(#linearGradient2551);stroke-miterlimit:20" + d="m 10.637,7.9275 c 0.37249,1.057 -0.28422,1.9724 -0.52499,2.6385 -2.7255,0.81565 -4.613,5.1206 -7.4195,7.3632 0.35058,0.36801 0.76241,0.76209 1.1196,1.0799 l 2.1328,-1.8634 -1.6104,2.3876 c 1.1598,0.9451 2.3651,1.5866 3.1526,1.8504 l 1.4437,-1.9294 -0.91874,2.1932 c 0.76229,0.31075 2.6172,0.78206 3.675,0.79154 l 1.052,-1.7955 -0.26941,1.8285 c 0.43551,0.08357 1.28,0.19747 1.8423,0.21438 1.7651,-2.9023 2.1,-7.6351 1.05,-9.7459 -0.2625,-1.0554 0.78749,-2.3746 1.575,-2.9023 -1.312,-1.0561 -4.307,-2.2718 -6.3,-2.1115 z" /> + <path + inkscape:connector-curvature="0" + id="path5975-1" + style="opacity:0.26667002;fill:#c4a000;fill-rule:evenodd" + d="M 4.6001,19.537 C 7.1287,16.893 6.9442,15.735 9.911,13.454 8.3452,16.002 8.0914,17.327 6.175,20.592 L 4.6,19.5366 z" /> + <path + inkscape:connector-curvature="0" + id="path5979-4" + style="opacity:0.41569004;fill:#c4a000;fill-rule:evenodd" + d="m 8.3537,21.491 2.2816,-5.1926 c 0.87386,-1.5745 1.5013,-3.1504 2.3777,-4.4049 -0.84102,2.8591 -2.5676,6.3966 -3.9539,9.8283 l -0.7051,-0.23 z" /> + <path + inkscape:connector-curvature="0" + id="path6014" + style="opacity:0.47843;fill:none;stroke:url(#linearGradient2553);stroke-width:1px" + d="m 11.547,8.8512 c 0.05079,1.0106 -0.80302,1.4666 -0.95832,1.8962 -0.05465,0.15024 0.27818,0.66925 -0.01074,0.58778 -2.5453,1.3384 -5.9207,5.8907 -6.7749,6.754 l 6.357,-6.167 -4.279,7.238 c 0.66676,0.54227 0.39408,0.55888 1.1839,0.87793 l 5.6511,-7.211 -3.3911,8.245 c 0.83766,0.27739 0.75453,0.22673 1.724,0.3645 l 3.6086,-5.9583 -1.1073,6.1533 0.14835,0.04006 c 0.75243,-1.338 0.72682,-2.2928 1.0979,-3.9036 0.36799,-1.5972 -0.29214,-3.5975 -0.26605,-4.6086 -0.1821,-0.73214 0.4285,-1.5354 0.79908,-2.1313 0.22412,-0.36043 -0.23142,-0.50359 0.04923,-0.77325 -0.615,-0.4125 -0.936,-0.413 -1.872,-0.753 -0.925,-0.3358 -1.221,-0.6399 -1.96,-0.6498 z" /> + <path + inkscape:connector-curvature="0" + id="path5977-4" + style="opacity:0.24706002;fill:url(#linearGradient2555);fill-rule:evenodd" + d="m 9.8336,21.911 c 1.1432,-3.0352 3.3578,-5.3133 4.2088,-8.4091 0.02706,1.9325 0.1311,5.3845 -0.99324,8.8213 -0.16788,9.37e-4 -0.09131,-0.05847 -0.24668,-0.06256 l 0.42041,-3.0208 -1.7228,2.931 c -1.1502,-0.08249 -0.67966,0.0172 -1.6666,-0.25992 z" /> + <path + inkscape:connector-curvature="0" + id="path5995-8" + style="opacity:0.48235001;fill:#c4a000;fill-rule:evenodd" + d="m 10.902,11.152 c -0.65729,0.32526 -1.0826,0.80594 -1.5661,1.2477 0.6439,-0.37395 1.249,-0.76463 2.0997,-1.0494 l -0.53364,-0.19823 z" /> + <path + inkscape:connector-curvature="0" + id="path5997-3" + style="opacity:0.48235001;fill:#c4a000;fill-rule:evenodd" + d="m 11.955,11.39 -0.53364,1.0494 1.5649,-0.83811 -1.0312,-0.21134 z" /> + <path + inkscape:connector-curvature="0" + id="path6007-5" + style="opacity:0.48235001;fill:#c4a000;fill-rule:evenodd" + d="M 11.918,8.6987 11.448,9.5995 12.27,9.8644 11.918,8.6987 z" /> + <path + inkscape:connector-curvature="0" + id="path6009-9" + style="opacity:0.48235001;fill:#c4a000;fill-rule:evenodd" + d="m 15.585,9.714 -1.2916,0.96856 0.822,0.26495 0.46962,-1.2335 z" /> + <path + inkscape:connector-curvature="0" + id="path6011-2" + style="opacity:0.48235001;fill:#c4a000;fill-rule:evenodd" + d="m 13.532,8.6866 -0.79479,1.3322 0.822,0.26495 -0.0272,-1.5972 z" /> + <path + inkscape:connector-curvature="0" + id="path6013-6" + style="opacity:0.2;fill-rule:evenodd" + d="m 9.8331,10.843 c -0.29756,-1.5649 4.8997,1.1361 5.7943,1.5801 -0.0034,0.56942 0,1.0554 -0.51282,1.0554 -1.3479,-0.73507 -3.431,-1.9024 -5.2814,-2.6355 z" /> + <path + inkscape:connector-curvature="0" + id="path5373" + style="fill:url(#linearGradient2557);fill-rule:evenodd;stroke:#464646;stroke-width:1px;stroke-linejoin:round" + d="m 9.6663,10.566 c -0.25641,-0.5277 0,-1.0554 0.51282,-1.0554 2.0955,0.51472 3.8455,1.1642 5.6411,2.1108 0.25641,0.5277 0,1.0554 -0.51282,1.0554 -1.8553,-0.98385 -3.605,-1.6226 -5.6411,-2.1108 z" /> + </g> + </g> + <g + transform="translate(-62.939338,180.80705)" + id="layer1-63"> + <path + inkscape:connector-curvature="0" + id="path2339" + style="fill:url(#linearGradient3328);fill-rule:evenodd;stroke:#888a86;stroke-width:0.99900001;stroke-linecap:square;stroke-linejoin:round;stroke-dashoffset:0.7" + d="m 22.494,6.4996 c 0.01344,3.8458 6.88e-4,8.0483 0,12.001 h -2.9942 v -5.8047 l -9,5.5438 V 12.6633 L 1.4937,18.2397 V 6.7607 l 9.006,5.576 V 6.7603 l 9,5.5438 c -8.42e-4,-1.8634 0,-4.0628 0,-5.8047 h 2.9942 z" /> + <path + inkscape:connector-curvature="0" + id="path3192" + style="opacity:0.4;fill:none;stroke:url(#linearGradient3203);stroke-linecap:square;stroke-dashoffset:0.7" + d="M 11.5,16.472 V 8.5271 l 6.5,3.9727 -6.5,3.9722 z" /> + <path + inkscape:connector-curvature="0" + id="path3190" + style="opacity:0.4;fill:none;stroke:url(#linearGradient3199);stroke-linecap:square;stroke-dashoffset:0.7" + d="M 2.4912,16.474 2.4956,8.5217 9,12.5 2.4912,16.474 z" /> + <path + inkscape:connector-curvature="0" + id="path2343" + style="opacity:0.4;fill:none;stroke:url(#linearGradient3035);stroke-width:0.96779001;stroke-linecap:square;stroke-dashoffset:0.7" + d="m 20.5,7.4839 h 1.0104 v 10.032 H 20.5 V 7.4839 z" /> + </g> + <g + style="display:inline" + id="layer1-8-6" + transform="matrix(0.13864219,0,0,0.13864219,493.32194,-42.754308)"> + <rect + style="opacity:0.74621211;fill:url(#linearGradient9477-2);fill-opacity:1;fill-rule:evenodd;stroke:none" + id="rect3108-4" + transform="matrix(0.9981479,-0.0608342,0.1048727,0.9944857,0,0)" + y="340.71729" + x="63.882298" + height="72.445557" + width="74.619125" /> + <rect + style="fill:url(#linearGradient9474-98);fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.31597084;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="rect1307-1" + transform="matrix(0.9981479,-0.0608342,0.1048727,0.9944857,0,0)" + y="337.67053" + x="60.043865" + height="72.445557" + width="74.619125" /> + <g + style="stroke:#000000;stroke-opacity:0.59230783" + id="g4884-7" + transform="matrix(0.2219064,-0.01352455,0.02485183,0.2356647,62.010554,262.81217)"> + <path + style="fill:none;stroke:#000000;stroke-width:1.13866174px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.59230783" + id="path4870-1" + d="m 186.47628,304.64652 c 0,294.06348 0,298.06436 0,298.06436" + inkscape:connector-curvature="0" /> + <use + xlink:href="#path4870-1" + height="1052.3622" + width="744.09448" + y="0" + x="0" + style="stroke:#000000;stroke-opacity:0.59230783" + id="use4872-4" + transform="translate(-48.94082,-4.83334e-5)" /> + <use + xlink:href="#path4870-1" + height="1052.3622" + width="744.09448" + y="0" + x="0" + style="stroke:#000000;stroke-opacity:0.59230783" + id="use4874-2" + transform="translate(146.8225,-4.83334e-5)" /> + <use + xlink:href="#path4870-1" + height="1052.3622" + width="744.09448" + y="0" + x="0" + style="stroke:#000000;stroke-opacity:0.59230783" + id="use4876-1" + transform="translate(48.94083,-4.83334e-5)" /> + <use + xlink:href="#path4870-1" + height="1052.3622" + width="744.09448" + y="0" + x="0" + style="stroke:#000000;stroke-opacity:0.59230783" + id="use4878-1" + transform="translate(97.88164,-4.83334e-5)" /> + <use + xlink:href="#path4870-1" + height="1052.3622" + width="744.09448" + y="0" + x="0" + style="stroke:#000000;stroke-opacity:0.59230783" + id="use4880-4" + transform="translate(195.7633,-4.83334e-5)" /> + <use + xlink:href="#path4870-1" + height="1052.3622" + width="744.09448" + y="0" + x="0" + style="stroke:#000000;stroke-opacity:0.59230783" + id="use4882-4" + transform="translate(244.7041,-4.83334e-5)" /> + </g> + <g + style="stroke:#000000;stroke-opacity:0.59230783" + id="g4893-8" + transform="matrix(0.02570346,0.2437405,-0.2145541,0.01307645,227.24128,291.2289)"> + <path + style="fill:none;stroke:#000000;stroke-width:1.13866174px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.59230783" + id="path4895-7" + d="m 186.47628,304.64652 c 0,294.06348 0,298.06436 0,298.06436" + inkscape:connector-curvature="0" /> + <use + xlink:href="#path4870-1" + height="1052.3622" + width="744.09448" + y="0" + x="0" + style="stroke:#000000;stroke-opacity:0.59230783" + id="use4897-5" + transform="translate(-48.94082,-4.83334e-5)" /> + <use + xlink:href="#path4870-1" + height="1052.3622" + width="744.09448" + y="0" + x="0" + style="stroke:#000000;stroke-opacity:0.59230783" + id="use4899-8" + transform="translate(146.8225,-4.83334e-5)" /> + <use + xlink:href="#path4870-1" + height="1052.3622" + width="744.09448" + y="0" + x="0" + style="stroke:#000000;stroke-opacity:0.59230783" + id="use4901-6" + transform="translate(48.94083,-4.83334e-5)" /> + <use + xlink:href="#path4870-1" + height="1052.3622" + width="744.09448" + y="0" + x="0" + style="stroke:#000000;stroke-opacity:0.59230783" + id="use4903-4" + transform="translate(97.88164,-4.83334e-5)" /> + <use + xlink:href="#path4870-1" + height="1052.3622" + width="744.09448" + y="0" + x="0" + style="stroke:#000000;stroke-opacity:0.59230783" + id="use4905-9" + transform="translate(195.7633,-4.83334e-5)" /> + <use + xlink:href="#path4870-1" + height="1052.3622" + width="744.09448" + y="0" + x="0" + style="stroke:#000000;stroke-opacity:0.59230783" + id="use4907-6" + transform="translate(244.7041,-4.83334e-5)" /> + </g> + <path + style="fill:none;stroke:#f90000;stroke-width:1.96257424;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="path3079-5" + d="m 101.87045,376.48331 c 15.88269,-21.97532 15.54068,-22.2933 15.54068,-22.2933 l 11.1987,-2.03784 15.62825,-9.76202 8.0733,23.90355 11.92414,-15.63516 6.6307,13.14898" + inkscape:connector-curvature="0" /> + </g> </g> </svg> diff -r 95a0a427f3ef -r 131ea7f237b9 Images/instance_graph.png Binary file Images/instance_graph.png has changed diff -r 95a0a427f3ef -r 131ea7f237b9 Images/remove_element.png Binary file Images/remove_element.png has changed diff -r 95a0a427f3ef -r 131ea7f237b9 Images/reset.png Binary file Images/reset.png has changed diff -r 95a0a427f3ef -r 131ea7f237b9 Images/top.png Binary file Images/top.png has changed diff -r 95a0a427f3ef -r 131ea7f237b9 PLCOpenEditor.py --- a/PLCOpenEditor.py Fri Jun 15 18:03:25 2012 +0200 +++ b/PLCOpenEditor.py Mon Jun 25 20:03:53 2012 +0200 @@ -31,6 +31,10 @@ CWD = os.path.split(os.path.realpath(__file__))[0] base_folder = os.path.split(CWD)[0] sys.path.append(base_folder) + +from utils.BitmapLibrary import AddBitmapFolder, GetBitmap +AddBitmapFolder(os.path.join(CWD, "Images")) + from docutil import * from types import TupleType @@ -165,93 +169,93 @@ EditorToolBarItems = { "FBD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", - "move.png", _("Move the view")), + "move", _("Move the view")), (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", - "add_comment.png", _("Create a new comment")), + "add_comment", _("Create a new comment")), (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", - "add_variable.png", _("Create a new variable")), + "add_variable", _("Create a new variable")), (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", - "add_block.png", _("Create a new block")), + "add_block", _("Create a new block")), (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", - "add_connection.png", _("Create a new connection"))], + "add_connection", _("Create a new connection"))], "LD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", - "move.png", _("Move the view")), + "move", _("Move the view")), (True, FREEDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", - "add_comment.png", _("Create a new comment")), + "add_comment", _("Create a new comment")), (True, FREEDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool", - "add_powerrail.png", _("Create a new power rail")), + "add_powerrail", _("Create a new power rail")), (False, DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARRUNG, "OnRungTool", - "add_rung.png", _("Create a new rung")), + "add_rung", _("Create a new rung")), (True, FREEDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARCOIL, "OnCoilTool", - "add_coil.png", _("Create a new coil")), + "add_coil", _("Create a new coil")), (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", - "add_contact.png", _("Create a new contact")), + "add_contact", _("Create a new contact")), (False, DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARBRANCH, "OnBranchTool", - "add_branch.png", _("Create a new branch")), + "add_branch", _("Create a new branch")), (True, FREEDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", - "add_variable.png", _("Create a new variable")), + "add_variable", _("Create a new variable")), (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", - "add_block.png", _("Create a new block")), + "add_block", _("Create a new block")), (True, FREEDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", - "add_connection.png", _("Create a new connection"))], + "add_connection", _("Create a new connection"))], "SFC" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", - "move.png", _("Move the view")), + "move", _("Move the view")), (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", - "add_comment.png", _("Create a new comment")), + "add_comment", _("Create a new comment")), (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, "OnInitialStepTool", - "add_initial_step.png", _("Create a new initial step")), + "add_initial_step", _("Create a new initial step")), (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARSTEP, "OnStepTool", - "add_step.png", _("Create a new step")), + "add_step", _("Create a new step")), (True, FREEDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, "OnTransitionTool", - "add_transition.png", _("Create a new transition")), + "add_transition", _("Create a new transition")), (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, "OnActionBlockTool", - "add_action.png", _("Create a new action block")), + "add_action", _("Create a new action block")), (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, "OnDivergenceTool", - "add_divergence.png", _("Create a new divergence")), + "add_divergence", _("Create a new divergence")), (False, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARJUMP, "OnJumpTool", - "add_jump.png", _("Create a new jump")), + "add_jump", _("Create a new jump")), (True, FREEDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", - "add_variable.png", _("Create a new variable")), + "add_variable", _("Create a new variable")), (True, FREEDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", - "add_block.png", _("Create a new block")), + "add_block", _("Create a new block")), (True, FREEDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", - "add_connection.png", _("Create a new connection")), + "add_connection", _("Create a new connection")), (True, FREEDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool", - "add_powerrail.png", _("Create a new power rail")), + "add_powerrail", _("Create a new power rail")), (True, FREEDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", - "add_contact.png", _("Create a new contact"))], + "add_contact", _("Create a new contact"))], "ST" : [], "IL" : [], "debug": [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", - "move.png", _("Move the view"))], + "move", _("Move the view"))], } #------------------------------------------------------------------------------- @@ -460,14 +464,14 @@ self.Bind(wx.EVT_MENU, self.OnSelectAllMenu, id=wx.ID_SELECTALL) self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=wx.ID_DELETE) - self.AddToMenuToolBar([(wx.ID_UNDO, "undo.png", _(u'Undo'), None), - (wx.ID_REDO, "redo.png", _(u'Redo'), None), + self.AddToMenuToolBar([(wx.ID_UNDO, "undo", _(u'Undo'), None), + (wx.ID_REDO, "redo", _(u'Redo'), None), None, - (wx.ID_CUT, "cut.png", _(u'Cut'), None), - (wx.ID_COPY, "copy.png", _(u'Copy'), None), - (wx.ID_PASTE, "paste.png", _(u'Paste'), None), + (wx.ID_CUT, "cut", _(u'Cut'), None), + (wx.ID_COPY, "copy", _(u'Copy'), None), + (wx.ID_PASTE, "paste", _(u'Paste'), None), None, - (ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, "find.png", _(u'Search in Project'), None)]) + (ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, "find", _(u'Search in Project'), None)]) def _init_coll_DisplayMenu_Items(self, parent): AppendMenu(parent, help='', id=wx.ID_REFRESH, @@ -586,7 +590,7 @@ name='ProjectTree', parent=self.ProjectPanel, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_EDIT_LABELS) - self.ProjectTree.SetBackgroundBitmap(wx.Bitmap(os.path.join(CWD, 'Images', 'custom_tree_background.png')), + self.ProjectTree.SetBackgroundBitmap(GetBitmap("custom_tree_background"), wx.ALIGN_RIGHT|wx.ALIGN_BOTTOM) add_menu = wx.Menu() self._init_coll_AddMenu_Items(add_menu) @@ -639,7 +643,7 @@ wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER) EditorToolBar.SetToolBitmapSize(wx.Size(25, 25)) EditorToolBar.AddRadioTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, - wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, _("Select an object")) + GetBitmap("select"), wx.NullBitmap, _("Select an object")) EditorToolBar.Realize() self.Panes["EditorToolBar"] = EditorToolBar self.AUIManager.AddPane(EditorToolBar, wx.aui.AuiPaneInfo(). @@ -670,7 +674,7 @@ self.SetMenuBar(self.MenuBar) if self.EnableDebug: - self.DebugVariablePanel = DebugVariablePanel(self.RightNoteBook, self, self.Controler) + self.DebugVariablePanel = DebugVariablePanel(self.RightNoteBook, self.Controler) self.MainTabs["DebugVariablePanel"] = (self.DebugVariablePanel, _("Debugger")) self.RightNoteBook.AddPage(*self.MainTabs["DebugVariablePanel"]) @@ -694,7 +698,7 @@ # Icons for languages for language in LANGUAGES: - self.TreeImageDict[language]=self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%language))) + self.TreeImageDict[language] = self.TreeImageList.Add(GetBitmap(language)) # Icons for other items for imgname, itemtype in [ @@ -724,7 +728,7 @@ ("CONFIGURATIONS", ITEM_CONFIGURATIONS), ("RESOURCES", ITEM_RESOURCES), ("PROPERTIES", ITEM_PROPERTIES)]: - self.TreeImageDict[itemtype]=self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%imgname))) + self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname)) # Assign icon list to TreeCtrls self.ProjectTree.SetImageList(self.TreeImageList) @@ -1088,42 +1092,6 @@ #------------------------------------------------------------------------------- # Notebook Unified Functions #------------------------------------------------------------------------------- - - ## Function that generate bitmap for - # for wx.aui.AUINotebook. - # @param window Panel to display in tab. - # @param text title for the tab ctrl. - def GenerateBitmap(self, icon1_name, icon2_name = None): - # Find index of bitmap if already created - index = self.TabsImageListIndexes.get((icon1_name, icon2_name), None) - # Return index or bitmap if found - if index is not None: - return self.TabsImageList.GetBitmap(index) - if icon2_name is None: - # Bitmap with only one icon - bitmap = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name)) - else: - # Bitmap with two icon - icon1 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name)) - icon2 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon2_name)) - - # Calculate bitmap size - width = icon1.GetWidth() + icon2.GetWidth() - 1 - height = max(icon1.GetHeight(), icon2.GetHeight()) - # Create bitmap with both icons - bitmap = wx.EmptyBitmap(width, height) - dc = wx.MemoryDC() - dc.SelectObject(bitmap) - dc.Clear() - dc.DrawBitmap(icon1, 0, 0) - dc.DrawBitmap(icon2, icon1.GetWidth() - 1, 0) - dc.Destroy() - - # Store bitmap in ImageList - index = self.TabsImageList.Add(bitmap) - # Save bitmap index in ImageList in dictionary - self.TabsImageListIndexes[(icon1_name, icon2_name)] = index - return bitmap ## Function that add a tab in Notebook, calling refresh for tab DClick event # for wx.aui.AUINotebook. @@ -1196,7 +1164,7 @@ self.ProjectTree.Enable(False) self.PouInstanceVariablesPanel.ResetView() self.LibraryPanel.ResetTree() - self.LibraryPanel.SetControler(None) + self.LibraryPanel.SetController(None) self.Controler = None def OnCloseTabMenu(self, event): @@ -1603,10 +1571,10 @@ if infos["type"] == ITEM_POU: self.ProjectTree.SetItemImage(root, self.TreeImageDict[self.Controler.GetPouBodyType(infos["name"])]) elif infos.has_key("icon") and infos["icon"] is not None: - icon_path = infos["icon"] - if not self.TreeImageDict.has_key(icon_path): - self.TreeImageDict[icon_path] = self.TreeImageList.Add(wx.Bitmap(icon_path)) - self.ProjectTree.SetItemImage(root, self.TreeImageDict[icon_path]) + icon_name = infos["icon"] + if not self.TreeImageDict.has_key(icon_name): + self.TreeImageDict[icon_name] = self.TreeImageList.Add(GetBitmap(icon_name)) + self.ProjectTree.SetItemImage(root, self.TreeImageDict[icon_name]) elif self.TreeImageDict.has_key(infos["type"]): self.ProjectTree.SetItemImage(root, self.TreeImageDict[infos["type"]]) @@ -1853,11 +1821,11 @@ new_window = None if element == ITEM_CONFIGURATION: new_window = ConfigurationEditor(self.TabsOpened, tagname, self, self.Controler) - new_window.SetIcon(self.GenerateBitmap("CONFIGURATION")) + new_window.SetIcon(GetBitmap("CONFIGURATION")) self.AddPage(new_window, "") elif element == ITEM_RESOURCE: new_window = ResourceEditor(self.TabsOpened, tagname, self, self.Controler) - new_window.SetIcon(self.GenerateBitmap("RESOURCE")) + new_window.SetIcon(GetBitmap("RESOURCE")) self.AddPage(new_window, "") elif element in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]: bodytype = self.Controler.GetEditedElementBodyType(tagname) @@ -1879,16 +1847,16 @@ new_window.SetKeywords(ST_KEYWORDS) if element == ITEM_POU: pou_type = self.Controler.GetEditedElementType(tagname)[1].upper() - icon = self.GenerateBitmap(pou_type, bodytype) + icon = GetBitmap(pou_type, bodytype) elif element == ITEM_TRANSITION: - icon = self.GenerateBitmap("TRANSITION", bodytype) + icon = GetBitmap("TRANSITION", bodytype) elif element == ITEM_ACTION: - icon = self.GenerateBitmap("ACTION", bodytype) + icon = GetBitmap("ACTION", bodytype) new_window.SetIcon(icon) self.AddPage(new_window, "") elif element == ITEM_DATATYPE: new_window = DataTypeEditor(self.TabsOpened, tagname, self, self.Controler) - new_window.SetIcon(self.GenerateBitmap("DATATYPE")) + new_window.SetIcon(GetBitmap("DATATYPE")) self.AddPage(new_window, "") elif isinstance(element, EditorPanel): new_window = element @@ -2098,11 +2066,11 @@ if instance_category in [ITEM_FUNCTIONBLOCK, ITEM_PROGRAM]: pou_type = self.Controler.GetEditedElementType(instance_type, True)[1].upper() - icon = self.GenerateBitmap(pou_type, bodytype) + icon = GetBitmap(pou_type, bodytype) elif instance_category == ITEM_TRANSITION: - icon = self.GenerateBitmap("TRANSITION", bodytype) + icon = GetBitmap("TRANSITION", bodytype) elif instance_category == ITEM_ACTION: - icon = self.GenerateBitmap("ACTION", bodytype) + icon = GetBitmap("ACTION", bodytype) new_window.SetIcon(icon) self.AddPage(new_window, "") new_window.RefreshView() @@ -2114,6 +2082,7 @@ def OpenGraphicViewer(self, var_path): new_window = GraphicViewer(self.TabsOpened, self, self.Controler, var_path) + new_window.SetIcon(GetBitmap("GRAPH")) self.AddPage(new_window, "") new_window.RefreshView() new_window.SetFocus() @@ -2167,7 +2136,7 @@ MenuToolBar.AddSeparator() else: id, bitmap, help, callback = toolbar_item - MenuToolBar.AddSimpleTool(id=id, shortHelpString=help, bitmap=wx.Bitmap(os.path.join(CWD, 'Images', bitmap))) + MenuToolBar.AddSimpleTool(id=id, shortHelpString=help, bitmap=GetBitmap(bitmap)) if callback is not None: self.Bind(wx.EVT_TOOL, callback, id=id) MenuToolBar.Realize() @@ -2210,9 +2179,9 @@ for radio, modes, id, method, picture, help in EditorToolBarItems[menu]: if modes & self.DrawingMode: if radio or self.DrawingMode == FREEDRAWING_MODE: - EditorToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), wx.NullBitmap, help) + EditorToolBar.AddRadioTool(id, GetBitmap(picture), wx.NullBitmap, help) else: - EditorToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), help) + EditorToolBar.AddSimpleTool(id, GetBitmap(picture), help) self.Bind(wx.EVT_MENU, getattr(self, method), id=id) self.CurrentEditorToolBar.append(id) EditorToolBar.Realize() @@ -2667,11 +2636,11 @@ self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) - self.AddToMenuToolBar([(wx.ID_NEW, "new.png", _(u'New'), None), - (wx.ID_OPEN, "open.png", _(u'Open'), None), - (wx.ID_SAVE, "save.png", _(u'Save'), None), - (wx.ID_SAVEAS, "saveas.png", _(u'Save As...'), None), - (wx.ID_PRINT, "print.png", _(u'Print'), None)]) + self.AddToMenuToolBar([(wx.ID_NEW, "new", _(u'New'), None), + (wx.ID_OPEN, "open", _(u'Open'), None), + (wx.ID_SAVE, "save", _(u'Save'), None), + (wx.ID_SAVEAS, "saveas", _(u'Save As...'), None), + (wx.ID_PRINT, "print", _(u'Print'), None)]) def _init_coll_HelpMenu_Items(self, parent): AppendMenu(parent, help='', id=wx.ID_HELP, @@ -2703,13 +2672,13 @@ result = controler.OpenXMLFile(fileOpen) if result is None: self.Controler = controler - self.LibraryPanel.SetControler(controler) + self.LibraryPanel.SetController(controler) self.ProjectTree.Enable(True) self.PouInstanceVariablesPanel.SetController(controler) self._Refresh(PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) # Define PLCOpenEditor icon - self.SetIcon(wx.Icon(os.path.join(CWD,"Images", "poe.ico"),wx.BITMAP_TYPE_ICO)) + self.SetIcon(wx.Icon(os.path.join(CWD, "Images", "poe.ico"),wx.BITMAP_TYPE_ICO)) self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) @@ -2794,7 +2763,7 @@ self.ResetView() self.Controler = PLCControler() self.Controler.CreateNewProject(properties) - self.LibraryPanel.SetControler(self.Controler) + self.LibraryPanel.SetController(self.Controler) self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) @@ -2820,7 +2789,7 @@ result = controler.OpenXMLFile(filepath) if result is None: self.Controler = controler - self.LibraryPanel.SetControler(controler) + self.LibraryPanel.SetController(controler) self.ProjectTree.Enable(True) self.PouInstanceVariablesPanel.SetController(controler) self.LoadProjectLayout() diff -r 95a0a427f3ef -r 131ea7f237b9 RessourceEditor.py --- a/RessourceEditor.py Fri Jun 15 18:03:25 2012 +0200 +++ b/RessourceEditor.py Mon Jun 25 20:03:53 2012 +0200 @@ -23,10 +23,12 @@ #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import wx +import wx.lib.buttons import wx.grid from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD from controls import CustomGrid, CustomTable, EditorPanel, DurationCellEditor +from utils.BitmapLibrary import GetBitmap #------------------------------------------------------------------------------- # Configuration Editor class @@ -187,149 +189,81 @@ if len(col_highlights) == 0: row_highlights.pop(col) -[ID_RESOURCEEDITOR, ID_RESOURCEEDITORPANEL, ID_RESOURCEEDITORSTATICTEXT1, - ID_RESOURCEEDITORSTATICTEXT2, ID_RESOURCEEDITORINSTANCESGRID, - ID_RESOURCEEDITORTASKSGRID, ID_RESOURCEEDITORADDINSTANCEBUTTON, - ID_RESOURCEEDITORDELETEINSTANCEBUTTON, ID_RESOURCEEDITORUPINSTANCEBUTTON, - ID_RESOURCEEDITORDOWNINSTANCEBUTTON, ID_RESOURCEEDITORADDTASKBUTTON, - ID_RESOURCEEDITORDELETETASKBUTTON, ID_RESOURCEEDITORUPTASKBUTTON, - ID_RESOURCEEDITORDOWNTASKBUTTON, -] = [wx.NewId() for _init_ctrls in range(14)] + class ResourceEditor(EditorPanel): - ID = ID_RESOURCEEDITOR VARIABLE_PANEL_TYPE = "resource" - - def _init_coll_InstancesSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_coll_InstancesSizer_Items(self, parent): - parent.AddSizer(self.InstancesButtonsSizer, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.InstancesGrid, 0, border=0, flag=wx.GROW) - - def _init_coll_InstancesButtonsSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_coll_InstancesButtonsSizer_Items(self, parent): - parent.AddWindow(self.staticText2, 0, border=0, flag=wx.ALIGN_BOTTOM) - parent.AddWindow(self.AddInstanceButton, 0, border=0, flag=0) - parent.AddWindow(self.DeleteInstanceButton, 0, border=0, flag=0) - parent.AddWindow(self.UpInstanceButton, 0, border=0, flag=0) - parent.AddWindow(self.DownInstanceButton, 0, border=0, flag=0) - - def _init_coll_TasksSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_coll_TasksSizer_Items(self, parent): - parent.AddSizer(self.TasksButtonsSizer, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.TasksGrid, 0, border=0, flag=wx.GROW) - - def _init_coll_TasksButtonsSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_coll_TasksButtonsSizer_Items(self, parent): - parent.AddWindow(self.staticText1, 0, border=0, flag=wx.ALIGN_BOTTOM) - parent.AddWindow(self.AddTaskButton, 0, border=0, flag=0) - parent.AddWindow(self.DeleteTaskButton, 0, border=0, flag=0) - parent.AddWindow(self.UpTaskButton, 0, border=0, flag=0) - parent.AddWindow(self.DownTaskButton, 0, border=0, flag=0) - - def _init_coll_MainGridSizer_Items(self, parent): - parent.AddSizer(self.TasksSizer, 0, border=5, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.InstancesSizer, 0, border=5, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT) - - def _init_coll_MainGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - parent.AddGrowableRow(1) - - def _init_sizers(self): - self.MainGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - self.InstancesSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - self.InstancesButtonsSizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) - self.TasksSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - self.TasksButtonsSizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) - - self._init_coll_MainGridSizer_Growables(self.MainGridSizer) - self._init_coll_MainGridSizer_Items(self.MainGridSizer) - self._init_coll_InstancesSizer_Growables(self.InstancesSizer) - self._init_coll_InstancesSizer_Items(self.InstancesSizer) - self._init_coll_InstancesButtonsSizer_Growables(self.InstancesButtonsSizer) - self._init_coll_InstancesButtonsSizer_Items(self.InstancesButtonsSizer) - self._init_coll_TasksSizer_Growables(self.TasksSizer) - self._init_coll_TasksSizer_Items(self.TasksSizer) - self._init_coll_TasksButtonsSizer_Growables(self.TasksButtonsSizer) - self._init_coll_TasksButtonsSizer_Items(self.TasksButtonsSizer) - - self.Editor.SetSizer(self.MainGridSizer) - - def _init_Editor(self, prnt): - self.Editor = wx.Panel(id=ID_RESOURCEEDITORPANEL, name='ResourceEditor', parent=prnt, - size=wx.Size(0, 0), style=wx.SUNKEN_BORDER|wx.TAB_TRAVERSAL) - - self.staticText1 = wx.StaticText(id=ID_RESOURCEEDITORSTATICTEXT1, - label=_(u'Tasks:'), name='staticText2', parent=self.Editor, pos=wx.Point(0, - 0), size=wx.DefaultSize, style=0) - - self.TasksGrid = CustomGrid(id=ID_RESOURCEEDITORTASKSGRID, - name='TasksGrid', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.Size(-1, -1), style=wx.VSCROLL) - if wx.VERSION >= (2, 6, 0): - self.TasksGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnTasksGridCellChange) - else: - wx.grid.EVT_GRID_CELL_CHANGE(self.TasksGrid, self.OnTasksGridCellChange) - - self.AddTaskButton = wx.Button(id=ID_RESOURCEEDITORADDTASKBUTTON, label=_('Add Task'), - name='AddTaskButton', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.DefaultSize, style=0) - - self.DeleteTaskButton = wx.Button(id=ID_RESOURCEEDITORDELETETASKBUTTON, label=_('Delete Task'), - name='DeleteTaskButton', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.DefaultSize, style=0) - - self.UpTaskButton = wx.Button(id=ID_RESOURCEEDITORUPTASKBUTTON, label='^', - name='UpTaskButton', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.Size(32, -1), style=0) - - self.DownTaskButton = wx.Button(id=ID_RESOURCEEDITORDOWNTASKBUTTON, label='v', - name='DownTaskButton', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.Size(32, -1), style=0) - - self.staticText2 = wx.StaticText(id=ID_RESOURCEEDITORSTATICTEXT2, - label=_(u'Instances:'), name='staticText1', parent=self.Editor, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.InstancesGrid = CustomGrid(id=ID_RESOURCEEDITORINSTANCESGRID, - name='InstancesGrid', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.Size(-1, -1), style=wx.VSCROLL) - if wx.VERSION >= (2, 6, 0): - self.InstancesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnInstancesGridCellChange) - else: - wx.grid.EVT_GRID_CELL_CHANGE(self.InstancesGrid, self.OnInstancesGridCellChange) - - self.AddInstanceButton = wx.Button(id=ID_RESOURCEEDITORADDINSTANCEBUTTON, label=_('Add Instance'), - name='AddInstanceButton', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.DefaultSize, style=0) - - self.DeleteInstanceButton = wx.Button(id=ID_RESOURCEEDITORDELETEINSTANCEBUTTON, label=_('Delete Instance'), - name='DeleteInstanceButton', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.DefaultSize, style=0) - - self.UpInstanceButton = wx.Button(id=ID_RESOURCEEDITORUPINSTANCEBUTTON, label='^', - name='UpInstanceButton', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.Size(32, -1), style=0) - - self.DownInstanceButton = wx.Button(id=ID_RESOURCEEDITORDOWNINSTANCEBUTTON, label='v', - name='DownInstanceButton', parent=self.Editor, pos=wx.Point(0, 0), - size=wx.Size(32, -1), style=0) - - self._init_sizers() - + + def _init_Editor(self, parent): + self.Editor = wx.Panel(parent, style=wx.SUNKEN_BORDER|wx.TAB_TRAVERSAL) + + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(0) + main_sizer.AddGrowableRow(1) + + tasks_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) + tasks_sizer.AddGrowableCol(0) + tasks_sizer.AddGrowableRow(1) + main_sizer.AddSizer(tasks_sizer, border=5, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + + tasks_buttons_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) + tasks_buttons_sizer.AddGrowableCol(0) + tasks_buttons_sizer.AddGrowableRow(0) + tasks_sizer.AddSizer(tasks_buttons_sizer, flag=wx.GROW) + + tasks_label = wx.StaticText(self.Editor, label=_(u'Tasks:')) + tasks_buttons_sizer.AddWindow(tasks_label, flag=wx.ALIGN_BOTTOM) + + for name, bitmap, help in [ + ("AddTaskButton", "add_element", _("Add task")), + ("DeleteTaskButton", "remove_element", _("Remove task")), + ("UpTaskButton", "up", _("Move task up")), + ("DownTaskButton", "down", _("Move task down"))]: + button = wx.lib.buttons.GenBitmapButton(self.Editor, + bitmap=GetBitmap(bitmap), size=wx.Size(28, 28), style=wx.NO_BORDER) + button.SetToolTipString(help) + setattr(self, name, button) + tasks_buttons_sizer.AddWindow(button) + + self.TasksGrid = CustomGrid(self.Editor, style=wx.VSCROLL) + self.TasksGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnTasksGridCellChange) + tasks_sizer.AddWindow(self.TasksGrid, flag=wx.GROW) + + instances_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) + instances_sizer.AddGrowableCol(0) + instances_sizer.AddGrowableRow(1) + main_sizer.AddSizer(instances_sizer, border=5, + flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT) + + instances_buttons_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) + instances_buttons_sizer.AddGrowableCol(0) + instances_buttons_sizer.AddGrowableRow(0) + instances_sizer.AddSizer(instances_buttons_sizer, flag=wx.GROW) + + instances_label = wx.StaticText(self.Editor, label=_(u'Instances:')) + instances_buttons_sizer.AddWindow(instances_label, flag=wx.ALIGN_BOTTOM) + + for name, bitmap, help in [ + ("AddInstanceButton", "add_element", _("Add instance")), + ("DeleteInstanceButton", "remove_element", _("Remove instance")), + ("UpInstanceButton", "up", _("Move instance up")), + ("DownInstanceButton", "down", _("Move instance down"))]: + button = wx.lib.buttons.GenBitmapButton(self.Editor, + bitmap=GetBitmap(bitmap), size=wx.Size(28, 28), style=wx.NO_BORDER) + button.SetToolTipString(help) + setattr(self, name, button) + instances_buttons_sizer.AddWindow(button) + + self.InstancesGrid = CustomGrid(self.Editor, style=wx.VSCROLL) + self.InstancesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, + self.OnInstancesGridCellChange) + instances_sizer.AddWindow(self.InstancesGrid, flag=wx.GROW) + + self.Editor.SetSizer(main_sizer) + def __init__(self, parent, tagname, window, controler): EditorPanel.__init__(self, parent, tagname, window, controler) diff -r 95a0a427f3ef -r 131ea7f237b9 SearchResultPanel.py --- a/SearchResultPanel.py Fri Jun 15 18:03:25 2012 +0200 +++ b/SearchResultPanel.py Mon Jun 25 20:03:53 2012 +0200 @@ -25,11 +25,11 @@ from types import TupleType import wx +import wx.lib.buttons import wx.lib.agw.customtreectrl as CT from PLCControler import * - -CWD = os.path.split(os.path.realpath(__file__))[0] +from utils.BitmapLibrary import GetBitmap def GenerateName(infos): if infos[0] in ["input", "output", "value"]: @@ -100,17 +100,17 @@ self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnSearchResultsTreeItemActivated, id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE) - self.ResetButton = wx.Button(id=ID_SEARCHRESULTPANELRESETBUTTON, label=_('Reset'), - name='ResetButton', parent=self, pos=wx.Point(0, 0), - size=wx.DefaultSize, style=0) - self.Bind(wx.EVT_BUTTON, self.OnResetButton, - id=ID_SEARCHRESULTPANELRESETBUTTON) + self.ResetButton = wx.lib.buttons.GenBitmapButton(self, + bitmap=GetBitmap("reset"), size=wx.Size(28, 28), style=wx.NO_BORDER) + self.ResetButton.SetToolTipString(_("Reset search result")) + self.Bind(wx.EVT_BUTTON, self.OnResetButton, self.ResetButton) self._init_sizers() def __init__(self, parent, window): + self.ParentWindow = window + self._init_ctrls(parent) - self.ParentWindow = window # Define Tree item icon list self.TreeImageList = wx.ImageList(16, 16) @@ -128,7 +128,7 @@ ("ACTION", "action_block"), ("IL", "IL"), ("ST", "ST")]: - self.TreeImageDict[itemtype]=self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%imgname))) + self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname)) for itemtype in ["function", "functionBlock", "program", "comment", "block", "io_variable", @@ -136,7 +136,7 @@ "step", "transition", "jump", "var_local", "var_input", "var_inout", "var_output"]: - self.TreeImageDict[itemtype]=self.TreeImageList.Add(wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%itemtype.upper()))) + self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(itemtype.upper())) # Assign icon list to TreeCtrl self.SearchResultsTree.SetImageList(self.TreeImageList) diff -r 95a0a427f3ef -r 131ea7f237b9 controls/CustomEditableListBox.py --- a/controls/CustomEditableListBox.py Fri Jun 15 18:03:25 2012 +0200 +++ b/controls/CustomEditableListBox.py Mon Jun 25 20:03:53 2012 +0200 @@ -35,11 +35,12 @@ listbox.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnLabelBeginEdit) listbox.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnLabelEndEdit) - for button, tooltip, call_function in [(self.GetEditButton(), _("Edit item"), "_OnEditButton"), - (self.GetNewButton(), _("New item"), "_OnNewButton"), - (self.GetDelButton(), _("Delete item"), "_OnDelButton"), - (self.GetUpButton(), _("Move up"), "_OnUpButton"), - (self.GetDownButton(), _("Move down"), "_OnDownButton")]: + for button, tooltip, call_function in [ + (self.GetEditButton(), _("Edit item"), "_OnEditButton"), + (self.GetNewButton(), _("New item"), "_OnNewButton"), + (self.GetDelButton(), _("Delete item"), "_OnDelButton"), + (self.GetUpButton(), _("Move up"), "_OnUpButton"), + (self.GetDownButton(), _("Move down"), "_OnDownButton")]: button.SetToolTipString(tooltip) button.Bind(wx.EVT_BUTTON, self.GetButtonPressedFunction(call_function)) diff -r 95a0a427f3ef -r 131ea7f237b9 controls/CustomGrid.py --- a/controls/CustomGrid.py Fri Jun 15 18:03:25 2012 +0200 +++ b/controls/CustomGrid.py Mon Jun 25 20:03:53 2012 +0200 @@ -27,13 +27,6 @@ class CustomGrid(wx.grid.Grid): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - def __init__(self, *args, **kwargs): wx.grid.Grid.__init__(self, *args, **kwargs) @@ -50,11 +43,8 @@ self.SetSelectionForeground(wx.BLACK) self.DisableDragRowSize() - if wx.VERSION >= (2, 6, 0): - self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell) - self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden) - else: - wx.grid.EVT_GRID_SELECT_CELL(self, self.OnSelectCell) + self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell) + self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) def SetDefaultValue(self, default_value): diff -r 95a0a427f3ef -r 131ea7f237b9 controls/CustomTree.py --- a/controls/CustomTree.py Fri Jun 15 18:03:25 2012 +0200 +++ b/controls/CustomTree.py Mon Jun 25 20:03:53 2012 +0200 @@ -92,7 +92,6 @@ event.Skip() def OnScroll(self, event): - print "scroll event" self.RefreshBackground(True) event.Skip() diff -r 95a0a427f3ef -r 131ea7f237b9 controls/DebugVariablePanel.py --- a/controls/DebugVariablePanel.py Fri Jun 15 18:03:25 2012 +0200 +++ b/controls/DebugVariablePanel.py Mon Jun 25 20:03:53 2012 +0200 @@ -23,9 +23,11 @@ #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import wx +import wx.lib.buttons from graphics import DebugDataConsumer, DebugViewer from controls import CustomGrid, CustomTable +from utils.BitmapLibrary import GetBitmap def GetDebugVariablesTableColnames(): _ = lambda x : x @@ -159,7 +161,7 @@ class DebugVariablePanel(wx.Panel, DebugViewer): - def __init__(self, parent, window, producer): + def __init__(self, parent, producer): wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL) DebugViewer.__init__(self, producer, True) @@ -171,14 +173,15 @@ main_sizer.AddSizer(button_sizer, border=5, flag=wx.ALIGN_RIGHT|wx.ALL) - up_button = wx.Button(self, label='^', size=wx.Size(28, 28)) - button_sizer.AddWindow(up_button, border=5, flag=wx.RIGHT) - - down_button = wx.Button(self, label='v', size=wx.Size(28, 28)) - button_sizer.AddWindow(down_button, border=5, flag=wx.RIGHT) - - delete_button = wx.Button(self, label=_('Delete'), size=wx.DefaultSize) - button_sizer.AddWindow(delete_button) + for name, bitmap, help in [ + ("DeleteButton", "remove_element", _("Remove debug variable")), + ("UpButton", "up", _("Move debug variable up")), + ("DownButton", "down", _("Move debug variable down"))]: + button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap), + size=wx.Size(28, 28), style=wx.NO_BORDER) + button.SetToolTipString(help) + setattr(self, name, button) + button_sizer.AddWindow(button, border=5, flag=wx.LEFT) self.VariablesGrid = CustomGrid(self, size=wx.Size(0, 150), style=wx.VSCROLL) self.VariablesGrid.SetDropTarget(DebugVariableDropTarget(self)) @@ -192,9 +195,9 @@ self.Table = DebugVariableTable(self, [], GetDebugVariablesTableColnames()) self.VariablesGrid.SetTable(self.Table) - self.VariablesGrid.SetButtons({"Delete": delete_button, - "Up": up_button, - "Down": down_button}) + self.VariablesGrid.SetButtons({"Delete": self.DeleteButton, + "Up": self.UpButton, + "Down": self.DownButton}) def _AddVariable(new_row): return self.VariablesGrid.GetGridCursorRow() diff -r 95a0a427f3ef -r 131ea7f237b9 controls/DurationCellEditor.py --- a/controls/DurationCellEditor.py Fri Jun 15 18:03:25 2012 +0200 +++ b/controls/DurationCellEditor.py Mon Jun 25 20:03:53 2012 +0200 @@ -28,48 +28,30 @@ class DurationCellControl(wx.PyControl): - def _init_coll_MainSizer_Items(self, parent): - parent.AddWindow(self.Duration, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.EditButton, 0, border=0, flag=wx.GROW) - - def _init_coll_MainSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_sizers(self): - self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) - - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_MainSizer_Growables(self.MainSizer) - - self.SetSizer(self.MainSizer) - - def _init_ctrls(self, prnt): - wx.Control.__init__(self, id=-1, - name='DurationCellControl', parent=prnt, - size=wx.DefaultSize, style=0) - - # create location text control - self.Duration = wx.TextCtrl(id=-1, name='Duration', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TE_PROCESS_ENTER) - self.Duration.Bind(wx.EVT_KEY_DOWN, self.OnDurationChar) - - # create browse button - self.EditButton = wx.Button(id=-1, label='...', - name='EditButton', parent=self, pos=wx.Point(0, 0), - size=wx.Size(30, 0), style=0) - self.EditButton.Bind(wx.EVT_BUTTON, self.OnEditButtonClick) - - self.Bind(wx.EVT_SIZE, self.OnSize) - - self._init_sizers() - ''' Custom cell editor control with a text box and a button that launches the DurationEditorDialog. ''' def __init__(self, parent): - self._init_ctrls(parent) + wx.Control.__init__(self, parent) + + main_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(0) + + # create location text control + self.Duration = wx.TextCtrl(self, style=wx.TE_PROCESS_ENTER) + self.Duration.Bind(wx.EVT_KEY_DOWN, self.OnDurationChar) + main_sizer.AddWindow(self.Duration, flag=wx.GROW) + + # create browse button + self.EditButton = wx.Button(self, label='...', size=wx.Size(30, 0)) + self.Bind(wx.EVT_BUTTON, self.OnEditButtonClick, self.EditButton) + main_sizer.AddWindow(self.EditButton, flag=wx.GROW) + + self.Bind(wx.EVT_SIZE, self.OnSize) + + self.SetSizer(main_sizer) self.Default = None @@ -117,6 +99,7 @@ ''' def __init__(self, table): wx.grid.PyGridCellEditor.__init__(self) + self.Table = table def __del__(self): diff -r 95a0a427f3ef -r 131ea7f237b9 controls/EditorPanel.py --- a/controls/EditorPanel.py Fri Jun 15 18:03:25 2012 +0200 +++ b/controls/EditorPanel.py Mon Jun 25 20:03:53 2012 +0200 @@ -28,25 +28,17 @@ class EditorPanel(wx.SplitterWindow): - ID = wx.NewId() VARIABLE_PANEL_TYPE = None - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - def _init_Editor(self, prnt): self.Editor = None def _init_MenuItems(self): self.MenuItems = [] - def _init_ctrls(self, prnt): - wx.SplitterWindow.__init__(self, id=self.ID, name='MainSplitter', parent=prnt, - size=wx.Size(0, 0), style=wx.SUNKEN_BORDER|wx.SP_3D) + def _init_ctrls(self, parent): + wx.SplitterWindow.__init__(self, parent, + style=wx.SUNKEN_BORDER|wx.SP_3D) self.SetNeedUpdating(True) self.SetMinimumPaneSize(1) diff -r 95a0a427f3ef -r 131ea7f237b9 controls/LibraryPanel.py --- a/controls/LibraryPanel.py Fri Jun 15 18:03:25 2012 +0200 +++ b/controls/LibraryPanel.py Mon Jun 25 20:03:53 2012 +0200 @@ -24,78 +24,61 @@ import wx +#------------------------------------------------------------------------------- +# Helpers +#------------------------------------------------------------------------------- + [CATEGORY, BLOCK] = range(2) -[ID_LIBRARYPANEL, ID_LIBRARYSEARCHCTRL, - ID_LIBRARYTREE, ID_LIBRARYCOMMENT, -] = [wx.NewId() for _init_ctrls in range(4)] +#------------------------------------------------------------------------------- +# Library Panel +#------------------------------------------------------------------------------- class LibraryPanel(wx.Panel): - def _init_coll_MainSizer_Items(self, parent): - parent.AddWindow(self.SearchCtrl, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Tree, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Comment, 0, border=0, flag=wx.GROW) - - def _init_coll_MainSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_sizers(self): - self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=0) - - self._init_coll_MainSizer_Growables(self.MainSizer) - self._init_coll_MainSizer_Items(self.MainSizer) - - self.SetSizer(self.MainSizer) - - def _init_ctrls(self, prnt, enable_drag=False): - wx.Panel.__init__(self, id=ID_LIBRARYPANEL, - name='LibraryPanel', parent=prnt, - pos=wx.Point(0, 0), size=wx.Size(0, 0), - style=wx.TAB_TRAVERSAL) - - self.SearchCtrl = wx.SearchCtrl(id=ID_LIBRARYSEARCHCTRL, - name='SearchCtrl', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 28), style=0) + def __init__(self, parent, enable_drag=False): + wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL) + + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=0) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(1) + + self.SearchCtrl = wx.SearchCtrl(self) self.SearchCtrl.ShowSearchButton(True) - self.Bind(wx.EVT_TEXT, self.OnSearchCtrlChanged, - id=ID_LIBRARYSEARCHCTRL) - self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.OnSearchButtonClick, - id=ID_LIBRARYSEARCHCTRL) + self.Bind(wx.EVT_TEXT, self.OnSearchCtrlChanged, self.SearchCtrl) + self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, + self.OnSearchButtonClick, self.SearchCtrl) search_textctrl = self.SearchCtrl.GetChildren()[0] search_textctrl.Bind(wx.EVT_CHAR, self.OnKeyDown) - - self.Tree = wx.TreeCtrl(id=ID_LIBRARYTREE, - name='Tree', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 0), - style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_HIDE_ROOT|wx.TR_LINES_AT_ROOT) - self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTreeItemSelected, - id=ID_LIBRARYTREE) + main_sizer.AddWindow(self.SearchCtrl, flag=wx.GROW) + + self.Tree = wx.TreeCtrl(self, + style=wx.TR_HAS_BUTTONS| + wx.TR_SINGLE| + wx.SUNKEN_BORDER| + wx.TR_HIDE_ROOT| + wx.TR_LINES_AT_ROOT) + self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTreeItemSelected, self.Tree) self.Tree.Bind(wx.EVT_CHAR, self.OnKeyDown) if enable_drag: - self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnTreeBeginDrag, - id=ID_LIBRARYTREE) - - self.Comment = wx.TextCtrl(id=ID_LIBRARYCOMMENT, - name='Comment', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 80), + self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnTreeBeginDrag, self.Tree) + main_sizer.AddWindow(self.Tree, flag=wx.GROW) + + self.Comment = wx.TextCtrl(self, size=wx.Size(0, 80), style=wx.TE_READONLY|wx.TE_MULTILINE) - - self._init_sizers() - - def __init__(self, parent, enable_drag=False): - self._init_ctrls(parent, enable_drag) - - self.Controler = None + main_sizer.AddWindow(self.Comment, flag=wx.GROW) + + self.SetSizer(main_sizer) + + self.Controller = None self.BlockList = None def __del__(self): - self.Controler = None - - def SetControler(self, controler): - self.Controler = controler + self.Controller = None + + def SetController(self, controller): + self.Controller = controller def SetBlockList(self, blocklist): self.BlockList = blocklist @@ -110,7 +93,7 @@ self.Comment.SetValue("") def RefreshTree(self): - if self.Controler is not None: + if self.Controller is not None: to_delete = [] selected_name = None selected = self.Tree.GetSelection() @@ -121,14 +104,11 @@ if self.BlockList is not None: blocktypes = self.BlockList else: - blocktypes = self.Controler.GetBlockTypes() + blocktypes = self.Controller.GetBlockTypes() root = self.Tree.GetRootItem() if not root.IsOk(): root = self.Tree.AddRoot("") - if wx.VERSION >= (2, 6, 0): - category_item, root_cookie = self.Tree.GetFirstChild(root) - else: - category_item, root_cookie = self.Tree.GetFirstChild(root, 0) + category_item, root_cookie = self.Tree.GetFirstChild(root) for category in blocktypes: category_name = category["name"] if not category_item.IsOk(): @@ -138,10 +118,7 @@ else: self.Tree.SetItemText(category_item, _(category_name)) self.Tree.SetPyData(category_item, {"type" : CATEGORY}) - if wx.VERSION >= (2, 6, 0): - blocktype_item, category_cookie = self.Tree.GetFirstChild(category_item) - else: - blocktype_item, category_cookie = self.Tree.GetFirstChild(category_item, 0) + blocktype_item, category_cookie = self.Tree.GetFirstChild(category_item) for blocktype in category["list"]: if not blocktype_item.IsOk(): blocktype_item = self.Tree.AppendItem(category_item, blocktype["name"]) @@ -280,7 +257,7 @@ selected = event.GetItem() pydata = self.Tree.GetPyData(selected) if pydata is not None and pydata["type"] != CATEGORY: - blocktype = self.Controler.GetBlockType(self.Tree.GetItemText(selected), pydata["inputs"]) + blocktype = self.Controller.GetBlockType(self.Tree.GetItemText(selected), pydata["inputs"]) if blocktype: comment = blocktype["comment"] self.Comment.SetValue(_(comment) + blocktype.get("usage", "")) diff -r 95a0a427f3ef -r 131ea7f237b9 controls/LocationCellEditor.py --- a/controls/LocationCellEditor.py Fri Jun 15 18:03:25 2012 +0200 +++ b/controls/LocationCellEditor.py Mon Jun 25 20:03:53 2012 +0200 @@ -28,48 +28,31 @@ class LocationCellControl(wx.PyControl): - def _init_coll_MainSizer_Items(self, parent): - parent.AddWindow(self.Location, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.BrowseButton, 0, border=0, flag=wx.GROW) - - def _init_coll_MainSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_sizers(self): - self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) - - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_MainSizer_Growables(self.MainSizer) - - self.SetSizer(self.MainSizer) - - def _init_ctrls(self, prnt): - wx.Control.__init__(self, id=-1, - name='LocationCellControl', parent=prnt, - size=wx.DefaultSize, style=0) - - # create location text control - self.Location = wx.TextCtrl(id=-1, name='Location', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TE_PROCESS_ENTER) - self.Location.Bind(wx.EVT_KEY_DOWN, self.OnLocationChar) - - # create browse button - self.BrowseButton = wx.Button(id=-1, label='...', - name='BrowseButton', parent=self, pos=wx.Point(0, 0), - size=wx.Size(30, 0), style=0) - self.BrowseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonClick) - - self.Bind(wx.EVT_SIZE, self.OnSize) - - self._init_sizers() - ''' Custom cell editor control with a text box and a button that launches the BrowseLocationsDialog. ''' def __init__(self, parent): - self._init_ctrls(parent) + wx.Control.__init__(self, parent) + + main_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(0) + + # create location text control + self.Location = wx.TextCtrl(self, style=wx.TE_PROCESS_ENTER) + self.Location.Bind(wx.EVT_KEY_DOWN, self.OnLocationChar) + main_sizer.AddWindow(self.Location, flag=wx.GROW) + + # create browse button + self.BrowseButton = wx.Button(self, label='...', size=wx.Size(30, 0)) + self.BrowseButton.Bind(wx.EVT_BUTTON, self.OnBrowseButtonClick) + main_sizer.AddWindow(self.BrowseButton, flag=wx.GROW) + + self.Bind(wx.EVT_SIZE, self.OnSize) + + self.SetSizer(main_sizer) + self.Locations = None self.VarType = None self.Default = False @@ -123,10 +106,11 @@ ''' Grid cell editor that uses LocationCellControl to display a browse button. ''' - def __init__(self, table, controler): + def __init__(self, table, controller): wx.grid.PyGridCellEditor.__init__(self) + self.Table = table - self.Controler = controler + self.Controller = controller def __del__(self): self.CellControl = None @@ -139,10 +123,10 @@ def BeginEdit(self, row, col, grid): self.CellControl.Enable() - self.CellControl.SetLocations(self.Controler.GetVariableLocationTree()) + self.CellControl.SetLocations(self.Controller.GetVariableLocationTree()) self.CellControl.SetValue(self.Table.GetValueByName(row, 'Location')) if isinstance(self.CellControl, LocationCellControl): - self.CellControl.SetVarType(self.Controler.GetBaseType(self.Table.GetValueByName(row, 'Type'))) + self.CellControl.SetVarType(self.Controller.GetBaseType(self.Table.GetValueByName(row, 'Type'))) self.CellControl.SetFocus() def EndEdit(self, row, col, grid): @@ -160,5 +144,5 @@ wx.SIZE_ALLOW_MINUS_ONE) def Clone(self): - return LocationCellEditor(self.Table, self.Controler) + return LocationCellEditor(self.Table, self.Controller) diff -r 95a0a427f3ef -r 131ea7f237b9 controls/PouInstanceVariablesPanel.py --- a/controls/PouInstanceVariablesPanel.py Fri Jun 15 18:03:25 2012 +0200 +++ b/controls/PouInstanceVariablesPanel.py Mon Jun 25 20:03:53 2012 +0200 @@ -27,6 +27,7 @@ import wx.lib.agw.customtreectrl as CT from PLCControler import ITEMS_VARIABLE, ITEM_CONFIGURATION, ITEM_RESOURCE, ITEM_POU +from utils.BitmapLibrary import GetBitmap class PouInstanceVariablesPanel(wx.Panel): @@ -35,32 +36,24 @@ parent=parent, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - self.ParentButton = wx.lib.buttons.GenBitmapButton( - name='ParentButton', parent=self, - bitmap=window.GenerateBitmap("up"), - pos=wx.Point(0, 0), size=wx.Size(28, 28), - style=wx.NO_BORDER) + self.ParentButton = wx.lib.buttons.GenBitmapButton(self, + bitmap=GetBitmap("top"), size=wx.Size(28, 28), style=wx.NO_BORDER) + self.ParentButton.SetToolTipString(_("Parent instance")) self.Bind(wx.EVT_BUTTON, self.OnParentButtonClick, self.ParentButton) - self.InstanceChoice = wx.ComboBox(name='InstanceChoice', - parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) + self.InstanceChoice = wx.ComboBox(self, style=wx.CB_READONLY) self.Bind(wx.EVT_COMBOBOX, self.OnInstanceChoiceChanged, self.InstanceChoice) self.InstanceChoice.Bind(wx.EVT_LEFT_DOWN, self.OnInstanceChoiceLeftDown) - self.DebugButton = wx.lib.buttons.GenBitmapButton( - name='DebugButton', parent=self, - bitmap=window.GenerateBitmap("debug"), - pos=wx.Point(0, 0), size=wx.Size(28, 28), - style=wx.NO_BORDER) + self.DebugButton = wx.lib.buttons.GenBitmapButton(self, + bitmap=GetBitmap("debug_instance"), size=wx.Size(28, 28), style=wx.NO_BORDER) + self.ParentButton.SetToolTipString(_("Debug instance")) self.Bind(wx.EVT_BUTTON, self.OnDebugButtonClick, self.DebugButton) - self.VariablesList = CT.CustomTreeCtrl( - name='VariablesList', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 0), + self.VariablesList = CT.CustomTreeCtrl(self, style=wx.SUNKEN_BORDER, agwStyle=CT.TR_NO_BUTTONS| CT.TR_SINGLE| @@ -76,15 +69,15 @@ self.VariablesList.Bind(wx.EVT_LEFT_DOWN, self.OnVariablesListLeftDown) buttons_sizer = wx.FlexGridSizer(cols=3, hgap=0, rows=1, vgap=0) - buttons_sizer.AddWindow(self.ParentButton, 0, border=0, flag=0) - buttons_sizer.AddWindow(self.InstanceChoice, 0, border=0, flag=wx.GROW) - buttons_sizer.AddWindow(self.DebugButton, 0, border=0, flag=0) + buttons_sizer.AddWindow(self.ParentButton) + buttons_sizer.AddWindow(self.InstanceChoice, flag=wx.GROW) + buttons_sizer.AddWindow(self.DebugButton) buttons_sizer.AddGrowableCol(1) buttons_sizer.AddGrowableRow(0) main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) - main_sizer.AddSizer(buttons_sizer, 0, border=0, flag=wx.GROW) - main_sizer.AddWindow(self.VariablesList, 0, border=0, flag=wx.GROW) + main_sizer.AddSizer(buttons_sizer, flag=wx.GROW) + main_sizer.AddWindow(self.VariablesList, flag=wx.GROW) main_sizer.AddGrowableCol(0) main_sizer.AddGrowableRow(1) @@ -151,22 +144,22 @@ if (var_infos["debug"] and self.Debug and (self.Controller.IsOfType(var_infos["type"], "ANY_NUM", True) or self.Controller.IsOfType(var_infos["type"], "ANY_BIT", True))): - graph_button = wx.lib.buttons.GenBitmapButton(name="graph", - parent=panel, bitmap=self.ParentWindow.GenerateBitmap("graph"), - pos=wx.Point(0, 0), size=wx.Size(28, 28), style=wx.NO_BORDER) + graph_button = wx.lib.buttons.GenBitmapButton(panel, + bitmap=GetBitmap("instance_graph"), + size=wx.Size(28, 28), style=wx.NO_BORDER) self.Bind(wx.EVT_BUTTON, self.GenGraphButtonCallback(var_infos), graph_button) buttons.append(graph_button) elif var_infos["edit"]: - edit_button = wx.lib.buttons.GenBitmapButton(name="edit", - parent=panel, bitmap=self.ParentWindow.GenerateBitmap("edit"), - pos=wx.Point(0, 0), size=wx.Size(28, 28), style=wx.NO_BORDER) + edit_button = wx.lib.buttons.GenBitmapButton(panel, + bitmap=GetBitmap("edit"), + size=wx.Size(28, 28), style=wx.NO_BORDER) self.Bind(wx.EVT_BUTTON, self.GenEditButtonCallback(var_infos), edit_button) buttons.append(edit_button) if var_infos["debug"] and self.Debug: - debug_button = wx.lib.buttons.GenBitmapButton(name="debug", - parent=panel, bitmap=self.ParentWindow.GenerateBitmap("debug"), - pos=wx.Point(0, 0), size=wx.Size(28, 28), style=wx.NO_BORDER) + debug_button = wx.lib.buttons.GenBitmapButton(panel, + bitmap=GetBitmap("debug_instance"), + size=wx.Size(28, 28), style=wx.NO_BORDER) self.Bind(wx.EVT_BUTTON, self.GenDebugButtonCallback(var_infos), debug_button) buttons.append(debug_button) diff -r 95a0a427f3ef -r 131ea7f237b9 controls/ProjectPropertiesPanel.py --- a/controls/ProjectPropertiesPanel.py Fri Jun 15 18:03:25 2012 +0200 +++ b/controls/ProjectPropertiesPanel.py Mon Jun 25 20:03:53 2012 +0200 @@ -24,8 +24,20 @@ import wx +#------------------------------------------------------------------------------- +# Helpers +#------------------------------------------------------------------------------- + REQUIRED_PARAMS = ["projectName", "productName", "productVersion", "companyName"] +[TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, + POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES +] = range(10) + +#------------------------------------------------------------------------------- +# Project Properties Panel +#------------------------------------------------------------------------------- + class ProjectPropertiesPanel(wx.Notebook): def AddSizerParams(self, parent, sizer, params): @@ -36,25 +48,20 @@ elif idx == len(params) - 1: border |= wx.BOTTOM - st = wx.StaticText(id=-1, parent=parent, - label=label, name=name + '_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - sizer.AddWindow(st, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT) + st = wx.StaticText(parent, label=label) + sizer.AddWindow(st, border=10, + flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT) - tc_id = wx.NewId() - tc = wx.TextCtrl(id=tc_id, parent=parent, - name=name, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER) + tc = wx.TextCtrl(parent, style=wx.TE_PROCESS_ENTER) setattr(self, name, tc) callback = self.GetTextCtrlChangedFunction(tc, name) - self.Bind(wx.EVT_TEXT_ENTER, callback, id=tc_id) + self.Bind(wx.EVT_TEXT_ENTER, callback, tc) tc.Bind(wx.EVT_KILL_FOCUS, callback) - sizer.AddWindow(tc, 0, border=10, flag=wx.GROW|border|wx.RIGHT) + sizer.AddWindow(tc, border=10, + flag=wx.GROW|border|wx.RIGHT) def __init__(self, parent, controller=None, window=None, enable_required=True): - wx.Notebook.__init__(self, id=-1, parent=parent, - name='ProjectPropertiesPanel', style=0, - pos=wx.Point(0, 0), size=wx.Size(500, 300)) + wx.Notebook.__init__(self, parent, size=wx.Size(500, 300)) self.Controller = controller self.ParentWindow = window @@ -62,9 +69,7 @@ # Project Panel elements - self.ProjectPanel = wx.Panel(id=-1, parent=self, - name='ProjectPanel', pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) + self.ProjectPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) projectpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=5, vgap=15) projectpanel_sizer.AddGrowableCol(1) self.ProjectPanel.SetSizer(projectpanel_sizer) @@ -80,9 +85,7 @@ # Author Panel elements - self.AuthorPanel = wx.Panel(id=-1, parent=self, - name='AuthorPanel', pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) + self.AuthorPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) authorpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=4, vgap=15) authorpanel_sizer.AddGrowableCol(1) self.AuthorPanel.SetSizer(authorpanel_sizer) @@ -97,56 +100,48 @@ # Graphics Panel elements - self.GraphicsPanel = wx.Panel(id=-1, parent=self, - name='GraphicsPanel', pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) + self.GraphicsPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) graphicpanel_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=4, vgap=5) graphicpanel_sizer.AddGrowableCol(0) graphicpanel_sizer.AddGrowableRow(3) self.GraphicsPanel.SetSizer(graphicpanel_sizer) - pageSize_st = wx.StaticText(id=-1, parent=self.GraphicsPanel, - label=_('Page Size (optional):'), name='pageSize_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - graphicpanel_sizer.AddWindow(pageSize_st, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT|wx.RIGHT) + pageSize_st = wx.StaticText(self.GraphicsPanel, + label=_('Page Size (optional):')) + graphicpanel_sizer.AddWindow(pageSize_st, border=10, + flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT|wx.RIGHT) pageSize_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) pageSize_sizer.AddGrowableCol(1) - graphicpanel_sizer.AddSizer(pageSize_sizer, 0, border=10, flag=wx.GROW|wx.LEFT|wx.RIGHT) + graphicpanel_sizer.AddSizer(pageSize_sizer, border=10, + flag=wx.GROW|wx.LEFT|wx.RIGHT) for name, label in [('PageWidth', _('Width:')), ('PageHeight', _('Height:'))]: - st = wx.StaticText(id=-1, parent=self.GraphicsPanel, - label=label, name=name + "_label", - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - pageSize_sizer.AddWindow(st, 0, border=12, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT) + st = wx.StaticText(self.GraphicsPanel, label=label) + pageSize_sizer.AddWindow(st, border=12, + flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT) - sp_id = wx.NewId() - sp = wx.SpinCtrl(id=sp_id, parent=self.GraphicsPanel, - name=name, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER, - min=0, max=2**16) + sp = wx.SpinCtrl(self.GraphicsPanel, + min=0, max=2**16, style=wx.TE_PROCESS_ENTER) setattr(self, name, sp) callback = self.GetPageSizeChangedFunction(sp, name) - self.Bind(wx.EVT_TEXT_ENTER, callback, id=sp_id) + self.Bind(wx.EVT_TEXT_ENTER, callback, sp) sp.Bind(wx.EVT_KILL_FOCUS, callback) - pageSize_sizer.AddWindow(sp, 0, border=0, flag=wx.GROW) - - scaling_st = wx.StaticText(id=-1, parent=self.GraphicsPanel, - label=_('Grid Resolution:'), name='scaling_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - graphicpanel_sizer.AddWindow(scaling_st, 0, border=10, flag=wx.GROW|wx.LEFT|wx.RIGHT) - - scaling_nb = wx.Notebook(id=-1, parent=self.GraphicsPanel, - name='ScalingNotebook', pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=0) - graphicpanel_sizer.AddWindow(scaling_nb, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT) + pageSize_sizer.AddWindow(sp, flag=wx.GROW) + + scaling_st = wx.StaticText(self.GraphicsPanel, + label=_('Grid Resolution:')) + graphicpanel_sizer.AddWindow(scaling_st, border=10, + flag=wx.GROW|wx.LEFT|wx.RIGHT) + + scaling_nb = wx.Notebook(self.GraphicsPanel) + graphicpanel_sizer.AddWindow(scaling_nb, border=10, + flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT) self.Scalings = {} for language, translation in [("FBD",_("FBD")), ("LD",_("LD")), ("SFC",_("SFC"))]: - scaling_panel = wx.Panel(id=-1, parent=scaling_nb, - name=language + '_panel', pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) + scaling_panel = wx.Panel(scaling_nb, style=wx.TAB_TRAVERSAL) scalingpanel_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) scalingpanel_sizer.AddGrowableCol(1) scaling_panel.SetSizer(scalingpanel_sizer) @@ -159,21 +154,18 @@ else: border = wx.BOTTOM - st = wx.StaticText(id=-1, parent=scaling_panel, - label=label, name=name + '_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - scalingpanel_sizer.AddWindow(st, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT) + st = wx.StaticText(scaling_panel, label=label) + scalingpanel_sizer.AddWindow(st, border=10, + flag=wx.ALIGN_CENTER_VERTICAL|border|wx.LEFT) - sp_id = wx.NewId() - sp = wx.SpinCtrl(id=sp_id, parent=scaling_panel, - name=name, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER, - min=0, max=2**16) + sp = wx.SpinCtrl(scaling_panel, + min=0, max=2**16, style=wx.TE_PROCESS_ENTER) scaling_controls.append(sp) callback = self.GetScalingChangedFunction(sp, language, name) - self.Bind(wx.EVT_TEXT_ENTER, callback, id=sp_id) + self.Bind(wx.EVT_TEXT_ENTER, callback, sp) sp.Bind(wx.EVT_KILL_FOCUS, callback) - scalingpanel_sizer.AddWindow(sp, 0, border=10, flag=wx.GROW|border|wx.RIGHT) + scalingpanel_sizer.AddWindow(sp, border=10, + flag=wx.GROW|border|wx.RIGHT) self.Scalings[language] = scaling_controls scaling_nb.AddPage(scaling_panel, translation) @@ -190,30 +182,30 @@ miscellaneouspanel_sizer.AddGrowableRow(1) self.MiscellaneousPanel.SetSizer(miscellaneouspanel_sizer) - language_label = wx.StaticText(id=-1, parent=self.MiscellaneousPanel, - label=_('Language (optional):'), name='language_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - miscellaneouspanel_sizer.AddWindow(language_label, 0, border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT) - - language_id = wx.NewId() - self.Language = wx.ComboBox(id=language_id, parent=self.MiscellaneousPanel, - name='Language', pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnLanguageChanged, id=language_id) - miscellaneouspanel_sizer.AddWindow(self.Language, 0, border=10, flag=wx.GROW|wx.TOP|wx.RIGHT) - - description_label = wx.StaticText(id=-1, parent=self.MiscellaneousPanel, - label=_('Content Description (optional):'), name='description_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - miscellaneouspanel_sizer.AddWindow(description_label, 0, border=10, flag=wx.BOTTOM|wx.LEFT) - - description_id = wx.NewId() - self.ContentDescription = wx.TextCtrl(id=description_id, parent=self.MiscellaneousPanel, - name='ContentDescription', pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER) - self.Bind(wx.EVT_TEXT_ENTER, self.OnContentDescriptionChanged, id=description_id) - self.ContentDescription.Bind(wx.EVT_KILL_FOCUS, self.OnContentDescriptionChanged) - miscellaneouspanel_sizer.AddWindow(self.ContentDescription, 0, border=10, flag=wx.GROW|wx.BOTTOM|wx.RIGHT) + language_label = wx.StaticText(self.MiscellaneousPanel, + label=_('Language (optional):')) + miscellaneouspanel_sizer.AddWindow(language_label, border=10, + flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.LEFT) + + self.Language = wx.ComboBox(self.MiscellaneousPanel, + style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnLanguageChanged, self.Language) + miscellaneouspanel_sizer.AddWindow(self.Language, border=10, + flag=wx.GROW|wx.TOP|wx.RIGHT) + + description_label = wx.StaticText(self.MiscellaneousPanel, + label=_('Content Description (optional):')) + miscellaneouspanel_sizer.AddWindow(description_label, border=10, + flag=wx.BOTTOM|wx.LEFT) + + self.ContentDescription = wx.TextCtrl(self.MiscellaneousPanel, + style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER) + self.Bind(wx.EVT_TEXT_ENTER, self.OnContentDescriptionChanged, + self.ContentDescription) + self.ContentDescription.Bind(wx.EVT_KILL_FOCUS, + self.OnContentDescriptionChanged) + miscellaneouspanel_sizer.AddWindow(self.ContentDescription, border=10, + flag=wx.GROW|wx.BOTTOM|wx.RIGHT) self.AddPage(self.MiscellaneousPanel, _("Miscellaneous")) @@ -290,11 +282,8 @@ new_value = None if old_value != new_value: self.Controller.SetProjectProperties(properties={name: new_value}) - self.ParentWindow.RefreshTitle() - self.ParentWindow.RefreshFileMenu() - self.ParentWindow.RefreshEditMenu() - self.ParentWindow.RefreshProjectTree() - self.ParentWindow.RefreshPageTitles() + self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, + PROJECTTREE, PAGETITLES) wx.CallAfter(self.RefreshView) event.Skip() return TextCtrlChangedFunction @@ -312,11 +301,8 @@ new_value = (old_value[0], spinctrl.GetValue()) if old_value != new_value: self.Controller.SetProjectProperties(properties={"pageSize": new_value}) - self.ParentWindow.RefreshTitle() - self.ParentWindow.RefreshFileMenu() - self.ParentWindow.RefreshEditMenu() - self.ParentWindow.RefreshPageTitles() - self.ParentWindow.RefreshScaling() + self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, + PAGETITLES, SCALING) wx.CallAfter(self.RefreshView) event.Skip() return PageSizeChangedFunction @@ -335,11 +321,8 @@ new_value = (old_value[0], spinctrl.GetValue()) if old_value != new_value: self.Controller.SetProjectProperties(properties={"scaling": {language: new_value}}) - self.ParentWindow.RefreshTitle() - self.ParentWindow.RefreshFileMenu() - self.ParentWindow.RefreshEditMenu() - self.ParentWindow.RefreshPageTitles() - self.ParentWindow.RefreshScaling() + self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, + PAGETITLES, SCALING) wx.CallAfter(self.RefreshView) event.Skip() return ScalingChangedFunction @@ -355,10 +338,7 @@ new_value = None if old_value != new_value: self.Controller.SetProjectProperties(properties={"language": new_value}) - self.ParentWindow.RefreshTitle() - self.ParentWindow.RefreshFileMenu() - self.ParentWindow.RefreshEditMenu() - self.ParentWindow.RefreshPageTitles() + self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES) wx.CallAfter(self.RefreshView) event.Skip() @@ -373,9 +353,6 @@ new_value = None if old_value != new_value: self.Controller.SetProjectProperties(properties={"contentDescription": new_value}) - self.ParentWindow.RefreshTitle() - self.ParentWindow.RefreshFileMenu() - self.ParentWindow.RefreshEditMenu() - self.ParentWindow.RefreshPageTitles() + self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU, PAGETITLES) wx.CallAfter(self.RefreshView) event.Skip() diff -r 95a0a427f3ef -r 131ea7f237b9 controls/VariablePanel.py --- a/controls/VariablePanel.py Fri Jun 15 18:03:25 2012 +0200 +++ b/controls/VariablePanel.py Mon Jun 25 20:03:53 2012 +0200 @@ -23,32 +23,34 @@ #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import os -import wx, wx.grid import re - from types import TupleType, StringType, UnicodeType +import wx +import wx.grid +import wx.lib.buttons + from plcopen.structures import LOCATIONDATATYPES, TestIdentifier, IEC_KEYWORDS from graphics.GraphicCommons import REFRESH_HIGHLIGHT_PERIOD, ERROR_HIGHLIGHT from dialogs.ArrayTypeDialog import ArrayTypeDialog from CustomGrid import CustomGrid from CustomTable import CustomTable from LocationCellEditor import LocationCellEditor - -# Compatibility function for wx versions < 2.6 +from utils.BitmapLibrary import GetBitmap + +#------------------------------------------------------------------------------- +# Helpers +#------------------------------------------------------------------------------- + def AppendMenu(parent, help, id, kind, text): if wx.VERSION >= (2, 6, 0): parent.Append(help=help, id=id, kind=kind, text=text) else: parent.Append(helpString=help, id=id, kind=kind, item=text) -[TITLE, TOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, TYPESTREE, - POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING -] = range(9) - -#------------------------------------------------------------------------------- -# Variables Editor Panel -#------------------------------------------------------------------------------- +[TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, + POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES +] = range(10) def GetVariableTableColnames(location): _ = lambda x : x @@ -88,6 +90,10 @@ LOCATION_MODEL = re.compile("((?:%[IQM](?:\*|(?:[XBWLD]?[0-9]+(?:\.[0-9]+)*)))?)$") +#------------------------------------------------------------------------------- +# Variables Panel Table +#------------------------------------------------------------------------------- + class VariableTable(CustomTable): """ @@ -205,7 +211,10 @@ grid.SetCellBackgroundColour(row, col, highlight_colours[0]) grid.SetCellTextColour(row, col, highlight_colours[1]) self.ResizeRow(grid, row) - + +#------------------------------------------------------------------------------- +# Variable Panel Drop Target +#------------------------------------------------------------------------------- class VariableDropTarget(wx.TextDropTarget): ''' @@ -301,154 +310,101 @@ if message is not None: wx.CallAfter(self.ShowMessage, message) - - + def ShowMessage(self, message): message = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy() -[ID_VARIABLEEDITORPANEL, ID_VARIABLEEDITORPANELVARIABLESGRID, - ID_VARIABLEEDITORCONTROLPANEL, ID_VARIABLEEDITORPANELRETURNTYPELABEL, - ID_VARIABLEEDITORPANELRETURNTYPE, ID_VARIABLEEDITORPANELDESCRIPTIONLABEL, - ID_VARIABLEEDITORPANELDESCRIPTION, ID_VARIABLEEDITORPANELCLASSFILTERLABEL, - ID_VARIABLEEDITORPANELCLASSFILTER, ID_VARIABLEEDITORPANELADDBUTTON, - ID_VARIABLEEDITORPANELDELETEBUTTON, ID_VARIABLEEDITORPANELUPBUTTON, - ID_VARIABLEEDITORPANELDOWNBUTTON, -] = [wx.NewId() for _init_ctrls in range(13)] +#------------------------------------------------------------------------------- +# Variable Panel +#------------------------------------------------------------------------------- class VariablePanel(wx.Panel): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_MainSizer_Items(self, parent): - parent.AddWindow(self.ControlPanel, 0, border=5, flag=wx.GROW|wx.ALL) - parent.AddWindow(self.VariablesGrid, 0, border=0, flag=wx.GROW) - - def _init_coll_MainSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_coll_ControlPanelSizer_Items(self, parent): - parent.AddWindow(self.ReturnTypeLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) - parent.AddWindow(self.ReturnType, 0, border=0, flag=0) - parent.AddWindow(self.DescriptionLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) - parent.AddWindow(self.Description, 0, border=0, flag=0) - parent.AddWindow(self.ClassFilterLabel, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) - parent.AddWindow(self.ClassFilter, 0, border=0, flag=0) - parent.AddWindow(self.AddButton, 0, border=0, flag=0) - parent.AddWindow(self.DeleteButton, 0, border=0, flag=0) - parent.AddWindow(self.UpButton, 0, border=0, flag=0) - parent.AddWindow(self.DownButton, 0, border=0, flag=0) - - def _init_coll_ControlPanelSizer_Growables(self, parent): - parent.AddGrowableCol(5) - parent.AddGrowableRow(0) - - def _init_sizers(self): + def __init__(self, parent, window, controler, element_type, debug=False): + wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL) + self.MainSizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=0) - self.ControlPanelSizer = wx.FlexGridSizer(cols=10, hgap=5, rows=1, vgap=5) - - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_MainSizer_Growables(self.MainSizer) - self._init_coll_ControlPanelSizer_Items(self.ControlPanelSizer) - self._init_coll_ControlPanelSizer_Growables(self.ControlPanelSizer) - - self.ControlPanel.SetSizer(self.ControlPanelSizer) + self.MainSizer.AddGrowableCol(0) + self.MainSizer.AddGrowableRow(1) + + controls_sizer = wx.FlexGridSizer(cols=10, hgap=5, rows=1, vgap=5) + controls_sizer.AddGrowableCol(5) + controls_sizer.AddGrowableRow(0) + self.MainSizer.AddSizer(controls_sizer, border=5, flag=wx.GROW|wx.ALL) + + self.ReturnTypeLabel = wx.StaticText(self, label=_('Return Type:')) + controls_sizer.AddWindow(self.ReturnTypeLabel, flag=wx.ALIGN_CENTER_VERTICAL) + + self.ReturnType = wx.ComboBox(self, + size=wx.Size(145, -1), style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnReturnTypeChanged, self.ReturnType) + controls_sizer.AddWindow(self.ReturnType) + + self.DescriptionLabel = wx.StaticText(self, label=_('Description:')) + controls_sizer.AddWindow(self.DescriptionLabel, flag=wx.ALIGN_CENTER_VERTICAL) + + self.Description = wx.TextCtrl(self, + size=wx.Size(250, -1), style=wx.TE_PROCESS_ENTER) + self.Bind(wx.EVT_TEXT_ENTER, self.OnDescriptionChanged, self.Description) + self.Description.Bind(wx.EVT_KILL_FOCUS, self.OnDescriptionChanged) + controls_sizer.AddWindow(self.Description) + + class_filter_label = wx.StaticText(self, label=_('Class Filter:')) + controls_sizer.AddWindow(class_filter_label, flag=wx.ALIGN_CENTER_VERTICAL) + + self.ClassFilter = wx.ComboBox(self, + size=wx.Size(145, -1), style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnClassFilter, self.ClassFilter) + controls_sizer.AddWindow(self.ClassFilter) + + for name, bitmap, help in [ + ("AddButton", "add_element", _("Add variable")), + ("DeleteButton", "remove_element", _("Remove variable")), + ("UpButton", "up", _("Move variable up")), + ("DownButton", "down", _("Move variable down"))]: + button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap), + size=wx.Size(28, 28), style=wx.NO_BORDER) + button.SetToolTipString(help) + setattr(self, name, button) + controls_sizer.AddWindow(button) + + self.VariablesGrid = CustomGrid(self, style=wx.VSCROLL) + self.VariablesGrid.SetDropTarget(VariableDropTarget(self)) + self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, + self.OnVariablesGridCellChange) + self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, + self.OnVariablesGridCellLeftClick) + self.VariablesGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, + self.OnVariablesGridEditorShown) + self.MainSizer.AddWindow(self.VariablesGrid, flag=wx.GROW) + self.SetSizer(self.MainSizer) - - def _init_ctrls(self, prnt): - wx.Panel.__init__(self, id=ID_VARIABLEEDITORPANEL, - name='VariableEditorPanel', parent=prnt, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.VariablesGrid = CustomGrid(id=ID_VARIABLEEDITORPANELVARIABLESGRID, - name='VariablesGrid', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.VSCROLL) - self.VariablesGrid.SetDropTarget(VariableDropTarget(self)) - if wx.VERSION >= (2, 6, 0): - self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnVariablesGridCellChange) - self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnVariablesGridCellLeftClick) - self.VariablesGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnVariablesGridEditorShown) - else: - wx.grid.EVT_GRID_CELL_CHANGE(self.VariablesGrid, self.OnVariablesGridCellChange) - wx.grid.EVT_GRID_CELL_LEFT_CLICK(self.VariablesGrid, self.OnVariablesGridCellLeftClick) - wx.grid.EVT_GRID_EDITOR_SHOWN(self.VariablesGrid, self.OnVariablesGridEditorShown) - - self.ControlPanel = wx.ScrolledWindow(id=ID_VARIABLEEDITORCONTROLPANEL, - name='ControlPanel', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - self.ControlPanel.SetScrollRate(10, 0) - - self.ReturnTypeLabel = wx.StaticText(id=ID_VARIABLEEDITORPANELRETURNTYPELABEL, - label=_('Return Type:'), name='ReturnTypeLabel', parent=self.ControlPanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.ReturnType = wx.ComboBox(id=ID_VARIABLEEDITORPANELRETURNTYPE, - name='ReturnType', parent=self.ControlPanel, pos=wx.Point(0, 0), - size=wx.Size(145, -1), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnReturnTypeChanged, id=ID_VARIABLEEDITORPANELRETURNTYPE) - - self.DescriptionLabel = wx.StaticText(id=ID_VARIABLEEDITORPANELDESCRIPTIONLABEL, - label=_('Description:'), name='DescriptionLabel', parent=self.ControlPanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.Description = wx.TextCtrl(id=ID_VARIABLEEDITORPANELDESCRIPTION, - name='Description', parent=self.ControlPanel, pos=wx.Point(0, 0), - size=wx.Size(250, -1), style=wx.TE_PROCESS_ENTER) - self.Bind(wx.EVT_TEXT_ENTER, self.OnDescriptionChanged, id=ID_VARIABLEEDITORPANELDESCRIPTION) - self.Description.Bind(wx.EVT_KILL_FOCUS, self.OnDescriptionChanged) - - self.ClassFilterLabel = wx.StaticText(id=ID_VARIABLEEDITORPANELCLASSFILTERLABEL, - label=_('Class Filter:'), name='ClassFilterLabel', parent=self.ControlPanel, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.ClassFilter = wx.ComboBox(id=ID_VARIABLEEDITORPANELCLASSFILTER, - name='ClassFilter', parent=self.ControlPanel, pos=wx.Point(0, 0), - size=wx.Size(145, -1), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnClassFilter, id=ID_VARIABLEEDITORPANELCLASSFILTER) - - self.AddButton = wx.Button(id=ID_VARIABLEEDITORPANELADDBUTTON, label=_('Add'), - name='AddButton', parent=self.ControlPanel, pos=wx.Point(0, 0), - size=wx.DefaultSize, style=0) - - self.DeleteButton = wx.Button(id=ID_VARIABLEEDITORPANELDELETEBUTTON, label=_('Delete'), - name='DeleteButton', parent=self.ControlPanel, pos=wx.Point(0, 0), - size=wx.DefaultSize, style=0) - - self.UpButton = wx.Button(id=ID_VARIABLEEDITORPANELUPBUTTON, label='^', - name='UpButton', parent=self.ControlPanel, pos=wx.Point(0, 0), - size=wx.Size(28, -1), style=0) - - self.DownButton = wx.Button(id=ID_VARIABLEEDITORPANELDOWNBUTTON, label='v', - name='DownButton', parent=self.ControlPanel, pos=wx.Point(0, 0), - size=wx.Size(28, -1), style=0) - - self._init_sizers() - - def __init__(self, parent, window, controler, element_type, debug=False): - self._init_ctrls(parent) + self.ParentWindow = window self.Controler = controler self.ElementType = element_type self.Debug = debug self.RefreshHighlightsTimer = wx.Timer(self, -1) - self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, self.RefreshHighlightsTimer) + self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, + self.RefreshHighlightsTimer) self.Filter = "All" self.FilterChoices = [] self.FilterChoiceTransfer = GetFilterChoiceTransfer() - self.DefaultValue = { "Name" : "", "Class" : "", "Type" : "INT", "Location" : "", - "Initial Value" : "", "Option" : "", - "Documentation" : "", "Edit" : True - } + self.DefaultValue = { + "Name" : "", + "Class" : "", + "Type" : "INT", + "Location" : "", + "Initial Value" : "", + "Option" : "", + "Documentation" : "", + "Edit" : True + } if element_type in ["config", "resource"]: self.DefaultTypes = {"All" : "Global"} @@ -636,7 +592,6 @@ self.RefreshValues() self.VariablesGrid.RefreshButtons() - self.ControlPanelSizer.Layout() self.MainSizer.Layout() def OnReturnTypeChanged(self, event): diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/ActionBlockDialog.py --- a/dialogs/ActionBlockDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/ActionBlockDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -23,11 +23,13 @@ import wx import wx.grid +import wx.lib.buttons from controls import CustomGrid, CustomTable - -#------------------------------------------------------------------------------- -# Action Block Dialog +from utils.BitmapLibrary import GetBitmap + +#------------------------------------------------------------------------------- +# Helpers #------------------------------------------------------------------------------- def GetActionTableColnames(): @@ -38,6 +40,10 @@ _ = lambda x: x return [_("Action"), _("Variable"), _("Inline")] +#------------------------------------------------------------------------------- +# Action Table +#------------------------------------------------------------------------------- + class ActionTable(CustomTable): def GetValue(self, row, col): @@ -105,105 +111,54 @@ grid.SetCellBackgroundColour(row, col, wx.WHITE) self.ResizeRow(grid, row) - -[ID_ACTIONBLOCKDIALOG, ID_ACTIONBLOCKDIALOGVARIABLESGRID, - ID_ACTIONBLOCKDIALOGSTATICTEXT1, ID_ACTIONBLOCKDIALOGADDBUTTON, - ID_ACTIONBLOCKDIALOGDELETEBUTTON, ID_ACTIONBLOCKDIALOGUPBUTTON, - ID_ACTIONBLOCKDIALOGDOWNBUTTON, -] = [wx.NewId() for _init_ctrls in range(7)] +#------------------------------------------------------------------------------- +# Action Block Dialog +#------------------------------------------------------------------------------- class ActionBlockDialog(wx.Dialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_flexGridSizer1_Items(self, parent): - parent.AddSizer(self.TopSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.GridButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - - def _init_coll_flexGridSizer1_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_coll_TopSizer_Items(self, parent): - parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.ActionsGrid, 0, border=0, flag=wx.GROW) - - def _init_coll_TopSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_coll_GridButtonSizer_Items(self, parent): - parent.AddWindow(self.AddButton, 0, border=10, flag=wx.GROW|wx.LEFT) - parent.AddWindow(self.DeleteButton, 0, border=10, flag=wx.GROW|wx.LEFT) - parent.AddWindow(self.UpButton, 0, border=10, flag=wx.GROW|wx.LEFT) - parent.AddWindow(self.DownButton, 0, border=10, flag=wx.GROW|wx.LEFT) - - def _init_sizers(self): - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) - self.TopSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - self.GridButtonSizer = wx.BoxSizer(wx.HORIZONTAL) - - self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) - self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) - self._init_coll_TopSizer_Items(self.TopSizer) - self._init_coll_TopSizer_Growables(self.TopSizer) - self._init_coll_GridButtonSizer_Items(self.GridButtonSizer) - - self.SetSizer(self.flexGridSizer1) - - def _init_ctrls(self, prnt): - wx.Dialog.__init__(self, id=ID_ACTIONBLOCKDIALOG, - name='ActionBlockDialog', parent=prnt, - size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, - title=_('Edit action block properties')) - self.SetClientSize(wx.Size(500, 300)) - - self.staticText1 = wx.StaticText(id=ID_ACTIONBLOCKDIALOGSTATICTEXT1, - label=_('Actions:'), name='staticText1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.ActionsGrid = CustomGrid(id=ID_ACTIONBLOCKDIALOGVARIABLESGRID, - name='ActionsGrid', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.VSCROLL) + def __init__(self, parent): + wx.Dialog.__init__(self, parent, + size=wx.Size(500, 300), title=_('Edit action block properties')) + + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(1) + + top_sizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) + top_sizer.AddGrowableCol(0) + top_sizer.AddGrowableRow(0) + main_sizer.AddSizer(top_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + + actions_label = wx.StaticText(self, label=_('Actions:')) + top_sizer.AddWindow(actions_label, flag=wx.ALIGN_BOTTOM) + + for name, bitmap, help in [ + ("AddButton", "add_element", _("Add action")), + ("DeleteButton", "remove_element", _("Remove action")), + ("UpButton", "up", _("Move action up")), + ("DownButton", "down", _("Move action down"))]: + button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap), + size=wx.Size(28, 28), style=wx.NO_BORDER) + button.SetToolTipString(help) + setattr(self, name, button) + top_sizer.AddWindow(button) + + self.ActionsGrid = CustomGrid(self, style=wx.VSCROLL) self.ActionsGrid.DisableDragGridSize() self.ActionsGrid.EnableScrolling(False, True) - if wx.VERSION >= (2, 6, 0): - self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnActionsGridCellChange) - else: - wx.grid.EVT_GRID_CELL_CHANGE(self.ActionsGrid, self.OnActionsGridCellChange) - - self.AddButton = wx.Button(id=ID_ACTIONBLOCKDIALOGADDBUTTON, label=_('Add'), - name='AddButton', parent=self, pos=wx.Point(0, 0), - size=wx.DefaultSize, style=0) - - self.DeleteButton = wx.Button(id=ID_ACTIONBLOCKDIALOGDELETEBUTTON, label=_('Delete'), - name='DeleteButton', parent=self, pos=wx.Point(0, 0), - size=wx.DefaultSize, style=0) - - self.UpButton = wx.Button(id=ID_ACTIONBLOCKDIALOGUPBUTTON, label='^', - name='UpButton', parent=self, pos=wx.Point(0, 0), - size=wx.Size(32, 32), style=0) - - self.DownButton = wx.Button(id=ID_ACTIONBLOCKDIALOGDOWNBUTTON, label='v', - name='DownButton', parent=self, pos=wx.Point(0, 0), - size=wx.Size(32, 32), style=0) - - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - if wx.VERSION >= (2, 5, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - else: - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) - - self._init_sizers() - - def __init__(self, parent): - self._init_ctrls(parent) + self.ActionsGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, + self.OnActionsGridCellChange) + main_sizer.AddSizer(self.ActionsGrid, border=20, + flag=wx.GROW|wx.LEFT|wx.RIGHT) + + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) + main_sizer.AddSizer(button_sizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + + self.SetSizer(main_sizer) self.Table = ActionTable(self, [], GetActionTableColnames()) typelist = GetTypeList() diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/ArrayTypeDialog.py --- a/dialogs/ArrayTypeDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/ArrayTypeDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -28,75 +28,55 @@ from controls import CustomEditableListBox +#------------------------------------------------------------------------------- +# Helpers +#------------------------------------------------------------------------------- + DIMENSION_MODEL = re.compile("([0-9]+)\.\.([0-9]+)$") -[ID_ARRAYTYPEDIALOG, ID_ARRAYTYPEDIALOGBASETYPE, - ID_ARRAYTYPEDIALOGDIMENSIONS, ID_ARRAYTYPEDIALOGDIALOGSTATICTEXT1, -] = [wx.NewId() for _init_ctrls in range(4)] +#------------------------------------------------------------------------------- +# Array Type Dialog +#------------------------------------------------------------------------------- class ArrayTypeDialog(wx.Dialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_flexGridSizer1_Items(self, parent): - parent.AddSizer(self.TopSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddWindow(self.Dimensions, 0, border=20, flag=wx.GROW|wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + def __init__(self, parent, datatypes, infos): + wx.Dialog.__init__(self, parent, + size=wx.Size(500, 300), title=_('Edit array type properties')) - def _init_coll_flexGridSizer1_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(1) - def _init_coll_TopSizer_Items(self, parent): - parent.AddWindow(self.staticText1, 1, border=0, flag=wx.GROW) - parent.AddWindow(self.BaseType, 1, border=0, flag=wx.GROW) - - def _init_sizers(self): - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) - self.TopSizer = wx.BoxSizer(wx.HORIZONTAL) + top_sizer = wx.BoxSizer(wx.HORIZONTAL) + main_sizer.AddSizer(top_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) - self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) - self._init_coll_TopSizer_Items(self.TopSizer) + basetype_label = wx.StaticText(self, label=_('Base Type:')) + top_sizer.AddWindow(basetype_label, 1, flag=wx.ALIGN_BOTTOM) - self.SetSizer(self.flexGridSizer1) - - def _init_ctrls(self, prnt): - wx.Dialog.__init__(self, id=ID_ARRAYTYPEDIALOG, - name='ArrayTypeDialog', parent=prnt, - size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, - title=_('Edit array type properties')) - self.SetClientSize(wx.Size(500, 300)) + self.BaseType = wx.ComboBox(self, style=wx.CB_READONLY) + top_sizer.AddWindow(self.BaseType, 1, flag=wx.GROW) - self.staticText1 = wx.StaticText(id=ID_ARRAYTYPEDIALOGDIALOGSTATICTEXT1, - label=_('Base Type:'), name='staticText1', parent=self, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.BaseType = wx.ComboBox(id=ID_ARRAYTYPEDIALOGBASETYPE, - name='BaseType', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) + self.Dimensions = CustomEditableListBox(self, label=_("Dimensions:"), + style=wx.gizmos.EL_ALLOW_NEW| + wx.gizmos.EL_ALLOW_EDIT| + wx.gizmos.EL_ALLOW_DELETE) + for func in ["_OnLabelEndEdit", + "_OnAddButton", + "_OnDelButton", + "_OnUpButton", + "_OnDownButton"]: + setattr(self.Dimensions, func, self.OnDimensionsChanged) + main_sizer.AddSizer(self.Dimensions, border=20, + flag=wx.GROW|wx.LEFT|wx.RIGHT) - self.Dimensions = CustomEditableListBox(id=ID_ARRAYTYPEDIALOGDIMENSIONS, - name='ArrayDimensions', parent=self, label=_("Dimensions:"), pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.gizmos.EL_ALLOW_NEW | wx.gizmos.EL_ALLOW_EDIT | wx.gizmos.EL_ALLOW_DELETE) - for func in ["_OnLabelEndEdit", "_OnAddButton", "_OnDelButton", "_OnUpButton", "_OnDownButton"]: - setattr(self.Dimensions, func, self.OnDimensionsChanged) + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) + main_sizer.AddSizer(button_sizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - if wx.VERSION >= (2, 5, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - else: - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) - - self._init_sizers() - - def __init__(self, parent, datatypes, infos): - self._init_ctrls(parent) + self.SetSizer(main_sizer) for datatype in datatypes: self.BaseType.Append(datatype) diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/BrowseLocationsDialog.py --- a/dialogs/BrowseLocationsDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/BrowseLocationsDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -24,6 +24,10 @@ from plcopen.structures import LOCATIONDATATYPES from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY +#------------------------------------------------------------------------------- +# Helpers +#------------------------------------------------------------------------------- + CWD = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0] def GetDirChoiceOptions(): @@ -40,88 +44,52 @@ for type in types: LOCATION_SIZES[type] = size -[ID_BROWSELOCATIONSDIALOG, ID_BROWSELOCATIONSDIALOGLOCATIONSTREE, - ID_BROWSELOCATIONSDIALOGDIRCHOICE, ID_BROWSELOCATIONSDIALOGSTATICTEXT1, - ID_BROWSELOCATIONSDIALOGSTATICTEXT2, -] = [wx.NewId() for _init_ctrls in range(5)] +#------------------------------------------------------------------------------- +# Browse Locations Dialog +#------------------------------------------------------------------------------- class BrowseLocationsDialog(wx.Dialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_MainSizer_Items(self, parent): - parent.AddWindow(self.staticText1, 0, border=20, flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW) - parent.AddWindow(self.LocationsTree, 0, border=20, flag=wx.LEFT|wx.RIGHT|wx.GROW) - parent.AddSizer(self.ButtonGridSizer, 0, border=20, flag=wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.GROW) + def __init__(self, parent, var_type, locations): + wx.Dialog.__init__(self, parent, + size=wx.Size(600, 400), title=_('Browse Locations')) - def _init_coll_MainSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_coll_ButtonGridSizer_Items(self, parent): - parent.AddWindow(self.staticText2, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) - parent.AddWindow(self.DirChoice, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) - parent.AddSizer(self.ButtonSizer, 0, border=0, flag=wx.ALIGN_RIGHT) + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(1) - def _init_coll_ButtonGridSizer_Growables(self, parent): - parent.AddGrowableCol(2) - parent.AddGrowableRow(0) - - def _init_sizers(self): - self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) - self.ButtonGridSizer = wx.FlexGridSizer(cols=3, hgap=5, rows=1, vgap=0) + locations_label = wx.StaticText(self, label=_('Locations available:')) + main_sizer.AddWindow(locations_label, border=20, + flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW) - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_MainSizer_Growables(self.MainSizer) - self._init_coll_ButtonGridSizer_Items(self.ButtonGridSizer) - self._init_coll_ButtonGridSizer_Growables(self.ButtonGridSizer) + self.LocationsTree = wx.TreeCtrl(self, + style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER|wx.TR_HIDE_ROOT|wx.TR_LINES_AT_ROOT) + self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnLocationsTreeItemActivated, + self.LocationsTree) + main_sizer.AddWindow(self.LocationsTree, border=20, + flag=wx.LEFT|wx.RIGHT|wx.GROW) - self.SetSizer(self.MainSizer) - - def _init_ctrls(self, prnt): - wx.Dialog.__init__(self, id=ID_BROWSELOCATIONSDIALOG, - name='BrowseLocationsDialog', parent=prnt, - size=wx.Size(600, 400), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, - title=_('Browse Locations')) - - self.staticText1 = wx.StaticText(id=ID_BROWSELOCATIONSDIALOGSTATICTEXT1, - label=_('Locations available:'), name='staticText1', parent=self, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) + button_gridsizer = wx.FlexGridSizer(cols=3, hgap=5, rows=1, vgap=0) + button_gridsizer.AddGrowableCol(2) + button_gridsizer.AddGrowableRow(0) + main_sizer.AddSizer(button_gridsizer, border=20, + flag=wx.BOTTOM|wx.LEFT|wx.RIGHT|wx.GROW) - if wx.Platform == '__WXMSW__': - treestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER - else: - treestyle = wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_SINGLE|wx.SUNKEN_BORDER - self.LocationsTree = wx.TreeCtrl(id=ID_BROWSELOCATIONSDIALOGLOCATIONSTREE, - name='LocationsTree', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=treestyle) - self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnLocationsTreeItemActivated, - id=ID_BROWSELOCATIONSDIALOGLOCATIONSTREE) + direction_label = wx.StaticText(self, label=_('Direction:')) + button_gridsizer.AddWindow(direction_label, + flag=wx.ALIGN_CENTER_VERTICAL) - self.staticText2 = wx.StaticText(id=ID_BROWSELOCATIONSDIALOGSTATICTEXT2, - label=_('Direction:'), name='staticText2', parent=self, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) + self.DirChoice = wx.ComboBox(self, style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnDirChoice, self.DirChoice) + button_gridsizer.AddWindow(self.DirChoice, + flag=wx.ALIGN_CENTER_VERTICAL) - self.DirChoice = wx.ComboBox(id=ID_BROWSELOCATIONSDIALOGDIRCHOICE, - name='DirChoice', parent=self, pos=wx.Point(0, 0), - size=wx.DefaultSize, style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnDirChoice, id=ID_BROWSELOCATIONSDIALOGDIRCHOICE) + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) + button_gridsizer.AddWindow(button_sizer, flag=wx.ALIGN_RIGHT) - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - if wx.VERSION >= (2, 5, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - else: - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) + self.SetSizer(main_sizer) - self._init_sizers() - - def __init__(self, parent, var_type, locations): - self._init_ctrls(parent) self.VarType = var_type self.Locations = locations @@ -156,19 +124,13 @@ def RefreshLocationsTree(self): root = self.LocationsTree.GetRootItem() if not root.IsOk(): - if wx.Platform == '__WXMSW__': - root = self.LocationsTree.AddRoot(_('ConfNodes')) - else: - root = self.LocationsTree.AddRoot("") + root = self.LocationsTree.AddRoot("") self.GenerateLocationsTreeBranch(root, self.Locations) self.LocationsTree.Expand(root) def GenerateLocationsTreeBranch(self, root, locations): to_delete = [] - if wx.VERSION >= (2, 6, 0): - item, root_cookie = self.LocationsTree.GetFirstChild(root) - else: - item, root_cookie = self.LocationsTree.GetFirstChild(root, 0) + item, root_cookie = self.LocationsTree.GetFirstChild(root) for loc_infos in locations: infos = loc_infos.copy() if infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP] or\ @@ -211,8 +173,8 @@ if selected.IsOk(): var_infos = self.LocationsTree.GetPyData(selected) if var_infos is None or var_infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]: - message = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + dialog = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR) + dialog.ShowModal() + dialog.Destroy() else: self.EndModal(wx.ID_OK) diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/ConnectionDialog.py --- a/dialogs/ConnectionDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/ConnectionDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -30,137 +30,77 @@ # Create New Connection Dialog #------------------------------------------------------------------------------- -[ID_CONNECTIONDIALOG, ID_CONNECTIONDIALOGSPACER, - ID_CONNECTIONDIALOGNAME, ID_CONNECTIONDIALOGRADIOBUTTON1, - ID_CONNECTIONDIALOGRADIOBUTTON2, ID_CONNECTIONDIALOGPREVIEW, - ID_CONNECTIONDIALOGSTATICTEXT1, ID_CONNECTIONDIALOGSTATICTEXT2, - ID_CONNECTIONDIALOGSTATICTEXT3, -] = [wx.NewId() for _init_ctrls in range(9)] - class ConnectionDialog(wx.Dialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_flexGridSizer1_Items(self, parent): - parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + def __init__(self, parent, controller): + wx.Dialog.__init__(self, parent, + size=wx.Size(350, 220), title=_('Connection Properties')) - def _init_coll_flexGridSizer1_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_coll_MainSizer_Items(self, parent): - parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) - - def _init_coll_LeftGridSizer_Items(self, parent): - parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.ConnectionName, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) - - def _init_coll_LeftGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(5) - - def _init_coll_RightGridSizer_Items(self, parent): - parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(0) - def _init_coll_RightGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_sizers(self): - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) - self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5) - self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - - self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) - self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) - self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) - self._init_coll_RightGridSizer_Items(self.RightGridSizer) - self._init_coll_RightGridSizer_Growables(self.RightGridSizer) - - self.SetSizer(self.flexGridSizer1) - - def _init_ctrls(self, prnt, ctrler): - wx.Dialog.__init__(self, id=ID_CONNECTIONDIALOG, - name='ConnectionDialog', parent=prnt, - size=wx.Size(350, 220), style=wx.DEFAULT_DIALOG_STYLE, - title=_('Connection Properties')) - self.SetClientSize(wx.Size(350, 220)) - - self.staticText1 = wx.StaticText(id=ID_CONNECTIONDIALOGSTATICTEXT1, - label=_('Type:'), name='staticText1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText2 = wx.StaticText(id=ID_CONNECTIONDIALOGSTATICTEXT2, - label=_('Name:'), name='staticText2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText3 = wx.StaticText(id=ID_CONNECTIONDIALOGSTATICTEXT3, - label=_('Preview:'), name='staticText3', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.radioButton1 = wx.RadioButton(id=ID_CONNECTIONDIALOGRADIOBUTTON1, - label=_('Connector'), name='radioButton1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_CONNECTIONDIALOGRADIOBUTTON1) - self.radioButton1.SetValue(True) - - self.radioButton2 = wx.RadioButton(id=ID_CONNECTIONDIALOGRADIOBUTTON2, - label=_('Continuation'), name='radioButton2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_CONNECTIONDIALOGRADIOBUTTON2) - self.radioButton2.SetValue(False) + column_sizer = wx.BoxSizer(wx.HORIZONTAL) + main_sizer.AddSizer(column_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - self.ConnectionName = wx.TextCtrl(id=ID_CONNECTIONDIALOGNAME, - name='Name', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_CONNECTIONDIALOGNAME) - - self.Preview = wx.Panel(id=ID_CONNECTIONDIALOGPREVIEW, - name='Preview', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) + left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5) + left_gridsizer.AddGrowableCol(0) + column_sizer.AddSizer(left_gridsizer, 1, border=5, + flag=wx.GROW|wx.RIGHT) + + type_label = wx.StaticText(self, label=_('Type:')) + left_gridsizer.AddWindow(type_label, flag=wx.GROW) + + self.ConnectorRadioButton = wx.RadioButton(self, + label=_('Connector'), style=wx.RB_GROUP) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.ConnectorRadioButton) + self.ConnectorRadioButton.SetValue(True) + left_gridsizer.AddWindow(self.ConnectorRadioButton, flag=wx.GROW) + + self.ConnectionRadioButton = wx.RadioButton(self, label=_('Continuation')) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.ConnectionRadioButton) + left_gridsizer.AddWindow(self.ConnectionRadioButton, flag=wx.GROW) + + name_label = wx.StaticText(self, label=_('Name:')) + left_gridsizer.AddWindow(name_label, flag=wx.GROW) + + self.ConnectionName = wx.TextCtrl(self) + self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.ConnectionName) + left_gridsizer.AddWindow(self.ConnectionName, flag=wx.GROW) + + right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) + right_gridsizer.AddGrowableCol(0) + right_gridsizer.AddGrowableRow(1) + column_sizer.AddSizer(right_gridsizer, 1, border=5, + flag=wx.GROW|wx.LEFT) + + preview_label = wx.StaticText(self, label=_('Preview:')) + right_gridsizer.AddWindow(preview_label, flag=wx.GROW) + + self.Preview = wx.Panel(self, + style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) setattr(self.Preview, "GetScaling", lambda:None) - setattr(self.Preview, "IsOfType", ctrler.IsOfType) + setattr(self.Preview, "IsOfType", controller.IsOfType) + self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) + right_gridsizer.AddWindow(self.Preview, flag=wx.GROW) - self.Spacer = wx.Panel(id=ID_CONNECTIONDIALOGSPACER, - name='Spacer', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) + main_sizer.AddSizer(button_sizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - if wx.VERSION >= (2, 5, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) - else: - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) - wx.EVT_PAINT(self.Preview, self.OnPaint) + self.SetSizer(main_sizer) - self._init_sizers() - - def __init__(self, parent, controler): - self._init_ctrls(parent, controler) self.Connection = None self.MinConnectionSize = None self.PouNames = [] self.PouElementNames = [] - self.radioButton1.SetFocus() + self.ConnectorRadioButton.SetFocus() def SetPreviewFont(self, font): self.Preview.SetFont(font) @@ -172,16 +112,16 @@ for name, value in values.items(): if name == "type": if value == CONNECTOR: - self.radioButton1.SetValue(True) + self.ConnectorRadioButton.SetValue(True) elif value == CONTINUATION: - self.radioButton2.SetValue(True) + self.ConnectionRadioButton.SetValue(True) elif name == "name": self.ConnectionName.SetValue(value) self.RefreshPreview() def GetValues(self): values = {} - if self.radioButton1.GetValue(): + if self.ConnectorRadioButton.GetValue(): values["type"] = CONNECTOR else: values["type"] = CONTINUATION @@ -196,27 +136,22 @@ self.PouElementNames = [element_name.upper() for element_name in element_names] def OnOK(self, event): + message = None connection_name = self.ConnectionName.GetValue() if connection_name == "": - message = wx.MessageDialog(self, _("Form isn't complete. Name must be filled!"), _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("Form isn't complete. Name must be filled!") elif not TestIdentifier(connection_name): - message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%connection_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" is not a valid identifier!") % connection_name elif connection_name.upper() in IEC_KEYWORDS: - message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%connection_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" is a keyword. It can't be used!") % connection_name elif connection_name.upper() in self.PouNames: - message = wx.MessageDialog(self, _("\"%s\" pou already exists!")%connection_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" pou already exists!") % connection_name elif connection_name.upper() in self.PouElementNames: - message = wx.MessageDialog(self, _("\"%s\" element for this pou already exists!")%connection_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" element for this pou already exists!") % connection_name + if message is not None: + dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) + dialog.ShowModal() + dialog.Destroy() else: self.EndModal(wx.ID_OK) @@ -232,7 +167,7 @@ dc = wx.ClientDC(self.Preview) dc.SetFont(self.Preview.GetFont()) dc.Clear() - if self.radioButton1.GetValue(): + if self.ConnectorRadioButton.GetValue(): self.Connection = FBD_Connector(self.Preview, CONNECTOR, self.ConnectionName.GetValue()) else: self.Connection = FBD_Connector(self.Preview, CONTINUATION, self.ConnectionName.GetValue()) @@ -248,4 +183,4 @@ def OnPaint(self, event): self.RefreshPreview() - event.Skip() \ No newline at end of file + event.Skip() diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/DurationEditorDialog.py --- a/dialogs/DurationEditorDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/DurationEditorDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -26,6 +26,10 @@ import wx +#------------------------------------------------------------------------------- +# Helpers +#------------------------------------------------------------------------------- + MICROSECONDS = 0.001 MILLISECONDS = 1 SECOND = 1000 @@ -35,139 +39,58 @@ IEC_TIME_MODEL = re.compile("(?:(?:T|TIME)#)?(-)?(?:(%(float)s)D_?)?(?:(%(float)s)H_?)?(?:(%(float)s)M(?!S)_?)?(?:(%(float)s)S_?)?(?:(%(float)s)MS)?" % {"float": "[0-9]+(?:\.[0-9]+)?"}) +CONTROLS = [ + ("Days", _('Days:')), + ("Hours", _('Hours:')), + ("Minutes", _('Minutes:')), + ("Seconds", _('Seconds:')), + ("Milliseconds", _('Milliseconds:')), + ("Microseconds", _('Microseconds:')), +] + #------------------------------------------------------------------------------- # Edit Duration Value Dialog #------------------------------------------------------------------------------- -[ID_DURATIONEDITORDIALOG, ID_DURATIONEDITORDIALOGDAYSLABEL, - ID_DURATIONEDITORDIALOGDAYS, ID_DURATIONEDITORDIALOGHOURSLABEL, - ID_DURATIONEDITORDIALOGHOURS, ID_DURATIONEDITORDIALOGMINUTESLABEL, - ID_DURATIONEDITORDIALOGMINUTES, ID_DURATIONEDITORDIALOGSECONDSLABEL, - ID_DURATIONEDITORDIALOGSECONDS, ID_DURATIONEDITORDIALOGMILLISECONDSLABEL, - ID_DURATIONEDITORDIALOGMILLISECONDS, ID_DURATIONEDITORDIALOGMICROSECONDSLABEL, - ID_DURATIONEDITORDIALOGMICROSECONDS, -] = [wx.NewId() for _init_ctrls in range(13)] +class DurationEditorDialog(wx.Dialog): -class DurationEditorDialog(wx.Dialog): - - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_MainSizer_Items(self, parent): - parent.AddSizer(self.ControlsSizer, 0, border=20, flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.GROW) + def __init__(self, parent): + wx.Dialog.__init__(self, parent, + size=wx.Size(700, 200), title=_('Edit Duration')) - def _init_coll_MainSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(0) - def _init_coll_ControlsSizer_Items(self, parent): - parent.AddWindow(self.DaysLabel, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.HoursLabel, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.MinutesLabel, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.SecondsLabel, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.MillisecondsLabel, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.MicrosecondsLabel, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Days, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Hours, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Minutes, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Seconds, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Milliseconds, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Microseconds, 0, border=0, flag=wx.GROW) + controls_sizer = wx.FlexGridSizer(cols=len(CONTROLS), hgap=10, rows=2, vgap=10) + main_sizer.AddSizer(controls_sizer, border=20, + flag=wx.TOP|wx.LEFT|wx.RIGHT|wx.GROW) - def _init_coll_ControlsSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableCol(1) - parent.AddGrowableCol(2) - parent.AddGrowableCol(3) - parent.AddGrowableCol(4) - parent.AddGrowableCol(5) - - def _init_sizers(self): - self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.ControlsSizer = wx.FlexGridSizer(cols=6, hgap=10, rows=2, vgap=10) + controls = [] + for i, (name, label) in enumerate(CONTROLS): + controls_sizer.AddGrowableCol(i) + + st = wx.StaticText(self, label=label) + txtctrl = wx.TextCtrl(self, value='0', style=wx.TE_PROCESS_ENTER) + self.Bind(wx.EVT_TEXT_ENTER, + self.GetControlValueTestFunction(txtctrl), + txtctrl) + setattr(self, name, txtctrl) - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_MainSizer_Growables(self.MainSizer) - self._init_coll_ControlsSizer_Items(self.ControlsSizer) - self._init_coll_ControlsSizer_Growables(self.ControlsSizer) + controls.append((st, txtctrl)) + + for st, txtctrl in controls: + controls_sizer.AddWindow(st, flag=wx.GROW) + + for st, txtctrl in controls: + controls_sizer.AddWindow(txtctrl, flag=wx.GROW) - self.SetSizer(self.MainSizer) - - def _init_ctrls(self, prnt): - wx.Dialog.__init__(self, id=ID_DURATIONEDITORDIALOG, - name='DurationEditorDialog', parent=prnt, - size=wx.Size(700, 200), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, - title=_('Edit Duration')) + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) + main_sizer.AddSizer(button_sizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - self.DaysLabel = wx.StaticText(id=ID_DURATIONEDITORDIALOGDAYSLABEL, - label=_('Days:'), name='DaysLabel', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.Days = wx.TextCtrl(id=ID_DURATIONEDITORDIALOGDAYS, value='0', - name='Days', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER) - self.Bind(wx.EVT_TEXT_ENTER, self.GetControlValueTestFunction(self.Days), id=ID_DURATIONEDITORDIALOGDAYS) - - self.HoursLabel = wx.StaticText(id=ID_DURATIONEDITORDIALOGHOURSLABEL, - label=_('Hours:'), name='HoursLabel', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.Hours = wx.TextCtrl(id=ID_DURATIONEDITORDIALOGHOURS, value='0', - name='Hours', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER) - self.Bind(wx.EVT_TEXT_ENTER, self.GetControlValueTestFunction(self.Hours), id=ID_DURATIONEDITORDIALOGHOURS) - - self.MinutesLabel = wx.StaticText(id=ID_DURATIONEDITORDIALOGMINUTESLABEL, - label=_('Minutes:'), name='MinutesLabel', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.Minutes = wx.TextCtrl(id=ID_DURATIONEDITORDIALOGMINUTES, value='0', - name='Minutes', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER) - self.Bind(wx.EVT_TEXT_ENTER, self.GetControlValueTestFunction(self.Minutes), id=ID_DURATIONEDITORDIALOGMINUTES) - - self.SecondsLabel = wx.StaticText(id=ID_DURATIONEDITORDIALOGSECONDSLABEL, - label=_('Seconds:'), name='SecondsLabel', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.Seconds = wx.TextCtrl(id=ID_DURATIONEDITORDIALOGSECONDS, value='0', - name='Seconds', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER) - self.Bind(wx.EVT_TEXT_ENTER, self.GetControlValueTestFunction(self.Seconds), id=ID_DURATIONEDITORDIALOGSECONDS) - - self.MillisecondsLabel = wx.StaticText(id=ID_DURATIONEDITORDIALOGMILLISECONDSLABEL, - label=_('Milliseconds:'), name='MillisecondsLabel', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.Milliseconds = wx.TextCtrl(id=ID_DURATIONEDITORDIALOGMILLISECONDS, value='0', - name='Milliseconds', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER) - self.Bind(wx.EVT_TEXT_ENTER, self.GetControlValueTestFunction(self.Milliseconds), id=ID_DURATIONEDITORDIALOGMILLISECONDS) - - self.MicrosecondsLabel = wx.StaticText(id=ID_DURATIONEDITORDIALOGMICROSECONDSLABEL, - label=_('Microseconds:'), name='MicrosecondsLabel', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.Microseconds = wx.TextCtrl(id=ID_DURATIONEDITORDIALOGMICROSECONDS, value='0', - name='Microseconds', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.TE_PROCESS_ENTER) - self.Bind(wx.EVT_TEXT_ENTER, self.GetControlValueTestFunction(self.Milliseconds), id=ID_DURATIONEDITORDIALOGMICROSECONDS) - - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - if wx.VERSION >= (2, 5, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - else: - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) - - self._init_sizers() - - def __init__(self, parent): - self._init_ctrls(parent) + self.SetSizer(main_sizer) self.Days.SetFocus() diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/FBDBlockDialog.py --- a/dialogs/FBDBlockDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/FBDBlockDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -31,156 +31,97 @@ # Create New Block Dialog #------------------------------------------------------------------------------- -[ID_FBDBLOCKDIALOG, ID_FBDBLOCKDIALOGNAME, - ID_FBDBLOCKDIALOGTYPETREE, ID_FBDBLOCKDIALOGTYPEDESC, - ID_FBDBLOCKDIALOGINPUTS, ID_FBDBLOCKDIALOGPREVIEW, - ID_FBDBLOCKDIALOGEXECUTIONORDER, ID_FBDBLOCKDIALOGEXECUTIONCONTROL, - ID_FBDBLOCKDIALOGSTATICTEXT1, ID_FBDBLOCKDIALOGSTATICTEXT2, - ID_FBDBLOCKDIALOGSTATICTEXT3, ID_FBDBLOCKDIALOGSTATICTEXT4, - ID_FBDBLOCKDIALOGSTATICTEXT5, ID_FBDBLOCKDIALOGSTATICTEXT6, -] = [wx.NewId() for _init_ctrls in range(14)] - -[CATEGORY, BLOCK] = range(2) - class FBDBlockDialog(wx.Dialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_flexGridSizer1_Items(self, parent): - parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - - def _init_coll_flexGridSizer1_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_coll_MainSizer_Items(self, parent): - parent.AddSizer(self.LeftBoxSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) - - def _init_coll_LeftBoxSizer_Items(self, parent): - parent.AddWindow(self.LibraryPanel, 1, border=5, flag=wx.GROW|wx.TOP) - - def _init_coll_RightGridSizer_Items(self, parent): - parent.AddSizer(self.RightUpGridSizer, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText6, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) - - def _init_coll_RightGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(2) - - def _init_coll_RightUpGridSizer_Items(self, parent): - parent.AddWindow(self.staticText2, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) - parent.AddWindow(self.BlockName, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText3, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) - parent.AddWindow(self.Inputs, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText4, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) - parent.AddWindow(self.ExecutionOrder, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText5, 0, border=4, flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) - parent.AddWindow(self.ExecutionControl, 0, border=0, flag=wx.GROW) - - def _init_coll_RightUpGridSizer_Growables(self, parent): - parent.AddGrowableCol(1) - - def _init_sizers(self): - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) - self.LeftBoxSizer = wx.StaticBoxSizer(self.staticbox1, wx.VERTICAL) - self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5) - self.RightUpGridSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=4, vgap=5) - - self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) - self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_LeftBoxSizer_Items(self.LeftBoxSizer) - self._init_coll_RightGridSizer_Items(self.RightGridSizer) - self._init_coll_RightGridSizer_Growables(self.RightGridSizer) - self._init_coll_RightUpGridSizer_Items(self.RightUpGridSizer) - self._init_coll_RightUpGridSizer_Growables(self.RightUpGridSizer) - - self.SetSizer(self.flexGridSizer1) - - def _init_ctrls(self, prnt): - wx.Dialog.__init__(self, id=ID_FBDBLOCKDIALOG, - name='FBDBlockDialog', parent=prnt, - size=wx.Size(600, 400), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, - title=_('Block Properties')) - self.SetClientSize(wx.Size(600, 400)) - - self.staticbox1 = wx.StaticBox(id=ID_FBDBLOCKDIALOGSTATICTEXT1, - label=_('Type:'), name='staticBox1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) - - self.staticText2 = wx.StaticText(id=ID_FBDBLOCKDIALOGSTATICTEXT2, - label=_('Name:'), name='staticText2', parent=self, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.staticText3 = wx.StaticText(id=ID_FBDBLOCKDIALOGSTATICTEXT2, - label=_('Inputs:'), name='staticText4', parent=self, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.staticText4 = wx.StaticText(id=ID_FBDBLOCKDIALOGSTATICTEXT4, - label=_('Execution Order:'), name='staticText4', parent=self, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.staticText5 = wx.StaticText(id=ID_FBDBLOCKDIALOGSTATICTEXT5, - label=_('Execution Control:'), name='staticText5', parent=self, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.staticText6 = wx.StaticText(id=ID_FBDBLOCKDIALOGSTATICTEXT6, - label=_('Preview:'), name='staticText6', parent=self, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - + def __init__(self, parent, controller): + wx.Dialog.__init__(self, parent, + size=wx.Size(600, 400), title=_('Block Properties')) + + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=4, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(0) + + column_sizer = wx.BoxSizer(wx.HORIZONTAL) + main_sizer.AddSizer(column_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + + type_staticbox = wx.StaticBox(self, label=_('Type:')) + left_staticboxsizer = wx.StaticBoxSizer(type_staticbox, wx.VERTICAL) + column_sizer.AddSizer(left_staticboxsizer, 1, border=5, + flag=wx.GROW|wx.RIGHT) + self.LibraryPanel = LibraryPanel(self) - - self.BlockName = wx.TextCtrl(id=ID_FBDBLOCKDIALOGNAME, value='', - name='BlockName', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_FBDBLOCKDIALOGNAME) - - self.Inputs = wx.SpinCtrl(id=ID_FBDBLOCKDIALOGINPUTS, - name='Inputs', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=2, max=20) - self.Bind(wx.EVT_SPINCTRL, self.OnInputsChanged, id=ID_FBDBLOCKDIALOGINPUTS) - - self.ExecutionOrder = wx.SpinCtrl(id=ID_FBDBLOCKDIALOGEXECUTIONORDER, - name='ExecutionOrder', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0) - self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, id=ID_FBDBLOCKDIALOGEXECUTIONORDER) - - self.ExecutionControl = wx.CheckBox(id=ID_FBDBLOCKDIALOGEXECUTIONCONTROL, - name='ExecutionControl', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_CHECKBOX, self.OnExecutionOrderChanged, id=ID_FBDBLOCKDIALOGEXECUTIONCONTROL) - - self.Preview = wx.Panel(id=ID_FBDBLOCKDIALOGPREVIEW, - name='Preview', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) + self.LibraryPanel.SetController(controller) + setattr(self.LibraryPanel, "_OnTreeItemSelected", + self.OnLibraryTreeItemSelected) + left_staticboxsizer.AddWindow(self.LibraryPanel, 1, border=5, + flag=wx.GROW|wx.TOP) + + right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5) + right_gridsizer.AddGrowableCol(0) + right_gridsizer.AddGrowableRow(2) + column_sizer.AddSizer(right_gridsizer, 1, border=5, + flag=wx.GROW|wx.LEFT) + + top_right_gridsizer = wx.FlexGridSizer(cols=2, hgap=0, rows=4, vgap=5) + top_right_gridsizer.AddGrowableCol(1) + right_gridsizer.AddSizer(top_right_gridsizer, flag=wx.GROW) + + name_label = wx.StaticText(self, label=_('Name:')) + top_right_gridsizer.AddWindow(name_label, + flag=wx.ALIGN_CENTER_VERTICAL) + + self.BlockName = wx.TextCtrl(self) + self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.BlockName) + top_right_gridsizer.AddWindow(self.BlockName, flag=wx.GROW) + + inputs_label = wx.StaticText(self, label=_('Inputs:')) + top_right_gridsizer.AddWindow(inputs_label, + flag=wx.ALIGN_CENTER_VERTICAL) + + self.Inputs = wx.SpinCtrl(self, min=2, max=20, + style=wx.SP_ARROW_KEYS) + self.Bind(wx.EVT_SPINCTRL, self.OnInputsChanged, self.Inputs) + top_right_gridsizer.AddWindow(self.Inputs, flag=wx.GROW) + + execution_order_label = wx.StaticText(self, label=_('Execution Order:')) + top_right_gridsizer.AddWindow(execution_order_label, + flag=wx.ALIGN_CENTER_VERTICAL) + + self.ExecutionOrder = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS) + self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, self.ExecutionOrder) + top_right_gridsizer.AddWindow(self.ExecutionOrder, flag=wx.GROW) + + execution_control_label = wx.StaticText(self, label=_('Execution Control:')) + top_right_gridsizer.AddWindow(execution_control_label, + flag=wx.ALIGN_CENTER_VERTICAL) + + self.ExecutionControl = wx.CheckBox(self) + self.Bind(wx.EVT_CHECKBOX, self.OnExecutionOrderChanged, self.ExecutionControl) + top_right_gridsizer.AddWindow(self.ExecutionControl, flag=wx.GROW) + + preview_label = wx.StaticText(self, label=_('Preview:')) + right_gridsizer.AddWindow(preview_label, flag=wx.GROW) + + self.Preview = wx.Panel(self, + style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) setattr(self.Preview, "GetScaling", lambda:None) - setattr(self.Preview, "GetBlockType", self.Controler.GetBlockType) - setattr(self.Preview, "IsOfType", self.Controler.IsOfType) - - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - if wx.VERSION >= (2, 5, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) - else: - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) - wx.EVT_PAINT(self.Preview, self.OnPaint) - - self._init_sizers() - - def __init__(self, parent, controler): - self.Controler = controler - self._init_ctrls(parent) + setattr(self.Preview, "GetBlockType", controller.GetBlockType) + setattr(self.Preview, "IsOfType", controller.IsOfType) + self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) + right_gridsizer.AddWindow(self.Preview, flag=wx.GROW) + + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) + main_sizer.AddSizer(button_sizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + + self.SetSizer(main_sizer) + + self.Controller = controller + self.BlockName.SetValue("") self.BlockName.Enable(False) self.Inputs.Enable(False) @@ -191,8 +132,6 @@ self.PouNames = [] self.PouElementNames = [] - self.LibraryPanel.SetControler(controler) - setattr(self.LibraryPanel, "_OnTreeItemSelected", self.OnLibraryTreeItemSelected) self.LibraryPanel.SetFocus() def SetBlockList(self, blocklist): @@ -202,33 +141,26 @@ self.Preview.SetFont(font) def OnOK(self, event): + message = None selected = self.LibraryPanel.GetSelectedBlock() block_name = self.BlockName.GetValue() name_enabled = self.BlockName.IsEnabled() if selected is None: - message = wx.MessageDialog(self, _("Form isn't complete. Valid block type must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("Form isn't complete. Valid block type must be selected!") elif name_enabled and block_name == "": - message = wx.MessageDialog(self, _("Form isn't complete. Name must be filled!"), _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("Form isn't complete. Name must be filled!") elif name_enabled and not TestIdentifier(block_name): - message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%block_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" is not a valid identifier!") % block_name elif name_enabled and block_name.upper() in IEC_KEYWORDS: - message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%block_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" is a keyword. It can't be used!") % block_name elif name_enabled and block_name.upper() in self.PouNames: - message = wx.MessageDialog(self, _("\"%s\" pou already exists!")%block_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" pou already exists!") % block_name elif name_enabled and block_name.upper() in self.PouElementNames: - message = wx.MessageDialog(self, _("\"%s\" element for this pou already exists!")%block_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" element for this pou already exists!") % block_name + if message is not None: + dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) + dialog.ShowModal() + dialog.Destroy() else: self.EndModal(wx.ID_OK) @@ -269,7 +201,7 @@ def OnLibraryTreeItemSelected(self, event): values = self.LibraryPanel.GetSelectedBlock() if values is not None: - blocktype = self.Controler.GetBlockType(values["type"], values["inputs"]) + blocktype = self.Controller.GetBlockType(values["type"], values["inputs"]) else: blocktype = None if blocktype is not None: diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/FBDVariableDialog.py --- a/dialogs/FBDVariableDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/FBDVariableDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -27,163 +27,93 @@ from graphics import * #------------------------------------------------------------------------------- -# Create New Variable Dialog -#------------------------------------------------------------------------------- - -[ID_FBDVARIABLEDIALOG, ID_FBDVARIABLEDIALOGSPACER, - ID_FBDVARIABLEDIALOGNAME, ID_FBDVARIABLEDIALOGCLASS, - ID_FBDVARIABLEDIALOGPREVIEW, ID_FBDVARIABLEDIALOGEXPRESSION, - ID_FBDVARIABLEDIALOGEXECUTIONORDER, ID_FBDVARIABLEDIALOGSTATICTEXT1, - ID_FBDVARIABLEDIALOGSTATICTEXT2, ID_FBDVARIABLEDIALOGSTATICTEXT3, - ID_FBDVARIABLEDIALOGSTATICTEXT4, ID_FBDVARIABLEDIALOGSTATICTEXT5 -] = [wx.NewId() for _init_ctrls in range(12)] +# Helpers +#------------------------------------------------------------------------------- VARIABLE_CLASSES_DICT = {INPUT : _("Input"), INOUT : _("InOut"), OUTPUT : _("Output")} -VARIABLE_CLASSES_DICT_REVERSE = dict([(value, key) for key, value in VARIABLE_CLASSES_DICT.iteritems()]) +VARIABLE_CLASSES_DICT_REVERSE = dict( + [(value, key) for key, value in VARIABLE_CLASSES_DICT.iteritems()]) + +#------------------------------------------------------------------------------- +# Create New Variable Dialog +#------------------------------------------------------------------------------- class FBDVariableDialog(wx.Dialog): - - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_flexGridSizer1_Items(self, parent): - parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - - def _init_coll_flexGridSizer1_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_coll_MainSizer_Items(self, parent): - parent.AddSizer(self.TopSizer, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText5, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) - - def _init_coll_MainSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(2) - - def _init_coll_TopSizer_Items(self, parent): - parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) - - def _init_coll_LeftGridSizer_Items(self, parent): - parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Class, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Expression, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.ExecutionOrder, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) - - def _init_coll_LeftGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(2) - - def _init_coll_RightGridSizer_Items(self, parent): - parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.VariableName, 0, border=0, flag=wx.GROW) - - def _init_coll_RightGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_sizers(self): - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5) - self.TopSizer = wx.BoxSizer(wx.HORIZONTAL) - self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5) - self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - - self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) - self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_MainSizer_Growables(self.MainSizer) - self._init_coll_TopSizer_Items(self.TopSizer) - self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) - self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) - self._init_coll_RightGridSizer_Items(self.RightGridSizer) - self._init_coll_RightGridSizer_Growables(self.RightGridSizer) - - self.SetSizer(self.flexGridSizer1) - - def _init_ctrls(self, prnt, ctrler): - wx.Dialog.__init__(self, id=ID_FBDVARIABLEDIALOG, - name='FBDVariableDialog', parent=prnt, - size=wx.Size(400, 380), style=wx.DEFAULT_DIALOG_STYLE, - title=_('Variable Properties')) - self.SetClientSize(wx.Size(400, 380)) - - self.staticText1 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT1, - label=_('Class:'), name='staticText1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText2 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT2, - label=_('Expression:'), name='staticText2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText3 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT3, - label=_('Execution Order:'), name='staticText3', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText4 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT4, - label=_('Name:'), name='staticText4', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText5 = wx.StaticText(id=ID_FBDVARIABLEDIALOGSTATICTEXT5, - label=_('Preview:'), name='staticText5', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.Class = wx.ComboBox(id=ID_FBDVARIABLEDIALOGCLASS, - name='Class', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnClassChanged, id=ID_FBDVARIABLEDIALOGCLASS) - - self.VariableName = wx.ListBox(id=ID_FBDVARIABLEDIALOGNAME, - name='Name', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 90), style=wx.LB_SINGLE|wx.LB_SORT) - self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, id=ID_FBDVARIABLEDIALOGNAME) - - self.Expression = wx.TextCtrl(id=ID_FBDVARIABLEDIALOGEXPRESSION, - name='Expression', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_TEXT, self.OnExpressionChanged, id=ID_FBDVARIABLEDIALOGEXPRESSION) - - self.ExecutionOrder = wx.SpinCtrl(id=ID_FBDVARIABLEDIALOGEXECUTIONORDER, - name='ExecutionOrder', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0) - self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, id=ID_FBDVARIABLEDIALOGEXECUTIONORDER) - - self.Spacer = wx.Panel(id=ID_FBDVARIABLEDIALOGSPACER, - name='Spacer', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.Preview = wx.Panel(id=ID_FBDVARIABLEDIALOGPREVIEW, - name='Preview', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) + + def __init__(self, parent, controller, transition = ""): + wx.Dialog.__init__(self, parent, + size=wx.Size(400, 380), title=_('Variable Properties')) + + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=4, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(2) + + column_sizer = wx.BoxSizer(wx.HORIZONTAL) + main_sizer.AddSizer(column_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + + left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5) + left_gridsizer.AddGrowableCol(0) + column_sizer.AddSizer(left_gridsizer, 1, border=5, + flag=wx.GROW|wx.RIGHT) + + class_label = wx.StaticText(self, label=_('Class:')) + left_gridsizer.AddWindow(class_label, flag=wx.GROW) + + self.Class = wx.ComboBox(self, style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnClassChanged, self.Class) + left_gridsizer.AddWindow(self.Class, flag=wx.GROW) + + expression_label = wx.StaticText(self, label=_('Expression:')) + left_gridsizer.AddWindow(expression_label, flag=wx.GROW) + + self.Expression = wx.TextCtrl(self) + self.Bind(wx.EVT_TEXT, self.OnExpressionChanged, self.Expression) + left_gridsizer.AddWindow(self.Expression, flag=wx.GROW) + + execution_order_label = wx.StaticText(self, label=_('Execution Order:')) + left_gridsizer.AddWindow(execution_order_label, flag=wx.GROW) + + self.ExecutionOrder = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS) + self.Bind(wx.EVT_SPINCTRL, self.OnExecutionOrderChanged, self.ExecutionOrder) + left_gridsizer.AddWindow(self.ExecutionOrder, flag=wx.GROW) + + right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) + right_gridsizer.AddGrowableCol(0) + right_gridsizer.AddGrowableRow(1) + column_sizer.AddSizer(right_gridsizer, 1, border=5, + flag=wx.GROW|wx.LEFT) + + name_label = wx.StaticText(self, label=_('Name:')) + right_gridsizer.AddWindow(name_label, flag=wx.GROW) + + self.VariableName = wx.ListBox(self, style=wx.LB_SINGLE|wx.LB_SORT) + self.Bind(wx.EVT_LISTBOX, self.OnNameChanged, self.VariableName) + right_gridsizer.AddWindow(self.VariableName, flag=wx.GROW) + + preview_label = wx.StaticText(self, label=_('Preview:')) + main_sizer.AddWindow(preview_label, border=20, + flag=wx.GROW|wx.LEFT|wx.RIGHT) + + self.Preview = wx.Panel(self, + style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) setattr(self.Preview, "GetScaling", lambda:None) - setattr(self.Preview, "IsOfType", ctrler.IsOfType) - - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - if wx.VERSION >= (2, 5, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) - else: - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) - wx.EVT_PAINT(self.Preview, self.OnPaint) - - self._init_sizers() - - def __init__(self, parent, controler, transition = ""): - self._init_ctrls(parent, controler) + setattr(self.Preview, "IsOfType", controller.IsOfType) + self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) + main_sizer.AddWindow(self.Preview, border=20, + flag=wx.GROW|wx.LEFT|wx.RIGHT) + + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) + main_sizer.AddSizer(button_sizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + + self.SetSizer(main_sizer) + self.Transition = transition self.Variable = None self.VarList = [] @@ -256,17 +186,18 @@ return values def OnOK(self, event): + message = None expression = self.Expression.GetValue() if self.Expression.IsEnabled(): value = expression else: value = self.VariableName.GetStringSelection() if value == "": - message = wx.MessageDialog(self, _("At least a variable or an expression must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("At least a variable or an expression must be selected!") elif value.upper() in IEC_KEYWORDS: - message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%value, _("Error"), wx.OK|wx.ICON_ERROR) + message = _("\"%s\" is a keyword. It can't be used!") % value + if message is not None: + message = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) message.ShowModal() message.Destroy() else: diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/ForceVariableDialog.py --- a/dialogs/ForceVariableDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/ForceVariableDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -21,12 +21,13 @@ #License along with this library; if not, write to the Free Software #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -import wx import re import datetime +import wx + #------------------------------------------------------------------------------- -# Force Variable Dialog +# Helpers #------------------------------------------------------------------------------- LOCATIONDATATYPES = {"X" : ["BOOL"], @@ -141,41 +142,35 @@ "DT": getdatetime, "TOD": gettimeofday} +#------------------------------------------------------------------------------- +# Force Variable Dialog +#------------------------------------------------------------------------------- class ForceVariableDialog(wx.TextEntryDialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - def __init__(self, parent, iec_type, defaultValue=""): wx.TextEntryDialog.__init__(self, parent, message = _("Forcing Variable Value"), caption = _("Please enter value for a \"%s\" variable:"%iec_type), defaultValue = defaultValue, style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition) self.IEC_Type = iec_type - if wx.VERSION >= (2, 8, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId()) - elif wx.VERSION >= (2, 6, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId()) - else: - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) - + + self.Bind(wx.EVT_BUTTON, self.OnOK, + self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton()) + def OnOK(self, event): + message = None value = self.GetSizer().GetItem(1).GetWindow().GetValue() if value == "": - message = wx.MessageDialog(self, _("You must type a value!"), _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("You must type a value!") elif GetTypeValue[self.IEC_Type](value) is None: - message = wx.MessageDialog(self, _("Invalid value \"%s\" for \"%s\" variable!")%(value, self.IEC_Type), _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("Invalid value \"%s\" for \"%s\" variable!") % (value, self.IEC_Type) + if message is not None: + dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) + dialog.ShowModal() + dialog.Destroy() else: self.EndModal(wx.ID_OK) def GetValue(self): - return GetTypeValue[self.IEC_Type](self.GetSizer().GetItem(1).GetWindow().GetValue()) + return GetTypeValue[self.IEC_Type](wx.TextEntryDialog.GetValue(self)) diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/LDElementDialog.py --- a/dialogs/LDElementDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/LDElementDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -30,170 +30,99 @@ # Edit Ladder Element Properties Dialog #------------------------------------------------------------------------------- - -[ID_LDELEMENTDIALOG, ID_LDELEMENTDIALOGSPACER, - ID_LDELEMENTDIALOGNAME, ID_LDELEMENTDIALOGRADIOBUTTON1, - ID_LDELEMENTDIALOGRADIOBUTTON2, ID_LDELEMENTDIALOGRADIOBUTTON3, - ID_LDELEMENTDIALOGRADIOBUTTON4, ID_LDELEMENTDIALOGRADIOBUTTON5, - ID_LDELEMENTDIALOGRADIOBUTTON6, ID_LDELEMENTDIALOGPREVIEW, - ID_LDELEMENTDIALOGSTATICTEXT1, ID_LDELEMENTDIALOGSTATICTEXT2, - ID_LDELEMENTDIALOGSTATICTEXT3, -] = [wx.NewId() for _init_ctrls in range(13)] - class LDElementDialog(wx.Dialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_flexGridSizer1_Items(self, parent): - parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - - def _init_coll_flexGridSizer1_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_coll_MainSizer_Items(self, parent): - parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) - - def _init_coll_LeftGridSizer_Items(self, parent): - parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) - parent.AddSizer(self.RadioButtonSizer, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.ElementName, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) - - def _init_coll_LeftGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(7) - - def _init_coll_RadioButtonSizer_Items(self, parent): - parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton4, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton5, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton6, 0, border=0, flag=wx.GROW) - - def _init_coll_RightGridSizer_Items(self, parent): - parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) - - def _init_coll_RightGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_sizers(self): - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) - self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5) - self.RadioButtonSizer = wx.BoxSizer(wx.VERTICAL) - self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - - self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) - self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) - self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) - self._init_coll_RadioButtonSizer_Items(self.RadioButtonSizer) - self._init_coll_RightGridSizer_Items(self.RightGridSizer) - self._init_coll_RightGridSizer_Growables(self.RightGridSizer) - - self.SetSizer(self.flexGridSizer1) - - def _init_ctrls(self, prnt, ctrler, title, extra_size = 0): - wx.Dialog.__init__(self, id=ID_LDELEMENTDIALOG, - name='LDElementDialog', parent=prnt, - size=wx.Size(350, 260 + extra_size), style=wx.DEFAULT_DIALOG_STYLE, - title=title) - self.SetClientSize(wx.Size(350, 260 + extra_size)) - - self.staticText1 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT1, - label=_('Modifier:'), name='staticText1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText2 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT2, - label=_('Name:'), name='staticText2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText3 = wx.StaticText(id=ID_LDELEMENTDIALOGSTATICTEXT3, - label=_('Preview:'), name='staticText3', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.radioButton1 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON1, - label=_("Normal"), name='radioButton1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON1) - self.radioButton1.SetValue(True) - - self.radioButton2 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON2, - label=_("Negated"), name='radioButton2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON2) - - self.radioButton3 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON3, - label=_("Set"), name='radioButton3', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON3) - - self.radioButton4 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON4, - label=_("Reset"), name='radioButton4', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON4) - - self.radioButton5 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON5, - label=_("Rising Edge"), name='radioButton5', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON5) - - self.radioButton6 = wx.RadioButton(id=ID_LDELEMENTDIALOGRADIOBUTTON6, - label=_("Falling Edge"), name='radioButton6', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDELEMENTDIALOGRADIOBUTTON6) - - self.ElementName = wx.ComboBox(id=ID_LDELEMENTDIALOGNAME, - name='Name', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnNameChanged, id=ID_LDELEMENTDIALOGNAME) - - self.Preview = wx.Panel(id=ID_LDELEMENTDIALOGPREVIEW, - name='Preview', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) + def __init__(self, parent, controller, type): + if type == "contact": + wx.Dialog.__init__(self, parent, size=wx.Size(350, 310), + title=_("Edit Contact Values")) + else: + wx.Dialog.__init__(self, parent, size=wx.Size(350, 260), + title=_("Edit Coil Values")) + + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(0) + + column_sizer = wx.BoxSizer(wx.HORIZONTAL) + main_sizer.AddSizer(column_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + + if type == "contact": + left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=9, vgap=5) + else: + left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5) + left_gridsizer.AddGrowableCol(0) + column_sizer.AddSizer(left_gridsizer, 1, border=5, + flag=wx.GROW|wx.RIGHT) + + modifier_label = wx.StaticText(self, label=_('Modifier:')) + left_gridsizer.AddWindow(modifier_label, flag=wx.GROW) + + self.Normal = wx.RadioButton(self, label=_("Normal"), style=wx.RB_GROUP) + self.Normal.SetValue(True) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Normal) + left_gridsizer.AddWindow(self.Normal, flag=wx.GROW) + + self.Negated = wx.RadioButton(self, label=_("Negated")) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Negated) + left_gridsizer.AddWindow(self.Negated, flag=wx.GROW) + + if type == "contact": + self.Set = wx.RadioButton(self, label=_("Set")) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Set) + left_gridsizer.AddWindow(self.Set, flag=wx.GROW) + + self.Reset = wx.RadioButton(self, label=_("Reset")) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.Reset) + left_gridsizer.AddWindow(self.Reset, flag=wx.GROW) + + self.RisingEdge = wx.RadioButton(self, label=_("Rising Edge")) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.RisingEdge) + left_gridsizer.AddWindow(self.RisingEdge, flag=wx.GROW) + + self.FallingEdge = wx.RadioButton(self, label=_("Falling Edge")) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.FallingEdge) + left_gridsizer.AddWindow(self.FallingEdge, flag=wx.GROW) + + element_name_label = wx.StaticText(self, label=_('Name:')) + left_gridsizer.AddWindow(element_name_label, flag=wx.GROW) + + self.ElementName = wx.ComboBox(self, style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnNameChanged, self.ElementName) + left_gridsizer.AddWindow(self.ElementName, flag=wx.GROW) + + right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) + right_gridsizer.AddGrowableCol(0) + right_gridsizer.AddGrowableRow(1) + column_sizer.AddSizer(right_gridsizer, 1, border=5, + flag=wx.GROW|wx.LEFT) + + preview_sizer = wx.StaticText(self, label=_('Preview:')) + right_gridsizer.AddWindow(preview_sizer, flag=wx.GROW) + + self.Preview = wx.Panel(self, + style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) setattr(self.Preview, "GetScaling", lambda:None) - setattr(self.Preview, "IsOfType", ctrler.IsOfType) - - self.Spacer = wx.Panel(id=ID_LDELEMENTDIALOGSPACER, - name='Spacer', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - - if wx.VERSION >= (2, 5, 0): - self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) + setattr(self.Preview, "IsOfType", controller.IsOfType) + self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) + + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + main_sizer.AddSizer(button_sizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + + self.SetSizer(main_sizer) + + if type == "contact": + self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "") else: - wx.EVT_PAINT(self.Preview, self.OnPaint) - - self._init_sizers() - - def __init__(self, parent, controler, type): + self.Element = LD_Coil(self.Preview, COIL_NORMAL, "") + self.Type = type - if type == "contact": - self._init_ctrls(parent, controler, _("Edit Contact Values")) - self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "") - self.radioButton3.Hide() - self.radioButton4.Hide() - elif type == "coil": - self._init_ctrls(parent, controler, _("Edit Coil Values"), 50) - self.Element = LD_Coil(self.Preview, COIL_NORMAL, "") - - self.radioButton1.SetFocus() + + self.Normal.SetFocus() def SetPreviewFont(self, font): self.Preview.SetFont(font) @@ -218,26 +147,26 @@ self.Element.SetType(value) if self.Type == "contact": if value == CONTACT_NORMAL: - self.radioButton1.SetValue(True) + self.Normal.SetValue(True) elif value == CONTACT_REVERSE: - self.radioButton2.SetValue(True) + self.Negated.SetValue(True) elif value == CONTACT_RISING: - self.radioButton5.SetValue(True) + self.RisingEdge.SetValue(True) elif value == CONTACT_FALLING: - self.radioButton6.SetValue(True) + self.FallingEdge.SetValue(True) elif self.Type == "coil": if value == COIL_NORMAL: - self.radioButton1.SetValue(True) + self.Normal.SetValue(True) elif value == COIL_REVERSE: - self.radioButton2.SetValue(True) + self.Negated.SetValue(True) elif value == COIL_SET: - self.radioButton3.SetValue(True) + self.Set.SetValue(True) elif value == COIL_RESET: - self.radioButton4.SetValue(True) + self.Reset.SetValue(True) elif value == COIL_RISING: - self.radioButton5.SetValue(True) + self.RisingEdge.SetValue(True) elif value == COIL_FALLING: - self.radioButton6.SetValue(True) + self.FallingEdge.SetValue(True) def GetValues(self): values = {} @@ -248,26 +177,26 @@ def OnTypeChanged(self, event): if self.Type == "contact": - if self.radioButton1.GetValue(): + if self.Normal.GetValue(): self.Element.SetType(CONTACT_NORMAL) - elif self.radioButton2.GetValue(): + elif self.Negated.GetValue(): self.Element.SetType(CONTACT_REVERSE) - elif self.radioButton5.GetValue(): + elif self.RisingEdge.GetValue(): self.Element.SetType(CONTACT_RISING) - elif self.radioButton6.GetValue(): + elif self.FallingEdge.GetValue(): self.Element.SetType(CONTACT_FALLING) elif self.Type == "coil": - if self.radioButton1.GetValue(): + if self.Normal.GetValue(): self.Element.SetType(COIL_NORMAL) - elif self.radioButton2.GetValue(): + elif self.Negated.GetValue(): self.Element.SetType(COIL_REVERSE) - elif self.radioButton3.GetValue(): + elif self.Set.GetValue(): self.Element.SetType(COIL_SET) - elif self.radioButton4.GetValue(): + elif self.Reset.GetValue(): self.Element.SetType(COIL_RESET) - elif self.radioButton5.GetValue(): + elif self.RisingEdge.GetValue(): self.Element.SetType(COIL_RISING) - elif self.radioButton6.GetValue(): + elif self.FallingEdge.GetValue(): self.Element.SetType(COIL_FALLING) self.RefreshPreview() event.Skip() diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/LDPowerRailDialog.py --- a/dialogs/LDPowerRailDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/LDPowerRailDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -25,145 +25,85 @@ from graphics import * - #------------------------------------------------------------------------------- # Edit Ladder Power Rail Properties Dialog #------------------------------------------------------------------------------- - -[ID_LDPOWERRAILDIALOG, ID_LDPOWERRAILDIALOGSPACER, - ID_LDPOWERRAILDIALOGTYPE, ID_LDPOWERRAILDIALOGRADIOBUTTON1, - ID_LDPOWERRAILDIALOGRADIOBUTTON2, ID_LDPOWERRAILDIALOGPREVIEW, - ID_LDPOWERRAILDIALOGSTATICTEXT1, ID_LDPOWERRAILDIALOGSTATICTEXT2, - ID_LDPOWERRAILDIALOGSTATICTEXT3, ID_LDPOWERRAILDIALOGPINNUMBER, -] = [wx.NewId() for _init_ctrls in range(10)] - class LDPowerRailDialog(wx.Dialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_flexGridSizer1_Items(self, parent): - parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + def __init__(self, parent, controller, type = LEFTRAIL, number = 1): + wx.Dialog.__init__(self, parent, size=wx.Size(350, 260), + title=_('Power Rail Properties')) - def _init_coll_flexGridSizer1_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_coll_MainSizer_Items(self, parent): - parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) - - def _init_coll_LeftGridSizer_Items(self, parent): - parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.PinNumber, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) - - def _init_coll_LeftGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(5) - - def _init_coll_RightGridSizer_Items(self, parent): - parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(0) - def _init_coll_RightGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_sizers(self): - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) - self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5) - self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - - self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) - self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) - self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) - self._init_coll_RightGridSizer_Items(self.RightGridSizer) - self._init_coll_RightGridSizer_Growables(self.RightGridSizer) - - self.SetSizer(self.flexGridSizer1) - - def _init_ctrls(self, prnt, ctrler): - wx.Dialog.__init__(self, id=ID_LDPOWERRAILDIALOG, - name='PowerRailDialog', parent=prnt, - size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE, - title=_('Power Rail Properties')) - self.SetClientSize(wx.Size(350, 260)) - - self.staticText1 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT1, - label=_('Type:'), name='staticText1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText2 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT2, - label=_('Pin number:'), name='staticText2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText3 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT3, - label=_('Preview:'), name='staticText3', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.radioButton1 = wx.RadioButton(id=ID_LDPOWERRAILDIALOGRADIOBUTTON1, - label=_('Left PowerRail'), name='radioButton1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDPOWERRAILDIALOGRADIOBUTTON1) - self.radioButton1.SetValue(True) - - self.radioButton2 = wx.RadioButton(id=ID_LDPOWERRAILDIALOGRADIOBUTTON2, - label=_('Right PowerRail'), name='radioButton2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDPOWERRAILDIALOGRADIOBUTTON2) - - self.PinNumber = wx.SpinCtrl(id=ID_LDPOWERRAILDIALOGPINNUMBER, - name='PinNumber', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=1, max=50) - self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, id=ID_LDPOWERRAILDIALOGPINNUMBER) - - self.Preview = wx.Panel(id=ID_LDPOWERRAILDIALOGPREVIEW, - name='Preview', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) + column_sizer = wx.BoxSizer(wx.HORIZONTAL) + main_sizer.AddSizer(column_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + + left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=5, vgap=5) + left_gridsizer.AddGrowableCol(0) + column_sizer.AddSizer(left_gridsizer, 1, border=5, + flag=wx.GROW|wx.RIGHT) + + type_label = wx.StaticText(self, label=_('Type:')) + left_gridsizer.AddWindow(type_label, flag=wx.GROW) + + self.LeftPowerRail = wx.RadioButton(self, + label=_('Left PowerRail'), style=wx.RB_GROUP) + self.LeftPowerRail.SetValue(True) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.LeftPowerRail) + left_gridsizer.AddWindow(self.LeftPowerRail, flag=wx.GROW) + + self.RightPowerRail = wx.RadioButton(self, label=_('Right PowerRail')) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.RightPowerRail) + left_gridsizer.AddWindow(self.RightPowerRail, flag=wx.GROW) + + pin_number_label = wx.StaticText(self, label=_('Pin number:')) + left_gridsizer.AddWindow(pin_number_label, flag=wx.GROW) + + self.PinNumber = wx.SpinCtrl(self, min=1, max=50, + style=wx.SP_ARROW_KEYS) + self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, self.PinNumber) + left_gridsizer.AddWindow(self.PinNumber, flag=wx.GROW) + + right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) + right_gridsizer.AddGrowableCol(0) + right_gridsizer.AddGrowableRow(1) + column_sizer.AddSizer(right_gridsizer, 1, border=5, + flag=wx.GROW|wx.LEFT) + + preview_label = wx.StaticText(self, label=_('Preview:')) + right_gridsizer.AddWindow(preview_label, flag=wx.GROW) + + self.Preview = wx.Panel(self, + style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) setattr(self.Preview, "GetScaling", lambda:None) - setattr(self.Preview, "IsOfType", ctrler.IsOfType) - - self.Spacer = wx.Panel(id=ID_LDPOWERRAILDIALOGSPACER, - name='Spacer', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + setattr(self.Preview, "IsOfType", controller.IsOfType) + self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) + right_gridsizer.AddWindow(self.Preview, flag=wx.GROW) - if wx.VERSION >= (2, 5, 0): - self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) - else: - wx.EVT_PAINT(self.Preview, self.OnPaint) + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + main_sizer.AddSizer(button_sizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - self._init_sizers() - - def __init__(self, parent, controler, type = LEFTRAIL, number = 1): - self._init_ctrls(parent, controler) + self.SetSizer(main_sizer) + self.Type = type if type == LEFTRAIL: - self.radioButton1.SetValue(True) + self.LeftPowerRail.SetValue(True) elif type == RIGHTRAIL: - self.radioButton2.SetValue(True) + self.RightPowerRail.SetValue(True) self.PinNumber.SetValue(number) self.PowerRailMinSize = (0, 0) self.PowerRail = None - self.radioButton1.SetFocus() + self.LeftPowerRail.SetFocus() def SetPreviewFont(self, font): self.Preview.SetFont(font) @@ -180,9 +120,9 @@ return values def OnTypeChanged(self, event): - if self.radioButton1.GetValue(): + if self.LeftPowerRail.GetValue(): self.Type = LEFTRAIL - elif self.radioButton2.GetValue(): + elif self.RightPowerRail.GetValue(): self.Type = RIGHTRAIL self.RefreshPreview() event.Skip() diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/PouActionDialog.py --- a/dialogs/PouActionDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/PouActionDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -34,10 +34,8 @@ class PouActionDialog(wx.Dialog): def __init__(self, parent): - wx.Dialog.__init__(self, id=-1, parent=parent, - name='PouActionDialog', title=_('Create a new action'), - size=wx.Size(320, 200), style=wx.DEFAULT_DIALOG_STYLE) - self.SetClientSize(wx.Size(320, 160)) + wx.Dialog.__init__(self, parent, size=wx.Size(320, 160), + title=_('Create a new action')) main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) main_sizer.AddGrowableCol(0) @@ -45,35 +43,28 @@ infos_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=3, vgap=15) infos_sizer.AddGrowableCol(1) - main_sizer.AddSizer(infos_sizer, 0, border=20, - flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + main_sizer.AddSizer(infos_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - actionname_label = wx.StaticText(id=-1, parent=self, - label=_('Action Name:'), name='actionname_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - infos_sizer.AddWindow(actionname_label, 0, border=4, - flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) + actionname_label = wx.StaticText(self, label=_('Action Name:')) + infos_sizer.AddWindow(actionname_label, border=4, + flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) - self.ActionName = wx.TextCtrl(id=-1, parent=self, - name='ActionName', pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=0) - infos_sizer.AddWindow(self.ActionName, 0, border=0, flag=wx.GROW) + self.ActionName = wx.TextCtrl(self) + infos_sizer.AddWindow(self.ActionName, flag=wx.GROW) - language_label = wx.StaticText(id=-1, parent=self, - label=_('Language:'), name='language_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - infos_sizer.AddWindow(language_label, 0, border=4, - flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) + language_label = wx.StaticText(self, label=_('Language:')) + infos_sizer.AddWindow(language_label, border=4, + flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) - self.Language = wx.ComboBox(id=ID_POUACTIONDIALOGLANGUAGE, - name='Language', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) - infos_sizer.AddWindow(self.Language, 0, border=0, flag=wx.GROW) + self.Language = wx.ComboBox(self, style=wx.CB_READONLY) + infos_sizer.AddWindow(self.Language, flag=wx.GROW) - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - main_sizer.AddSizer(self.ButtonSizer, 0, border=20, - flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, + button_sizer.GetAffirmativeButton()) + main_sizer.AddSizer(self.ButtonSizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) self.SetSizer(main_sizer) diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/PouDialog.py --- a/dialogs/PouDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/PouDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -50,47 +50,35 @@ infos_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=3, vgap=15) infos_sizer.AddGrowableCol(1) - main_sizer.AddSizer(infos_sizer, 0, border=20, - flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + main_sizer.AddSizer(infos_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - pouname_label = wx.StaticText(id=-1, parent=self, - label=_('POU Name:'), name='pouname_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - infos_sizer.AddWindow(pouname_label, 0, border=4, - flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) + pouname_label = wx.StaticText(self, label=_('POU Name:')) + infos_sizer.AddWindow(pouname_label, border=4, + flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) - self.PouName = wx.TextCtrl(id=-1, parent=self, - name='POUName', pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=0) - infos_sizer.AddWindow(self.PouName, 0, border=0, flag=wx.GROW) + self.PouName = wx.TextCtrl(self) + infos_sizer.AddWindow(self.PouName, flag=wx.GROW) - poutype_label = wx.StaticText(id=-1, parent=self, - label=_('POU Type:'), name='poutype_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - infos_sizer.AddWindow(poutype_label, 0, border=4, - flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) + poutype_label = wx.StaticText(self, label=_('POU Type:')) + infos_sizer.AddWindow(poutype_label, border=4, + flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) - self.PouType = wx.ComboBox(id=-1, parent=self, - name='POUType', pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnTypeChanged, id=self.PouType.GetId()) - infos_sizer.AddWindow(self.PouType, 0, border=0, flag=wx.GROW) + self.PouType = wx.ComboBox(self, style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnTypeChanged, self.PouType) + infos_sizer.AddWindow(self.PouType, flag=wx.GROW) - language_label = wx.StaticText(id=-1, parent=self, - label=_('Language:'), name='language_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - infos_sizer.AddWindow(language_label, 0, border=4, - flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) + language_label = wx.StaticText(self, label=_('Language:')) + infos_sizer.AddWindow(language_label, border=4, + flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) - self.Language = wx.ComboBox(id=-1, parent=self, - name='Language', pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) - infos_sizer.AddWindow(self.Language, 0, border=0, flag=wx.GROW) + self.Language = wx.ComboBox(self, style=wx.CB_READONLY) + infos_sizer.AddWindow(self.Language, flag=wx.GROW) - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - main_sizer.AddSizer(self.ButtonSizer, 0, border=20, - flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) + main_sizer.AddSizer(button_sizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) self.SetSizer(main_sizer) @@ -181,5 +169,3 @@ values["pouType"] = POU_TYPES_DICT[self.PouType.GetStringSelection()] values["language"] = POU_LANGUAGES_DICT[self.Language.GetStringSelection()] return values - - diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/PouNameDialog.py --- a/dialogs/PouNameDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/PouNameDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -29,49 +29,33 @@ class PouNameDialog(wx.TextEntryDialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition): wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos) self.PouNames = [] - if wx.VERSION >= (2, 8, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId()) - elif wx.VERSION >= (2, 6, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId()) - else: - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) - + + self.Bind(wx.EVT_BUTTON, self.OnOK, + self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton()) + def OnOK(self, event): + message = None step_name = self.GetSizer().GetItem(1).GetWindow().GetValue() if step_name == "": - message = wx.MessageDialog(self, _("You must type a name!"), _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("You must type a name!") elif not TestIdentifier(step_name): - message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" is not a valid identifier!") % step_name elif step_name.upper() in IEC_KEYWORDS: - message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" is a keyword. It can't be used!") % step_name elif step_name.upper() in self.PouNames: - message = wx.MessageDialog(self, _("A POU named \"%s\" already exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("A POU named \"%s\" already exists!") % step_name + if message is not None: + dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) + dialog.ShowModal() + dialog.Destroy() else: self.EndModal(wx.ID_OK) def SetPouNames(self, pou_names): self.PouNames = [pou_name.upper() for pou_name in pou_names] - def GetValue(self): - return self.GetSizer().GetItem(1).GetWindow().GetValue() diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/PouTransitionDialog.py --- a/dialogs/PouTransitionDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/PouTransitionDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -26,6 +26,10 @@ from plcopen.structures import TestIdentifier, IEC_KEYWORDS +#------------------------------------------------------------------------------- +# POU Transition Dialog +#------------------------------------------------------------------------------- + def GetTransitionLanguages(): _ = lambda x : x return [_("IL"), _("ST"), _("LD"), _("FBD")] @@ -34,10 +38,8 @@ class PouTransitionDialog(wx.Dialog): def __init__(self, parent): - wx.Dialog.__init__(self, id=-1, parent=parent, - name='PouTransitionDialog', title=_('Create a new transition'), - size=wx.Size(350, 200), style=wx.DEFAULT_DIALOG_STYLE) - self.SetClientSize(wx.Size(350, 160)) + wx.Dialog.__init__(self, parent, size=wx.Size(350, 160), + title=_('Create a new transition')) main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) main_sizer.AddGrowableCol(0) @@ -45,35 +47,27 @@ infos_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=3, vgap=15) infos_sizer.AddGrowableCol(1) - main_sizer.AddSizer(infos_sizer, 0, border=20, - flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + main_sizer.AddSizer(infos_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - transitionname_label = wx.StaticText(id=-1, parent=self, - label=_('Transition Name:'), name='transitionname_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - infos_sizer.AddWindow(transitionname_label, 0, border=4, - flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) + transitionname_label = wx.StaticText(self, label=_('Transition Name:')) + infos_sizer.AddWindow(transitionname_label, border=4, + flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) - self.TransitionName = wx.TextCtrl(id=-1, parent=self, - name='TransitionName', pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=0) - infos_sizer.AddWindow(self.TransitionName, 0, border=0, flag=wx.GROW) + self.TransitionName = wx.TextCtrl(self) + infos_sizer.AddWindow(self.TransitionName, flag=wx.GROW) - language_label = wx.StaticText(id=-1, parent=self, - label=_('Language:'), name='language_label', - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - infos_sizer.AddWindow(language_label, 0, border=4, - flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) + language_label = wx.StaticText(self, label=_('Language:')) + infos_sizer.AddWindow(language_label, border=4, + flag=wx.ALIGN_CENTER_VERTICAL|wx.TOP) - self.Language = wx.ComboBox(id=-1, parent=self, - name='Language', pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) - infos_sizer.AddWindow(self.Language, 0, border=0, flag=wx.GROW) + self.Language = wx.ComboBox(self, style=wx.CB_READONLY) + infos_sizer.AddWindow(self.Language, flag=wx.GROW) - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - main_sizer.AddSizer(self.ButtonSizer, 0, border=20, - flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton()) + main_sizer.AddSizer(button_sizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) self.SetSizer(main_sizer) diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/ProjectDialog.py --- a/dialogs/ProjectDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/ProjectDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -29,21 +29,22 @@ class ProjectDialog(wx.Dialog): def __init__(self, parent, enable_required=True): - wx.Dialog.__init__(self, id=-1, parent=parent, - name='ProjectDialog', title=_('Project properties'), + wx.Dialog.__init__(self, parent, title=_('Project properties'), size=wx.Size(500, 350), style=wx.DEFAULT_DIALOG_STYLE) - self.SetClientSize(wx.Size(500, 350)) main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) main_sizer.AddGrowableCol(0) main_sizer.AddGrowableRow(0) - self.ProjectProperties = ProjectPropertiesPanel(self, enable_required=enable_required) - main_sizer.AddWindow(self.ProjectProperties, 0, border=0, flag=wx.GROW) + self.ProjectProperties = ProjectPropertiesPanel(self, + enable_required=enable_required) + main_sizer.AddWindow(self.ProjectProperties, flag=wx.GROW) self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - main_sizer.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + self.Bind(wx.EVT_BUTTON, self.OnOK, + self.ButtonSizer.GetAffirmativeButton()) + main_sizer.AddSizer(self.ButtonSizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) self.SetSizer(main_sizer) @@ -65,9 +66,11 @@ text += " and %s"%item else: text += ", %s"%item - message = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + dialog = wx.MessageDialog(self, + _("Form isn't complete. %s must be filled!") % text, + _("Error"), wx.OK|wx.ICON_ERROR) + dialog.ShowModal() + dialog.Destroy() else: self.EndModal(wx.ID_OK) diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/SFCDivergenceDialog.py --- a/dialogs/SFCDivergenceDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/SFCDivergenceDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -29,159 +29,97 @@ # Create New Divergence Dialog #------------------------------------------------------------------------------- -[ID_SFCDIVERGENCEDIALOG, ID_SFCDIVERGENCEDIALOGSPACER, - ID_SFCDIVERGENCEDIALOGRADIOBUTTON1, ID_SFCDIVERGENCEDIALOGRADIOBUTTON2, - ID_SFCDIVERGENCEDIALOGRADIOBUTTON3, ID_SFCDIVERGENCEDIALOGRADIOBUTTON4, - ID_SFCDIVERGENCEDIALOGSEQUENCES, ID_SFCDIVERGENCEDIALOGPREVIEW, - ID_SFCDIVERGENCEDIALOGSTATICTEXT1, ID_SFCDIVERGENCEDIALOGSTATICTEXT2, - ID_SFCDIVERGENCEDIALOGSTATICTEXT3, -] = [wx.NewId() for _init_ctrls in range(11)] - class SFCDivergenceDialog(wx.Dialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_flexGridSizer1_Items(self, parent): - parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + def __init__(self, parent, controller): + wx.Dialog.__init__(self, parent, size=wx.Size(500, 300), + title=_('Create a new divergence or convergence')) - def _init_coll_flexGridSizer1_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_coll_MainSizer_Items(self, parent): - parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) - - def _init_coll_LeftGridSizer_Items(self, parent): - parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton4, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Sequences, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) - - def _init_coll_LeftGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(7) - - def _init_coll_RightGridSizer_Items(self, parent): - parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(0) - def _init_coll_RightGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) + column_sizer = wx.BoxSizer(wx.HORIZONTAL) + main_sizer.AddSizer(column_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + + left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5) + left_gridsizer.AddGrowableCol(0) + column_sizer.AddSizer(left_gridsizer, 1, border=5, + flag=wx.GROW|wx.RIGHT) + + type_label = wx.StaticText(self, label=_('Type:')) + left_gridsizer.AddWindow(type_label, flag=wx.GROW) - def _init_sizers(self): - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) - self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5) - self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - - self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) - self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) - self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) - self._init_coll_RightGridSizer_Items(self.RightGridSizer) - self._init_coll_RightGridSizer_Growables(self.RightGridSizer) - - self.SetSizer(self.flexGridSizer1) - - def _init_ctrls(self, prnt, ctrler): - wx.Dialog.__init__(self, id=ID_SFCDIVERGENCEDIALOG, - name='SFCDivergenceDialog', parent=prnt, - size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE, - title=_('Create a new divergence or convergence')) - self.SetClientSize(wx.Size(500, 300)) - - self.staticText1 = wx.StaticText(id=ID_SFCDIVERGENCEDIALOGSTATICTEXT1, - label=_('Type:'), name='staticText1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.radioButton1 = wx.RadioButton(id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON1, - label=_('Selection Divergence'), name='radioButton1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON1) - self.radioButton1.SetValue(True) - - self.radioButton2 = wx.RadioButton(id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON2, - label=_('Selection Convergence'), name='radioButton2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON2) - self.radioButton2.SetValue(False) - - self.radioButton3 = wx.RadioButton(id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON3, - label=_('Simultaneous Divergence'), name='radioButton3', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON3) - self.radioButton3.SetValue(False) - - self.radioButton4 = wx.RadioButton(id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON4, - label=_('Simultaneous Convergence'), name='radioButton4', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_SFCDIVERGENCEDIALOGRADIOBUTTON4) - self.radioButton4.SetValue(False) - - self.staticText2 = wx.StaticText(id=ID_SFCDIVERGENCEDIALOGSTATICTEXT2, - label=_('Number of sequences:'), name='staticText2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.Sequences = wx.SpinCtrl(id=ID_SFCDIVERGENCEDIALOGSEQUENCES, - name='Sequences', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=0, min=2, max=20) - self.Bind(wx.EVT_SPINCTRL, self.OnSequencesChanged, id=ID_SFCDIVERGENCEDIALOGSEQUENCES) - - self.staticText3 = wx.StaticText(id=ID_SFCDIVERGENCEDIALOGSTATICTEXT3, - label=_('Preview:'), name='staticText3', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.Preview = wx.Panel(id=ID_SFCDIVERGENCEDIALOGPREVIEW, - name='Preview', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) + self.SelectionDivergence = wx.RadioButton(self, + label=_('Selection Divergence'), style=wx.RB_GROUP) + self.SelectionDivergence.SetValue(True) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, + self.SelectionDivergence) + left_gridsizer.AddWindow(self.SelectionDivergence, flag=wx.GROW) + + self.SelectionConvergence = wx.RadioButton(self, + label=_('Selection Convergence')) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, + self.SelectionConvergence) + left_gridsizer.AddWindow(self.SelectionConvergence, flag=wx.GROW) + + self.SimultaneousDivergence = wx.RadioButton(self, + label=_('Simultaneous Divergence')) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, + self.SimultaneousDivergence) + left_gridsizer.AddWindow(self.SimultaneousDivergence, flag=wx.GROW) + + self.SimultaneousConvergence = wx.RadioButton(self, + label=_('Simultaneous Convergence')) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, + self.SimultaneousConvergence) + left_gridsizer.AddWindow(self.SimultaneousConvergence, flag=wx.GROW) + + sequences_label = wx.StaticText(self, + label=_('Number of sequences:')) + left_gridsizer.AddWindow(sequences_label, flag=wx.GROW) + + self.Sequences = wx.SpinCtrl(self, min=2, max=20) + self.Bind(wx.EVT_SPINCTRL, self.OnSequencesChanged, self.Sequences) + left_gridsizer.AddWindow(self.Sequences, flag=wx.GROW) + + right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) + right_gridsizer.AddGrowableCol(0) + right_gridsizer.AddGrowableRow(1) + column_sizer.AddSizer(right_gridsizer, 1, border=5, + flag=wx.GROW|wx.LEFT) + + preview_label = wx.StaticText(self, label=_('Preview:')) + right_gridsizer.AddWindow(preview_label, flag=wx.GROW) + + self.Preview = wx.Panel(self, style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) + self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) - setattr(self.Preview, "IsOfType", ctrler.IsOfType) - - self.Spacer = wx.Panel(id=ID_SFCDIVERGENCEDIALOGSPACER, - name='Spacer', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + setattr(self.Preview, "IsOfType", controller.IsOfType) + right_gridsizer.AddWindow(self.Preview, flag=wx.GROW) - if wx.VERSION >= (2, 5, 0): - self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) - else: - wx.EVT_PAINT(self.Preview, self.OnPaint) + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + main_sizer.AddSizer(button_sizer, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - self._init_sizers() - - def __init__(self, parent, controler): - self._init_ctrls(parent, controler) + self.SetSizer(main_sizer) self.Divergence = None self.MinSize = (0, 0) - self.radioButton1.SetFocus() + self.SelectionDivergence.SetFocus() def SetPreviewFont(self, font): self.Preview.SetFont(font) def GetValues(self): values = {} - if self.radioButton1.GetValue(): + if self.SelectionDivergence.GetValue(): values["type"] = SELECTION_DIVERGENCE - elif self.radioButton2.GetValue(): + elif self.SelectionConvergence.GetValue(): values["type"] = SELECTION_CONVERGENCE - elif self.radioButton3.GetValue(): + elif self.SimultaneousDivergence.GetValue(): values["type"] = SIMULTANEOUS_DIVERGENCE else: values["type"] = SIMULTANEOUS_CONVERGENCE @@ -203,11 +141,11 @@ dc = wx.ClientDC(self.Preview) dc.SetFont(self.Preview.GetFont()) dc.Clear() - if self.radioButton1.GetValue(): + if self.SelectionDivergence.GetValue(): self.Divergence = SFC_Divergence(self.Preview, SELECTION_DIVERGENCE, self.Sequences.GetValue()) - elif self.radioButton2.GetValue(): + elif self.SelectionConvergence.GetValue(): self.Divergence = SFC_Divergence(self.Preview, SELECTION_CONVERGENCE, self.Sequences.GetValue()) - elif self.radioButton3.GetValue(): + elif self.SimultaneousDivergence.GetValue(): self.Divergence = SFC_Divergence(self.Preview, SIMULTANEOUS_DIVERGENCE, self.Sequences.GetValue()) else: self.Divergence = SFC_Divergence(self.Preview, SIMULTANEOUS_CONVERGENCE, self.Sequences.GetValue()) diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/SFCStepDialog.py --- a/dialogs/SFCStepDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/SFCStepDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -29,135 +29,75 @@ # Edit Step Content Dialog #------------------------------------------------------------------------------- -[ID_SFCSTEPDIALOG, ID_SFCSTEPDIALOGSPACER, - ID_SFCSTEPDIALOGNAME, ID_SFCSTEPDIALOGPREVIEW, - ID_SFCSTEPDIALOGCHECKBOX1, ID_SFCSTEPDIALOGCHECKBOX2, - ID_SFCSTEPDIALOGCHECKBOX3, ID_SFCSTEPDIALOGSTATICTEXT1, - ID_SFCSTEPDIALOGSTATICTEXT2, ID_SFCSTEPDIALOGSTATICTEXT3, -] = [wx.NewId() for _init_ctrls in range(10)] - class SFCStepDialog(wx.Dialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_flexGridSizer1_Items(self, parent): - parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - - def _init_coll_flexGridSizer1_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_coll_MainSizer_Items(self, parent): - parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) - - def _init_coll_LeftGridSizer_Items(self, parent): - parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.StepName, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.checkBox1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.checkBox2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.checkBox3, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) - - def _init_coll_LeftGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(6) - - def _init_coll_RightGridSizer_Items(self, parent): - parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) - - def _init_coll_RightGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_sizers(self): - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) - self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5) - self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - - self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) - self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) - self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) - self._init_coll_RightGridSizer_Items(self.RightGridSizer) - self._init_coll_RightGridSizer_Growables(self.RightGridSizer) - - self.SetSizer(self.flexGridSizer1) - - def _init_ctrls(self, prnt, ctrler): - wx.Dialog.__init__(self, id=ID_SFCSTEPDIALOG, - name='SFCStepDialog', parent=prnt, - size=wx.Size(400, 250), style=wx.DEFAULT_DIALOG_STYLE, - title=_('Edit Step')) - self.SetClientSize(wx.Size(400, 250)) - - self.staticText1 = wx.StaticText(id=ID_SFCSTEPDIALOGSTATICTEXT1, - label=_('Name:'), name='staticText1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText2 = wx.StaticText(id=ID_SFCSTEPDIALOGSTATICTEXT2, - label=_('Connectors:'), name='staticText2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText3 = wx.StaticText(id=ID_SFCSTEPDIALOGSTATICTEXT3, - label=_('Preview:'), name='staticText4', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.StepName = wx.TextCtrl(id=ID_SFCSTEPDIALOGNAME, - name='Name', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_TEXT, self.OnNameChanged, id=ID_SFCSTEPDIALOGNAME) - - self.checkBox1 = wx.CheckBox(id=ID_SFCSTEPDIALOGCHECKBOX1, - label=_("Input"), name='checkBox1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, id=ID_SFCSTEPDIALOGCHECKBOX1) - - self.checkBox2 = wx.CheckBox(id=ID_SFCSTEPDIALOGCHECKBOX2, - label=_("Output"), name='checkBox2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, id=ID_SFCSTEPDIALOGCHECKBOX2) - - self.checkBox3 = wx.CheckBox(id=ID_SFCSTEPDIALOGCHECKBOX3, - label=_("Action"), name='checkBox3', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, id=ID_SFCSTEPDIALOGCHECKBOX3) - - self.Spacer = wx.Panel(id=ID_SFCSTEPDIALOGSPACER, - name='Spacer', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.Preview = wx.Panel(id=ID_SFCSTEPDIALOGPREVIEW, - name='Preview', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) + def __init__(self, parent, controller, initial = False): + wx.Dialog.__init__(self, parent, title=_('Edit Step'), + size=wx.Size(400, 250), style=wx.DEFAULT_DIALOG_STYLE) + + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(0) + + column_sizer = wx.BoxSizer(wx.HORIZONTAL) + main_sizer.AddSizer(column_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + + left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5) + left_gridsizer.AddGrowableCol(0) + column_sizer.AddSizer(left_gridsizer, 1, border=5, + flag=wx.GROW|wx.RIGHT) + + name_label = wx.StaticText(self, label=_('Name:')) + left_gridsizer.AddWindow(name_label, flag=wx.GROW) + + self.StepName = wx.TextCtrl(self) + self.Bind(wx.EVT_TEXT, self.OnNameChanged, self.StepName) + left_gridsizer.AddWindow(self.StepName, flag=wx.GROW) + + connectors_label = wx.StaticText(self, label=_('Connectors:')) + left_gridsizer.AddWindow(connectors_label, flag=wx.GROW) + + self.Input = wx.CheckBox(self, label=_("Input")) + self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, self.Input) + left_gridsizer.AddWindow(self.Input, flag=wx.GROW) + + self.Output = wx.CheckBox(self, label=_("Output")) + self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, self.Output) + left_gridsizer.AddWindow(self.Output, flag=wx.GROW) + + self.Action = wx.CheckBox(self, label=_("Action")) + self.Bind(wx.EVT_CHECKBOX, self.OnConnectorsChanged, self.Action) + left_gridsizer.AddWindow(self.Action, flag=wx.GROW) + + right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) + right_gridsizer.AddGrowableCol(0) + right_gridsizer.AddGrowableRow(1) + column_sizer.AddSizer(right_gridsizer, 1, border=5, + flag=wx.GROW|wx.LEFT) + + preview_label = wx.StaticText(self, label=_('Preview:')) + right_gridsizer.AddWindow(preview_label, flag=wx.GROW) + + self.Preview = wx.Panel(self, + style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) setattr(self.Preview, "RefreshStepModel", lambda x:None) setattr(self.Preview, "GetScaling", lambda:None) - setattr(self.Preview, "IsOfType", ctrler.IsOfType) - - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - if wx.VERSION >= (2, 5, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) - else: - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) - wx.EVT_PAINT(self.Preview, self.OnPaint) - - self._init_sizers() - - def __init__(self, parent, controler, initial = False): - self._init_ctrls(parent, controler) + setattr(self.Preview, "IsOfType", controller.IsOfType) + self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) + right_gridsizer.AddWindow(self.Preview, flag=wx.GROW) + + button_sizer = self.CreateButtonSizer( + wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, + button_sizer.GetAffirmativeButton()) + main_sizer.AddSizer(button_sizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + + self.SetSizer(main_sizer) + self.Step = None self.Initial = initial self.MinStepSize = None @@ -172,31 +112,24 @@ self.Preview.SetFont(font) def OnOK(self, event): + message = None step_name = self.StepName.GetValue() if step_name == "": - message = wx.MessageDialog(self, _("You must type a name!"), _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("You must type a name!") elif not TestIdentifier(step_name): - message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" is not a valid identifier!") % step_name elif step_name.upper() in IEC_KEYWORDS: - message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" is a keyword. It can't be used!") % step_name elif step_name.upper() in self.PouNames: - message = wx.MessageDialog(self, _("A POU named \"%s\" already exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("A POU named \"%s\" already exists!") % step_name elif step_name.upper() in self.Variables: - message = wx.MessageDialog(self, _("A variable with \"%s\" as name already exists in this pou!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("A variable with \"%s\" as name already exists in this pou!") % step_name elif step_name.upper() in self.StepNames: - message = wx.MessageDialog(self, _("\"%s\" step already exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" step already exists!") % step_name + if message is not None: + dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) + dialog.ShowModal() + dialog.Destroy() else: self.EndModal(wx.ID_OK) @@ -218,17 +151,17 @@ self.StepName.SetValue(value_name) else: self.StepName.SetValue("") - self.checkBox1.SetValue(values.get("input", False)) - self.checkBox2.SetValue(values.get("output", False)) - self.checkBox3.SetValue(values.get("action", False)) + self.Input.SetValue(values.get("input", False)) + self.Output.SetValue(values.get("output", False)) + self.Action.SetValue(values.get("action", False)) self.RefreshPreview() def GetValues(self): values = {} values["name"] = self.StepName.GetValue() - values["input"] = self.checkBox1.IsChecked() - values["output"] = self.checkBox2.IsChecked() - values["action"] = self.checkBox3.IsChecked() + values["input"] = self.Input.IsChecked() + values["output"] = self.Output.IsChecked() + values["action"] = self.Action.IsChecked() values["width"], values["height"] = self.Step.GetSize() return values @@ -245,15 +178,15 @@ dc.SetFont(self.Preview.GetFont()) dc.Clear() self.Step = SFC_Step(self.Preview, self.StepName.GetValue(), self.Initial) - if self.checkBox1.IsChecked(): + if self.Input.IsChecked(): self.Step.AddInput() else: self.Step.RemoveInput() - if self.checkBox2.IsChecked(): + if self.Output.IsChecked(): self.Step.AddOutput() else: self.Step.RemoveOutput() - if self.checkBox3.IsChecked(): + if self.Action.IsChecked(): self.Step.AddAction() else: self.Step.RemoveAction() diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/SFCStepNameDialog.py --- a/dialogs/SFCStepNameDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/SFCStepNameDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -29,14 +29,6 @@ class SFCStepNameDialog(wx.TextEntryDialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition): wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos) @@ -44,39 +36,29 @@ self.PouNames = [] self.Variables = [] self.StepNames = [] - if wx.VERSION >= (2, 8, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton().GetId()) - elif wx.VERSION >= (2, 6, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId()) - else: - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) - + + self.Bind(wx.EVT_BUTTON, self.OnOK, + self.GetSizer().GetItem(2).GetSizer().GetItem(1).GetSizer().GetAffirmativeButton()) + def OnOK(self, event): + message = None step_name = self.GetSizer().GetItem(1).GetWindow().GetValue() if step_name == "": - message = wx.MessageDialog(self, _("You must type a name!"), _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("You must type a name!") elif not TestIdentifier(step_name): - message = wx.MessageDialog(self, _("\"%s\" is not a valid identifier!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" is not a valid identifier!") % step_name elif step_name.upper() in IEC_KEYWORDS: - message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" is a keyword. It can't be used!") % step_name elif step_name.upper() in self.PouNames: - message = wx.MessageDialog(self, _("A POU named \"%s\" already exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("A POU named \"%s\" already exists!") % step_name elif step_name.upper() in self.Variables: - message = wx.MessageDialog(self, _("A variable with \"%s\" as name already exists in this pou!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("A variable with \"%s\" as name already exists in this pou!") % step_name elif step_name.upper() in self.StepNames: - message = wx.MessageDialog(self, _("\"%s\" step already exists!")%step_name, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("\"%s\" step already exists!") % step_name + if message is not None: + dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) + dialog.ShowModal() + dialog.Destroy() else: self.EndModal(wx.ID_OK) @@ -88,6 +70,3 @@ def SetStepNames(self, step_names): self.StepNames = [step_name.upper() for step_name in step_names] - - def GetValue(self): - return self.GetSizer().GetItem(1).GetWindow().GetValue() diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/SFCTransitionDialog.py --- a/dialogs/SFCTransitionDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/SFCTransitionDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -29,161 +29,97 @@ # Edit Transition Content Dialog #------------------------------------------------------------------------------- -[ID_SFCTRANSITIONDIALOG, ID_SFCTRANSITIONDIALOGSPACER, - ID_SFCTRANSITIONDIALOGREFERENCE, ID_SFCTRANSITIONDIALOGINLINE, - ID_SFCTRANSITIONDIALOGPRIORITY, ID_SFCTRANSITIONDIALOGPREVIEW, - ID_SFCTRANSITIONDIALOGRADIOBUTTON1, ID_SFCTRANSITIONDIALOGRADIOBUTTON2, - ID_SFCTRANSITIONDIALOGRADIOBUTTON3, ID_SFCTRANSITIONDIALOGSTATICTEXT1, - ID_SFCTRANSITIONDIALOGSTATICTEXT2, ID_SFCTRANSITIONDIALOGSTATICTEXT3, -] = [wx.NewId() for _init_ctrls in range(12)] - class SFCTransitionDialog(wx.Dialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_flexGridSizer1_Items(self, parent): - parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - - def _init_coll_flexGridSizer1_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(0) - - def _init_coll_MainSizer_Items(self, parent): - parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT) - parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT) - - def _init_coll_LeftGridSizer_Items(self, parent): - parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Reference, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Inline, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Priority, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) - - def _init_coll_LeftGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(6) - - def _init_coll_RightGridSizer_Items(self, parent): - parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW) - - def _init_coll_RightGridSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_sizers(self): - self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) - self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) - self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=9, vgap=5) - self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) - - self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) - self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) - self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) - self._init_coll_RightGridSizer_Items(self.RightGridSizer) - self._init_coll_RightGridSizer_Growables(self.RightGridSizer) - - self.SetSizer(self.flexGridSizer1) - - def _init_ctrls(self, prnt, ctrler): - wx.Dialog.__init__(self, id=ID_SFCTRANSITIONDIALOG, - name='SFCTransitionDialog', parent=prnt, - size=wx.Size(350, 300), style=wx.DEFAULT_DIALOG_STYLE, - title=_('Edit transition')) - self.SetClientSize(wx.Size(350, 300)) - - self.staticText1 = wx.StaticText(id=ID_SFCTRANSITIONDIALOGSTATICTEXT1, - label=_('Type:'), name='staticText1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText2 = wx.StaticText(id=ID_SFCTRANSITIONDIALOGSTATICTEXT2, - label=_('Preview:'), name='staticText2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.staticText3 = wx.StaticText(id=ID_SFCTRANSITIONDIALOGSTATICTEXT3, - label=_('Priority:'), name='staticText3', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) - - self.radioButton1 = wx.RadioButton(id=ID_SFCTRANSITIONDIALOGRADIOBUTTON1, - label=_('Reference'), name='radioButton1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_SFCTRANSITIONDIALOGRADIOBUTTON1) - self.radioButton1.SetValue(True) - - self.Reference = wx.ComboBox(id=ID_SFCTRANSITIONDIALOGREFERENCE, - name='Reference', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 28), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnReferenceChanged, id=ID_SFCTRANSITIONDIALOGREFERENCE) - - self.radioButton2 = wx.RadioButton(id=ID_SFCTRANSITIONDIALOGRADIOBUTTON2, - label=_('Inline'), name='radioButton2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_SFCTRANSITIONDIALOGRADIOBUTTON2) - self.radioButton2.SetValue(False) - - self.Inline = wx.TextCtrl(id=ID_SFCTRANSITIONDIALOGINLINE, - name='Inline', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_TEXT, self.OnInlineChanged, id=ID_SFCTRANSITIONDIALOGINLINE) + def __init__(self, parent, controller, connection): + self.Connection = connection + + wx.Dialog.__init__(self, parent, + size=wx.Size(350, 300), title=_('Edit transition')) + + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(0) + + column_sizer = wx.BoxSizer(wx.HORIZONTAL) + main_sizer.AddSizer(column_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) + + left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5) + left_gridsizer.AddGrowableCol(0) + column_sizer.AddSizer(left_gridsizer, 1, border=5, + flag=wx.GROW|wx.RIGHT) + + type_label = wx.StaticText(self, label=_('Type:')) + left_gridsizer.AddWindow(type_label, flag=wx.GROW) + + self.ReferenceRadioButton = wx.RadioButton(self, + label=_('Reference'), style=wx.RB_GROUP) + self.ReferenceRadioButton.SetValue(True) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.ReferenceRadioButton) + left_gridsizer.AddWindow(self.ReferenceRadioButton, flag=wx.GROW) + + self.Reference = wx.ComboBox(self, style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnReferenceChanged, self.Reference) + left_gridsizer.AddWindow(self.Reference, flag=wx.GROW) + + self.InlineRadioButton = wx.RadioButton(self, label=_('Inline')) + self.InlineRadioButton.SetValue(False) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.InlineRadioButton) + left_gridsizer.AddWindow(self.InlineRadioButton, flag=wx.GROW) + + self.Inline = wx.TextCtrl(self) self.Inline.Enable(False) - - self.radioButton3 = wx.RadioButton(id=ID_SFCTRANSITIONDIALOGRADIOBUTTON3, - label=_('Connection'), name='radioButton3', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_SFCTRANSITIONDIALOGRADIOBUTTON3) - self.radioButton3.SetValue(False) + self.Bind(wx.EVT_TEXT, self.OnInlineChanged, self.Inline) + left_gridsizer.AddWindow(self.Inline, flag=wx.GROW) + + self.ConnectionRadioButton = wx.RadioButton(self, label=_('Connection')) + self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.ConnectionRadioButton) + self.ConnectionRadioButton.SetValue(False) if not self.Connection: - self.radioButton3.Hide() - - self.Priority = wx.SpinCtrl(id=ID_SFCTRANSITIONDIALOGPRIORITY, - name='Priority', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0) - self.Bind(wx.EVT_TEXT, self.OnPriorityChanged, id=ID_SFCTRANSITIONDIALOGPRIORITY) - - self.Preview = wx.Panel(id=ID_SFCTRANSITIONDIALOGPREVIEW, - name='Preview', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) + self.ConnectionRadioButton.Hide() + left_gridsizer.AddWindow(self.ConnectionRadioButton, flag=wx.GROW) + + priority_label = wx.StaticText(self, label=_('Priority:')) + left_gridsizer.AddWindow(priority_label, flag=wx.GROW) + + self.Priority = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS) + self.Bind(wx.EVT_TEXT, self.OnPriorityChanged, self.Priority) + left_gridsizer.AddWindow(self.Priority, flag=wx.GROW) + + right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) + right_gridsizer.AddGrowableCol(0) + right_gridsizer.AddGrowableRow(1) + column_sizer.AddSizer(right_gridsizer, 1, border=5, + flag=wx.GROW|wx.LEFT) + + preview_label = wx.StaticText(self, label=_('Preview:')) + right_gridsizer.AddWindow(preview_label, flag=wx.GROW) + + self.Preview = wx.Panel(self, + style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER) self.Preview.SetBackgroundColour(wx.Colour(255,255,255)) setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE) setattr(self.Preview, "RefreshTransitionModel", lambda x:None) setattr(self.Preview, "GetScaling", lambda:None) - setattr(self.Preview, "IsOfType", ctrler.IsOfType) - - self.Spacer = wx.Panel(id=ID_SFCTRANSITIONDIALOGSPACER, - name='Spacer', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - if wx.VERSION >= (2, 5, 0): - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) - self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) - else: - self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) - wx.EVT_PAINT(self.Preview, self.OnPaint) - - self._init_sizers() - - def __init__(self, parent, controler, connection): - self.Connection = connection - self._init_ctrls(parent, controler) + setattr(self.Preview, "IsOfType", controller.IsOfType) + self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) + right_gridsizer.AddWindow(self.Preview, flag=wx.GROW) + + button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) + self.Bind(wx.EVT_BUTTON, self.OnOK, + button_sizer.GetAffirmativeButton()) + main_sizer.AddSizer(button_sizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) + + self.SetSizer(main_sizer) + self.Transition = None self.MinTransitionSize = None self.Element = SFC_Transition(self.Preview) - self.radioButton1.SetFocus() + self.ReferenceRadioButton.SetFocus() def SetPreviewFont(self, font): self.Preview.SetFont(font) @@ -195,9 +131,9 @@ def OnOK(self, event): error = [] - if self.radioButton1.GetValue() and self.Reference.GetStringSelection() == "": + if self.ReferenceRadioButton.GetValue() and self.Reference.GetStringSelection() == "": error.append(_("Reference")) - if self.radioButton2.GetValue() and self.Inline.GetValue() == "": + if self.InlineRadioButton.GetValue() and self.Inline.GetValue() == "": error.append(_("Inline")) if len(error) > 0: text = "" @@ -208,18 +144,18 @@ text += _(" and %s")%item else: text += _(", %s")%item - message = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + dialog = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR) + dialog.ShowModal() + dialog.Destroy() else: self.EndModal(wx.ID_OK) def OnTypeChanged(self, event): - if self.radioButton1.GetValue(): + if self.ReferenceRadioButton.GetValue(): self.Element.SetType("reference", self.Reference.GetStringSelection()) self.Reference.Enable(True) self.Inline.Enable(False) - elif self.radioButton2.GetValue(): + elif self.InlineRadioButton.GetValue(): self.Element.SetType("inline", self.Inline.GetValue()) self.Reference.Enable(False) self.Inline.Enable(True) @@ -252,25 +188,25 @@ def SetValues(self, values): if values["type"] == "reference": - self.radioButton1.SetValue(True) - self.radioButton2.SetValue(False) - self.radioButton3.SetValue(False) + self.ReferenceRadioButton.SetValue(True) + self.InlineRadioButton.SetValue(False) + self.ConnectionRadioButton.SetValue(False) self.Reference.Enable(True) self.Inline.Enable(False) self.Reference.SetStringSelection(values["value"]) self.Element.SetType("reference", values["value"]) elif values["type"] == "inline": - self.radioButton1.SetValue(False) - self.radioButton2.SetValue(True) - self.radioButton3.SetValue(False) + self.ReferenceRadioButton.SetValue(False) + self.InlineRadioButton.SetValue(True) + self.ConnectionRadioButton.SetValue(False) self.Reference.Enable(False) self.Inline.Enable(True) self.Inline.SetValue(values["value"]) self.Element.SetType("inline", values["value"]) elif values["type"] == "connection" and self.Connection: - self.radioButton1.SetValue(False) - self.radioButton2.SetValue(False) - self.radioButton3.SetValue(True) + self.ReferenceRadioButton.SetValue(False) + self.InlineRadioButton.SetValue(False) + self.ConnectionRadioButton.SetValue(True) self.Reference.Enable(False) self.Inline.Enable(False) self.Element.SetType("connection") @@ -280,10 +216,10 @@ def GetValues(self): values = {"priority" : int(self.Priority.GetValue())} - if self.radioButton1.GetValue(): + if self.ReferenceRadioButton.GetValue(): values["type"] = "reference" values["value"] = self.Reference.GetStringSelection() - elif self.radioButton2.GetValue(): + elif self.InlineRadioButton.GetValue(): values["type"] = "inline" values["value"] = self.Inline.GetValue() else: diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/SearchInProjectDialog.py --- a/dialogs/SearchInProjectDialog.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/SearchInProjectDialog.py Mon Jun 25 20:03:53 2012 +0200 @@ -46,119 +46,70 @@ ("program", _("Program")), ("configuration", _("Configuration"))] -[ID_SEARCHINPROJECTDIALOG, ID_SEARCHINPROJECTDIALOGPATTERNLABEL, - ID_SEARCHINPROJECTDIALOGPATTERN, ID_SEARCHINPROJECTDIALOGCASESENSITIVE, - ID_SEARCHINPROJECTDIALOGREGULAREXPRESSION, ID_SEARCHINPROJECTDIALOGSCOPESTATICBOX, - ID_SEARCHINPROJECTDIALOGWHOLEPROJECT, ID_SEARCHINPROJECTDIALOGONLYELEMENTS, - ID_SEARCHINPROJECTDIALOGELEMENTSLIST, -] = [wx.NewId() for _init_ctrls in range(9)] - class SearchInProjectDialog(wx.Dialog): - if wx.VERSION < (2, 6, 0): - def Bind(self, event, function, id = None): - if id is not None: - event(self, id, function) - else: - event(self, function) - - def _init_coll_MainSizer_Items(self, parent): - parent.AddSizer(self.PatternSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.ScopeSizer, 0, border=20, flag=wx.GROW|wx.LEFT|wx.RIGHT) - parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - - def _init_coll_MainSizer_Growables(self, parent): - parent.AddGrowableCol(0) - parent.AddGrowableRow(1) - - def _init_coll_PatternSizer_Items(self, parent): - parent.AddWindow(self.PatternLabel, 0, border=0, flag=wx.ALIGN_BOTTOM) - parent.AddWindow(self.CaseSensitive, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.Pattern, 0, border=0, flag=wx.GROW) - parent.AddWindow(self.RegularExpression, 0, border=0, flag=wx.GROW) - - def _init_coll_PatternSizer_Growables(self, parent): - parent.AddGrowableCol(0) - - def _init_coll_ScopeSizer_Items(self, parent): - parent.AddSizer(self.ScopeSelectionSizer, 1, border=5, flag=wx.GROW|wx.TOP|wx.LEFT|wx.BOTTOM) - parent.AddWindow(self.ElementsList, 1, border=5, flag=wx.GROW|wx.TOP|wx.RIGHT|wx.BOTTOM) - - def _init_coll_ScopeSelectionSizer_Items(self, parent): - parent.AddWindow(self.WholeProject, 0, border=5, flag=wx.GROW|wx.BOTTOM) - parent.AddWindow(self.OnlyElements, 0, border=0, flag=wx.GROW) - - def _init_sizers(self): - self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) - self.PatternSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) - self.ScopeSizer = wx.StaticBoxSizer(self.ScopeStaticBox, wx.HORIZONTAL) - self.ScopeSelectionSizer = wx.BoxSizer(wx.VERTICAL) + def __init__(self, parent): + wx.Dialog.__init__(self, parent, title=_('Search in Project'), + size=wx.Size(600, 300), style=wx.DEFAULT_DIALOG_STYLE| + wx.RESIZE_BORDER) - self._init_coll_MainSizer_Items(self.MainSizer) - self._init_coll_MainSizer_Growables(self.MainSizer) - self._init_coll_PatternSizer_Items(self.PatternSizer) - self._init_coll_PatternSizer_Growables(self.PatternSizer) - self._init_coll_ScopeSizer_Items(self.ScopeSizer) - self._init_coll_ScopeSelectionSizer_Items(self.ScopeSelectionSizer) + main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=10) + main_sizer.AddGrowableCol(0) + main_sizer.AddGrowableRow(1) - self.SetSizer(self.MainSizer) - - def _init_ctrls(self, prnt): - wx.Dialog.__init__(self, id=ID_SEARCHINPROJECTDIALOG, - name='SearchInProjectDialog', parent=prnt, - size=wx.Size(600, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, - title=_('Search in Project')) + pattern_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=2, vgap=5) + pattern_sizer.AddGrowableCol(0) + main_sizer.AddSizer(pattern_sizer, border=20, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) - self.PatternLabel = wx.StaticText(id=ID_SEARCHINPROJECTDIALOGPATTERNLABEL, - label=_('Pattern to search:'), name='PatternLabel', parent=self, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) - - self.Pattern = wx.TextCtrl(id=ID_SEARCHINPROJECTDIALOGPATTERN, - name='Pattern', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 24), style=0) - - self.CaseSensitive = wx.CheckBox(id=ID_SEARCHINPROJECTDIALOGCASESENSITIVE, - label=_('Case sensitive'), name='CaseSensitive', parent=self, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) + pattern_label = wx.StaticText(self, label=_('Pattern to search:')) + pattern_sizer.AddWindow(pattern_label, flag=wx.ALIGN_BOTTOM) - self.RegularExpression = wx.CheckBox(id=ID_SEARCHINPROJECTDIALOGREGULAREXPRESSION, - label=_('Regular expression'), name='RegularExpression', parent=self, - pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) + self.CaseSensitive = wx.CheckBox(self, label=_('Case sensitive')) + pattern_sizer.AddWindow(self.CaseSensitive, flag=wx.GROW) - self.ScopeStaticBox = wx.StaticBox(id=ID_SEARCHINPROJECTDIALOGSCOPESTATICBOX, - label=_('Scope'), name='ScopeStaticBox', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) + self.Pattern = wx.TextCtrl(self, size=wx.Size(0, 24)) + pattern_sizer.AddWindow(self.Pattern, flag=wx.GROW) - self.WholeProject = wx.RadioButton(id=ID_SEARCHINPROJECTDIALOGWHOLEPROJECT, - label=_('Whole Project'), name='WholeProject', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP) - self.Bind(wx.EVT_RADIOBUTTON, self.OnScopeChanged, id=ID_SEARCHINPROJECTDIALOGWHOLEPROJECT) + self.RegularExpression = wx.CheckBox(self, label=_('Regular expression')) + pattern_sizer.AddWindow(self.RegularExpression, flag=wx.GROW) + + scope_staticbox = wx.StaticBox(self, label=_('Scope')) + scope_sizer = wx.StaticBoxSizer(scope_staticbox, wx.HORIZONTAL) + main_sizer.AddSizer(scope_sizer, border=20, + flag=wx.GROW|wx.LEFT|wx.RIGHT) + + scope_selection_sizer = wx.BoxSizer(wx.VERTICAL) + scope_sizer.AddSizer(scope_selection_sizer, 1, border=5, + flag=wx.GROW|wx.TOP|wx.LEFT|wx.BOTTOM) + + self.WholeProject = wx.RadioButton(self, label=_('Whole Project'), + size=wx.Size(0, 24), style=wx.RB_GROUP) self.WholeProject.SetValue(True) + self.Bind(wx.EVT_RADIOBUTTON, self.OnScopeChanged, self.WholeProject) + scope_selection_sizer.AddWindow(self.WholeProject, border=5, + flag=wx.GROW|wx.BOTTOM) - self.OnlyElements = wx.RadioButton(id=ID_SEARCHINPROJECTDIALOGONLYELEMENTS, - label=_('Only Elements'), name='OnlyElements', parent=self, - pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) - self.Bind(wx.EVT_RADIOBUTTON, self.OnScopeChanged, id=ID_SEARCHINPROJECTDIALOGONLYELEMENTS) + self.OnlyElements = wx.RadioButton(self, + label=_('Only Elements'), size=wx.Size(0, 24)) + self.Bind(wx.EVT_RADIOBUTTON, self.OnScopeChanged, self.OnlyElements) self.OnlyElements.SetValue(False) + scope_selection_sizer.AddWindow(self.OnlyElements, flag=wx.GROW) - self.ElementsList = wx.CheckListBox(id=ID_SEARCHINPROJECTDIALOGELEMENTSLIST, - name='ElementsList', parent=self, pos=wx.Point(0, 0), - size=wx.Size(0, 0), style=0) + self.ElementsList = wx.CheckListBox(self) self.ElementsList.Enable(False) + scope_sizer.AddWindow(self.ElementsList, 1, border=5, + flag=wx.GROW|wx.TOP|wx.RIGHT|wx.BOTTOM) self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) - if wx.VERSION >= (2, 5, 0): - ok_button = self.ButtonSizer.GetAffirmativeButton() - else: - ok_button = self.ButtonSizer.GetChildren()[0].GetSizer().GetChildren()[0].GetWindow() + ok_button = self.ButtonSizer.GetAffirmativeButton() ok_button.SetLabel(_('Search')) - self.Bind(wx.EVT_BUTTON, self.OnOK, id=ok_button.GetId()) + self.Bind(wx.EVT_BUTTON, self.OnOK, ok_button) + main_sizer.AddSizer(self.ButtonSizer, border=20, + flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) - self._init_sizers() - - def __init__(self, parent): - self._init_ctrls(parent) - + self.SetSizer(main_sizer) + for name, label in GetElementsChoices(): self.ElementsList.Append(_(label)) @@ -191,9 +142,7 @@ def OnOK(self, event): if self.Pattern.GetValue() == "": - message = wx.MessageDialog(self, _("Form isn't complete. Pattern to search must be filled!"), _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() + message = _("Form isn't complete. Pattern to search must be filled!") else: wrong_pattern = False if self.RegularExpression.GetValue(): @@ -202,8 +151,11 @@ except: wrong_pattern = True if wrong_pattern: - message = wx.MessageDialog(self, _("Syntax error in regular expression of pattern to search!"), _("Error"), wx.OK|wx.ICON_ERROR) - message.ShowModal() - message.Destroy() - else: - self.EndModal(wx.ID_OK) + message = _("Syntax error in regular expression of pattern to search!") + + if message is not None: + dialog = wx.MessageDialog(self, message, _("Error"), wx.OK|wx.ICON_ERROR) + dialog.ShowModal() + dialog.Destroy() + else: + self.EndModal(wx.ID_OK) diff -r 95a0a427f3ef -r 131ea7f237b9 dialogs/__init__.py --- a/dialogs/__init__.py Fri Jun 15 18:03:25 2012 +0200 +++ b/dialogs/__init__.py Mon Jun 25 20:03:53 2012 +0200 @@ -26,7 +26,7 @@ from ConnectionDialog import ConnectionDialog from ActionBlockDialog import ActionBlockDialog -from FBDBlockDialog import FBDBlockDialog, CATEGORY, BLOCK +from FBDBlockDialog import FBDBlockDialog from FBDVariableDialog import FBDVariableDialog from LDElementDialog import LDElementDialog from LDPowerRailDialog import LDPowerRailDialog diff -r 95a0a427f3ef -r 131ea7f237b9 utils/BitmapLibrary.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils/BitmapLibrary.py Mon Jun 25 20:03:53 2012 +0200 @@ -0,0 +1,85 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor +#based on the plcopen standard. +# +#Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD +# +#See COPYING file for copyrights details. +# +#This library is free software; you can redistribute it and/or +#modify it under the terms of the GNU General Public +#License as published by the Free Software Foundation; either +#version 2.1 of the License, or (at your option) any later version. +# +#This library is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +#General Public License for more details. +# +#You should have received a copy of the GNU General Public +#License along with this library; if not, write to the Free Software +#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import os + +import wx + +#------------------------------------------------------------------------------- +# Library Structures +#------------------------------------------------------------------------------- + +BitmapLibrary = {} +BitmapFolders = [] + +#------------------------------------------------------------------------------- +# Library Helpers +#------------------------------------------------------------------------------- + +def AddBitmapFolder(path): + if path not in BitmapFolders: + BitmapFolders.append(path) + +def SearchBitmap(bmp_name): + for folder in BitmapFolders: + bmp_path = os.path.join(folder, bmp_name + ".png") + if os.path.isfile(bmp_path): + return wx.Bitmap(bmp_path) + return None + +def GetBitmap(bmp_name1, bmp_name2=None, size=None): + bmp = BitmapLibrary.get((bmp_name1, bmp_name2, size)) + if bmp is not None: + return bmp + + if bmp_name2 is None: + bmp = SearchBitmap(bmp_name1) + else: + # Bitmap with two icon + bmp1 = SearchBitmap(bmp_name1) + bmp2 = SearchBitmap(bmp_name2) + + if bmp1 is not None and bmp2 is not None: + # Calculate bitmap size + width = bmp1.GetWidth() + bmp2.GetWidth() - 1 + height = max(bmp1.GetHeight(), bmp2.GetHeight()) + + # Create bitmap with both icons + bmp = wx.EmptyBitmap(width, height) + dc = wx.MemoryDC() + dc.SelectObject(bmp) + dc.Clear() + dc.DrawBitmap(bmp1, 0, 0) + dc.DrawBitmap(bmp2, bmp1.GetWidth() - 1, 0) + dc.Destroy() + + elif bmp1 is not None: + bmp = bmp1 + elif bmp2 is not None: + bmp = bmp2 + + if bmp is not None: + BitmapLibrary[(bmp_name1, bmp_name2, size)] = bmp + + return bmp