from wxPython.wx import *

# Anmerkung c++ python
# wxCB_READONLY -> wx.CB_READONLY
# statische Funktionen wxDateTime::Now -> wxDateTime_Now
# cb -> Combobox
# chb -> Checkbox
# sc -> SpinCtrl

class Messung(wxPanel):
    def geometry_check(self,event):
        if self.chbGeometry.IsChecked():
            self.cbModus.Clear()
            self.cbModus.Append("Magnetoscan single")
            self.cbModus.Append("Hallscan single")
            self.cbModus.SetSelection(0)
            self.scWidth.Disable()
            self.scLength.Disable()
            self.scRadius.Enable()
        else:
            self.cbModus.Clear()
            self.cbModus.Append("Magnetoscan single")
            self.cbModus.Append("Magnetoscan line")
            self.cbModus.Append("Hallscan single")
            self.cbModus.Append("Hallscan line")
            self.cbModus.SetSelection(0)
            self.scLength.Enable()
            self.scWidth.Enable()
            self.scRadius.Disable()
            
    def __init__(self,parent):
        self.CHB_GEOMETRY=1

        print 'tata'
        self.LENGTH_MIN=1 #nachschauen
        self.LENGTH_MAX=10000
        self.LENGTH_DEF=200

        self.WIDTH_MIN=1 #nachschauen
        self.WIDTH_MAX=10000
        self.WIDTH_DEF=200

        self.RADIUS_MIN=1 #nachschauen
        self.RADIUS_MAX=10000
        self.RADIUS_DEF=200

        self.STEP_WIDTH_MIN=1
        self.STEP_WIDTH_MAX=200
        self.STEP_WIDTH_DEF=30

        self.SPEED_MIN=20
        self.SPEED_MAX=200
        self.SPEED_DEF=150

        self.HALL_DEF=16.6
        
        wxPanel.__init__(self,parent,-1,(0,200),(400,400))
        wxStaticBox(self,-1,"Parameter",(5,5),(375,200))
        
        wxStaticText(self,-1,"Type:",(10,32),(80,20),wxALIGN_RIGHT)
        self.cbModus=wxComboBox(self,-1,"",(85,30),(200,20),style=wxCB_READONLY)
        self.chbGeometry=wxCheckBox(self,self.CHB_GEOMETRY,"Circle",(300,30),(70,20),style=wxALIGN_RIGHT)

        wxStaticText(self,-1,"Start position:",(10,62),(70,20),style=wxALIGN_RIGHT)
        self.cbStartPosition=wxComboBox(self,-1,"",(85,60),(200,20),style=wxCB_READONLY)
        self.cbStartPosition.Append("left/top")
        self.cbStartPosition.Append("right/top")
        self.cbStartPosition.Append("left/bottom")
        self.cbStartPosition.Append("right/bottom")
        self.cbStartPosition.SetSelection(0)
        
        wxStaticText(self,-1,"Length [mm]:",(10,102),(70,20),style=wxALIGN_RIGHT)
        self.scLength=wxSpinCtrl(self,-1,pos=(85,100),size=(80,20),style=wxSP_ARROW_KEYS)
        self.scLength.SetRange(self.LENGTH_MIN,self.LENGTH_MAX)
        self.scLength.SetValue(self.LENGTH_DEF)

        wxStaticText(self,-1,"Width [mm]:",(10,132),(70,20),style=wxALIGN_RIGHT)
        self.scWidth=wxSpinCtrl(self,-1,pos=(85,130),size=(80,20),style=wxSP_ARROW_KEYS)
        self.scWidth.SetRange(self.WIDTH_MIN,self.LENGTH_MAX)
        self.scWidth.SetValue(self.WIDTH_DEF)

        wxStaticText(self,-1,"Radius [mm]:",(10,162),(70,20),style=wxALIGN_RIGHT)
        self.scRadius=wxSpinCtrl(self,-1,pos=(85,160),size=(80,20),style=wxSP_ARROW_KEYS)
        self.scRadius.SetRange(self.RADIUS_MIN,self.RADIUS_MAX)
        self.scRadius.SetValue(self.RADIUS_DEF)

        wxStaticText(self,-1,"Step width [mm/100]:",(165,102),(120,20),style=wxALIGN_RIGHT)
        self.scStepWidth=wxSpinCtrl(self,-1,pos=(290,100),size=(80,20),style=wxSP_ARROW_KEYS)
        self.scStepWidth.SetRange(self.STEP_WIDTH_MIN,self.STEP_WIDTH_MAX)
        self.scStepWidth.SetValue(self.STEP_WIDTH_DEF)

        wxStaticText(self,-1,"Steps/sec:",(165,132),(60,20),style=wxALIGN_RIGHT)
        self.scSpeed=wxSpinCtrl(self,-1,pos=(290,130),size=(80,20),style=wxSP_ARROW_KEYS)
        self.scSpeed.SetRange(self.SPEED_MIN,self.SPEED_MAX)
        self.scSpeed.SetValue(self.SPEED_DEF)

        wxStaticText(self,-1,"Hall factor:",(165,162),(60,20),style=wxALIGN_RIGHT)
        self.tcHall=wxTextCtrl(self,-1,"%f"%self.HALL_DEF,(290,160),(80,20))

        wxStaticBox(self,-1,"File",(5,210),(375,115))

        wxStaticText(self,-1,"Comment char:",(10,232),(100,20),style=wxALIGN_RIGHT)
        self.cbCommentChar=wxComboBox(self,-1,pos=(125,230),size=(40,20),style=wxCB_READONLY)
        self.cbCommentChar.Append("\\t")
        self.cbCommentChar.Append(",")
        self.cbCommentChar.Append(";")
        self.cbCommentChar.Append(":")
        self.cbCommentChar.SetSelection(0)

        wxStaticText(self,-1,"Separator:",(10,262),(100,20),style=wxALIGN_RIGHT)
        self.cbSeparatorChar=wxComboBox(self,-1,pos=(125,260),size=(40,20),style=wxCB_READONLY)
        self.cbSeparatorChar.Append("#")
        self.cbSeparatorChar.Append('"')
        self.cbSeparatorChar.Append("'")
        self.cbSeparatorChar.Append("%")
        self.cbSeparatorChar.SetSelection(0)

        wxStaticText(self,-1,"Comment:",(10,337),(60,20))
        self.tcCommentLine=wxTextCtrl(self,-1,pos=(10,360),size=(360,20))

        self.geometry_check(EVT_CHECKBOX)
        EVT_CHECKBOX(self,self.CHB_GEOMETRY,self.geometry_check)
        
