21 #You should have received a copy of the GNU General Public |
21 #You should have received a copy of the GNU General Public |
22 #License along with this library; if not, write to the Free Software |
22 #License along with this library; if not, write to the Free Software |
23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
24 |
25 import wx |
25 import wx |
|
26 from plcopen.plcopen import * |
26 |
27 |
27 class FindInPouDialog(wx.Frame): |
28 class FindInPouDialog(wx.Frame): |
28 |
29 |
29 def _init_icon(self, parent): |
30 def _init_icon(self, parent): |
30 if parent and parent.icon: |
31 if parent and parent.icon: |
31 self.SetIcon(parent.icon) |
32 self.SetIcon(parent.icon) |
32 |
33 |
33 |
34 |
34 def __init__(self, parent): |
35 def __init__(self, parent): |
35 wx.Frame.__init__(self, parent, title=_("Find"), |
36 wx.Frame.__init__(self, parent, title=_("Find"), |
36 size=wx.Size(400, 250), style=wx.CAPTION| |
37 size=wx.Size(410, 250), style=wx.CAPTION| |
37 wx.CLOSE_BOX| |
38 wx.CLOSE_BOX| |
38 wx.CLIP_CHILDREN| |
39 wx.CLIP_CHILDREN| |
39 wx.RESIZE_BORDER| |
40 wx.RESIZE_BORDER| |
40 wx.STAY_ON_TOP) |
41 wx.STAY_ON_TOP) |
41 |
42 |
42 self._init_icon(parent) |
43 self._init_icon(parent) |
|
44 self.CreateStatusBar(style=wx.SB_FLAT) |
43 panel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
45 panel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
44 |
46 |
45 main_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=2, vgap=5) |
47 main_sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=2, vgap=5) |
46 main_sizer.AddGrowableCol(0) |
48 main_sizer.AddGrowableCol(0) |
47 main_sizer.AddGrowableRow(0) |
49 main_sizer.AddGrowableRow(0) |
114 panel.SetSizer(main_sizer) |
116 panel.SetSizer(main_sizer) |
115 |
117 |
116 self.ParentWindow = parent |
118 self.ParentWindow = parent |
117 |
119 |
118 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
120 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
119 |
121 self.infosPrev = {} |
|
122 self.criteria = {} |
120 self.FindPattern.SetFocus() |
123 self.FindPattern.SetFocus() |
121 self.RefreshButtonsState() |
124 self.RefreshButtonsState() |
122 |
125 |
123 def RefreshButtonsState(self): |
126 def RefreshButtonsState(self): |
124 find_pattern = self.FindPattern.GetValue() |
127 find_pattern = self.FindPattern.GetValue() |
139 def OnFindButton(self, event): |
142 def OnFindButton(self, event): |
140 infos = { |
143 infos = { |
141 "find_pattern": self.FindPattern.GetValue(), |
144 "find_pattern": self.FindPattern.GetValue(), |
142 "wrap": self.WrapSearch.GetValue(), |
145 "wrap": self.WrapSearch.GetValue(), |
143 "case_sensitive": self.CaseSensitive.GetValue(), |
146 "case_sensitive": self.CaseSensitive.GetValue(), |
144 "regular_expression": self.RegularExpressions.GetValue()} |
147 "regular_expression": self.RegularExpressions.GetValue(), |
145 wx.CallAfter(self.ParentWindow.FindInPou, |
148 "filter": "all"} |
146 {True: 1, False:-1}[self.Forward.GetValue()], |
149 |
147 infos) |
150 if self.infosPrev != infos: |
|
151 self.infosPrev = infos |
|
152 message = "" |
|
153 try: |
|
154 self.criteria = infos |
|
155 CompilePattern(self.criteria) |
|
156 except: |
|
157 self.criteria.clear() |
|
158 message = _("Syntax error in regular expression of pattern to search!") |
|
159 self.SetStatusText(message) |
|
160 if len(self.criteria) > 0: |
|
161 wx.CallAfter(self.ParentWindow.FindInPou, |
|
162 {True: 1, False:-1}[self.Forward.GetValue()], |
|
163 self.criteria) |
148 event.Skip() |
164 event.Skip() |