LPCManager.py
changeset 27 77b6f3c5f1ba
parent 26 735464c8616a
child 28 79ee4178006c
equal deleted inserted replaced
26:735464c8616a 27:77b6f3c5f1ba
  1300         self.MainTabs["PLCConfig"] = (self.PLCConfig, _("Topology"))
  1300         self.MainTabs["PLCConfig"] = (self.PLCConfig, _("Topology"))
  1301         self.LeftNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True)
  1301         self.LeftNoteBook.InsertPage(0, self.PLCConfig, _("Topology"), True)
  1302         
  1302         
  1303         self.PLCConfigMainSizer = wx.FlexGridSizer(cols=1, hgap=2, rows=2, vgap=2)
  1303         self.PLCConfigMainSizer = wx.FlexGridSizer(cols=1, hgap=2, rows=2, vgap=2)
  1304         self.PLCParamsSizer = wx.BoxSizer(wx.VERTICAL)
  1304         self.PLCParamsSizer = wx.BoxSizer(wx.VERTICAL)
  1305         self.ConfNodeTreeSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=0, vgap=2)
  1305         self.ConfNodeTreeSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=0, vgap=2)
  1306         self.ConfNodeTreeSizer.AddGrowableCol(0)
  1306         self.ConfNodeTreeSizer.AddGrowableCol(0)
  1307         self.ConfNodeTreeSizer.AddGrowableCol(1)
       
  1308         
  1307         
  1309         self.PLCConfigMainSizer.AddSizer(self.PLCParamsSizer, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
  1308         self.PLCConfigMainSizer.AddSizer(self.PLCParamsSizer, 0, border=10, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
  1310         self.PLCConfigMainSizer.AddSizer(self.ConfNodeTreeSizer, 0, border=10, flag=wx.BOTTOM|wx.LEFT|wx.RIGHT)
  1309         self.PLCConfigMainSizer.AddSizer(self.ConfNodeTreeSizer, 0, border=10, flag=wx.BOTTOM|wx.LEFT|wx.RIGHT)
  1311         self.PLCConfigMainSizer.AddGrowableCol(0)
  1310         self.PLCConfigMainSizer.AddGrowableCol(0)
  1312         self.PLCConfigMainSizer.AddGrowableRow(1)
  1311         self.PLCConfigMainSizer.AddGrowableRow(1)
  1411             if self.CTR.CTNTestModified():
  1410             if self.CTR.CTNTestModified():
  1412                 bkgdclr = CHANGED_TITLE_COLOUR
  1411                 bkgdclr = CHANGED_TITLE_COLOUR
  1413             else:
  1412             else:
  1414                 bkgdclr = TITLE_COLOUR
  1413                 bkgdclr = TITLE_COLOUR
  1415                 
  1414                 
  1416             if self.CTR not in self.ConfNodeInfos:
       
  1417                 self.ConfNodeInfos[self.CTR] = {"right_visible" : False}
       
  1418             
       
  1419             plcwindow.SetBackgroundColour(TITLE_COLOUR)
  1415             plcwindow.SetBackgroundColour(TITLE_COLOUR)
  1420             plcwindow.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown)
  1416             plcwindow.Bind(wx.EVT_LEFT_DOWN, self.OnPanelLeftDown)
  1421             self.PLCParamsSizer.AddWindow(plcwindow, 0, border=0, flag=wx.GROW)
  1417             self.PLCParamsSizer.AddWindow(plcwindow, 0, border=0, flag=wx.GROW)
  1422             
  1418             
  1423             plcwindowsizer = wx.BoxSizer(wx.HORIZONTAL)
  1419             plcwindowsizer = wx.BoxSizer(wx.HORIZONTAL)
  1432             plcwindowsizer.AddSizer(plcwindowmainsizer, 0, border=5, flag=wx.ALL)
  1428             plcwindowsizer.AddSizer(plcwindowmainsizer, 0, border=5, flag=wx.ALL)
  1433             
  1429             
  1434             plcwindowbuttonsizer = wx.BoxSizer(wx.HORIZONTAL)
  1430             plcwindowbuttonsizer = wx.BoxSizer(wx.HORIZONTAL)
  1435             plcwindowmainsizer.AddSizer(plcwindowbuttonsizer, 0, border=0, flag=wx.ALIGN_CENTER)
  1431             plcwindowmainsizer.AddSizer(plcwindowbuttonsizer, 0, border=0, flag=wx.ALIGN_CENTER)
  1436             
  1432             
  1437             msizer = self.GenerateMethodButtonSizer(self.CTR, plcwindow, not self.ConfNodeInfos[self.CTR]["right_visible"])
  1433             msizer = self.GenerateMethodButtonSizer(self.CTR, plcwindow)
  1438             plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW)
  1434             plcwindowbuttonsizer.AddSizer(msizer, 0, border=0, flag=wx.GROW)
  1439             
  1435             
  1440         self.PLCConfigMainSizer.Layout()
  1436         self.PLCConfigMainSizer.Layout()
  1441         self.RefreshScrollBars()
  1437         self.RefreshScrollBars()
  1442         self.Thaw()
  1438         self.Thaw()
  1443 
  1439 
  1444     def GenerateMethodButtonSizer(self, confnode, parent, horizontal = True):
  1440     def GenerateMethodButtonSizer(self, confnode, parent):
  1445         normal_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["helv"])
  1441         normal_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["helv"])
  1446         mouseover_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, underline=True, faceName = faces["helv"])
  1442         mouseover_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, underline=True, faceName = faces["helv"])
  1447         if horizontal:
  1443         msizer = wx.FlexGridSizer(cols=len(confnode.ConfNodeMethods))
  1448             msizer = wx.FlexGridSizer(cols=len(confnode.ConfNodeMethods))
       
  1449         else:
       
  1450             msizer = wx.FlexGridSizer(cols=1)
       
  1451         for confnode_method in confnode.ConfNodeMethods:
  1444         for confnode_method in confnode.ConfNodeMethods:
  1452             if "method" in confnode_method and confnode_method.get("shown",True):
  1445             if "method" in confnode_method and confnode_method.get("shown",True):
  1453                 id = wx.NewId()
  1446                 id = wx.NewId()
  1454                 label = confnode_method["name"]
  1447                 label = confnode_method["name"]
  1455                 button = GenBitmapTextButton(id=id, parent=parent,
  1448                 button = GenBitmapTextButton(id=id, parent=parent,
  1503         self.PLCConfigMainSizer.Layout()
  1496         self.PLCConfigMainSizer.Layout()
  1504         self.RefreshScrollBars()
  1497         self.RefreshScrollBars()
  1505         self.Thaw()
  1498         self.Thaw()
  1506 
  1499 
  1507     def GenerateTreeBranch(self, confnode):
  1500     def GenerateTreeBranch(self, confnode):
  1508         leftwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
  1501         nodewindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
  1509         if confnode.CTNTestModified():
  1502         if confnode.CTNTestModified():
  1510             bkgdclr=CHANGED_WINDOW_COLOUR
  1503             bkgdclr=CHANGED_WINDOW_COLOUR
  1511         else:
  1504         else:
  1512             bkgdclr=WINDOW_COLOUR
  1505             bkgdclr=WINDOW_COLOUR
  1513 
  1506 
  1514         leftwindow.SetBackgroundColour(bkgdclr)
  1507         nodewindow.SetBackgroundColour(bkgdclr)
  1515         
  1508         
  1516         if confnode not in self.ConfNodeInfos:
  1509         if confnode not in self.ConfNodeInfos:
  1517             self.ConfNodeInfos[confnode] = {"expanded" : False, "left_visible" : False, "right_visible" : False}
  1510             self.ConfNodeInfos[confnode] = {"expanded" : False, "visible" : False}
  1518             
  1511             
  1519         self.ConfNodeInfos[confnode]["children"] = confnode.IECSortedChildren()
  1512         self.ConfNodeInfos[confnode]["children"] = confnode.IECSortedChildren()
  1520         confnode_infos = confnode.GetVariableLocationTree()
  1513         confnode_infos = confnode.GetVariableLocationTree()
  1521         confnode_locations = []
  1514         confnode_locations = []
  1522         if len(self.ConfNodeInfos[confnode]["children"]) == 0:
  1515         if len(self.ConfNodeInfos[confnode]["children"]) == 0:
  1523             confnode_locations = confnode_infos["children"]
  1516             confnode_locations = confnode_infos["children"]
  1524             if not self.ConfNodeInfos[confnode].has_key("locations_infos"):
  1517             if not self.ConfNodeInfos[confnode].has_key("locations_infos"):
  1525                 self.ConfNodeInfos[confnode]["locations_infos"] = {"root": {"expanded" : False}}
  1518                 self.ConfNodeInfos[confnode]["locations_infos"] = {"root": {"expanded" : False}}
  1526             
  1519             
  1527             self.ConfNodeInfos[confnode]["locations_infos"]["root"]["left"] = None
  1520             self.ConfNodeInfos[confnode]["locations_infos"]["root"]["window"] = None
  1528             self.ConfNodeInfos[confnode]["locations_infos"]["root"]["right"] = None
       
  1529             self.ConfNodeInfos[confnode]["locations_infos"]["root"]["children"] = []
  1521             self.ConfNodeInfos[confnode]["locations_infos"]["root"]["children"] = []
  1530         
  1522         
  1531         self.ConfNodeTreeSizer.AddWindow(leftwindow, 0, border=0, flag=wx.GROW)
  1523         self.ConfNodeTreeSizer.AddWindow(nodewindow, 0, border=0, flag=wx.GROW)
  1532         
  1524         
  1533         leftwindowvsizer = wx.BoxSizer(wx.VERTICAL)
  1525         nodewindowvsizer = wx.BoxSizer(wx.VERTICAL)
  1534         leftwindow.SetSizer(leftwindowvsizer)
  1526         nodewindow.SetSizer(nodewindowvsizer)
  1535         
  1527         
  1536         leftwindowsizer = wx.BoxSizer(wx.HORIZONTAL)
  1528         nodewindowsizer = wx.BoxSizer(wx.HORIZONTAL)
  1537         leftwindowvsizer.AddSizer(leftwindowsizer, 0, border=0, flag=0)
  1529         nodewindowvsizer.AddSizer(nodewindowsizer, 0, border=0, flag=0)
  1538         
  1530         
  1539         #self.GenerateEnableButton(leftwindow, leftwindowsizer, confnode)
  1531         #self.GenerateEnableButton(nodewindow, nodewindowsizer, confnode)
  1540         
  1532         
  1541         st = wx.StaticText(leftwindow, -1)
  1533         st = wx.StaticText(nodewindow, -1)
  1542         st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
  1534         st.SetFont(wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
  1543         st.SetLabel(confnode.GetFullIEC_Channel())
  1535         st.SetLabel(confnode.GetFullIEC_Channel())
  1544         leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.LEFT|wx.RIGHT)
  1536         nodewindowsizer.AddWindow(st, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
  1545         
  1537         
  1546         expandbutton_id = wx.NewId()
  1538         expandbutton_id = wx.NewId()
  1547         expandbutton = wx.lib.buttons.GenBitmapToggleButton(id=expandbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'plus.png')),
  1539         expandbutton = wx.lib.buttons.GenBitmapToggleButton(id=expandbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'plus.png')),
  1548               name='ExpandButton', parent=leftwindow, pos=wx.Point(0, 0),
  1540               name='ExpandButton', parent=nodewindow, pos=wx.Point(0, 0),
  1549               size=wx.Size(13, 13), style=wx.NO_BORDER)
  1541               size=wx.Size(13, 13), style=wx.NO_BORDER)
  1550         expandbutton.labelDelta = 0
  1542         expandbutton.labelDelta = 0
  1551         expandbutton.SetBezelWidth(0)
  1543         expandbutton.SetBezelWidth(0)
  1552         expandbutton.SetUseFocusIndicator(False)
  1544         expandbutton.SetUseFocusIndicator(False)
  1553         expandbutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'minus.png')))
  1545         expandbutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'minus.png')))
  1578                 self.RefreshScrollBars()
  1570                 self.RefreshScrollBars()
  1579                 event.Skip()
  1571                 event.Skip()
  1580             expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id)
  1572             expandbutton.Bind(wx.EVT_BUTTON, togglebutton, id=expandbutton_id)
  1581         else:
  1573         else:
  1582             expandbutton.Enable(False)
  1574             expandbutton.Enable(False)
  1583         leftwindowsizer.AddWindow(expandbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
  1575         nodewindowsizer.AddWindow(expandbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
  1584         
  1576         
  1585         sb = wx.StaticBitmap(leftwindow, -1)
  1577         sb = wx.StaticBitmap(nodewindow, -1)
  1586         icon = confnode_infos.get("icon", None)
  1578         icon = confnode_infos.get("icon", None)
  1587         if icon is None:
  1579         if icon is None:
  1588             icon_bitmap = self.LocationImageList.GetBitmap(self.LocationImageDict[confnode_infos["type"]])
  1580             icon_bitmap = self.LocationImageList.GetBitmap(self.LocationImageDict[confnode_infos["type"]])
  1589         else: 
  1581         else: 
  1590             icon_bitmap = wx.Bitmap(icon)
  1582             icon_bitmap = wx.Bitmap(icon)
  1591         sb.SetBitmap(icon_bitmap)
  1583         sb.SetBitmap(icon_bitmap)
  1592         leftwindowsizer.AddWindow(sb, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
  1584         nodewindowsizer.AddWindow(sb, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
  1593         
  1585         
  1594         st_id = wx.NewId()
  1586         st_id = wx.NewId()
  1595         st = wx.StaticText(leftwindow, st_id, size=wx.DefaultSize, style=wx.NO_BORDER)
  1587         st = wx.StaticText(nodewindow, st_id, size=wx.DefaultSize, style=wx.NO_BORDER)
  1596         st.SetFont(wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
  1588         st.SetFont(wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, wx.BOLD, faceName = faces["helv"]))
  1597         st.SetLabel(confnode.MandatoryParams[1].getName())
  1589         st.SetLabel(confnode.MandatoryParams[1].getName())
  1598         leftwindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
  1590         nodewindowsizer.AddWindow(st, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
  1599         
  1591         
  1600         rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
  1592         buttons_sizer = self.GenerateMethodButtonSizer(confnode, nodewindow)
  1601         rightwindow.SetBackgroundColour(bkgdclr) 
  1593         nodewindowsizer.AddSizer(buttons_sizer, flag=wx.ALIGN_CENTER_VERTICAL)
  1602         rightwindowsizer = self.GenerateMethodButtonSizer(confnode, rightwindow, not self.ConfNodeInfos[confnode]["right_visible"])
  1594         
  1603         rightwindow.SetSizer(rightwindowsizer)
  1595         self.ConfNodeInfos[confnode]["window"] = nodewindow
  1604         self.ConfNodeTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW)
       
  1605 
       
  1606         self.ConfNodeInfos[confnode]["left"] = leftwindow
       
  1607         self.ConfNodeInfos[confnode]["right"] = rightwindow
       
  1608         for child in self.ConfNodeInfos[confnode]["children"]:
  1596         for child in self.ConfNodeInfos[confnode]["children"]:
  1609             self.GenerateTreeBranch(child)
  1597             self.GenerateTreeBranch(child)
  1610             if not self.ConfNodeInfos[child]["expanded"]:
  1598             if not self.ConfNodeInfos[child]["expanded"]:
  1611                 self.CollapseConfNode(child)
  1599                 self.CollapseConfNode(child)
  1612         
  1600         
  1620             treectrl.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.GenerateLocationExpandCollapseFunction(locations_infos, False))
  1608             treectrl.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.GenerateLocationExpandCollapseFunction(locations_infos, False))
  1621             
  1609             
  1622             treectrl.AddRoot("")
  1610             treectrl.AddRoot("")
  1623             self.ConfNodeTreeSizer.AddWindow(treectrl, 0, border=0, flag=0)
  1611             self.ConfNodeTreeSizer.AddWindow(treectrl, 0, border=0, flag=0)
  1624             
  1612             
  1625             rightwindow = wx.Panel(self.PLCConfig, -1, size=wx.Size(-1, -1))
  1613             locations_infos["root"]["window"] = treectrl
  1626             rightwindow.SetBackgroundColour(wx.WHITE)
       
  1627             self.ConfNodeTreeSizer.AddWindow(rightwindow, 0, border=0, flag=wx.GROW)
       
  1628             
       
  1629             locations_infos["root"]["left"] = treectrl
       
  1630             locations_infos["root"]["right"] = rightwindow
       
  1631             for location in confnode_locations:
  1614             for location in confnode_locations:
  1632                 locations_infos["root"]["children"].append("root.%s" % location["name"])
  1615                 locations_infos["root"]["children"].append("root.%s" % location["name"])
  1633                 self.GenerateLocationTreeBranch(treectrl, treectrl.GetRootItem(), locations_infos, "root", location)
  1616                 self.GenerateLocationTreeBranch(treectrl, treectrl.GetRootItem(), locations_infos, "root", location)
  1634             if locations_infos["root"]["expanded"]:
  1617             if locations_infos["root"]["expanded"]:
  1635                 self.ExpandLocation(locations_infos, "root")
  1618                 self.ExpandLocation(locations_infos, "root")
  1636 
  1619 
  1637     def ExpandConfNode(self, confnode, force = False):
  1620     def ExpandConfNode(self, confnode, force = False):
  1638         for child in self.ConfNodeInfos[confnode]["children"]:
  1621         for child in self.ConfNodeInfos[confnode]["children"]:
  1639             self.ConfNodeInfos[child]["left"].Show()
  1622             self.ConfNodeInfos[child]["window"].Show()
  1640             self.ConfNodeInfos[child]["right"].Show()
       
  1641             if force or self.ConfNodeInfos[child]["expanded"]:
  1623             if force or self.ConfNodeInfos[child]["expanded"]:
  1642                 self.ExpandConfNode(child, force)
  1624                 self.ExpandConfNode(child, force)
  1643                 if force:
  1625                 if force:
  1644                     self.ConfNodeInfos[child]["expanded"] = True
  1626                     self.ConfNodeInfos[child]["expanded"] = True
  1645         locations_infos = self.ConfNodeInfos[confnode].get("locations_infos", None)
  1627         locations_infos = self.ConfNodeInfos[confnode].get("locations_infos", None)
  1649                 if force:
  1631                 if force:
  1650                     locations_infos["root"]["expanded"] = True
  1632                     locations_infos["root"]["expanded"] = True
  1651     
  1633     
  1652     def CollapseConfNode(self, confnode, force = False):
  1634     def CollapseConfNode(self, confnode, force = False):
  1653         for child in self.ConfNodeInfos[confnode]["children"]:
  1635         for child in self.ConfNodeInfos[confnode]["children"]:
  1654             self.ConfNodeInfos[child]["left"].Hide()
  1636             self.ConfNodeInfos[child]["window"].Hide()
  1655             self.ConfNodeInfos[child]["right"].Hide()
       
  1656             self.CollapseConfNode(child, force)
  1637             self.CollapseConfNode(child, force)
  1657             if force:
  1638             if force:
  1658                 self.ConfNodeInfos[child]["expanded"] = False
  1639                 self.ConfNodeInfos[child]["expanded"] = False
  1659         locations_infos = self.ConfNodeInfos[confnode].get("locations_infos", None)
  1640         locations_infos = self.ConfNodeInfos[confnode].get("locations_infos", None)
  1660         if locations_infos is not None:
  1641         if locations_infos is not None:
  1663                 locations_infos["root"]["expanded"] = False
  1644                 locations_infos["root"]["expanded"] = False
  1664 
  1645 
  1665     def ExpandLocation(self, locations_infos, group, force = False, refresh_size=True):
  1646     def ExpandLocation(self, locations_infos, group, force = False, refresh_size=True):
  1666         locations_infos[group]["expanded"] = True
  1647         locations_infos[group]["expanded"] = True
  1667         if group == "root":
  1648         if group == "root":
  1668             if locations_infos[group]["left"] is not None:
  1649             if locations_infos[group]["window"] is not None:
  1669                 locations_infos[group]["left"].Show()
  1650                 locations_infos[group]["window"].Show()
  1670             if locations_infos[group]["right"] is not None:
  1651         elif locations_infos["root"]["window"] is not None:
  1671                 locations_infos[group]["right"].Show()
  1652             locations_infos["root"]["window"].Expand(locations_infos[group]["item"])
  1672         elif locations_infos["root"]["left"] is not None:
       
  1673             locations_infos["root"]["left"].Expand(locations_infos[group]["item"])
       
  1674             if force:
  1653             if force:
  1675                 for child in locations_infos[group]["children"]:
  1654                 for child in locations_infos[group]["children"]:
  1676                     self.ExpandLocation(locations_infos, child, force, False)
  1655                     self.ExpandLocation(locations_infos, child, force, False)
  1677         if locations_infos["root"]["left"] is not None and refresh_size:
  1656         if locations_infos["root"]["window"] is not None and refresh_size:
  1678             self.RefreshTreeCtrlSize(locations_infos["root"]["left"])
  1657             self.RefreshTreeCtrlSize(locations_infos["root"]["window"])
  1679         
  1658         
  1680     def CollapseLocation(self, locations_infos, group, force = False, refresh_size=True):
  1659     def CollapseLocation(self, locations_infos, group, force = False, refresh_size=True):
  1681         locations_infos[group]["expanded"] = False
  1660         locations_infos[group]["expanded"] = False
  1682         if group == "root":
  1661         if group == "root":
  1683             if locations_infos[group]["left"] is not None:
  1662             if locations_infos[group]["window"] is not None:
  1684                 locations_infos[group]["left"].Hide()
  1663                 locations_infos[group]["window"].Hide()
  1685             if locations_infos[group]["right"] is not None:
  1664         elif locations_infos["root"]["window"] is not None:
  1686                 locations_infos[group]["right"].Hide()
  1665             locations_infos["root"]["window"].Collapse(locations_infos[group]["item"])
  1687         elif locations_infos["root"]["left"] is not None:
       
  1688             locations_infos["root"]["left"].Collapse(locations_infos[group]["item"])
       
  1689             if force:
  1666             if force:
  1690                 for child in locations_infos[group]["children"]:
  1667                 for child in locations_infos[group]["children"]:
  1691                     self.CollapseLocation(locations_infos, child, force, False)
  1668                     self.CollapseLocation(locations_infos, child, force, False)
  1692         if locations_infos["root"]["left"] is not None and refresh_size:
  1669         if locations_infos["root"]["window"] is not None and refresh_size:
  1693             self.RefreshTreeCtrlSize(locations_infos["root"]["left"])
  1670             self.RefreshTreeCtrlSize(locations_infos["root"]["window"])
  1694 
  1671 
  1695     def GenerateLocationTreeBranch(self, treectrl, root, locations_infos, parent, location):
  1672     def GenerateLocationTreeBranch(self, treectrl, root, locations_infos, parent, location):
  1696         location_name = "%s.%s" % (parent, location["name"])
  1673         location_name = "%s.%s" % (parent, location["name"])
  1697         if not locations_infos.has_key(location_name):
  1674         if not locations_infos.has_key(location_name):
  1698             locations_infos[location_name] = {"expanded" : False}
  1675             locations_infos[location_name] = {"expanded" : False}
  1720             self.ExpandLocation(locations_infos, location_name)
  1697             self.ExpandLocation(locations_infos, location_name)
  1721     
  1698     
  1722     def GenerateLocationBeginDragFunction(self, locations_infos):
  1699     def GenerateLocationBeginDragFunction(self, locations_infos):
  1723         def OnLocationBeginDragFunction(event):
  1700         def OnLocationBeginDragFunction(event):
  1724             item = event.GetItem()
  1701             item = event.GetItem()
  1725             location_name = locations_infos["root"]["left"].GetPyData(item)
  1702             location_name = locations_infos["root"]["window"].GetPyData(item)
  1726             if location_name is not None:
  1703             if location_name is not None:
  1727                 infos = locations_infos[location_name]["infos"]
  1704                 infos = locations_infos[location_name]["infos"]
  1728                 if infos["type"] in [LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY]:
  1705                 if infos["type"] in [LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY]:
  1729                     data = wx.TextDataObject(str((infos["location"], "location", infos["IEC_type"], infos["var_name"], infos["description"])))
  1706                     data = wx.TextDataObject(str((infos["location"], "location", infos["IEC_type"], infos["var_name"], infos["description"])))
  1730                     dragSource = wx.DropSource(self)
  1707                     dragSource = wx.DropSource(self)
  1763         return wx.Rect(minx, miny, maxx - minx, maxy - miny)
  1740         return wx.Rect(minx, miny, maxx - minx, maxy - miny)
  1764     
  1741     
  1765     def GenerateLocationExpandCollapseFunction(self, locations_infos, expand):
  1742     def GenerateLocationExpandCollapseFunction(self, locations_infos, expand):
  1766         def OnLocationExpandedFunction(event):
  1743         def OnLocationExpandedFunction(event):
  1767             item = event.GetItem()
  1744             item = event.GetItem()
  1768             location_name = locations_infos["root"]["left"].GetPyData(item)
  1745             location_name = locations_infos["root"]["window"].GetPyData(item)
  1769             if location_name is not None:
  1746             if location_name is not None:
  1770                 locations_infos[location_name]["expanded"] = expand
  1747                 locations_infos[location_name]["expanded"] = expand
  1771                 self.RefreshTreeCtrlSize(locations_infos["root"]["left"])
  1748                 self.RefreshTreeCtrlSize(locations_infos["root"]["window"])
  1772             event.Skip()
  1749             event.Skip()
  1773         return OnLocationExpandedFunction
  1750         return OnLocationExpandedFunction
  1774     
  1751     
  1775     def GetButtonCallBackFunction(self, confnode, method):
  1752     def GetButtonCallBackFunction(self, confnode, method):
  1776         """ Generate the callbackfunc for a given confnode method"""
  1753         """ Generate the callbackfunc for a given confnode method"""