Dialogs.py
changeset 80 c798a68c5560
parent 71 0578bc212c20
child 95 ee66a9a1748b
equal deleted inserted replaced
79:b22f661cbcfb 80:c798a68c5560
   294         
   294         
   295     def RefreshPreview(self):
   295     def RefreshPreview(self):
   296         dc = wx.ClientDC(self.Preview)
   296         dc = wx.ClientDC(self.Preview)
   297         dc.Clear()
   297         dc.Clear()
   298         item = self.TypeTree.GetSelection()
   298         item = self.TypeTree.GetSelection()
   299         pydata = self.TypeTree.GetPyData(item)
   299         if item.IsOk():
   300         if pydata["type"] == CATEGORY:
   300             pydata = self.TypeTree.GetPyData(item)
   301             self.Block = None
   301             if pydata["type"] == CATEGORY:
   302         else:
   302                 self.Block = None
   303             blocktype = self.TypeTree.GetItemText(item)
       
   304             if blocktype:
       
   305                 self.Block = FBD_Block(self.Preview, blocktype, self.Name.GetValue(), extension = self.Inputs.GetValue(), inputs = pydata["inputs"])
       
   306                 width, height = self.MinBlockSize
       
   307                 min_width, min_height = self.Block.GetMinSize()
       
   308                 width, height = max(min_width, width), max(min_height, height)
       
   309                 self.Block.SetSize(width, height)
       
   310                 clientsize = self.Preview.GetClientSize()
       
   311                 x = (clientsize.width - width) / 2
       
   312                 y = (clientsize.height - height) / 2
       
   313                 self.Block.SetPosition(x, y)
       
   314                 self.Block.Draw(dc)
       
   315             else:
   303             else:
   316                 self.Block = None
   304                 blocktype = self.TypeTree.GetItemText(item)
       
   305                 if blocktype:
       
   306                     self.Block = FBD_Block(self.Preview, blocktype, self.Name.GetValue(), extension = self.Inputs.GetValue(), inputs = pydata["inputs"])
       
   307                     width, height = self.MinBlockSize
       
   308                     min_width, min_height = self.Block.GetMinSize()
       
   309                     width, height = max(min_width, width), max(min_height, height)
       
   310                     self.Block.SetSize(width, height)
       
   311                     clientsize = self.Preview.GetClientSize()
       
   312                     x = (clientsize.width - width) / 2
       
   313                     y = (clientsize.height - height) / 2
       
   314                     self.Block.SetPosition(x, y)
       
   315                     self.Block.Draw(dc)
       
   316                 else:
       
   317                     self.Block = None
   317 
   318 
   318     def OnPaint(self, event):
   319     def OnPaint(self, event):
   319         if self.Block:
   320         if self.Block:
   320             self.RefreshPreview()
   321             self.RefreshPreview()
   321 
   322 
  1361 #                          Edit Transition Content Dialog
  1362 #                          Edit Transition Content Dialog
  1362 #-------------------------------------------------------------------------------
  1363 #-------------------------------------------------------------------------------
  1363 
  1364 
  1364 [ID_TRANSITIONCONTENTDIALOG, ID_TRANSITIONCONTENTDIALOGSPACER, 
  1365 [ID_TRANSITIONCONTENTDIALOG, ID_TRANSITIONCONTENTDIALOGSPACER, 
  1365  ID_TRANSITIONCONTENTDIALOGREFERENCE, ID_TRANSITIONCONTENTDIALOGINLINE, 
  1366  ID_TRANSITIONCONTENTDIALOGREFERENCE, ID_TRANSITIONCONTENTDIALOGINLINE, 
  1366  ID_TRANSITIONCONTENTDIALOGPREVIEW, ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, 
  1367  ID_TRANSITIONCONTENTDIALOGPRIORITY, ID_TRANSITIONCONTENTDIALOGPREVIEW, 
  1367  ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3, 
  1368  ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1, ID_TRANSITIONCONTENTDIALOGRADIOBUTTON2, 
  1368  ID_TRANSITIONCONTENTDIALOGSTATICTEXT1, ID_TRANSITIONCONTENTDIALOGSTATICTEXT2, 
  1369  ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3, ID_TRANSITIONCONTENTDIALOGSTATICTEXT1, 
  1369 ] = [wx.NewId() for _init_ctrls in range(10)]
  1370  ID_TRANSITIONCONTENTDIALOGSTATICTEXT2, ID_TRANSITIONCONTENTDIALOGSTATICTEXT3, 
       
  1371 ] = [wx.NewId() for _init_ctrls in range(12)]
  1370 
  1372 
  1371 class TransitionContentDialog(wx.Dialog):
  1373 class TransitionContentDialog(wx.Dialog):
  1372     def _init_coll_flexGridSizer1_Items(self, parent):
  1374     def _init_coll_flexGridSizer1_Items(self, parent):
  1373         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
  1375         parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
  1374         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
  1376         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
  1386         parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
  1388         parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
  1387         parent.AddWindow(self.Reference, 0, border=0, flag=wx.GROW)
  1389         parent.AddWindow(self.Reference, 0, border=0, flag=wx.GROW)
  1388         parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
  1390         parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
  1389         parent.AddWindow(self.Inline, 0, border=0, flag=wx.GROW)
  1391         parent.AddWindow(self.Inline, 0, border=0, flag=wx.GROW)
  1390         parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW)
  1392         parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW)
       
  1393         parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
       
  1394         parent.AddWindow(self.Priority, 0, border=0, flag=wx.GROW)
  1391         parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
  1395         parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
  1392     
  1396     
  1393     def _init_coll_LeftGridSizer_Growables(self, parent):
  1397     def _init_coll_LeftGridSizer_Growables(self, parent):
  1394         parent.AddGrowableCol(0)
  1398         parent.AddGrowableCol(0)
  1395         parent.AddGrowableRow(6)
  1399         parent.AddGrowableRow(6)
  1403         parent.AddGrowableRow(1)
  1407         parent.AddGrowableRow(1)
  1404 
  1408 
  1405     def _init_sizers(self):
  1409     def _init_sizers(self):
  1406         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
  1410         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
  1407         self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
  1411         self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
  1408         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5)
  1412         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=9, vgap=5)
  1409         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
  1413         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
  1410 
  1414 
  1411         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
  1415         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
  1412         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
  1416         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
  1413         self._init_coll_MainSizer_Items(self.MainSizer)
  1417         self._init_coll_MainSizer_Items(self.MainSizer)
  1419         self.SetSizer(self.flexGridSizer1)
  1423         self.SetSizer(self.flexGridSizer1)
  1420 
  1424 
  1421     def _init_ctrls(self, prnt):
  1425     def _init_ctrls(self, prnt):
  1422         wx.Dialog.__init__(self, id=ID_TRANSITIONCONTENTDIALOG,
  1426         wx.Dialog.__init__(self, id=ID_TRANSITIONCONTENTDIALOG,
  1423               name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223),
  1427               name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223),
  1424               size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
  1428               size=wx.Size(350, 300), style=wx.DEFAULT_DIALOG_STYLE,
  1425               title='Edit transition')
  1429               title='Edit transition')
  1426         self.SetClientSize(wx.Size(350, 260))
  1430         self.SetClientSize(wx.Size(350, 300))
  1427 
  1431 
  1428         self.staticText1 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT1,
  1432         self.staticText1 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT1,
  1429               label='Type:', name='staticText1', parent=self,
  1433               label='Type:', name='staticText1', parent=self,
  1430               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1434               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1431 
  1435 
  1432         self.staticText2 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT2,
  1436         self.staticText2 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT2,
  1433               label='Preview:', name='staticText2', parent=self,
  1437               label='Preview:', name='staticText2', parent=self,
  1434               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1438               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
  1435 
  1439 
       
  1440         self.staticText3 = wx.StaticText(id=ID_TRANSITIONCONTENTDIALOGSTATICTEXT3,
       
  1441               label='Priority:', name='staticText3', parent=self,
       
  1442               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
       
  1443         
  1436         self.radioButton1 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1,
  1444         self.radioButton1 = wx.RadioButton(id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1,
  1437               label='Reference', name='radioButton1', parent=self,
  1445               label='Reference', name='radioButton1', parent=self,
  1438               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
  1446               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
  1439         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1)
  1447         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON1)
  1440         self.radioButton1.SetValue(True)
  1448         self.radioButton1.SetValue(True)
  1460               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
  1468               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
  1461         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3)
  1469         self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_TRANSITIONCONTENTDIALOGRADIOBUTTON3)
  1462         self.radioButton3.SetValue(False)
  1470         self.radioButton3.SetValue(False)
  1463         if not self.Connection:
  1471         if not self.Connection:
  1464             self.radioButton3.Hide()
  1472             self.radioButton3.Hide()
       
  1473 
       
  1474         self.Priority = wx.SpinCtrl(id=ID_TRANSITIONCONTENTDIALOGPRIORITY,
       
  1475               name='Priority', parent=self, pos=wx.Point(0, 0),
       
  1476               size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=0)
       
  1477         self.Bind(wx.EVT_TEXT, self.OnPriorityChanged, id=ID_TRANSITIONCONTENTDIALOGPRIORITY)
  1465 
  1478 
  1466         self.Preview = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGPREVIEW,
  1479         self.Preview = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGPREVIEW,
  1467               name='Preview', parent=self, pos=wx.Point(0, 0),
  1480               name='Preview', parent=self, pos=wx.Point(0, 0),
  1468               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
  1481               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
  1469         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
  1482         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
  1536         self.RefreshPreview()
  1549         self.RefreshPreview()
  1537         event.Skip()
  1550         event.Skip()
  1538 
  1551 
  1539     def OnInlineChanged(self, event):
  1552     def OnInlineChanged(self, event):
  1540         self.Element.SetType("inline", self.Inline.GetValue())
  1553         self.Element.SetType("inline", self.Inline.GetValue())
       
  1554         self.RefreshPreview()
       
  1555         event.Skip()
       
  1556 
       
  1557     def OnPriorityChanged(self, event):
       
  1558         self.Element.SetPriority(int(self.Priority.GetValue()))
  1541         self.RefreshPreview()
  1559         self.RefreshPreview()
  1542         event.Skip()
  1560         event.Skip()
  1543 
  1561 
  1544     def SetTransitions(self, transitions):
  1562     def SetTransitions(self, transitions):
  1545         self.Reference.Append("")
  1563         self.Reference.Append("")
  1568             self.radioButton2.SetValue(False)
  1586             self.radioButton2.SetValue(False)
  1569             self.radioButton3.SetValue(True)
  1587             self.radioButton3.SetValue(True)
  1570             self.Reference.Enable(False)
  1588             self.Reference.Enable(False)
  1571             self.Inline.Enable(False)
  1589             self.Inline.Enable(False)
  1572             self.Element.SetType("connection")
  1590             self.Element.SetType("connection")
       
  1591         self.Element.SetPriority(values["priority"])
  1573         self.RefreshPreview()
  1592         self.RefreshPreview()
  1574         
  1593         
  1575     def GetValues(self):
  1594     def GetValues(self):
  1576         values = {}
  1595         values = {"priority" : int(self.Priority.GetValue())}
  1577         if self.radioButton1.GetValue():
  1596         if self.radioButton1.GetValue():
  1578             values["type"] = "reference"
  1597             values["type"] = "reference"
  1579             values["value"] = self.Reference.GetStringSelection()
  1598             values["value"] = self.Reference.GetStringSelection()
  1580         elif self.radioButton2.GetValue():
  1599         elif self.radioButton2.GetValue():
  1581             values["type"] = "inline"
  1600             values["type"] = "inline"