3 |
3 |
4 # This file is part of Beremiz, a Integrated Development Environment for |
4 # This file is part of Beremiz, a Integrated Development Environment for |
5 # programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
5 # programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
6 # |
6 # |
7 # Copyright (C) 2013: Edouard TISSERANT and Laurent BESSARD |
7 # Copyright (C) 2013: Edouard TISSERANT and Laurent BESSARD |
|
8 # Copyright (C) 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com> |
8 # |
9 # |
9 # See COPYING file for copyrights details. |
10 # See COPYING file for copyrights details. |
10 # |
11 # |
11 # This program is free software; you can redistribute it and/or |
12 # This program is free software; you can redistribute it and/or |
12 # modify it under the terms of the GNU General Public License |
13 # modify it under the terms of the GNU General Public License |
36 graphic created by dialog |
37 graphic created by dialog |
37 """ |
38 """ |
38 |
39 |
39 class BlockPreviewDialog(wx.Dialog): |
40 class BlockPreviewDialog(wx.Dialog): |
40 |
41 |
41 def __init__(self, parent, controller, tagname, size, title): |
42 def __init__(self, parent, controller, tagname, title): |
42 """ |
43 """ |
43 Constructor |
44 Constructor |
44 @param parent: Parent wx.Window of dialog for modal |
45 @param parent: Parent wx.Window of dialog for modal |
45 @param controller: Reference to project controller |
46 @param controller: Reference to project controller |
46 @param tagname: Tagname of project POU edited |
47 @param tagname: Tagname of project POU edited |
47 @param size: wx.Size object containing size of dialog |
|
48 @param title: Title of dialog frame |
48 @param title: Title of dialog frame |
49 """ |
49 """ |
50 wx.Dialog.__init__(self, parent, size=size, title=title) |
50 wx.Dialog.__init__(self, parent, title=title) |
51 |
51 |
52 # Save reference to |
52 # Save reference to |
53 self.Controller = controller |
53 self.Controller = controller |
54 self.TagName = tagname |
54 self.TagName = tagname |
55 |
55 |
78 self.Element = None # Graphic element to display in preview |
78 self.Element = None # Graphic element to display in preview |
79 self.MinElementSize = None # Graphic element minimal size |
79 self.MinElementSize = None # Graphic element minimal size |
80 |
80 |
81 # Variable containing the graphic element name when dialog is opened |
81 # Variable containing the graphic element name when dialog is opened |
82 self.DefaultElementName = None |
82 self.DefaultElementName = None |
|
83 self.Fit() |
83 |
84 |
84 # List of variables defined in POU {var_name: (var_class, var_type),...} |
85 # List of variables defined in POU {var_name: (var_class, var_type),...} |
85 self.VariableList = {} |
86 self.VariableList = {} |
86 |
87 |
87 def __del__(self): |
88 def __del__(self): |
112 self.MainSizer.AddGrowableCol(0) |
113 self.MainSizer.AddGrowableCol(0) |
113 if main_growable_row is not None: |
114 if main_growable_row is not None: |
114 self.MainSizer.AddGrowableRow(main_growable_row) |
115 self.MainSizer.AddGrowableRow(main_growable_row) |
115 |
116 |
116 # Create a sizer for dividing parameters in two columns |
117 # Create a sizer for dividing parameters in two columns |
117 column_sizer = wx.BoxSizer(wx.HORIZONTAL) |
118 self.ColumnSizer = wx.BoxSizer(wx.HORIZONTAL) |
118 self.MainSizer.AddSizer(column_sizer, border=20, |
119 self.MainSizer.AddSizer(self.ColumnSizer, border=20, |
119 flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
120 flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
120 |
121 |
121 # Create a sizer for left column |
122 # Create a sizer for left column |
122 self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, |
123 self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, |
123 rows=left_rows, vgap=5) |
124 rows=left_rows, vgap=5) |
124 self.LeftGridSizer.AddGrowableCol(0) |
125 self.LeftGridSizer.AddGrowableCol(0) |
125 if left_growable_row is not None: |
126 if left_growable_row is not None: |
126 self.LeftGridSizer.AddGrowableRow(left_growable_row) |
127 self.LeftGridSizer.AddGrowableRow(left_growable_row) |
127 column_sizer.AddSizer(self.LeftGridSizer, 1, border=5, |
128 self.ColumnSizer.AddSizer(self.LeftGridSizer, 1, border=5, |
128 flag=wx.GROW|wx.RIGHT) |
129 flag=wx.GROW|wx.RIGHT|wx.EXPAND) |
129 |
130 |
130 # Create a sizer for right column |
131 # Create a sizer for right column |
131 self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, |
132 self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, |
132 rows=right_rows, vgap=0) |
133 rows=right_rows, vgap=0) |
133 self.RightGridSizer.AddGrowableCol(0) |
134 self.RightGridSizer.AddGrowableCol(0) |
134 if right_growable_row is not None: |
135 if right_growable_row is not None: |
135 self.RightGridSizer.AddGrowableRow(right_growable_row) |
136 self.RightGridSizer.AddGrowableRow(right_growable_row) |
136 column_sizer.AddSizer(self.RightGridSizer, 1, border=5, |
137 self.ColumnSizer.AddSizer(self.RightGridSizer, 1, border=5, |
137 flag=wx.GROW|wx.LEFT) |
138 flag=wx.GROW|wx.LEFT) |
138 |
139 |
139 self.SetSizer(self.MainSizer) |
140 self.SetSizer(self.MainSizer) |
140 |
141 |
141 def SetMinElementSize(self, size): |
142 def SetMinElementSize(self, size): |