24 |
24 |
25 import wx |
25 import wx |
26 |
26 |
27 from controls import VariablePanel |
27 from controls import VariablePanel |
28 |
28 |
|
29 |
29 class EditorPanel(wx.SplitterWindow): |
30 class EditorPanel(wx.SplitterWindow): |
30 |
31 |
31 VARIABLE_PANEL_TYPE = None |
32 VARIABLE_PANEL_TYPE = None |
32 |
33 |
33 def _init_Editor(self, prnt): |
34 def _init_Editor(self, prnt): |
34 self.Editor = None |
35 self.Editor = None |
35 |
36 |
36 def _init_MenuItems(self): |
37 def _init_MenuItems(self): |
37 self.MenuItems = [] |
38 self.MenuItems = [] |
38 |
39 |
39 def _init_ctrls(self, parent): |
40 def _init_ctrls(self, parent): |
40 wx.SplitterWindow.__init__(self, parent, |
41 wx.SplitterWindow.__init__(self, parent, |
41 style=wx.SUNKEN_BORDER|wx.SP_3D) |
42 style=wx.SUNKEN_BORDER | wx.SP_3D) |
42 self.SetMinimumPaneSize(1) |
43 self.SetMinimumPaneSize(1) |
43 |
44 |
44 self._init_MenuItems() |
45 self._init_MenuItems() |
45 |
46 |
46 if self.VARIABLE_PANEL_TYPE is not None: |
47 if self.VARIABLE_PANEL_TYPE is not None: |
47 self.VariableEditor = VariablePanel(self, self, self.Controler, self.VARIABLE_PANEL_TYPE, self.Debug) |
48 self.VariableEditor = VariablePanel(self, self, self.Controler, self.VARIABLE_PANEL_TYPE, self.Debug) |
48 self.VariableEditor.SetTagName(self.TagName) |
49 self.VariableEditor.SetTagName(self.TagName) |
49 else: |
50 else: |
50 self.VariableEditor = None |
51 self.VariableEditor = None |
51 |
52 |
52 self._init_Editor(self) |
53 self._init_Editor(self) |
53 |
54 |
54 if self.Editor is not None and self.VariableEditor is not None: |
55 if self.Editor is not None and self.VariableEditor is not None: |
55 self.SplitHorizontally(self.VariableEditor, self.Editor, 200) |
56 self.SplitHorizontally(self.VariableEditor, self.Editor, 200) |
56 elif self.VariableEditor is not None: |
57 elif self.VariableEditor is not None: |
57 self.Initialize(self.VariableEditor) |
58 self.Initialize(self.VariableEditor) |
58 elif self.Editor is not None: |
59 elif self.Editor is not None: |
59 self.Initialize(self.Editor) |
60 self.Initialize(self.Editor) |
60 |
61 |
61 def __init__(self, parent, tagname, window, controler, debug=False): |
62 def __init__(self, parent, tagname, window, controler, debug=False): |
62 self.ParentWindow = window |
63 self.ParentWindow = window |
63 self.Controler = controler |
64 self.Controler = controler |
64 self.TagName = tagname |
65 self.TagName = tagname |
65 self.Icon = None |
66 self.Icon = None |
66 self.Debug = debug |
67 self.Debug = debug |
67 |
68 |
68 self._init_ctrls(parent) |
69 self._init_ctrls(parent) |
69 |
70 |
70 def SetTagName(self, tagname): |
71 def SetTagName(self, tagname): |
71 self.TagName = tagname |
72 self.TagName = tagname |
72 if self.VARIABLE_PANEL_TYPE is not None: |
73 if self.VARIABLE_PANEL_TYPE is not None: |
73 self.VariableEditor.SetTagName(tagname) |
74 self.VariableEditor.SetTagName(tagname) |
74 |
75 |
75 def GetTagName(self): |
76 def GetTagName(self): |
76 return self.TagName |
77 return self.TagName |
77 |
78 |
78 def Select(self): |
79 def Select(self): |
79 self.ParentWindow.EditProjectElement(None, self.GetTagName(), True) |
80 self.ParentWindow.EditProjectElement(None, self.GetTagName(), True) |
80 |
81 |
81 def GetTitle(self): |
82 def GetTitle(self): |
82 return ".".join(self.TagName.split("::")[1:]) |
83 return ".".join(self.TagName.split("::")[1:]) |
83 |
84 |
84 def GetIcon(self): |
85 def GetIcon(self): |
85 return self.Icon |
86 return self.Icon |
86 |
87 |
87 def SetIcon(self, icon): |
88 def SetIcon(self, icon): |
88 self.Icon = icon |
89 self.Icon = icon |
89 |
90 |
90 def IsViewing(self, tagname): |
91 def IsViewing(self, tagname): |
91 return self.GetTagName() == tagname |
92 return self.GetTagName() == tagname |
92 |
93 |
93 def IsDebugging(self): |
94 def IsDebugging(self): |
94 return self.Debug |
95 return self.Debug |
96 def SetMode(self, mode): |
97 def SetMode(self, mode): |
97 pass |
98 pass |
98 |
99 |
99 def ResetBuffer(self): |
100 def ResetBuffer(self): |
100 pass |
101 pass |
101 |
102 |
102 def IsModified(self): |
103 def IsModified(self): |
103 return False |
104 return False |
104 |
105 |
105 def CheckSaveBeforeClosing(self): |
106 def CheckSaveBeforeClosing(self): |
106 return True |
107 return True |
107 |
108 |
108 def Save(self): |
109 def Save(self): |
109 pass |
110 pass |
110 |
111 |
111 def SaveAs(self): |
112 def SaveAs(self): |
112 pass |
113 pass |
113 |
114 |
114 def GetBufferState(self): |
115 def GetBufferState(self): |
115 if self.Controler is not None: |
116 if self.Controler is not None: |
116 return self.Controler.GetBufferState() |
117 return self.Controler.GetBufferState() |
117 return False, False |
118 return False, False |
118 |
119 |
119 def Undo(self): |
120 def Undo(self): |
120 if self.Controler is not None: |
121 if self.Controler is not None: |
121 self.Controler.LoadPrevious() |
122 self.Controler.LoadPrevious() |
122 self.RefreshView() |
123 self.RefreshView() |
123 |
124 |
124 def Redo(self): |
125 def Redo(self): |
125 if self.Controler is not None: |
126 if self.Controler is not None: |
126 self.Controler.LoadNext() |
127 self.Controler.LoadNext() |
127 self.RefreshView() |
128 self.RefreshView() |
128 |
129 |
129 def Find(self, direction, search_params): |
130 def Find(self, direction, search_params): |
130 pass |
131 pass |
131 |
132 |
132 def HasNoModel(self): |
133 def HasNoModel(self): |
133 return False |
134 return False |
134 |
135 |
135 def RefreshView(self, variablepanel=True): |
136 def RefreshView(self, variablepanel=True): |
136 if variablepanel: |
137 if variablepanel: |
137 self.RefreshVariablePanel() |
138 self.RefreshVariablePanel() |
138 |
139 |
139 def RefreshVariablePanel(self): |
140 def RefreshVariablePanel(self): |
140 if self.VariableEditor is not None: |
141 if self.VariableEditor is not None: |
141 self.VariableEditor.RefreshView() |
142 self.VariableEditor.RefreshView() |
142 |
143 |
143 def GetConfNodeMenuItems(self): |
144 def GetConfNodeMenuItems(self): |
144 return self.MenuItems |
145 return self.MenuItems |
145 |
146 |
146 def RefreshConfNodeMenu(self, confnode_menu): |
147 def RefreshConfNodeMenu(self, confnode_menu): |
147 pass |
148 pass |
148 |
149 |
149 def _Refresh(self, *args): |
150 def _Refresh(self, *args): |
150 self.ParentWindow._Refresh(*args) |
151 self.ParentWindow._Refresh(*args) |
151 |
152 |
152 def RefreshScaling(self, refresh=True): |
153 def RefreshScaling(self, refresh=True): |
153 pass |
154 pass |
157 self.VariableEditor.AddVariableHighlight(infos[1:], highlight_type) |
158 self.VariableEditor.AddVariableHighlight(infos[1:], highlight_type) |
158 |
159 |
159 def RemoveHighlight(self, infos, start, end, highlight_type): |
160 def RemoveHighlight(self, infos, start, end, highlight_type): |
160 if self.VariableEditor is not None and infos[0] in ["var_local", "var_input", "var_output", "var_inout"]: |
161 if self.VariableEditor is not None and infos[0] in ["var_local", "var_input", "var_output", "var_inout"]: |
161 self.VariableEditor.RemoveVariableHighlight(infos[1:], highlight_type) |
162 self.VariableEditor.RemoveVariableHighlight(infos[1:], highlight_type) |
162 |
163 |
163 def ClearHighlights(self, highlight_type=None): |
164 def ClearHighlights(self, highlight_type=None): |
164 if self.VariableEditor is not None: |
165 if self.VariableEditor is not None: |
165 self.VariableEditor.ClearHighlights(highlight_type) |
166 self.VariableEditor.ClearHighlights(highlight_type) |