dialogs/LDPowerRailDialog.py
author Laurent Bessard
Fri, 15 Jun 2012 18:02:09 +0200
changeset 712 c11b54730a7b
parent 583 3f3f9b25ff9f
child 714 131ea7f237b9
permissions -rw-r--r--
Adding Paste POU to project node contextual menu
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     1
# -*- coding: utf-8 -*-
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     2
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     3
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     4
#based on the plcopen standard. 
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     5
#
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     6
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     7
#
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     8
#See COPYING file for copyrights details.
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
     9
#
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    10
#This library is free software; you can redistribute it and/or
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    11
#modify it under the terms of the GNU General Public
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    12
#License as published by the Free Software Foundation; either
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    13
#version 2.1 of the License, or (at your option) any later version.
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    14
#
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    15
#This library is distributed in the hope that it will be useful,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    16
#but WITHOUT ANY WARRANTY; without even the implied warranty of
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    17
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    18
#General Public License for more details.
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    19
#
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    20
#You should have received a copy of the GNU General Public
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    21
#License along with this library; if not, write to the Free Software
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    22
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    23
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    24
import wx
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    25
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    26
from graphics import *
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    27
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    28
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    29
#-------------------------------------------------------------------------------
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    30
#                      Edit Ladder Power Rail Properties Dialog
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    31
#-------------------------------------------------------------------------------
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    32
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    33
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    34
[ID_LDPOWERRAILDIALOG, ID_LDPOWERRAILDIALOGSPACER, 
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    35
 ID_LDPOWERRAILDIALOGTYPE, ID_LDPOWERRAILDIALOGRADIOBUTTON1, 
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    36
 ID_LDPOWERRAILDIALOGRADIOBUTTON2, ID_LDPOWERRAILDIALOGPREVIEW,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    37
 ID_LDPOWERRAILDIALOGSTATICTEXT1, ID_LDPOWERRAILDIALOGSTATICTEXT2, 
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    38
 ID_LDPOWERRAILDIALOGSTATICTEXT3, ID_LDPOWERRAILDIALOGPINNUMBER,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    39
] = [wx.NewId() for _init_ctrls in range(10)]
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    40
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    41
class LDPowerRailDialog(wx.Dialog):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    42
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    43
    if wx.VERSION < (2, 6, 0):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    44
        def Bind(self, event, function, id = None):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    45
            if id is not None:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    46
                event(self, id, function)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    47
            else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    48
                event(self, function)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    49
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    50
    def _init_coll_flexGridSizer1_Items(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    51
        parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    52
        parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    53
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    54
    def _init_coll_flexGridSizer1_Growables(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    55
        parent.AddGrowableCol(0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    56
        parent.AddGrowableRow(0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    57
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    58
    def _init_coll_MainSizer_Items(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    59
        parent.AddSizer(self.LeftGridSizer, 1, border=5, flag=wx.GROW|wx.RIGHT)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    60
        parent.AddSizer(self.RightGridSizer, 1, border=5, flag=wx.GROW|wx.LEFT)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    61
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    62
    def _init_coll_LeftGridSizer_Items(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    63
        parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    64
        parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    65
        parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    66
        parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    67
        parent.AddWindow(self.PinNumber, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    68
        parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    69
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    70
    def _init_coll_LeftGridSizer_Growables(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    71
        parent.AddGrowableCol(0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    72
        parent.AddGrowableRow(5)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    73
            
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    74
    def _init_coll_RightGridSizer_Items(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    75
        parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    76
        parent.AddWindow(self.Preview, 0, border=0, flag=wx.GROW)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    77
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    78
    def _init_coll_RightGridSizer_Growables(self, parent):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    79
        parent.AddGrowableCol(0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    80
        parent.AddGrowableRow(1)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    81
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    82
    def _init_sizers(self):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    83
        self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    84
        self.MainSizer = wx.BoxSizer(wx.HORIZONTAL)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    85
        self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=5)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    86
        self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    87
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    88
        self._init_coll_flexGridSizer1_Items(self.flexGridSizer1)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    89
        self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    90
        self._init_coll_MainSizer_Items(self.MainSizer)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    91
        self._init_coll_LeftGridSizer_Items(self.LeftGridSizer)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    92
        self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    93
        self._init_coll_RightGridSizer_Items(self.RightGridSizer)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    94
        self._init_coll_RightGridSizer_Growables(self.RightGridSizer)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    95
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    96
        self.SetSizer(self.flexGridSizer1)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    97
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    98
    def _init_ctrls(self, prnt, ctrler):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    99
        wx.Dialog.__init__(self, id=ID_LDPOWERRAILDIALOG,
534
d506a353b3d3 Fix dialogs positions to stay on the same screen than parent frame
laurent
parents: 466
diff changeset
   100
              name='PowerRailDialog', parent=prnt,
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   101
              size=wx.Size(350, 260), style=wx.DEFAULT_DIALOG_STYLE,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   102
              title=_('Power Rail Properties'))
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   103
        self.SetClientSize(wx.Size(350, 260))
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   104
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   105
        self.staticText1 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT1,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   106
              label=_('Type:'), name='staticText1', parent=self,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   107
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   108
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   109
        self.staticText2 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT2,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   110
              label=_('Pin number:'), name='staticText2', parent=self,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   111
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   112
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   113
        self.staticText3 = wx.StaticText(id=ID_LDPOWERRAILDIALOGSTATICTEXT3,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   114
              label=_('Preview:'), name='staticText3', parent=self,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   115
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   116
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   117
        self.radioButton1 = wx.RadioButton(id=ID_LDPOWERRAILDIALOGRADIOBUTTON1,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   118
              label=_('Left PowerRail'), name='radioButton1', parent=self,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   119
              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   120
        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDPOWERRAILDIALOGRADIOBUTTON1)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   121
        self.radioButton1.SetValue(True)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   122
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   123
        self.radioButton2 = wx.RadioButton(id=ID_LDPOWERRAILDIALOGRADIOBUTTON2,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   124
              label=_('Right PowerRail'), name='radioButton2', parent=self, 
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   125
              pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   126
        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, id=ID_LDPOWERRAILDIALOGRADIOBUTTON2)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   127
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   128
        self.PinNumber = wx.SpinCtrl(id=ID_LDPOWERRAILDIALOGPINNUMBER,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   129
              name='PinNumber', parent=self, pos=wx.Point(0, 0),
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   130
              size=wx.Size(0, 24), style=wx.SP_ARROW_KEYS, min=1, max=50)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   131
        self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, id=ID_LDPOWERRAILDIALOGPINNUMBER)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   132
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   133
        self.Preview = wx.Panel(id=ID_LDPOWERRAILDIALOGPREVIEW,
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   134
              name='Preview', parent=self, pos=wx.Point(0, 0),
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   135
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   136
        self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   137
        setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   138
        setattr(self.Preview, "GetScaling", lambda:None)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   139
        setattr(self.Preview, "IsOfType", ctrler.IsOfType)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   140
466
68aacce44fe0 Bug on opening LDPowerRail Dialog fixed
laurent
parents: 409
diff changeset
   141
        self.Spacer = wx.Panel(id=ID_LDPOWERRAILDIALOGSPACER,
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   142
              name='Spacer', parent=self, pos=wx.Point(0, 0),
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   143
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   144
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   145
        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   146
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   147
        if wx.VERSION >= (2, 5, 0):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   148
            self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   149
        else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   150
            wx.EVT_PAINT(self.Preview, self.OnPaint)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   151
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   152
        self._init_sizers()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   153
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   154
    def __init__(self, parent, controler, type = LEFTRAIL, number = 1):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   155
        self._init_ctrls(parent, controler)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   156
        self.Type = type
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   157
        if type == LEFTRAIL:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   158
            self.radioButton1.SetValue(True)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   159
        elif type == RIGHTRAIL:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   160
            self.radioButton2.SetValue(True)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   161
        self.PinNumber.SetValue(number)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   162
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   163
        self.PowerRailMinSize = (0, 0)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   164
        self.PowerRail = None
577
9dbb79722fbc Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents: 534
diff changeset
   165
        
9dbb79722fbc Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents: 534
diff changeset
   166
        self.radioButton1.SetFocus()
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   167
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   168
    def SetPreviewFont(self, font):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   169
        self.Preview.SetFont(font)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   170
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   171
    def SetMinSize(self, size):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   172
        self.PowerRailMinSize = size
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   173
        self.RefreshPreview()    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   174
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   175
    def GetValues(self):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   176
        values = {}
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   177
        values["type"] = self.Type
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   178
        values["number"] = self.PinNumber.GetValue()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   179
        values["width"], values["height"] = self.PowerRail.GetSize()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   180
        return values
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   181
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   182
    def OnTypeChanged(self, event):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   183
        if self.radioButton1.GetValue():
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   184
            self.Type = LEFTRAIL
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   185
        elif self.radioButton2.GetValue():
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   186
            self.Type = RIGHTRAIL
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   187
        self.RefreshPreview()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   188
        event.Skip()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   189
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   190
    def OnPinNumberChanged(self, event):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   191
        self.RefreshPreview()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   192
        event.Skip()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   193
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   194
    def RefreshPreview(self):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   195
        dc = wx.ClientDC(self.Preview)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   196
        dc.SetFont(self.Preview.GetFont())
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   197
        dc.Clear()
583
3f3f9b25ff9f Fix bug in LDPowerRailDialog
laurent
parents: 577
diff changeset
   198
        self.PowerRail = LD_PowerRail(self.Preview, self.Type, connectors = self.PinNumber.GetValue())
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   199
        min_width, min_height = 2, LD_LINE_SIZE * self.PinNumber.GetValue()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   200
        width, height = max(min_width, self.PowerRailMinSize[0]), max(min_height, self.PowerRailMinSize[1])
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   201
        self.PowerRail.SetSize(width, height)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   202
        clientsize = self.Preview.GetClientSize()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   203
        self.PowerRail.SetPosition((clientsize.width - width) / 2, (clientsize.height - height) / 2)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   204
        self.PowerRail.Draw(dc)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   205
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   206
    def OnPaint(self, event):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   207
        self.RefreshPreview()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   208
        event.Skip()