Dialogs.py
changeset 226 6a2f7ddd2e50
parent 165 e464a4e4e06d
child 251 cc5377a296ea
--- a/Dialogs.py	Tue Aug 12 16:28:55 2008 +0200
+++ b/Dialogs.py	Tue Aug 12 16:30:39 2008 +0200
@@ -162,6 +162,8 @@
         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
         setattr(self.Preview, "GetScaling", lambda:None)
+        setattr(self.Preview, "GetBlockType", self.Controler.GetBlockType)
+        setattr(self.Preview, "IsOfType", self.Controler.IsOfType)
 
         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
         if wx.VERSION >= (2, 5, 0):
@@ -173,7 +175,8 @@
         
         self._init_sizers()
 
-    def __init__(self, parent):
+    def __init__(self, parent, controler):
+        self.Controler = controler
         self._init_ctrls(parent)
         self.BlockName.SetValue("")
         self.BlockName.Enable(False)
@@ -299,7 +302,7 @@
         selected = event.GetItem()
         pydata = self.TypeTree.GetPyData(selected)
         if pydata["type"] != CATEGORY:
-            blocktype = GetBlockType(self.TypeTree.GetItemText(selected), pydata["inputs"])
+            blocktype = self.Controler.GetBlockType(self.TypeTree.GetItemText(selected), pydata["inputs"])
             if blocktype:
                 self.Inputs.SetValue(len(blocktype["inputs"]))
                 self.Inputs.Enable(blocktype["extensible"])
@@ -451,7 +454,7 @@
         
         self.SetSizer(self.flexGridSizer1)
 
