Beremiz.py
changeset 1281 47131e3388f4
parent 1274 6b38acbe1fd0
child 1282 f427352f9727
equal deleted inserted replaced
1279:0eb9f8af479f 1281:47131e3388f4
   152 from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY, ITEM_PROJECT, ITEM_RESOURCE
   152 from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY, ITEM_PROJECT, ITEM_RESOURCE
   153 from ProjectController import ProjectController, MATIEC_ERROR_MODEL, ITEM_CONFNODE
   153 from ProjectController import ProjectController, MATIEC_ERROR_MODEL, ITEM_CONFNODE
   154 
   154 
   155 
   155 
   156 MAX_RECENT_PROJECTS = 10
   156 MAX_RECENT_PROJECTS = 10
   157 
       
   158 class GenStaticBitmap(wx.lib.statbmp.GenStaticBitmap):
       
   159     """ Customized GenStaticBitmap, fix transparency redraw bug on wx2.8/win32, 
       
   160     and accept image name as __init__ parameter, fail silently if file do not exist"""
       
   161     def __init__(self, parent, ID, bitmapname,
       
   162                  pos = wx.DefaultPosition, size = wx.DefaultSize,
       
   163                  style = 0,
       
   164                  name = "genstatbmp"):
       
   165         
       
   166         wx.lib.statbmp.GenStaticBitmap.__init__(self, parent, ID, 
       
   167                  GetBitmap(bitmapname),
       
   168                  pos, size,
       
   169                  style,
       
   170                  name)
       
   171         
       
   172     def OnPaint(self, event):
       
   173         dc = wx.PaintDC(self)
       
   174         colour = self.GetParent().GetBackgroundColour()
       
   175         dc.SetPen(wx.Pen(colour))
       
   176         dc.SetBrush(wx.Brush(colour ))
       
   177         dc.DrawRectangle(0, 0, *dc.GetSizeTuple())
       
   178         if self._bitmap:
       
   179             dc.DrawBitmap(self._bitmap, 0, 0, True)
       
   180 
   157 
   181 if wx.Platform == '__WXMSW__':
   158 if wx.Platform == '__WXMSW__':
   182     faces = {
   159     faces = {
   183         'mono' : 'Courier New',
   160         'mono' : 'Courier New',
   184         'size' : 8,
   161         'size' : 8,
   298         self.output.SetReadOnly(True)
   275         self.output.SetReadOnly(True)
   299     
   276     
   300     def isatty(self):
   277     def isatty(self):
   301         return False
   278         return False
   302 
   279 
   303 [ID_BEREMIZ, ID_BEREMIZMAINSPLITTER, 
   280 ID_FILEMENURECENTPROJECTS = wx.NewId()
   304  ID_BEREMIZPLCCONFIG, ID_BEREMIZLOGCONSOLE, 
       
   305  ID_BEREMIZINSPECTOR] = [wx.NewId() for _init_ctrls in range(5)]
       
   306 
       
   307 [ID_FILEMENURECENTPROJECTS,
       
   308 ] = [wx.NewId() for _init_ctrls in range(1)]
       
   309 
       
   310 CONFNODEMENU_POSITION = 3
       
   311 
   281 
   312 class Beremiz(IDEFrame):
   282 class Beremiz(IDEFrame):
   313     
   283     
   314     def _init_utils(self):
   284     def _init_utils(self):
   315         self.ConfNodeMenu = wx.Menu(title='')
   285         self.ConfNodeMenu = wx.Menu(title='')
   392     def _init_ctrls(self, prnt):
   362     def _init_ctrls(self, prnt):
   393         IDEFrame._init_ctrls(self, prnt)
   363         IDEFrame._init_ctrls(self, prnt)
   394         
   364         
   395         self.EditMenuSize = self.EditMenu.GetMenuItemCount()
   365         self.EditMenuSize = self.EditMenu.GetMenuItemCount()
   396         
   366         
   397         self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=ID_BEREMIZINSPECTOR)
   367         inspectorID = wx.NewId()
   398         accels = [wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), ID_BEREMIZINSPECTOR)]
   368         self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=inspectorID)
       
   369         accels = [wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), inspectorID)]
   399         for method,shortcut in [("Stop",     wx.WXK_F4),
   370         for method,shortcut in [("Stop",     wx.WXK_F4),
   400                                 ("Run",      wx.WXK_F5),
   371                                 ("Run",      wx.WXK_F5),
   401                                 ("Transfer", wx.WXK_F6),
   372                                 ("Transfer", wx.WXK_F6),
   402                                 ("Connect",  wx.WXK_F7),
   373                                 ("Connect",  wx.WXK_F7),
   403                                 ("Build",    wx.WXK_F11)]:
   374                                 ("Build",    wx.WXK_F11)]:
   411             self.Bind(wx.EVT_MENU, OnMethodGen(self,method), id=newid)
   382             self.Bind(wx.EVT_MENU, OnMethodGen(self,method), id=newid)
   412             accels += [wx.AcceleratorEntry(wx.ACCEL_NORMAL, shortcut,newid)]
   383             accels += [wx.AcceleratorEntry(wx.ACCEL_NORMAL, shortcut,newid)]
   413         
   384         
   414         self.SetAcceleratorTable(wx.AcceleratorTable(accels))
   385         self.SetAcceleratorTable(wx.AcceleratorTable(accels))
   415         
   386         
   416         self.LogConsole = CustomStyledTextCtrl(id=ID_BEREMIZLOGCONSOLE,
   387         self.LogConsole = CustomStyledTextCtrl(
   417                   name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0),
   388                   name='LogConsole', parent=self.BottomNoteBook, pos=wx.Point(0, 0),
   418                   size=wx.Size(0, 0))
   389                   size=wx.Size(0, 0))
   419         self.LogConsole.Bind(wx.EVT_SET_FOCUS, self.OnLogConsoleFocusChanged)
   390         self.LogConsole.Bind(wx.EVT_SET_FOCUS, self.OnLogConsoleFocusChanged)
   420         self.LogConsole.Bind(wx.EVT_KILL_FOCUS, self.OnLogConsoleFocusChanged)
   391         self.LogConsole.Bind(wx.EVT_KILL_FOCUS, self.OnLogConsoleFocusChanged)
   421         self.LogConsole.Bind(wx.stc.EVT_STC_UPDATEUI, self.OnLogConsoleUpdateUI)
   392         self.LogConsole.Bind(wx.stc.EVT_STC_UPDATEUI, self.OnLogConsoleUpdateUI)