Dialogs.py
changeset 62 1908c45f21ef
parent 58 39cd981ff242
child 64 dd6f693e46a1
equal deleted inserted replaced
61:dc7142ae9438 62:1908c45f21ef
   591 
   591 
   592 #-------------------------------------------------------------------------------
   592 #-------------------------------------------------------------------------------
   593 #                          Create New Connection Dialog
   593 #                          Create New Connection Dialog
   594 #-------------------------------------------------------------------------------
   594 #-------------------------------------------------------------------------------
   595 
   595 
   596 [wxID_CONNECTIONPROPERTIESDIALOG, wxID_CONNECTIONPROPERTIESDIALOGMAINPANEL, 
   596 [wxID_CONNECTIONPROPERTIESDIALOG, wxID_CONNECTIONPROPERTIESDIALOGSPACER, 
   597  wxID_CONNECTIONPROPERTIESDIALOGNAME, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, 
   597  wxID_CONNECTIONPROPERTIESDIALOGNAME, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, 
   598  wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, wxID_CONNECTIONPROPERTIESDIALOGPREVIEW,
   598  wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, wxID_CONNECTIONPROPERTIESDIALOGPREVIEW,
   599  wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, 
   599  wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1, wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2, 
   600  wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, 
   600  wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3, 
   601 ] = [wx.NewId() for _init_ctrls in range(9)]
   601 ] = [wx.NewId() for _init_ctrls in range(9)]
   602 
   602 
   603 class ConnectionPropertiesDialog(wx.Dialog):
   603 class ConnectionPropertiesDialog(wx.Dialog):
   604     def _init_coll_flexGridSizer1_Items(self, parent):
   604     def _init_coll_flexGridSizer1_Items(self, parent):
   605         # generated method, don't edit
   605         # generated method, don't edit
   606 
   606 
   607         parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
   607         parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT)
       
   608         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT)
       
   609         
       
   610     def _init_coll_flexGridSizer1_Growables(self, parent):
       
   611         # generated method, don't edit
       
   612 
       
   613         parent.AddGrowableCol(0)
       
   614         parent.AddGrowableRow(0)
       
   615     
       
   616     def _init_coll_MainSizer_Items(self, parent):
       
   617         # generated method, don't edit
       
   618 
       
   619         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT)
       
   620         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT)
       
   621     
       
   622     def _init_coll_LeftGridSizer_Items(self, parent):
       
   623         # generated method, don't edit
       
   624 
       
   625         parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW)
       
   626         parent.AddWindow(self.radioButton1, 0, border=0, flag=wxGROW)
       
   627         parent.AddWindow(self.radioButton2, 0, border=0, flag=wxGROW)
       
   628         parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW)
       
   629         parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW)
       
   630         parent.AddWindow(self.Name, 0, border=0, flag=wxGROW)
       
   631     
       
   632     def _init_coll_LeftGridSizer_Growables(self, parent):
       
   633         # generated method, don't edit
       
   634 
       
   635         parent.AddGrowableCol(0)
       
   636         parent.AddGrowableRow(3)
       
   637             
       
   638     def _init_coll_RightGridSizer_Items(self, parent):
       
   639         # generated method, don't edit
       
   640 
       
   641         parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW)
       
   642         parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW)
       
   643         
       
   644     def _init_coll_RightGridSizer_Growables(self, parent):
       
   645         # generated method, don't edit
       
   646 
       
   647         parent.AddGrowableCol(0)
       
   648         parent.AddGrowableRow(1)
   608 
   649 
   609     def _init_sizers(self):
   650     def _init_sizers(self):
   610         # generated method, don't edit
   651         # generated method, don't edit
   611         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
   652         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
       
   653         self.MainSizer = wx.BoxSizer(wxHORIZONTAL)
       
   654         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5)
       
   655         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
   612 
   656 
   613         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
   657         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
       
   658         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
       
   659         self._init_coll_MainSizer_Items(self.MainSizer)
       
   660         self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
       
   661         self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
       
   662         self._init_coll_RightGridSizer_Items(self.RightGridSizer)
       
   663         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
   614 
   664 
   615         self.SetSizer(self.flexGridSizer1)
   665         self.SetSizer(self.flexGridSizer1)
   616 
   666 
   617     def _init_ctrls(self, prnt):
   667     def _init_ctrls(self, prnt):
   618         # generated method, don't edit
   668         # generated method, don't edit
   620               name='ConnectionPropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
   670               name='ConnectionPropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
   621               size=wx.Size(350, 220), style=wx.DEFAULT_DIALOG_STYLE,
   671               size=wx.Size(350, 220), style=wx.DEFAULT_DIALOG_STYLE,
   622               title='Connection Properties')
   672               title='Connection Properties')
   623         self.SetClientSize(wx.Size(350, 220))
   673         self.SetClientSize(wx.Size(350, 220))
   624 
   674 
   625         self.MainPanel = wx.Panel(id=wxID_CONNECTIONPROPERTIESDIALOGMAINPANEL,
       
   626               name='MainPanel', parent=self, pos=wx.Point(0, 0),
       
   627               size=wx.Size(340, 360), style=wx.TAB_TRAVERSAL)
       
   628         self.MainPanel.SetAutoLayout(True)
       
   629 
       
   630         self.staticText1 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1,
   675         self.staticText1 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT1,
   631               label='Type:', name='staticText1', parent=self.MainPanel,
   676               label='Type:', name='staticText1', parent=self,
   632               pos=wx.Point(24, 24), size=wx.Size(70, 17), style=0)
   677               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   633 
   678 
   634         self.staticText2 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2,
   679         self.staticText2 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT2,
   635               label='Name:', name='staticText2', parent=self.MainPanel,
   680               label='Name:', name='staticText2', parent=self,
   636               pos=wx.Point(24, 104), size=wx.Size(70, 17), style=0)
   681               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   637 
   682 
   638         self.staticText3 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3,
   683         self.staticText3 = wx.StaticText(id=wxID_CONNECTIONPROPERTIESDIALOGSTATICTEXT3,
   639               label='Preview:', name='staticText3', parent=self.MainPanel,
   684               label='Preview:', name='staticText3', parent=self,
   640               pos=wx.Point(174, 24), size=wx.Size(100, 17), style=0)
   685               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   641 
   686 
   642         self.radioButton1 = wx.RadioButton(id=wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1,
   687         self.radioButton1 = wx.RadioButton(id=wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1,
   643               label='Connector', name='radioButton1', parent=self.MainPanel,
   688               label='Connector', name='radioButton1', parent=self,
   644               pos=wx.Point(24, 48), size=wx.Size(114, 24), style=0)
   689               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   645         EVT_RADIOBUTTON(self, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, self.OnTypeChanged)
   690         EVT_RADIOBUTTON(self, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON1, self.OnTypeChanged)
   646         self.radioButton1.SetValue(True)
   691         self.radioButton1.SetValue(True)
   647 
   692 
   648         self.radioButton2 = wx.RadioButton(id=wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2,
   693         self.radioButton2 = wx.RadioButton(id=wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2,
   649               label='Continuation', name='radioButton2', parent=self.MainPanel, 
   694               label='Continuation', name='radioButton2', parent=self, 
   650               pos=wx.Point(24, 72), size=wx.Size(128, 24), style=0)
   695               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   651         EVT_RADIOBUTTON(self, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, self.OnTypeChanged)
   696         EVT_RADIOBUTTON(self, wxID_CONNECTIONPROPERTIESDIALOGRADIOBUTTON2, self.OnTypeChanged)
   652         self.radioButton2.SetValue(False)
   697         self.radioButton2.SetValue(False)
   653         
   698         
   654         self.Name = wx.TextCtrl(id=wxID_CONNECTIONPROPERTIESDIALOGNAME,
   699         self.Name = wx.TextCtrl(id=wxID_CONNECTIONPROPERTIESDIALOGNAME,
   655               name='Name', parent=self.MainPanel, pos=wx.Point(24, 130),
   700               name='Name', parent=self, pos=wx.Point(0, 0),
   656               size=wx.Size(145, 24), style=0)
   701               size=wx.Size(0, 24), style=0)
   657         EVT_TEXT(self, wxID_CONNECTIONPROPERTIESDIALOGNAME, self.OnNameChanged)
   702         EVT_TEXT(self, wxID_CONNECTIONPROPERTIESDIALOGNAME, self.OnNameChanged)
   658 
   703 
   659         self.Preview = wx.Panel(id=wxID_CONNECTIONPROPERTIESDIALOGPREVIEW,
   704         self.Preview = wx.Panel(id=wxID_CONNECTIONPROPERTIESDIALOGPREVIEW,
   660               name='Preview', parent=self.MainPanel, pos=wx.Point(174, 48),
   705               name='Preview', parent=self, pos=wx.Point(0, 0),
   661               size=wx.Size(150, 100), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   706               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   662         self.Preview.SetBackgroundColour(wxColour(255,255,255))
   707         self.Preview.SetBackgroundColour(wxColour(255,255,255))
   663         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
   708         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
   664 
   709 
       
   710         self.Spacer = wx.Panel(id=wxID_CONNECTIONPROPERTIESDIALOGSPACER,
       
   711               name='Spacer', parent=self, pos=wx.Point(0, 0),
       
   712               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
       
   713 
       
   714         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
       
   715         
   665         self._init_sizers()
   716         self._init_sizers()
   666 
   717 
   667     def __init__(self, parent):
   718     def __init__(self, parent):
   668         self._init_ctrls(parent)
   719         self._init_ctrls(parent)
   669         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
       
   670         self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT)
       
   671         self.Connection = None
   720         self.Connection = None
   672         self.MinConnectionSize = None
   721         self.MinConnectionSize = None
   673         
   722         
   674         EVT_PAINT(self, self.OnPaint)
   723         EVT_PAINT(self, self.OnPaint)
   675             
   724             
   729 #-------------------------------------------------------------------------------
   778 #-------------------------------------------------------------------------------
   730 #                        Edit Ladder Element Properties Dialog
   779 #                        Edit Ladder Element Properties Dialog
   731 #-------------------------------------------------------------------------------
   780 #-------------------------------------------------------------------------------
   732 
   781 
   733 
   782 
   734 [wxID_LDELEMENTDIALOG, wxID_LDELEMENTDIALOGMAINPANEL, 
   783 [wxID_LDELEMENTDIALOG, wxID_LDELEMENTDIALOGSPACER, 
   735  wxID_LDELEMENTDIALOGNAME, wxID_LDELEMENTDIALOGRADIOBUTTON1, 
   784  wxID_LDELEMENTDIALOGNAME, wxID_LDELEMENTDIALOGRADIOBUTTON1, 
   736  wxID_LDELEMENTDIALOGRADIOBUTTON2, wxID_LDELEMENTDIALOGRADIOBUTTON3,
   785  wxID_LDELEMENTDIALOGRADIOBUTTON2, wxID_LDELEMENTDIALOGRADIOBUTTON3,
   737  wxID_LDELEMENTDIALOGRADIOBUTTON4, wxID_LDELEMENTDIALOGPREVIEW,
   786  wxID_LDELEMENTDIALOGRADIOBUTTON4, wxID_LDELEMENTDIALOGPREVIEW,
   738  wxID_LDELEMENTDIALOGSTATICTEXT1, wxID_LDELEMENTDIALOGSTATICTEXT2, 
   787  wxID_LDELEMENTDIALOGSTATICTEXT1, wxID_LDELEMENTDIALOGSTATICTEXT2, 
   739  wxID_LDELEMENTDIALOGSTATICTEXT3, 
   788  wxID_LDELEMENTDIALOGSTATICTEXT3, 
   741 
   790 
   742 class LDElementDialog(wx.Dialog):
   791 class LDElementDialog(wx.Dialog):
   743     def _init_coll_flexGridSizer1_Items(self, parent):
   792     def _init_coll_flexGridSizer1_Items(self, parent):
   744         # generated method, don't edit
   793         # generated method, don't edit
   745 
   794 
   746         parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
   795         parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT)
       
   796         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT)
       
   797         
       
   798     def _init_coll_flexGridSizer1_Growables(self, parent):
       
   799         # generated method, don't edit
       
   800 
       
   801         parent.AddGrowableCol(0)
       
   802         parent.AddGrowableRow(0)
       
   803     
       
   804     def _init_coll_MainSizer_Items(self, parent):
       
   805         # generated method, don't edit
       
   806 
       
   807         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT)
       
   808         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT)
       
   809     
       
   810     def _init_coll_LeftGridSizer_Items(self, parent):
       
   811         # generated method, don't edit
       
   812 
       
   813         parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW)
       
   814         parent.AddWindow(self.radioButton1, 0, border=0, flag=wxGROW)
       
   815         parent.AddWindow(self.radioButton2, 0, border=0, flag=wxGROW)
       
   816         parent.AddWindow(self.radioButton3, 0, border=0, flag=wxGROW)
       
   817         parent.AddWindow(self.radioButton4, 0, border=0, flag=wxGROW)
       
   818         parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW)
       
   819         parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW)
       
   820         parent.AddWindow(self.Name, 0, border=0, flag=wxGROW)
       
   821     
       
   822     def _init_coll_LeftGridSizer_Growables(self, parent):
       
   823         # generated method, don't edit
       
   824 
       
   825         parent.AddGrowableCol(0)
       
   826         parent.AddGrowableRow(5)
       
   827             
       
   828     def _init_coll_RightGridSizer_Items(self, parent):
       
   829         # generated method, don't edit
       
   830 
       
   831         parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW)
       
   832         parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW)
       
   833         
       
   834     def _init_coll_RightGridSizer_Growables(self, parent):
       
   835         # generated method, don't edit
       
   836 
       
   837         parent.AddGrowableCol(0)
       
   838         parent.AddGrowableRow(1)
   747 
   839 
   748     def _init_sizers(self):
   840     def _init_sizers(self):
   749         # generated method, don't edit
   841         # generated method, don't edit
   750         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
   842         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
       
   843         self.MainSizer = wx.BoxSizer(wxHORIZONTAL)
       
   844         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5)
       
   845         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
   751 
   846 
   752         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
   847         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
       
   848         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
       
   849         self._init_coll_MainSizer_Items(self.MainSizer)
       
   850         self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
       
   851         self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
       
   852         self._init_coll_RightGridSizer_Items(self.RightGridSizer)
       
   853         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
   753 
   854 
   754         self.SetSizer(self.flexGridSizer1)
   855         self.SetSizer(self.flexGridSizer1)
   755 
   856 
   756     def _init_ctrls(self, prnt, title, labels):
   857     def _init_ctrls(self, prnt, title, labels):
   757         # generated method, don't edit
   858         # generated method, don't edit
   759               name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
   860               name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
   760               size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
   861               size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
   761               title=title)
   862               title=title)
   762         self.SetClientSize(wx.Size(350, 260))
   863         self.SetClientSize(wx.Size(350, 260))
   763 
   864 
   764         self.MainPanel = wx.Panel(id=wxID_LDELEMENTDIALOGMAINPANEL,
       
   765               name='MainPanel', parent=self, pos=wx.Point(0, 0),
       
   766               size=wx.Size(340, 200), style=wx.TAB_TRAVERSAL)
       
   767         self.MainPanel.SetAutoLayout(True)
       
   768 
       
   769         self.staticText1 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT1,
   865         self.staticText1 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT1,
   770               label='Modifier:', name='staticText1', parent=self.MainPanel,
   866               label='Modifier:', name='staticText1', parent=self,
   771               pos=wx.Point(24, 24), size=wx.Size(70, 17), style=0)
   867               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   772 
   868 
   773         self.staticText2 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT2,
   869         self.staticText2 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT2,
   774               label='Name:', name='staticText2', parent=self.MainPanel,
   870               label='Name:', name='staticText2', parent=self,
   775               pos=wx.Point(24, 150), size=wx.Size(70, 17), style=0)
   871               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   776 
   872 
   777         self.staticText3 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT3,
   873         self.staticText3 = wx.StaticText(id=wxID_LDELEMENTDIALOGSTATICTEXT3,
   778               label='Preview:', name='staticText3', parent=self.MainPanel,
   874               label='Preview:', name='staticText3', parent=self,
   779               pos=wx.Point(174, 24), size=wx.Size(100, 17), style=0)
   875               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   780 
   876 
   781         self.radioButton1 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON1,
   877         self.radioButton1 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON1,
   782               label=labels[0], name='radioButton1', parent=self.MainPanel,
   878               label=labels[0], name='radioButton1', parent=self,
   783               pos=wx.Point(24, 48), size=wx.Size(114, 24), style=0)
   879               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   784         EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON1, self.OnTypeChanged)
   880         EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON1, self.OnTypeChanged)
   785         self.radioButton1.SetValue(True)
   881         self.radioButton1.SetValue(True)
   786 
   882 
   787         self.radioButton2 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON2,
   883         self.radioButton2 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON2,
   788               label=labels[1], name='radioButton2', parent=self.MainPanel, 
   884               label=labels[1], name='radioButton2', parent=self, 
   789               pos=wx.Point(24, 72), size=wx.Size(128, 24), style=0)
   885               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   790         EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON2, self.OnTypeChanged)
   886         EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON2, self.OnTypeChanged)
   791 
   887 
   792         self.radioButton3 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON3,
   888         self.radioButton3 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON3,
   793               label=labels[2], name='radioButton3', parent=self.MainPanel,
   889               label=labels[2], name='radioButton3', parent=self,
   794               pos=wx.Point(24, 96), size=wx.Size(114, 24), style=0)
   890               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   795         EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON3, self.OnTypeChanged)
   891         EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON3, self.OnTypeChanged)
   796 
   892 
   797         self.radioButton4 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON4,
   893         self.radioButton4 = wx.RadioButton(id=wxID_LDELEMENTDIALOGRADIOBUTTON4,
   798               label=labels[3], name='radioButton4', parent=self.MainPanel, 
   894               label=labels[3], name='radioButton4', parent=self, 
   799               pos=wx.Point(24, 120), size=wx.Size(128, 24), style=0)
   895               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   800         EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON4, self.OnTypeChanged)
   896         EVT_RADIOBUTTON(self, wxID_LDELEMENTDIALOGRADIOBUTTON4, self.OnTypeChanged)
   801 
   897 
   802         self.Name = wx.Choice(id=wxID_LDELEMENTDIALOGNAME,
   898         self.Name = wx.Choice(id=wxID_LDELEMENTDIALOGNAME,
   803               name='Name', parent=self.MainPanel, pos=wx.Point(24, 174),
   899               name='Name', parent=self, pos=wx.Point(0, 0),
   804               size=wx.Size(145, 24), style=0)
   900               size=wx.Size(0, 24), style=0)
   805         EVT_CHOICE(self, wxID_LDELEMENTDIALOGNAME, self.OnNameChanged)
   901         EVT_CHOICE(self, wxID_LDELEMENTDIALOGNAME, self.OnNameChanged)
   806 
   902 
   807         self.Preview = wx.Panel(id=wxID_LDELEMENTDIALOGPREVIEW,
   903         self.Preview = wx.Panel(id=wxID_LDELEMENTDIALOGPREVIEW,
   808               name='Preview', parent=self.MainPanel, pos=wx.Point(174, 48),
   904               name='Preview', parent=self, pos=wx.Point(0, 0),
   809               size=wx.Size(150, 150), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   905               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   810         self.Preview.SetBackgroundColour(wxColour(255,255,255))
   906         self.Preview.SetBackgroundColour(wxColour(255,255,255))
   811         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
   907         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
       
   908 
       
   909         self.Spacer = wx.Panel(id=wxID_LDELEMENTDIALOGSPACER,
       
   910               name='Spacer', parent=self, pos=wx.Point(0, 0),
       
   911               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
       
   912 
       
   913         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
   812 
   914 
   813         self._init_sizers()
   915         self._init_sizers()
   814 
   916 
   815     def __init__(self, parent, type):
   917     def __init__(self, parent, type):
   816         self.Type = type
   918         self.Type = type
   819             self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "")
   921             self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "")
   820         elif type == "coil":
   922         elif type == "coil":
   821             self._init_ctrls(parent, "Edit Coil Values", ['Normal','Negate','Set','Reset'])
   923             self._init_ctrls(parent, "Edit Coil Values", ['Normal','Negate','Set','Reset'])
   822             self.Element = LD_Coil(self.Preview, COIL_NORMAL, "")
   924             self.Element = LD_Coil(self.Preview, COIL_NORMAL, "")
   823         self.Element.SetPosition((150 - LD_ELEMENT_SIZE[0]) / 2, (150 - LD_ELEMENT_SIZE[1]) / 2)
   925         self.Element.SetPosition((150 - LD_ELEMENT_SIZE[0]) / 2, (150 - LD_ELEMENT_SIZE[1]) / 2)
   824 
       
   825         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
       
   826         self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT)
       
   827 
   926 
   828         EVT_PAINT(self, self.OnPaint)
   927         EVT_PAINT(self, self.OnPaint)
   829 
   928 
   830     def SetElementSize(self, size):
   929     def SetElementSize(self, size):
   831         min_width, min_height = self.Element.GetMinSize()
   930         min_width, min_height = self.Element.GetMinSize()
   900         event.Skip()
   999         event.Skip()
   901 
  1000 
   902     def RefreshPreview(self):
  1001     def RefreshPreview(self):
   903         dc = wxClientDC(self.Preview)
  1002         dc = wxClientDC(self.Preview)
   904         dc.Clear()
  1003         dc.Clear()
       
  1004         clientsize = self.Preview.GetClientSize()
       
  1005         width, height = self.Element.GetSize()
       
  1006         self.Element.SetPosition((clientsize.width - width) / 2, (clientsize.height - height) / 2)
   905         self.Element.Draw(dc)
  1007         self.Element.Draw(dc)
   906 
  1008 
   907     def OnPaint(self, event):
  1009     def OnPaint(self, event):
   908         self.RefreshPreview()
  1010         self.RefreshPreview()
   909         event.Skip()
  1011         event.Skip()
   912 #-------------------------------------------------------------------------------
  1014 #-------------------------------------------------------------------------------
   913 #                      Edit Ladder Power Rail Properties Dialog
  1015 #                      Edit Ladder Power Rail Properties Dialog
   914 #-------------------------------------------------------------------------------
  1016 #-------------------------------------------------------------------------------
   915 
  1017 
   916 
  1018 
   917 [wxID_LDPOWERRAILDIALOG, wxID_LDPOWERRAILDIALOGMAINPANEL, 
  1019 [wxID_LDPOWERRAILDIALOG, wxID_LDPOWERRAILDIALOGSPACER, 
   918  wxID_LDPOWERRAILDIALOGTYPE, wxID_LDPOWERRAILDIALOGRADIOBUTTON1, 
  1020  wxID_LDPOWERRAILDIALOGTYPE, wxID_LDPOWERRAILDIALOGRADIOBUTTON1, 
   919  wxID_LDPOWERRAILDIALOGRADIOBUTTON2, wxID_LDPOWERRAILDIALOGPREVIEW,
  1021  wxID_LDPOWERRAILDIALOGRADIOBUTTON2, wxID_LDPOWERRAILDIALOGPREVIEW,
   920  wxID_LDPOWERRAILDIALOGSTATICTEXT1, wxID_LDPOWERRAILDIALOGSTATICTEXT2, 
  1022  wxID_LDPOWERRAILDIALOGSTATICTEXT1, wxID_LDPOWERRAILDIALOGSTATICTEXT2, 
   921  wxID_LDPOWERRAILDIALOGSTATICTEXT3, wxID_LDPOWERRAILDIALOGPINNUMBER,
  1023  wxID_LDPOWERRAILDIALOGSTATICTEXT3, wxID_LDPOWERRAILDIALOGPINNUMBER,
   922 ] = [wx.NewId() for _init_ctrls in range(10)]
  1024 ] = [wx.NewId() for _init_ctrls in range(10)]
   923 
  1025 
   924 class LDPowerRailDialog(wx.Dialog):
  1026 class LDPowerRailDialog(wx.Dialog):
   925     def _init_coll_flexGridSizer1_Items(self, parent):
  1027     def _init_coll_flexGridSizer1_Items(self, parent):
   926         # generated method, don't edit
  1028         # generated method, don't edit
   927 
  1029 
   928         parent.AddWindow(self.MainPanel, 0, border=0, flag=0)
  1030         parent.AddSizer(self.MainSizer, 0, border=20, flag=wxGROW|wxTOP|wxLEFT|wxRIGHT)
       
  1031         parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT)
       
  1032         
       
  1033     def _init_coll_flexGridSizer1_Growables(self, parent):
       
  1034         # generated method, don't edit
       
  1035 
       
  1036         parent.AddGrowableCol(0)
       
  1037         parent.AddGrowableRow(0)
       
  1038     
       
  1039     def _init_coll_MainSizer_Items(self, parent):
       
  1040         # generated method, don't edit
       
  1041 
       
  1042         parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wxGROW|wxRIGHT)
       
  1043         parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wxGROW|wxLEFT)
       
  1044     
       
  1045     def _init_coll_LeftGridSizer_Items(self, parent):
       
  1046         # generated method, don't edit
       
  1047 
       
  1048         parent.AddWindow(self.staticText1, 0, border=0, flag=wxGROW)
       
  1049         parent.AddWindow(self.radioButton1, 0, border=0, flag=wxGROW)
       
  1050         parent.AddWindow(self.radioButton2, 0, border=0, flag=wxGROW)
       
  1051         parent.AddWindow(self.Spacer, 0, border=0, flag=wxGROW)
       
  1052         parent.AddWindow(self.staticText2, 0, border=0, flag=wxGROW)
       
  1053         parent.AddWindow(self.PinNumber, 0, border=0, flag=wxGROW)
       
  1054     
       
  1055     def _init_coll_LeftGridSizer_Growables(self, parent):
       
  1056         # generated method, don't edit
       
  1057 
       
  1058         parent.AddGrowableCol(0)
       
  1059         parent.AddGrowableRow(3)
       
  1060             
       
  1061     def _init_coll_RightGridSizer_Items(self, parent):
       
  1062         # generated method, don't edit
       
  1063 
       
  1064         parent.AddWindow(self.staticText3, 0, border=0, flag=wxGROW)
       
  1065         parent.AddWindow(self.Preview, 0, border=0, flag=wxGROW)
       
  1066         
       
  1067     def _init_coll_RightGridSizer_Growables(self, parent):
       
  1068         # generated method, don't edit
       
  1069 
       
  1070         parent.AddGrowableCol(0)
       
  1071         parent.AddGrowableRow(1)
   929 
  1072 
   930     def _init_sizers(self):
  1073     def _init_sizers(self):
   931         # generated method, don't edit
  1074         # generated method, don't edit
   932         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
  1075         self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
       
  1076         self.MainSizer = wx.BoxSizer(wxHORIZONTAL)
       
  1077         self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5)
       
  1078         self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
   933 
  1079 
   934         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
  1080         self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
       
  1081         self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
       
  1082         self._init_coll_MainSizer_Items(self.MainSizer)
       
  1083         self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
       
  1084         self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
       
  1085         self._init_coll_RightGridSizer_Items(self.RightGridSizer)
       
  1086         self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
   935 
  1087 
   936         self.SetSizer(self.flexGridSizer1)
  1088         self.SetSizer(self.flexGridSizer1)
   937 
  1089 
   938     def _init_ctrls(self, prnt):
  1090     def _init_ctrls(self, prnt):
   939         # generated method, don't edit
  1091         # generated method, don't edit
   941               name='PowerRailDialog', parent=prnt, pos=wx.Point(376, 223),
  1093               name='PowerRailDialog', parent=prnt, pos=wx.Point(376, 223),
   942               size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
  1094               size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
   943               title='Power Rail Properties')
  1095               title='Power Rail Properties')
   944         self.SetClientSize(wx.Size(350, 260))
  1096         self.SetClientSize(wx.Size(350, 260))
   945 
  1097 
   946         self.MainPanel = wx.Panel(id=wxID_LDPOWERRAILDIALOGMAINPANEL,
       
   947               name='MainPanel', parent=self, pos=wx.Point(0, 0),
       
   948               size=wx.Size(340, 200), style=wx.TAB_TRAVERSAL)
       
   949         self.MainPanel.SetAutoLayout(True)
       
   950 
       
   951         self.staticText1 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT1,
  1098         self.staticText1 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT1,
   952               label='Type:', name='staticText1', parent=self.MainPanel,
  1099               label='Type:', name='staticText1', parent=self,
   953               pos=wx.Point(24, 24), size=wx.Size(70, 17), style=0)
  1100               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   954 
  1101 
   955         self.staticText2 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT2,
  1102         self.staticText2 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT2,
   956               label='Pin number:', name='staticText2', parent=self.MainPanel,
  1103               label='Pin number:', name='staticText2', parent=self,
   957               pos=wx.Point(24, 100), size=wx.Size(70, 17), style=0)
  1104               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   958 
  1105 
   959         self.staticText3 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT3,
  1106         self.staticText3 = wx.StaticText(id=wxID_LDPOWERRAILDIALOGSTATICTEXT3,
   960               label='Preview:', name='staticText3', parent=self.MainPanel,
  1107               label='Preview:', name='staticText3', parent=self,
   961               pos=wx.Point(174, 24), size=wx.Size(100, 17), style=0)
  1108               pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
   962 
  1109 
   963         self.radioButton1 = wx.RadioButton(id=wxID_LDPOWERRAILDIALOGRADIOBUTTON1,
  1110         self.radioButton1 = wx.RadioButton(id=wxID_LDPOWERRAILDIALOGRADIOBUTTON1,
   964               label='Left PowerRail', name='radioButton1', parent=self.MainPanel,
  1111               label='Left PowerRail', name='radioButton1', parent=self,
   965               pos=wx.Point(24, 48), size=wx.Size(114, 24), style=0)
  1112               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   966         EVT_RADIOBUTTON(self, wxID_LDPOWERRAILDIALOGRADIOBUTTON1, self.OnTypeChanged)
  1113         EVT_RADIOBUTTON(self, wxID_LDPOWERRAILDIALOGRADIOBUTTON1, self.OnTypeChanged)
   967         self.radioButton1.SetValue(True)
  1114         self.radioButton1.SetValue(True)
   968 
  1115 
   969         self.radioButton2 = wx.RadioButton(id=wxID_LDPOWERRAILDIALOGRADIOBUTTON2,
  1116         self.radioButton2 = wx.RadioButton(id=wxID_LDPOWERRAILDIALOGRADIOBUTTON2,
   970               label='Right PowerRail', name='radioButton2', parent=self.MainPanel, 
  1117               label='Right PowerRail', name='radioButton2', parent=self, 
   971               pos=wx.Point(24, 72), size=wx.Size(128, 24), style=0)
  1118               pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
   972         EVT_RADIOBUTTON(self, wxID_LDPOWERRAILDIALOGRADIOBUTTON2, self.OnTypeChanged)
  1119         EVT_RADIOBUTTON(self, wxID_LDPOWERRAILDIALOGRADIOBUTTON2, self.OnTypeChanged)
   973 
  1120 
   974         self.PinNumber = wx.SpinCtrl(id=wxID_LDPOWERRAILDIALOGPINNUMBER,
  1121         self.PinNumber = wx.SpinCtrl(id=wxID_LDPOWERRAILDIALOGPINNUMBER,
   975               name='PinNumber', parent=self.MainPanel, pos=wx.Point(24, 124),
  1122               name='PinNumber', parent=self, pos=wx.Point(0, 0),
   976               size=wx.Size(145, 24), style=wxSP_ARROW_KEYS, min=1, max=20)
  1123               size=wx.Size(0, 24), style=wxSP_ARROW_KEYS, min=1, max=20)
   977         EVT_SPINCTRL(self, wxID_LDPOWERRAILDIALOGPINNUMBER, self.OnPinNumberChanged)
  1124         EVT_SPINCTRL(self, wxID_LDPOWERRAILDIALOGPINNUMBER, self.OnPinNumberChanged)
   978 
  1125 
   979         self.Preview = wx.Panel(id=wxID_LDPOWERRAILDIALOGPREVIEW,
  1126         self.Preview = wx.Panel(id=wxID_LDPOWERRAILDIALOGPREVIEW,
   980               name='Preview', parent=self.MainPanel, pos=wx.Point(174, 48),
  1127               name='Preview', parent=self, pos=wx.Point(0, 0),
   981               size=wx.Size(150, 150), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
  1128               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
   982         self.Preview.SetBackgroundColour(wxColour(255,255,255))
  1129         self.Preview.SetBackgroundColour(wxColour(255,255,255))
   983         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
  1130         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
       
  1131 
       
  1132         self.Spacer = wx.Panel(id=wxID_LDELEMENTDIALOGSPACER,
       
  1133               name='Spacer', parent=self, pos=wx.Point(0, 0),
       
  1134               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
       
  1135 
       
  1136         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
   984 
  1137 
   985         self._init_sizers()
  1138         self._init_sizers()
   986 
  1139 
   987     def __init__(self, parent, type = LEFTRAIL, number = 1):
  1140     def __init__(self, parent, type = LEFTRAIL, number = 1):
   988         self._init_ctrls(parent)
  1141         self._init_ctrls(parent)
   991             self.radioButton1.SetValue(True)
  1144             self.radioButton1.SetValue(True)
   992         elif type == RIGHTRAIL:
  1145         elif type == RIGHTRAIL:
   993             self.radioButton2.SetValue(True)
  1146             self.radioButton2.SetValue(True)
   994         self.PinNumber.SetValue(number)
  1147         self.PinNumber.SetValue(number)
   995         
  1148         
   996         self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL|wxCENTRE)
       
   997         self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_RIGHT)
       
   998 
       
   999         self.PowerRailMinSize = (0, 0)
  1149         self.PowerRailMinSize = (0, 0)
  1000         self.PowerRail = None
  1150         self.PowerRail = None
  1001 
  1151 
  1002         EVT_PAINT(self, self.OnPaint)
  1152         EVT_PAINT(self, self.OnPaint)
  1003 
  1153 
  1029         dc.Clear()
  1179         dc.Clear()
  1030         self.PowerRail = LD_PowerRail(self.Preview, self.Type, connectors = [True for i in xrange(self.PinNumber.GetValue())])
  1180         self.PowerRail = LD_PowerRail(self.Preview, self.Type, connectors = [True for i in xrange(self.PinNumber.GetValue())])
  1031         min_width, min_height = self.PowerRail.GetMinSize()
  1181         min_width, min_height = self.PowerRail.GetMinSize()
  1032         width, height = max(min_width, self.PowerRailMinSize[0]), max(min_height, self.PowerRailMinSize[1])
  1182         width, height = max(min_width, self.PowerRailMinSize[0]), max(min_height, self.PowerRailMinSize[1])
  1033         self.PowerRail.SetSize(width, height)
  1183         self.PowerRail.SetSize(width, height)
  1034         self.PowerRail.RefreshConnectors()
  1184         clientsize = self.Preview.GetClientSize()
  1035         self.PowerRail.SetPosition((150 - width) / 2, (150 - height) / 2)
  1185         self.PowerRail.SetPosition((clientsize.width - width) / 2, (clientsize.height - height) / 2)
  1036         self.PowerRail.Draw(dc)
  1186         self.PowerRail.Draw(dc)
  1037 
  1187 
  1038     def OnPaint(self, event):
  1188     def OnPaint(self, event):
  1039         self.RefreshPreview()
  1189         self.RefreshPreview()
  1040         event.Skip()
  1190         event.Skip()