-    def _init_ctrls(self, prnt):
+    def _init_ctrls(self, prnt, ctrler):
         wx.Dialog.__init__(self, id=ID_VARIABLEPROPERTIESDIALOG,
               name='VariablePropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
               size=wx.Size(400, 380), style=wx.DEFAULT_DIALOG_STYLE,
@@ -508,6 +511,7 @@
         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
         setattr(self.Preview, "GetScaling", lambda:None)
+        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
 
         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
 
@@ -518,8 +522,8 @@
         
         self._init_sizers()
 
-    def __init__(self, parent):
-        self._init_ctrls(parent)
+    def __init__(self, parent, controler):
+        self._init_ctrls(parent, controler)
         self.Variable = None
         self.VarList = []
         self.MinVariableSize = None
@@ -733,7 +737,7 @@
 
         self.SetSizer(self.flexGridSizer1)
 
-    def _init_ctrls(self, prnt):
+    def _init_ctrls(self, prnt, ctrler):
         wx.Dialog.__init__(self, id=ID_CONNECTIONPROPERTIESDIALOG,
               name='ConnectionPropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
               size=wx.Size(350, 220), style=wx.DEFAULT_DIALOG_STYLE,
@@ -775,6 +779,7 @@
         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
         setattr(self.Preview, "GetScaling", lambda:None)
+        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
 
         self.Spacer = wx.Panel(id=ID_CONNECTIONPROPERTIESDIALOGSPACER,
               name='Spacer', parent=self, pos=wx.Point(0, 0),
@@ -789,8 +794,8 @@
         
         self._init_sizers()
 
-    def __init__(self, parent):
-        self._init_ctrls(parent)
+    def __init__(self, parent, controler):
+        self._init_ctrls(parent, controler)
         self.Connection = None
         self.MinConnectionSize = None
     
@@ -923,7 +928,7 @@
 
         self.SetSizer(self.flexGridSizer1)
 
-    def _init_ctrls(self, prnt, title, labels):
+    def _init_ctrls(self, prnt, ctrler, title, labels):
         wx.Dialog.__init__(self, id=ID_LDELEMENTDIALOG,
               name='LDElementDialog', parent=prnt, pos=wx.Point(376, 223),
               size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
@@ -974,6 +979,7 @@
         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
         setattr(self.Preview, "GetScaling", lambda:None)
+        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
 
         self.Spacer = wx.Panel(id=ID_LDELEMENTDIALOGSPACER,
               name='Spacer', parent=self, pos=wx.Point(0, 0),
@@ -988,13 +994,13 @@
         
         self._init_sizers()
 
-    def __init__(self, parent, type):
+    def __init__(self, parent, controler, type):
         self.Type = type
         if type == "contact":
-            self._init_ctrls(parent, "Edit Contact Values", ['Normal','Negate','Rising Edge','Falling Edge'])
+            self._init_ctrls(parent, controler, "Edit Contact Values", ['Normal','Negate','Rising Edge','Falling Edge'])
             self.Element = LD_Contact(self.Preview, CONTACT_NORMAL, "")
         elif type == "coil":
-            self._init_ctrls(parent, "Edit Coil Values", ['Normal','Negate','Set','Reset'])
+            self._init_ctrls(parent, controler, "Edit Coil Values", ['Normal','Negate','Set','Reset'])
             self.Element = LD_Coil(self.Preview, COIL_NORMAL, "")
     
     def SetPreviewFont(self, font):
@@ -1154,7 +1160,7 @@
 
         self.SetSizer(self.flexGridSizer1)
 
-    def _init_ctrls(self, prnt):
+    def _init_ctrls(self, prnt, ctrler):
         wx.Dialog.__init__(self, id=ID_LDPOWERRAILDIALOG,
               name='PowerRailDialog', parent=prnt, pos=wx.Point(376, 223),
               size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
@@ -1195,6 +1201,7 @@
         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
         setattr(self.Preview, "GetScaling", lambda:None)
+        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
 
         self.Spacer = wx.Panel(id=ID_LDELEMENTDIALOGSPACER,
               name='Spacer', parent=self, pos=wx.Point(0, 0),
@@ -1209,8 +1216,8 @@
         
         self._init_sizers()
 
-    def __init__(self, parent, type = LEFTRAIL, number = 1):
-        self._init_ctrls(parent)
+    def __init__(self, parent, controler, type = LEFTRAIL, number = 1):
+        self._init_ctrls(parent, controler)
         self.Type = type
         if type == LEFTRAIL:
             self.radioButton1.SetValue(True)
@@ -1333,7 +1340,7 @@
 
         self.SetSizer(self.flexGridSizer1)
 
-    def _init_ctrls(self, prnt):
+    def _init_ctrls(self, prnt, ctrler):
         wx.Dialog.__init__(self, id=ID_STEPCONTENTDIALOG,
               name='StepContentDialog', parent=prnt, pos=wx.Point(376, 223),
               size=wx.Size(400, 250), style=wx.DEFAULT_DIALOG_STYLE,
@@ -1383,6 +1390,7 @@
         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
         setattr(self.Preview, "RefreshStepModel", lambda x:None)
         setattr(self.Preview, "GetScaling", lambda:None)
+        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
 
         self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
         if wx.VERSION >= (2, 5, 0):
@@ -1394,8 +1402,8 @@
         
         self._init_sizers()
 
-    def __init__(self, parent, initial = False):
-        self._init_ctrls(parent)
+    def __init__(self, parent, controler, initial = False):
+        self._init_ctrls(parent, controler)
         self.Step = None
         self.Initial = initial
         self.MinStepSize = None
@@ -1579,7 +1587,7 @@
 
         self.SetSizer(self.flexGridSizer1)
 
-    def _init_ctrls(self, prnt):
+    def _init_ctrls(self, prnt, ctrler):
         wx.Dialog.__init__(self, id=ID_TRANSITIONCONTENTDIALOG,
               name='ProjectDialog', parent=prnt, pos=wx.Point(376, 223),
               size=wx.Size(350, 300), style=wx.DEFAULT_DIALOG_STYLE,
@@ -1641,6 +1649,7 @@
         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
         setattr(self.Preview, "RefreshTransitionModel", lambda x:None)
         setattr(self.Preview, "GetScaling", lambda:None)
+        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
 
         self.Spacer = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGSPACER,
               name='Spacer', parent=self, pos=wx.Point(0, 0),
@@ -1656,9 +1665,9 @@
         
         self._init_sizers()
 
-    def __init__(self, parent, connection):
+    def __init__(self, parent, controler, connection):
         self.Connection = connection
-        self._init_ctrls(parent)
+        self._init_ctrls(parent, controler)
         self.Transition = None
         self.MinTransitionSize = None
         
@@ -1856,7 +1865,7 @@
 
         self.SetSizer(self.flexGridSizer1)
     
-    def _init_ctrls(self, prnt):
+    def _init_ctrls(self, prnt, ctrler):
         wx.Dialog.__init__(self, id=ID_DIVERGENCECREATEDIALOG,
               name='DivergencePropertiesDialog', parent=prnt, pos=wx.Point(376, 223),
               size=wx.Size(500, 300), style=wx.DEFAULT_DIALOG_STYLE,
@@ -1909,6 +1918,7 @@
               size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
         self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
         setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
+        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
 
         self.Spacer = wx.Panel(id=ID_TRANSITIONCONTENTDIALOGSPACER,
               name='Spacer', parent=self, pos=wx.Point(0, 0),
@@ -1923,8 +1933,8 @@
         
         self._init_sizers()
 
-    def __init__(self, parent):
-        self._init_ctrls(parent)
+    def __init__(self, parent, controler):
+        self._init_ctrls(parent, controler)
         
         self.Divergence = None
         self.MinSize = (0, 0)