dialogs/SFCDivergenceDialog.py
author Laurent Bessard
Fri, 13 Jul 2012 12:42:02 +0200
changeset 724 57b6446d54f8
parent 714 131ea7f237b9
permissions -rw-r--r--
Adding support for using middle button for moving debug graph
Adding button for resetting zoom and of position of debug graph
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
#                         Create New Divergence Dialog
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    30
#-------------------------------------------------------------------------------
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
class SFCDivergenceDialog(wx.Dialog):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    33
    
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    34
    def __init__(self, parent, controller):
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    35
        wx.Dialog.__init__(self, parent, size=wx.Size(500, 300), 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    36
              title=_('Create a new divergence or convergence'))
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    37
        
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    38
        main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    39
        main_sizer.AddGrowableCol(0)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    40
        main_sizer.AddGrowableRow(0)
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    41
        
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    42
        column_sizer = wx.BoxSizer(wx.HORIZONTAL)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    43
        main_sizer.AddSizer(column_sizer, border=20, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    44
              flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    45
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    46
        left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=7, vgap=5)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    47
        left_gridsizer.AddGrowableCol(0)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    48
        column_sizer.AddSizer(left_gridsizer, 1, border=5, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    49
              flag=wx.GROW|wx.RIGHT)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    50
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    51
        type_label = wx.StaticText(self, label=_('Type:'))
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    52
        left_gridsizer.AddWindow(type_label, flag=wx.GROW)
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    53
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    54
        self.SelectionDivergence = wx.RadioButton(self, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    55
              label=_('Selection Divergence'), style=wx.RB_GROUP)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    56
        self.SelectionDivergence.SetValue(True)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    57
        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    58
                  self.SelectionDivergence)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    59
        left_gridsizer.AddWindow(self.SelectionDivergence, flag=wx.GROW)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    60
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    61
        self.SelectionConvergence = wx.RadioButton(self,
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    62
              label=_('Selection Convergence'))
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    63
        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    64
                  self.SelectionConvergence)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    65
        left_gridsizer.AddWindow(self.SelectionConvergence, flag=wx.GROW)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    66
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    67
        self.SimultaneousDivergence = wx.RadioButton(self,
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    68
              label=_('Simultaneous Divergence'))
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    69
        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    70
                  self.SimultaneousDivergence)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    71
        left_gridsizer.AddWindow(self.SimultaneousDivergence, flag=wx.GROW)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    72
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    73
        self.SimultaneousConvergence = wx.RadioButton(self,
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    74
              label=_('Simultaneous Convergence'))
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    75
        self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    76
                  self.SimultaneousConvergence)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    77
        left_gridsizer.AddWindow(self.SimultaneousConvergence, flag=wx.GROW)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    78
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    79
        sequences_label = wx.StaticText(self, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    80
              label=_('Number of sequences:'))
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    81
        left_gridsizer.AddWindow(sequences_label, flag=wx.GROW)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    82
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    83
        self.Sequences = wx.SpinCtrl(self, min=2, max=20)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    84
        self.Bind(wx.EVT_SPINCTRL, self.OnSequencesChanged, self.Sequences)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    85
        left_gridsizer.AddWindow(self.Sequences, flag=wx.GROW)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    86
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    87
        right_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    88
        right_gridsizer.AddGrowableCol(0)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    89
        right_gridsizer.AddGrowableRow(1)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    90
        column_sizer.AddSizer(right_gridsizer, 1, border=5, 
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    91
              flag=wx.GROW|wx.LEFT)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    92
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    93
        preview_label = wx.StaticText(self, label=_('Preview:'))
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    94
        right_gridsizer.AddWindow(preview_label, flag=wx.GROW)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    95
        
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    96
        self.Preview = wx.Panel(self, style=wx.TAB_TRAVERSAL|wx.SIMPLE_BORDER)
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    97
        self.Preview.SetBackgroundColour(wx.Colour(255,255,255))
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
    98
        self.Preview.Bind(wx.EVT_PAINT, self.OnPaint)
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
    99
        setattr(self.Preview, "GetDrawingMode", lambda:FREEDRAWING_MODE)
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
   100
        setattr(self.Preview, "IsOfType", controller.IsOfType)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
   101
        right_gridsizer.AddWindow(self.Preview, flag=wx.GROW)
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   102
        
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
   103
        button_sizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
   104
        main_sizer.AddSizer(button_sizer, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT)
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   105
        
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
   106
        self.SetSizer(main_sizer)
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   107
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   108
        self.Divergence = None
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   109
        self.MinSize = (0, 0)
577
9dbb79722fbc Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents: 534
diff changeset
   110
        
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
   111
        self.SelectionDivergence.SetFocus()
409
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
    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
   114
        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
   115
    
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   116
    def GetValues(self):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   117
        values = {}
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
   118
        if self.SelectionDivergence.GetValue():
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   119
            values["type"] = SELECTION_DIVERGENCE
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
   120
        elif self.SelectionConvergence.GetValue():
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   121
            values["type"] = SELECTION_CONVERGENCE
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
   122
        elif self.SimultaneousDivergence.GetValue():
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   123
            values["type"] = SIMULTANEOUS_DIVERGENCE
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   124
        else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   125
            values["type"] = SIMULTANEOUS_CONVERGENCE
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   126
        values["number"] = self.Sequences.GetValue()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   127
        return values
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   128
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   129
    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
   130
        self.MinSize = size
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   131
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   132
    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
   133
        self.RefreshPreview()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   134
        event.Skip()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   135
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   136
    def OnSequencesChanged(self, event):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   137
        self.RefreshPreview()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   138
        event.Skip()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   139
        
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   140
    def RefreshPreview(self):
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   141
        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
   142
        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
   143
        dc.Clear()
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
   144
        if self.SelectionDivergence.GetValue():
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   145
            self.Divergence = SFC_Divergence(self.Preview, SELECTION_DIVERGENCE, self.Sequences.GetValue())
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
   146
        elif self.SelectionConvergence.GetValue():
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   147
            self.Divergence = SFC_Divergence(self.Preview, SELECTION_CONVERGENCE, self.Sequences.GetValue())
714
131ea7f237b9 Replacing buttons with text by buttons with icons
Laurent Bessard
parents: 577
diff changeset
   148
        elif self.SimultaneousDivergence.GetValue():
409
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   149
            self.Divergence = SFC_Divergence(self.Preview, SIMULTANEOUS_DIVERGENCE, self.Sequences.GetValue())
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   150
        else:
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   151
            self.Divergence = SFC_Divergence(self.Preview, SIMULTANEOUS_CONVERGENCE, self.Sequences.GetValue())
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   152
        width, height = self.Divergence.GetSize()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   153
        min_width, min_height = max(width, self.MinSize[0]), max(height, self.MinSize[1])
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   154
        self.Divergence.SetSize(min_width, min_height)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   155
        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
   156
        x = (clientsize.width - min_width) / 2
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   157
        y = (clientsize.height - min_height) / 2
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   158
        self.Divergence.SetPosition(x, y)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   159
        self.Divergence.Draw(dc)
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   160
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   161
    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
   162
        self.RefreshPreview()
34c9f624c2fe Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff changeset
   163
        event.Skip()