author | Laurent Bessard |
Fri, 13 Jul 2012 12:42:38 +0200 | |
changeset 725 | 7c44fc339889 |
parent 714 | 131ea7f237b9 |
permissions | -rw-r--r-- |
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 |
# Edit Transition Content 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 SFCTransitionDialog(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, connection): |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
35 |
self.Connection = connection |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
36 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
37 |
wx.Dialog.__init__(self, parent, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
38 |
size=wx.Size(350, 300), title=_('Edit transition')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
39 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
40 |
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
|
41 |
main_sizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
42 |
main_sizer.AddGrowableRow(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
43 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
44 |
column_sizer = wx.BoxSizer(wx.HORIZONTAL) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
45 |
main_sizer.AddSizer(column_sizer, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
46 |
flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
47 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
48 |
left_gridsizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
49 |
left_gridsizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
50 |
column_sizer.AddSizer(left_gridsizer, 1, border=5, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
51 |
flag=wx.GROW|wx.RIGHT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
52 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
53 |
type_label = wx.StaticText(self, label=_('Type:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
54 |
left_gridsizer.AddWindow(type_label, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
55 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
56 |
self.ReferenceRadioButton = wx.RadioButton(self, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
57 |
label=_('Reference'), style=wx.RB_GROUP) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
58 |
self.ReferenceRadioButton.SetValue(True) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
59 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.ReferenceRadioButton) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
60 |
left_gridsizer.AddWindow(self.ReferenceRadioButton, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
61 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
62 |
self.Reference = wx.ComboBox(self, style=wx.CB_READONLY) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
63 |
self.Bind(wx.EVT_COMBOBOX, self.OnReferenceChanged, self.Reference) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
64 |
left_gridsizer.AddWindow(self.Reference, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
65 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
66 |
self.InlineRadioButton = wx.RadioButton(self, label=_('Inline')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
67 |
self.InlineRadioButton.SetValue(False) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
68 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.InlineRadioButton) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
69 |
left_gridsizer.AddWindow(self.InlineRadioButton, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
70 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
71 |
self.Inline = wx.TextCtrl(self) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
72 |
self.Inline.Enable(False) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
73 |
self.Bind(wx.EVT_TEXT, self.OnInlineChanged, self.Inline) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
74 |
left_gridsizer.AddWindow(self.Inline, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
75 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
76 |
self.ConnectionRadioButton = wx.RadioButton(self, label=_('Connection')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
77 |
self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, self.ConnectionRadioButton) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
78 |
self.ConnectionRadioButton.SetValue(False) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
79 |
if not self.Connection: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
80 |
self.ConnectionRadioButton.Hide() |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
81 |
left_gridsizer.AddWindow(self.ConnectionRadioButton, 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 |
priority_label = wx.StaticText(self, label=_('Priority:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
84 |
left_gridsizer.AddWindow(priority_label, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
85 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
86 |
self.Priority = wx.SpinCtrl(self, min=0, style=wx.SP_ARROW_KEYS) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
87 |
self.Bind(wx.EVT_TEXT, self.OnPriorityChanged, self.Priority) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
88 |
left_gridsizer.AddWindow(self.Priority, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
89 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
90 |
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
|
91 |
right_gridsizer.AddGrowableCol(0) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
92 |
right_gridsizer.AddGrowableRow(1) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
93 |
column_sizer.AddSizer(right_gridsizer, 1, border=5, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
94 |
flag=wx.GROW|wx.LEFT) |
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 |
preview_label = wx.StaticText(self, label=_('Preview:')) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
97 |
right_gridsizer.AddWindow(preview_label, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
98 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
99 |
self.Preview = wx.Panel(self, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
100 |
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
|
101 |
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
|
102 |
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
|
103 |
setattr(self.Preview, "RefreshTransitionModel", lambda x:None) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
104 |
setattr(self.Preview, "GetScaling", lambda:None) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
105 |
setattr(self.Preview, "IsOfType", controller.IsOfType) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
106 |
self.Preview.Bind(wx.EVT_PAINT, self.OnPaint) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
107 |
right_gridsizer.AddWindow(self.Preview, flag=wx.GROW) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
108 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
109 |
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
|
110 |
self.Bind(wx.EVT_BUTTON, self.OnOK, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
111 |
button_sizer.GetAffirmativeButton()) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
112 |
main_sizer.AddSizer(button_sizer, border=20, |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
113 |
flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
114 |
|
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
115 |
self.SetSizer(main_sizer) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
116 |
|
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
117 |
self.Transition = None |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
118 |
self.MinTransitionSize = None |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
119 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
120 |
self.Element = SFC_Transition(self.Preview) |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
534
diff
changeset
|
121 |
|
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
122 |
self.ReferenceRadioButton.SetFocus() |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
123 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
124 |
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
|
125 |
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
|
126 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
127 |
def SetElementSize(self, size): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
128 |
min_width, min_height = self.Element.GetMinSize() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
129 |
width, height = max(min_width, size[0]), max(min_height, size[1]) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
130 |
self.Element.SetSize(width, height) |
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 OnOK(self, event): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
133 |
error = [] |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
134 |
if self.ReferenceRadioButton.GetValue() and self.Reference.GetStringSelection() == "": |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
135 |
error.append(_("Reference")) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
136 |
if self.InlineRadioButton.GetValue() and self.Inline.GetValue() == "": |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
137 |
error.append(_("Inline")) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
138 |
if len(error) > 0: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
139 |
text = "" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
140 |
for i, item in enumerate(error): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
141 |
if i == 0: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
142 |
text += item |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
143 |
elif i == len(error) - 1: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
144 |
text += _(" and %s")%item |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
145 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
146 |
text += _(", %s")%item |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
147 |
dialog = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
148 |
dialog.ShowModal() |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
149 |
dialog.Destroy() |
409
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.EndModal(wx.ID_OK) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
152 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
153 |
def OnTypeChanged(self, event): |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
154 |
if self.ReferenceRadioButton.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
155 |
self.Element.SetType("reference", self.Reference.GetStringSelection()) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
156 |
self.Reference.Enable(True) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
157 |
self.Inline.Enable(False) |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
158 |
elif self.InlineRadioButton.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
159 |
self.Element.SetType("inline", self.Inline.GetValue()) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
160 |
self.Reference.Enable(False) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
161 |
self.Inline.Enable(True) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
162 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
163 |
self.Element.SetType("connection") |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
164 |
self.Reference.Enable(False) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
165 |
self.Inline.Enable(False) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
166 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
167 |
event.Skip() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
168 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
169 |
def OnReferenceChanged(self, event): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
170 |
self.Element.SetType("reference", self.Reference.GetStringSelection()) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
171 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
172 |
event.Skip() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
173 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
174 |
def OnInlineChanged(self, event): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
175 |
self.Element.SetType("inline", self.Inline.GetValue()) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
176 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
177 |
event.Skip() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
178 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
179 |
def OnPriorityChanged(self, event): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
180 |
self.Element.SetPriority(int(self.Priority.GetValue())) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
181 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
182 |
event.Skip() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
183 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
184 |
def SetTransitions(self, transitions): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
185 |
self.Reference.Append("") |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
186 |
for transition in transitions: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
187 |
self.Reference.Append(transition) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
188 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
189 |
def SetValues(self, values): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
190 |
if values["type"] == "reference": |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
191 |
self.ReferenceRadioButton.SetValue(True) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
192 |
self.InlineRadioButton.SetValue(False) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
193 |
self.ConnectionRadioButton.SetValue(False) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
194 |
self.Reference.Enable(True) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
195 |
self.Inline.Enable(False) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
196 |
self.Reference.SetStringSelection(values["value"]) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
197 |
self.Element.SetType("reference", values["value"]) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
198 |
elif values["type"] == "inline": |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
199 |
self.ReferenceRadioButton.SetValue(False) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
200 |
self.InlineRadioButton.SetValue(True) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
201 |
self.ConnectionRadioButton.SetValue(False) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
202 |
self.Reference.Enable(False) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
203 |
self.Inline.Enable(True) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
204 |
self.Inline.SetValue(values["value"]) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
205 |
self.Element.SetType("inline", values["value"]) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
206 |
elif values["type"] == "connection" and self.Connection: |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
207 |
self.ReferenceRadioButton.SetValue(False) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
208 |
self.InlineRadioButton.SetValue(False) |
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
209 |
self.ConnectionRadioButton.SetValue(True) |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
210 |
self.Reference.Enable(False) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
211 |
self.Inline.Enable(False) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
212 |
self.Element.SetType("connection") |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
213 |
self.Priority.SetValue(values["priority"]) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
214 |
self.Element.SetPriority(values["priority"]) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
215 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
216 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
217 |
def GetValues(self): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
218 |
values = {"priority" : int(self.Priority.GetValue())} |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
219 |
if self.ReferenceRadioButton.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
220 |
values["type"] = "reference" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
221 |
values["value"] = self.Reference.GetStringSelection() |
714
131ea7f237b9
Replacing buttons with text by buttons with icons
Laurent Bessard
parents:
577
diff
changeset
|
222 |
elif self.InlineRadioButton.GetValue(): |
409
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
223 |
values["type"] = "inline" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
224 |
values["value"] = self.Inline.GetValue() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
225 |
else: |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
226 |
values["type"] = "connection" |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
227 |
values["value"] = None |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
228 |
return values |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
229 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
230 |
def RefreshPreview(self): |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
231 |
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
|
232 |
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
|
233 |
dc.Clear() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
234 |
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
|
235 |
posx, posy = self.Element.GetPosition() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
236 |
rect = self.Element.GetBoundingBox() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
237 |
diffx, diffy = posx - rect.x, posy - rect.y |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
238 |
self.Element.SetPosition((clientsize.width - rect.width) / 2 + diffx, (clientsize.height - rect.height) / 2 + diffy) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
239 |
self.Element.Draw(dc) |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
240 |
|
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
241 |
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
|
242 |
self.RefreshPreview() |
34c9f624c2fe
Reorganization of Dialog classes by splitting Dialogs.py into several files, one for each Dialog class
laurent
parents:
diff
changeset
|
243 |
event.Skip() |